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

UDF writing data: duplicated results

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

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   April 3, 2012, 16:07
Default UDF writing data: duplicated results
  #1
Member
 
HJ
Join Date: Nov 2011
Posts: 30
Rep Power: 14
wanghaojie is on a distinguished road
Hi all,
I wrote a UDF to record transient data but I usually get lots of zero for one time step and also two non-zero data for a single step, does anyone know whats wrong in my code?
Thanks
I try to calculate the bi-directional flow thru a opening and record the flow rate.


#include "udf.h"
#define ID1 10036 /*Window ID*/
#define ID2 10028 /*Horizontal Plane ID*/
#define ID3 10040 /*Horizontal Plane Inside ID*/
#define ID4 10029 /*Vertical Plane ID*/
#define ID5 10042 /*Vertical Plane Inside ID*/
#define ID6 2 /*Building ID*/
#define Vel 3
#define Angle 90
#define Alfa 1.0
#define Gama 0.15
#define rho 1.225

FILE *fp;
DEFINE_EXECUTE_AT_END(SaveData)
{
Domain *d;
face_t f;
real A[2];
real x[ND_ND],z;
Thread *t,*t0,*t1;
real incid;
real P=0,Vol=0,VolTotal=0,u=0,v=0,v_door=0,VentRate=0,t ime=0;
cell_t c, 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;
}
end_f_loop(f, t)
time=CURRENT_TIME;
fprintf (fp, "%g,%g\n",time, VentRate);
fclose(fp);

and so on....

and the results i get is like:
344.35 0
344.35 0
344.35 0
344.35 0
344.35 0
344.35 0
344.35 0.209489
344.35 0
344.35 0.281943
344.38 0
344.38 0
344.38 0.198774
344.38 0
344.38 0.27797
344.38 0
344.38 0
344.38 0
344.38 0
344.41 0
344.41 0
344.41 0
344.41 0
344.41 0.271995
344.41 0
344.41 0.187409
wanghaojie is offline   Reply With Quote

Old   April 9, 2012, 12:37
Default
  #2
Member
 
HJ
Join Date: Nov 2011
Posts: 30
Rep Power: 14
wanghaojie is on a distinguished road
does anyone have this kind of problem before
wanghaojie is offline   Reply With Quote

Old   April 10, 2012, 11:40
Default
  #3
Member
 
HJ
Join Date: Nov 2011
Posts: 30
Rep Power: 14
wanghaojie is on a distinguished road
I see even if i use printf in the console, it still has several data at one time step....
wanghaojie is offline   Reply With Quote

Old   April 10, 2012, 12:25
Default
  #4
Member
 
HJ
Join Date: Nov 2011
Posts: 30
Rep Power: 14
wanghaojie is on a distinguished road
I finally figure it out. Its because i use parallel fluent and each cpu will give a result
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
fluent udf, saving data in udf mohsen zendehbad Fluent UDF and Scheme Programming 15 June 14, 2017 00:23
How to Mix AIR and WATER Elvis1991 FLUENT 12 December 1, 2016 13:28
Ansys Fluent UDF - for Data Center Air flow management kedarjan Fluent UDF and Scheme Programming 13 November 13, 2013 05:20
UDF for Species Mass Fraction Gradient *IN SPECIFIC ZONE * -- e.g. along axis of sym. ksiegs2 Fluent UDF and Scheme Programming 0 February 27, 2011 13:55
Seek help in writing UDF Jack Martinez FLUENT 9 June 14, 2007 11:24


All times are GMT -4. The time now is 17:55.