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 gradient (https://www.cfd-online.com/Forums/fluent-udf/104198-udf-gradient.html)

Honglin July 4, 2012 16:26

udf for gradient
 
#include "udf.h"
FILE *fid;
real flow;
real x;
real p;
real g;
real xc[ND_ND];

DEFINE_EXECUTE_AT_END(EXECUTE_AT_END)
{
Domain *d;
Thread *t ;
face_t f;
cell_t c;
d=Get_Domain(1);
t= Lookup_Thread(d, 6);

fid=fopen("flux.dat","w");
begin_f_loop(f, t)
{

c= F_C0(f, t);
flow = F_FLUX(f,t);

/* fprintf(fid,"MASS FLOW RATE:%g\n",flow);*/

}
end_f_loop(f,t)
begin_c_loop(c,t)
{
C_CENTROID(xc,c,t);
x=xc[0];
p = C_P(c,t);
g = C_P_RG(c,t)[0];
fprintf(fid,"x-coordinate:%g\t",x);
fprintf(fid,"Static PRESSURE:%g\t",p);
fprintf(fid,"PRESSURE GRADIENT:%g\n",g);
}
end_c_loop(c,t)
fclose(fid);
}


There have error at the end of one time steps. g = C_P_RG(c,t)[0]; it may be have some problem. If I remove it ,the result is right. Please help me!!!!!!!!!! Thank you !

akm July 6, 2012 08:46

did you enable the gradient macros using text commands?
solve/set/expert
Keep temporary solver memory from being freed? Yes

Also to use C_P_RG() you have to use the second order discretization scheme for pressure.
Alternatively, you can use C_P_G(c,t)[0] which need not have a second order discretization scheme.

Hope that helps.

Honglin July 6, 2012 10:08

Thanks for your reply. I am so glad for response.

of course.
Keep temporary solver memory from being freed? Yes
my cas use desity solve.
I had checked the result of radient use showgrad.c, but tht result only have C_P_RG() ,not C_P_G() . Do you have further advice?

Thanks again.

Best regards
lin


All times are GMT -4. The time now is 16:10.