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

UDF Output zero?

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

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   March 23, 2012, 11:00
Default UDF Output zero?
  #1
Member
 
HJ
Join Date: Nov 2011
Posts: 30
Rep Power: 14
wanghaojie is on a distinguished road
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)
}
wanghaojie is offline   Reply With Quote

Old   March 23, 2012, 11:03
Default
  #2
Member
 
HJ
Join Date: Nov 2011
Posts: 30
Rep Power: 14
wanghaojie is on a distinguished road
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...
wanghaojie is offline   Reply With Quote

Old   March 23, 2012, 11:27
Default
  #3
Member
 
HJ
Join Date: Nov 2011
Posts: 30
Rep Power: 14
wanghaojie is on a distinguished road
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
wanghaojie is offline   Reply With Quote

Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
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 Off
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
UDF with output text file manu Fluent UDF and Scheme Programming 18 December 12, 2018 23:46
UDF unit and FLUENT output saifulraju FLUENT 4 September 21, 2010 23:22
Help with DPM UDF for OUTPUT needed Zhengcai Ye FLUENT 0 January 5, 2004 17:58
udf to output velocity at some point Jun FLUENT 4 August 19, 2003 14:43
UDF to output the modeling? Fluent Newbee FLUENT 4 August 22, 2001 04:45


All times are GMT -4. The time now is 20:37.