CFD Online Discussion Forums

CFD Online Discussion Forums (http://www.cfd-online.com/Forums/)
-   Fluent UDF and Scheme Programming (http://www.cfd-online.com/Forums/fluent-udf/)
-   -   UDF interpret in Fluent (http://www.cfd-online.com/Forums/fluent-udf/96878-udf-interpret-fluent.html)

wanghaojie February 3, 2012 12:02

UDF interpret in Fluent
 
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 February 3, 2012 15:51

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


All times are GMT -4. The time now is 07:50.