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

UDF interpret in Fluent

Register Blogs Community New Posts Updated Threads Search

Like Tree1Likes
  • 1 Post By wanghaojie

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   February 3, 2012, 12:02
Default UDF interpret in Fluent
  #1
Member
 
HJ
Join Date: Nov 2011
Posts: 30
Rep Power: 14
wanghaojie is on a distinguished road
Hi all, i have a very strange problem when using UDF.
I can interpret UDF on my own computer using Fluent 12.1 in Win7 64, but i cant do that in the cluster, Fluent 12.1 in Linux, it shows syntax error in line 8, which is where my udf begins. Does anyone have this problem before?

And also, when i use this udf to output result, it always have some 0 value at the beginning and i dont know why, is there anything wrong with my udf or its the compiler's fault?

My UDF


#include "udf.h"
#define ID 16
#define Vel 1
#define Angle 0
#define Alfa 1.0
#define Gama 0.15
#define rho 1.225
DEFINE_ON_DEMAND(VentilationRate)
{
Domain *d;
FILE *fp;
face_t f;
float A[2];
float x[2],z;
Thread *t,*t0,*t1;
double incid;
double v=0,v_door=0,cp=0,cp_sin=0,VentRate=0,deltaP=0;
cell_t c0, c1;
fp = fopen("data.csv","a+");
d = Get_Domain(1);
t = Lookup_Thread (d, ID);
incid = Angle/180.0*3.14159;
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, thread)


fprintf (fp, "%f\n",VentRate);
begin_f_loop(f, t)
{
F_CENTROID (x,f,t);
v = Vel*Alfa*pow(x[2]/10.0,Gama);
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);
deltaP= C_P(c0,t0)-C_P(c1,t1);/*Pressure difference before and after the door*/
cp=F_P(f,t)/0.5/v/v/rho;
cp_sin= cos (incid) * F_P(f,t)/0.5/v/v/rho;
fprintf (fp, "%f,%f,%f,%f,%f,%f\n",cp,cp_sin,deltaP,v,x[0],x[2]);
}
end_f_loop(f, thread)
fclose(fp);

}

DEFINE_PROFILE(inlet_u, thread, nv)
{
double x[2];
double z;
face_t f;
float incid = Angle/180.0*3.14159;
begin_f_loop(f, thread)
{
F_CENTROID (x,f,thread);
z=x[2]/10;
F_PROFILE(f, thread, nv) = sin(incid)*Vel*Alfa*pow(z,Gama);
}
end_f_loop(f, thread)
}

DEFINE_PROFILE(inlet_v, thread, nv)
{
double x[2];
double z;
face_t f;
float incid = Angle/180.0*3.14159;
begin_f_loop(f, thread)
{
F_CENTROID (x,f,thread);
z=x[2]/10;
F_PROFILE(f, thread, nv) = cos(incid)*Vel*Alfa*pow(z,Gama);
}
end_f_loop(f, thread)
}

DEFINE_PROFILE(inlet_e, thread, nv)
{
double x[ND_ND];
face_t f;

begin_f_loop(f, thread)
{
F_CENTROID (x,f,thread);
F_PROFILE(f, thread, nv) = Vel/log(1000.0)*0.4237*Vel/log(1000.0)*0.4237*Vel/log(1000.0)/(0.01+x[2]);
}
end_f_loop(f, thread)
}

DEFINE_PROFILE(inlet_k, thread, nv)
{

face_t f;

begin_f_loop(f, thread)
{
F_PROFILE(f, thread, nv) = Vel/log(1000.0)*0.4237*Vel/log(1000.0)*0.4237/0.3;
}
end_f_loop(f, thread)
}
wanghaojie is offline   Reply With Quote

Old   February 3, 2012, 15:51
Default
  #2
Member
 
HJ
Join Date: Nov 2011
Posts: 30
Rep Power: 14
wanghaojie is on a distinguished road
I resolved the problem. FYI, the txt file in windows and linux is different for return (create a new line)

ref:
http://kb.iu.edu/data/acux.html
nnvoro likes this.
wanghaojie is offline   Reply With Quote

Reply


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
UDF for Viscoelastic Fow in Fluent skris2009 FLUENT 2 September 20, 2011 00:59
Transient pressure UDF for parallel fluent droberts Fluent UDF and Scheme Programming 5 October 11, 2010 05:13
Using Fluent with a UDF frm a remote m/c aarti FLUENT 2 September 11, 2008 20:53
fluent UDF external library lapack problem Rick FLUENT 0 May 7, 2008 11:16


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