UDF Output zero?

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

 March 23, 2012, 11:00 UDF Output zero? #1 Member   HJ Join Date: Nov 2011 Posts: 30 Rep Power: 7 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, 11:03 #2 Member   HJ Join Date: Nov 2011 Posts: 30 Rep Power: 7 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, 11:27 #3 Member   HJ Join Date: Nov 2011 Posts: 30 Rep Power: 7 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

 Thread Tools Display Modes Linear Mode

 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 OffTrackbacks are On Pingbacks are On Refbacks are On Forum Rules

 Similar Threads Thread Thread Starter Forum Replies Last Post manu Fluent UDF and Scheme Programming 9 June 16, 2016 11:24 saifulraju FLUENT 4 September 21, 2010 22:22 Zhengcai Ye FLUENT 0 January 5, 2004 17:58 Jun FLUENT 4 August 19, 2003 13:43 Fluent Newbee FLUENT 4 August 22, 2001 03:45

All times are GMT -4. The time now is 12:49.