CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   Fluent UDF and Scheme Programming (https://www.cfd-online.com/Forums/fluent-udf/)
-   -   UDF for saving data of a transient simulation at particular locations (https://www.cfd-online.com/Forums/fluent-udf/138909-udf-saving-data-transient-simulation-particular-locations.html)

sreerajvarma July 14, 2014 03:52

UDF for saving data of a transient simulation at particular locations
 
Hi
I'm quite new to fluent and UDF programming. Could anyone suggest a method to save just pressure and temperature data at a few locations along X-Axis in a *.dat or *.txt files. I want data only at a few locations becausw otherwise the data to be stored will be very high. I also don't have much time to start learning UDF's. So kindly help

Thank you

GM_XIII July 15, 2014 09:35

You need a UDF that executes after every iterarion, I think that DEFINE_ADJUST (http://jullio.pe.kr/fluent6.1/help/html/udf/node55.htm) should fit your needs. In the reference given you have a sample of code that can be of your iterest, I commented in red what can fit your needs:

#include "udf.h"
DEFINE_EXECUTE_AT_END(execute_at_end)
{
Domain *d;
Thread *t;
real sum_diss=0.;
cell_t c;
d = Get_Domain(1); /* mixture domain if multiphase */
thread_loop_c (t,d)/*This loops over all cells in domain*/
{
if (FLUID_THREAD_P(t))
{ begin_c_loop (c,t)
/*Here you should check if the cell is one of the points you want*/
end_c_loop (c,t)
}
}
printf("Volume integral of turbulent dissipation: %g\n", sum_diss); fflush(stdout); }


To extract the variables you want, check http://aerojet.engr.ucdavis.edu/flue...udf/node90.htm. To save them into a file check http://aerojet.engr.ucdavis.edu/flue...df/node260.htm.

sreerajvarma July 16, 2014 02:59

Thank You very much. I will try the links you suggested.

Sreeraj Varma

sreerajvarma July 16, 2014 07:00

Quote:

Originally Posted by GM_XIII (Post 501574)
You need a UDF that executes after every iterarion, I think that DEFINE_ADJUST (http://jullio.pe.kr/fluent6.1/help/html/udf/node55.htm) should fit your needs. In the reference given you have a sample of code that can be of your iterest, I commented in red what can fit your needs:

#include "udf.h"
DEFINE_EXECUTE_AT_END(execute_at_end)
{
Domain *d;
Thread *t;
real sum_diss=0.;
cell_t c;
d = Get_Domain(1); /* mixture domain if multiphase */
thread_loop_c (t,d)/*This loops over all cells in domain*/
{
if (FLUID_THREAD_P(t))
{ begin_c_loop (c,t)
/*Here you should check if the cell is one of the points you want*/
end_c_loop (c,t)
}
}
printf("Volume integral of turbulent dissipation: %g\n", sum_diss); fflush(stdout); }


To extract the variables you want, check http://aerojet.engr.ucdavis.edu/flue...udf/node90.htm. To save them into a file check http://aerojet.engr.ucdavis.edu/flue...df/node260.htm.



I'm trying to model ma shocktube through transient simulation. So it is single phase modelling only.I have divided the tube into a a mesh of 1mm longitudinal length cells and I want the pressure at the cell bounded by face at 3.2mI tried to write to write the code as you siggested but an error msg(structure reference not implemented) is coming for line 49(if(Fluid_THREAD_P(t))). Could you pls tell me why. and also pls tell me the purpose of FLUID_THREAD_P(t) and fflush(stdout)

#include "udf.h"

DEFINE_INIT(sree_shock_tube_init,d)
{
cell_t c;
Thread *t;
float xc[ND_ND];

thread_loop_c(t,d)
{
begin_c_loop_all(c,t)
{

C_CENTROID(xc,c,t);

if (xc[0] < 3.2 )
{
C_U(c,t) = 0.;
C_V(c,t) = 0.;
C_P(c,t) = 2026500.0;
C_T(c,t) = 300.0;
C_R(c,t) = 23.536;
}

else

{

C_U(c,t) = 0.;
C_V(c,t) = 0.;
C_P(c,t) = 10132.5;
C_T(c,t) = 300.0;
C_R(c,t) = 0.11768;

}

}
end_c_loop_all(c,t)
}
}
DEFINE_EXECUTE_AT_END(exec)
{
Domain *d;
Thread *t;
float xc[ND_ND];
real pres=0.0;
thread_loop_c(t,d)
{
if(FLUID_THREAD_P(t))
{
begin_c_loop_all(c,t)
{
C_CENTROID(xc,c,t);
if(xc[0]==3.1995)
{
pres=C_P(c,t);
}
} }
end_c_loop_all(c,t)
}
}
printf("Pressure at the cells are %g\n",&pres);
fflush(stdout);
}


All times are GMT -4. The time now is 13:08.