CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Fluent UDF and Scheme Programming

udf for gradient

Register Blogs Members List Search Today's Posts Mark Forums Read

Reply
 
LinkBack Thread Tools Display Modes
Old   July 4, 2012, 16:26
Smile udf for gradient
  #1
New Member
 
honglin wang
Join Date: May 2012
Posts: 4
Rep Power: 5
Honglin is on a distinguished road
#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 !
Honglin is offline   Reply With Quote

Old   July 6, 2012, 08:46
Default
  #2
akm
New Member
 
Join Date: Jan 2010
Location: United Kingdom
Posts: 27
Rep Power: 7
akm is on a distinguished road
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.
akm is offline   Reply With Quote

Old   July 6, 2012, 10:08
Default
  #3
New Member
 
honglin wang
Join Date: May 2012
Posts: 4
Rep Power: 5
Honglin is on a distinguished road
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
Honglin is offline   Reply With Quote

Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Source Term UDF VS Porous Media Model pchoopanya Fluent UDF and Scheme Programming 1 August 28, 2013 06:12
UDF parallel error: chip-exec: function not found????? shankara.2 Fluent UDF and Scheme Programming 1 January 16, 2012 23:14
How to add a UDF to a compiled UDF library kim FLUENT 3 October 26, 2011 21:38
UDF...UDF...UDF...UDF Luc SEMINEL FLUENT 0 November 25, 2002 05:03
UDF, UDF, UDF, UDF Luc SEMINEL Main CFD Forum 0 November 25, 2002 05:01


All times are GMT -4. The time now is 23:52.