|
[Sponsors] |
March 23, 2012, 10:00 |
UDF Output zero?
|
#1 |
Member
HJ
Join Date: Nov 2011
Posts: 30
Rep Power: 14 |
Hi all,
I try to save the flow rate on a plane and velocity at another plane here is the udf I used. But the flow rate on the plane output is zero and i further check the velocity on the plane is also zero Can you guys help me check what the problem is? I think the thread id is correct. Can it be the numerical type problem? #include "udf.h" #define ID1 10036 /*Window ID*/ #define ID2 10028 /*Horizontal Plane ID*/ DEFINE_EXECUTE_AT_END(SaveData) { Domain *d; FILE *fp; face_t f; real A[2]; real x[ND_ND],z; Thread *t,*t0,*t1; real incid; real u=0,v=0,v_door=0,VentRate=0,time=0; cell_t c0, c1; /*Ventilation Rate*/ fp = fopen("VentRate.csv","a+"); d = Get_Domain(1); t = Lookup_Thread (d, ID1); begin_f_loop(f, t) { F_AREA(A,f,t); c0 = F_C0(f,t); t0 = THREAD_T0(t); c1 = F_C1(f,t); /* Get cell on other side of face */ t1 = THREAD_T1(t); v_door= 0.5*(C_V(c0,t0)+C_V(c1,t1));/*Average the velocity before and after the door)*/ VentRate=0.5*fabs(A[1]*v_door)+VentRate; printf ("%f\n",time, v_door); fprintf (fp, "%f\n",time, v_door); } end_f_loop(f, t) time=CURRENT_TIME; fprintf (fp, "%f,%f\n",time, VentRate); fclose(fp); /*Horizontal Velocity*/ fp = fopen("H.csv","a+"); time=CURRENT_TIME; fprintf (fp, "%f\n",time); d = Get_Domain(1); t = Lookup_Thread (d, ID2); begin_f_loop(f, t) { F_CENTROID(x,f,t); c0 = F_C0(f,t); t0 = THREAD_T0(t); c1 = F_C1(f,t); /* Get cell on other side of face */ t1 = THREAD_T1(t); u= 0.5*(C_U(c0,t0)+C_U(c1,t1)); v= 0.5*(C_V(c0,t0)+C_V(c1,t1)); t0 = THREAD_T0(t); c1 = F_C1(f,t); /* Get cell on other side of face */ t1 = THREAD_T1(t); fprintf (fp, "%f,%f,%f,%f,%f\n",x[0],x[1],x[2],u,v); } end_f_loop(f, t) } |
|
March 23, 2012, 10:03 |
|
#2 |
Member
HJ
Join Date: Nov 2011
Posts: 30
Rep Power: 14 |
Also, I think the fprintf in the loop function wont work at all. I cannot get anything in the output file, but fprintf outside the loop function can give an output...
|
|
March 23, 2012, 10:27 |
|
#3 |
Member
HJ
Join Date: Nov 2011
Posts: 30
Rep Power: 14 |
So now after i changed %f to %g, i am able to use printf and get real results in the fluent, but still cant use fprintf to save the data
|
|
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
UDF with output text file | manu | Fluent UDF and Scheme Programming | 18 | December 12, 2018 22:46 |
UDF unit and FLUENT output | saifulraju | FLUENT | 4 | September 21, 2010 22:22 |
Help with DPM UDF for OUTPUT needed | Zhengcai Ye | FLUENT | 0 | January 5, 2004 16:58 |
udf to output velocity at some point | Jun | FLUENT | 4 | August 19, 2003 13:43 |
UDF to output the modeling? | Fluent Newbee | FLUENT | 4 | August 22, 2001 03:45 |