CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   FLUENT (https://www.cfd-online.com/Forums/fluent/)
-   -   UDF error (https://www.cfd-online.com/Forums/fluent/138018-udf-error.html)

chinaduck June 26, 2014 17:38

UDF error
 
Hello Everyone,
I am trying to use UDF of the Fluent to generate the wave, I have compliled the UDF file, but the following error happened:

Error: E:\wave.c: line 41: parse error.
Error: E:\wave.c: line 77: parse error.
Error: E:\wave.c: line 82: parse error.



Could anyone give me some suggestions:

/************************************************** *********************/
/* Solitary Wave.c */
/* UDF for specifying a transient velocity profile boundary condition */
/* for a transitional water depth linear wave theory wave */
/************************************************** *********************/
#include "udf.h"
#define GRAV 9.81
#define H 0.2
#define D 1.0
DEFINE_PROFILE(x_velocity, thread, position)
{
real x[ND_ND]; /* this will hold the position vector */
real y;
real ELE;
real C;
real ratio;
real XX;
real xc;
real AA,BB,CC,DD,LL; /* y=position vector, AA,BB,etc are temporary stores */
face_t f;
begin_f_loop(f, thread)
{
real t = RP_Get_Real("flow-time");
F_CENTROID(x,f,thread);
y = x[1];
ratio = H/D;
xc = 200.;
C = pow( GRAV * D,0.5) * pow( ( 1. + ratio -1./20.* pow(ratio,2) -3./70.* pow(ratio,3.) ), 0.5 );
XX = xc - C * t;
ELE = H * pow ((1./cosh(pow(3./4.*ratio,0.5) * XX/D)),2.);
LL = ELE + D;
if (y <= LL)
AA = ratio + 3. * pow (ratio,3) *( 1./6. - 0.5*pow (y/D,2.));
BB = AA * ELE/H;
CC = pow(ratio,2.) * (7./4. - 9./4.* pow(y/D,2.)) * pow(ELE/H,2.);
DD = (BB - CC) * pow(GRAV * D, 0.5);
F_PROFILE(f,thread,position) = DD;
else
F_PROFILE(f, thread, position) = 0;
}
end_f_loop(f, thread)
}

DEFINE_PROFILE(y_velocity, thread, position)
{
{
real x[ND_ND]; /* this will hold the position vector */
real y;
real ELE;
real C;
real ratio;
real XX;
real xc;
real AA,BB,DD,LL; /* y=position vector, AA,BB,etc are temporary stores */
face_t f;
begin_f_loop(f, thread)
{
real t = RP_Get_Real("flow-time");
F_CENTROID(x,f,thread);
y = x[1];
ratio = H/D;
xc = 200.;
C = pow( GRAV * D,0.5) * pow( ( 1. + ratio -1./20.* pow(ratio,2.) -3./70.* pow(ratio,3.) ), 0.5 );
XX = xc - C * t;
ELE = H * pow ((1./cosh(pow(3./4.*ratio,0.5) * XX/D)),2.);
LL = ELE + D;
if (y <= LL)
AA = pow(3.*ratio,0.5) * y/D * ELE/D * tanh(pow(3.*ratio/4.,0.5) * XX/D);
BB = 1. + 0.5 * ratio* (1. - 7.*ELE/H - pow(y/D,2.)*(1.-3.*ELE/H));
DD = AA * BB * pow( GRAV * D, 0.5);
F_PROFILE(f,thread,position) = DD;
else
F_PROFILE(f, thread, position) = 0;
}
end_f_loop(f, thread)
}

chinaduck June 26, 2014 17:40

Addition:
 
The code file only contain 81 lines, while the error shows that 82 line also. This is strange to me.

ChinaDuck

pakk June 27, 2014 05:55

You say you are compiling, but it looks like you are interpreting...

chinaduck June 27, 2014 08:26

Quote:

Originally Posted by pakk (Post 498934)
You say you are compiling, but it looks like you are interpreting...

Yes, You are right, I interpreted it. The errors locate at the two "else". I don't know how to correct this. Thanks for your reply.

ChinaDuck.

chinaduck June 27, 2014 08:29

Quote:

Originally Posted by pakk (Post 498934)
You say you are compiling, but it looks like you are interpreting...

I have corrected this code and it can be run now. Thanks again!


ChinaDuck


All times are GMT -4. The time now is 05:11.