CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   Fluent UDF and Scheme Programming (https://www.cfd-online.com/Forums/fluent-udf/)
-   -   UDF line 1 parse error (https://www.cfd-online.com/Forums/fluent-udf/32523-udf-line-1-parse-error.html)

Dimitrios November 15, 2003 07:39

UDF line 1 parse error
 
Hi there fellow fluent users....this is the first time I've been using UDF's and I'm not a used user of Fluent. Anyway...I get an error message when trying to interpret the UDF in Fluent. The following message appears: line 1: parse error

My code is the following:

#include "udf.h" #include "dynamesh_tools.h"

DEFINE_CG_MOTION(rorlig_yttre, dt, cg_vel, cg_omega, time, dtime) { Thread *t = DT_THREAD ((Dynamic_Thread *)dt); face_t f; real force, dv, area, k_spring, s_force;

/* reset velocities */ NV_S (cg_vel, =, 0.0); NV_S (cg_omega, =, 0.0);

if (!Data_Valid_P ())

return;

/* compute force on rorlig_yttre wall */ force = 0.0; begin_f_loop (f, t)

force += F_P (f, t) * NV_MAG (F_AREA_CACHE (f, t)); end_f_loop (f, t)

#if RP_2D if (rp_axi)

force *= 2.0 * M_PI; #endif

/* compute change in velocity */ dv = dtime * force/ 1.2; v_prev += dv; loc += v_prev*dtime; Message ("time = %f, x_vel = %f, force = %f, loc(m)= %f \n", time, v_prev,

force,loc); Message ("time = %f, force = %f, spring = %f, loc(m)= %f \n", time, force,

s_force,loc);

cg_vel[0] = v_prev; }

Does anyone know why the error message pops up?

Ajay Rao November 15, 2003 12:28

Re: UDF line 1 parse error
 
Have your case file and UDF in c:\fluent.inc\ntbin\ntx86 folder ... It will run then ! -Ajay

Dimitrios November 16, 2003 05:21

Re: UDF line 1 parse error
 
You were right Ajay...it interpreted the file when .case and .c was in nt86 folder but now I get a new message: ***line 8: structure reference not implemented*** Can you perhaps see what can be wrong with my code?

Dimitrios November 16, 2003 05:43

Re: UDF line 1 parse error
 
By the way....line 8 is:

Thread *t = DT_THREAD ((Dynamic_Thread *)dt);

Ajay November 16, 2003 13:43

Re: UDF line 1 parse error
 
Hi, The error means that you cant use Interpreted UDF you have to use compiled UDF. compiled udf are bit more difficult to set up , you need to build the libraries and then load them. You should have an external compiler , VC++ compiler, thats the way i do it. Let me know if you need more help with it. -Ajay

ccc November 17, 2003 02:25

Re: UDF line 1 parse error
 
hi, Dimitrios:

Ajay is very right. there are some features of udf you can not use in the interpreted mode and Dynamic Mesh is one of them.


Dimitrios November 17, 2003 02:30

Re: UDF line 1 parse error
 
Dear Ajay

I would really appreciate if you could help me out with compiled UDF and the libraries setup.

Sincerely,

Dimitrios


Ajay Rao November 17, 2003 17:28

Re: UDF line 1 parse error
 
Hi, The New version of FLUENT has a GUI to help build and Load compiled UDF the older version have just the "Load" part. You would need Microsoft Visual Studio . Net for this ( I use it , dont know how to do with something else)

You need to follow the following steps

1) set up the environmental variable This is done by going to the start menu > Programs>Fluent> Set_environment clicking this would set the path and variable.

2) set up a directory structure as follows create a dir libudf in that create "src" and "ntx86". In ntx86 create "3d".( am asuming that ur simulation is 3d)

3) copy the udf (.C file) and the required header( u can get the header files frm c:\FLUENT.INC\fluent6.*.*\ntx86\src) files into the "src" folder.

4) go to c:\FLUENT.INC\fluent6.*.*\ntx86\3d copy the contents into the 3d folder which you created.

5) go to c:\FLUENT.INC\fluent6.*.*\ntx86\src copy makefile_nt.udf and user_nt.udf to your 3d folder

6) rename makefile_nt.edf to makefile and open user_nt.udf and read the instructions and do accordingly.

7) close FLUENT . Open command prompt ( start > accessories > command prompt ) type the following C:\ CD program Files \ microsoft visual studio .net\vc7\bin

8) type :- vcvars32

9)go to the libudf\ntx86\3d which u have created

10) type nmake

11) This will compile ur code and build a lib if u dont have any errors , if errors are present it will say so u need to debug it then.

12) once this is done u can open fluent again and load the lib u have just created , in this case it would be libudf.

I know its confusing ! Keep trying it took me a long time to get all things correct.

All the best Ajay

Dimitrios November 18, 2003 02:17

Re: UDF line 1 parse error
 
Once again Ajay....thanks for the help....now the code is working great....a small problem though...I have two reals that I want them to both have the value zero in the first iteration. If I define them as vel=0 and time=0 in the beginning of the code, where I define all my reals, they tend to get zero after each new iteration. How can I write the code so they have the value zero only in the first iteration?

Ajay Rao November 18, 2003 09:22

Re: UDF line 1 parse error
 
Hi Dimitrios , You could compare the time ,

real time;

time=RP_Get_Real("flow-time")

if (time ==0) { initialize

}

Hope this helps , -Ajay


17_freedom April 6, 2011 01:32

Thank you,I also meet the same problem.Thank you!

theja January 23, 2012 04:13

parse error line62
 
Quote:

Originally Posted by Dimitrios
;109119
Dear Ajay

I would really appreciate if you could help me out with compiled UDF and the libraries setup.

Sincerely,

Dimitrios

can you please help me out of this, i am getting parse error at line 62 when i am interpreting this udf valve.c

# include "udf.h"
# include "dynamesh_tools.h"
# ifndef intloop
# define intloop(n,m)for(n=0;n<m;++n);
# endif
/********************** Input Explanation Starts ***************************
DEBUG: will print out debug information.
NO_OF_VALVES: Number of valves
NO_OF_ZONES: a large number which is larger than the max number of face
zones per valve
valveid[NO_OF_VALVES][NO_OF_ZONES]={{22, 23, -1}, {13, 14, -1}}: valve face
zone list, in this example, invalve consists of face zone 21 and 23,
exvalve consists of face zone 13 and 14. -1 is a flag and so keep it.
These face zones will be used to calculate the pressure force.
axis[NO_OF_VALVES][ND_ND]={{0, 0, 1}, {0, 0, -1}}: valve motion axis. It points
from the max lift to min lift. And it has to be normalized.
r_rp_closed[NO_OF_VALVES][ND_ND]={{-0.025, 0, 0}, {0.025, 0, 0.005}}: The
reference point coordinates when valves are closed. A reference point,
used to keep track of valve motion, is a point in the valve. The
loation in the valve is immaterial and you can conveniently choose
the location.
lift_min[NO_OF_VALVES]={0.0005, 0.0005}: minimum lift
lift_max[NO_OF_VALVES]={0.01, 0.006}: maximum lift
rest_conts[NO_OF_VALVES]={0.5, 0.5}: bouncing factor
mass[NO_OF_VALVES]={0.02, 0.02}: valve mass
stiffness[NO_OF_VALVES]={2000, 5000}: valve stiffness
stretch_at_closed[NO_OF_VALVES]={0.002, 0.004}: what is the valve stretching
length when the valves are closed
gravity_direction: Gravitational direction. Has to be normalized.
current_vel_mag[NO_OF_VALVES]: Initial velocity. Could be negative if opposite
to valve axis
cur_r_rp[NO_OF_VALVES][ND_ND]: Initial position
previous_time[NO_OF_VALVES]: Initial time. Normally just 0.
How to use the udf:
- Modify the user input part of the udf. If more than one valve,then one needs to add
more DEFINE_CG_MOTION. See below for more details.
- Build the lib and hook the reader writer udf
- Use the udf for the valve motion
Note that this UDF is only valid in single precision.
Written by : Xiao Hu (Fluent Inc)
Last updated : 11/30/2004
********************** Input Explanation Ends *****************************/
/*************************** User Input Starts *****************************/
# define DEBUG
# define NO_OF_VALVES 1
# define NO_OF_ZONES 3
static int valveid[NO_OF_VALVES][NO_OF_ZONES]={{10, -1}};
static real axis[NO_OF_VALVES][ND_ND]={{-1,0}}; /* normalized */
static real r_rp_closed[NO_OF_VALVES][ND_ND]={{-0.01016, 0}};
static real lift_min[NO_OF_VALVES]={0};
static real lift_max[NO_OF_VALVES]={1e5};
static real rest_conts[NO_OF_VALVES]={0};
static real mass[NO_OF_VALVES]={0.01};
static real stiffness[NO_OF_VALVES]={150000};
static real stretch_at_closed[NO_OF_VALVES]={0};
static real gravity_direction[ND_ND]={0, 1}; /* normalized */
static real current_vel_mag[NO_OF_VALVES]={0};
static real cur_r_rp[NO_OF_VALVES][ND_ND]={{0, 0}};
static real previous_time[NO_OF_VALVES]={0};
/*************************** User Input Ends *******************************/
static void f_valve(int valveNo, void *dt, real *cg_vel, real *cg_omega, real time, real dtime)
{
#if !RP_HOST
real tmp[ND_ND], dv, current_vel[ND_ND], CG[ND_ND], force[3], moment[3], stretch;
real aero_force[ND_ND], aero_force_axis, spring_force, net_force, r_rp_new[NO_OF_VALVES][ND_ND];
int i;
Thread * tf;
Domain * domain;
/************************************************** ****************/
static real cg_vel_saved[NO_OF_VALVES][ND_ND];
/************************************************** ****************/
/* Do the calculation if the new time step */
if(fabs(previous_time[valveNo]-time)>0.2*dtime)
{
/* reset velocities */
NV_S (cg_vel, =, 0.0);
NV_S (cg_omega, =, 0.0);
/* Check to see if there is data */
if (!Data_Valid_P ())
{
Message0("\n\nNo data->No mesh motion!!!\n\n");
return;
}
/*Calculate force*/
domain = THREAD_DOMAIN (DT_THREAD ((Dynamic_Thread *)dt));
i=0;
NV_S(aero_force,=,0);
while(valveid[valveNo][i]>=0)
{
tf=Lookup_Thread(domain, valveid[valveNo][i]);
NV_S (CG, =, 0.0);
Compute_Force_And_Moment (domain, tf, CG, force, moment, FALSE);
NV_V(aero_force,+=,force);
i++;
}
aero_force_axis=NV_DOT(aero_force, axis[valveNo]);
NV_VV(tmp,=,r_rp_closed[valveNo],-,cur_r_rp[valveNo]);
stretch = (stretch_at_closed[valveNo]+NV_DOT(tmp,axis[valveNo]));
spring_force=stiffness[valveNo]*stretch;
net_force=spring_force+aero_force_axis+9.81*mass[valveNo]*NV_DOT(gravity_direction, axis[valveNo]);
dv=net_force/mass[valveNo]*dtime;

/* Calculate the C.G location and velocity if it does not hit the boundary */
NV_VS(current_vel,=,axis[valveNo],*,current_vel_mag[valveNo]);
NV_VS(tmp,=,current_vel,*,dtime);
NV_VV(r_rp_new[valveNo],=,cur_r_rp[valveNo],+,tmp);
/* Update velocity */
current_vel_mag[valveNo]+=dv;
/* debug info */
#ifdef DEBUG
Message0("\n\n*********************** DEBUG INFO ***************************\n");
Message0("\nvalveNo=%3d\n", valveNo);
Message0("\ncur_r_rp[%d]=(%10.3e, %10.3e, %10.3e)\n",
valveNo, cur_r_rp[valveNo][0], cur_r_rp[valveNo][1], cur_r_rp[valveNo][ND_ND-1]);
Message0("\naero force=(%10.3e, %10.3e, %10.3e)\n",
aero_force[0], aero_force[1], aero_force[ND_ND-1]);
Message0("\n(stretching at closed, stretching, force)=(%10.3e, %10.3e, %10.3e)\n",
stretch_at_closed[valveNo], stretch, spring_force);
Message0("\n(net_force, spring force, aero force)=(%10.3e, %10.3e, %10.3e)\n",
net_force, spring_force, aero_force_axis);
Message0("\nvel(cur)=%11.3e vel(next wo limit)=%11.3e ",
current_vel_mag[valveNo]-dv, current_vel_mag[valveNo]);
#endif
/* if it hits the lift_min boundary then it stays at lift_min*/
NV_VV(tmp,=,r_rp_closed[valveNo],-,r_rp_new[valveNo]);
if(NV_DOT(tmp,axis[valveNo])<(lift_min[valveNo]))
{
NV_V_VS(r_rp_new[valveNo],=,r_rp_closed[valveNo],-,axis[valveNo],*,lift_min[valveNo]);
current_vel_mag[valveNo]=-rest_conts[valveNo]*fabs(current_vel_mag[valveNo]);
}
/* if it hits the lift_max boundary then it stays at lift_max*/
NV_VV(tmp,=,r_rp_closed[valveNo],-,r_rp_new[valveNo]);
if(NV_DOT(tmp,axis[valveNo])>(lift_max[valveNo]))
{
NV_V_VS(r_rp_new[valveNo],=,r_rp_closed[valveNo],-,axis[valveNo],*,lift_max[valveNo]);
current_vel_mag[valveNo]=rest_conts[valveNo]*fabs(current_vel_mag[valveNo]);
}
/* set valve velocity */
NV_VV(tmp,=,r_rp_new[valveNo],-,cur_r_rp[valveNo]);
NV_VS(cg_vel,=,tmp,/,dtime);
/* Update location and velocity */
NV_V(cur_r_rp[valveNo],=,r_rp_new[valveNo]);
NV_V(cg_vel_saved[valveNo],=,cg_vel);
previous_time[valveNo]=time;
/* debug info */
#ifdef DEBUG
Message0("vel(next w limit)=%11.3e\n", current_vel_mag[valveNo]);
Message0("\nvelocity(CG)=(%10.3e, %10.3e, %10.3e)\n",
cg_vel[0], cg_vel[1], cg_vel[ND_ND-1]);
Message0("\nr_rp_new[%d]=(%10.3e, %10.3e, %10.3e)\n",
valveNo, r_rp_new[valveNo][0], r_rp_new[valveNo][1], r_rp_new[valveNo][ND_ND-1]);
Message0("\n*********************** DEBUG INFO ***************************\n\n");
#endif
}
else
{
NV_V(cg_vel,=,cg_vel_saved[valveNo]);
}
#endif
node_to_host_real(current_vel_mag, NO_OF_VALVES);
node_to_host_real(cur_r_rp[0], NO_OF_VALVES*ND_ND);
node_to_host_real(previous_time, NO_OF_VALVES);
}
/* Add more valves if necessary. For instance, if two valves, then
{
f_valve(0, dt, cg_vel, cg_omega, time, dtime);
}
{
f_valve(1, dt, cg_vel, cg_omega, time, dtime);
}
*/
DEFINE_CG_MOTION(valve, dt, cg_vel, cg_omega, time, dtime)
{
f_valve(0, dt, cg_vel, cg_omega, time, dtime);
node_to_host_real(cg_vel,ND_ND);
node_to_host_real(cg_omega,ND_ND);
}
DEFINE_EXECUTE_AT_END(output_results)
{
#if !RP_HOST
int i;
FILE *fp_results;
#if PARALLEL
if(I_AM_NODE_ZERO_P)
#endif
{
if(!(fp_results=fopen("results.txt","a")))
{
Message0("\nCan not open file-aborting!!");
exit(0);
}
}
#if PARALLEL
if(I_AM_NODE_ZERO_P)
#endif
{
fprintf(fp_results, "%12.4e ", CURRENT_TIME);
for(i=0; i<NO_OF_VALVES; i++)
{
fprintf(fp_results, "%12.4e ", NV_DOT(cur_r_rp[i],axis[i]));
}
fprintf(fp_results, "\n");
fclose(fp_results);
}
#endif
}
static void write_data(FILE *fp)
{
int i, j;
for(i=0; i<NO_OF_VALVES; i++)
{
fprintf(fp, "%e ", current_vel_mag[i]);
}
fprintf(fp, "\n");
for(i=0; i<NO_OF_VALVES; i++)
{
for(j=0; j<ND_ND; j++)
{
fprintf(fp, "%e ", cur_r_rp[i][j]);
}
fprintf(fp, "\n");
}
fprintf(fp, "\n");
for(i=0; i<NO_OF_VALVES; i++)
{
fprintf(fp, "%e ", previous_time[i]);
}
}
DEFINE_RW_FILE(writer, fp)
{
Message0("Writing UDF data to data file...\n");
#if PARALLEL
#if RP_HOST
write_data(fp);
#endif
#else
write_data(fp);
#endif
}
static void read_data(FILE * fp)
{
int i, j;
for(i=0; i<NO_OF_VALVES; i++)
{
fscanf(fp, "%e", current_vel_mag+i);
}
for(i=0; i<NO_OF_VALVES; i++)
{
for(j=0; j<ND_ND; j++)
{
fscanf(fp, "%e", cur_r_rp[i]+j);
}
}
for(i=0; i<NO_OF_VALVES; i++)
{
fscanf(fp, "%e", previous_time+i);
}
}
DEFINE_RW_FILE(reader, fp)
{
Message0("Reading UDF data from data file...\n");
#if PARALLEL
#if RP_HOST
read_data(fp);
#endif
#else
read_data(fp);
#endif
host_to_node_real(current_vel_mag, NO_OF_VALVES);
host_to_node_real(cur_r_rp[0], NO_OF_VALVES*ND_ND);
host_to_node_real(previous_time, NO_OF_VALVES);
}

thanks in advance

n7310889 August 9, 2012 19:44

Quote:

Originally Posted by Ajay Rao
;109092
Have your case file and UDF in c:\fluent.inc\ntbin\ntx86 folder ... It will run then ! -Ajay

Hi Ajoy, As a test case I have just copied a udf of inlet_x_velocity and modified it slightly to check with a fluent model. But strangely enough, it also shows the similar error message that of Dimitrios one. Obviously, I have followed your instruction and tried several times with different modifications. But the problem is persistent with a little change from line 1 to line 2 then finally line 3. Could you please check the code whats going wrong?
#include "udf.h"

DEFINE_PROFILE(inlet_x_velocity, thread, position)
{
real x[ND_ND];
real y, h;
face_t f;
h = 33.;
begin_f_loop(f,thread)
{
F_CENTROID(x, f, thread);
y = (2.*x[1]- h)/h;
F_PROFILE(f, thread, position) = 2.5*(1.0-y*y);
}
end_f_loop(f, thread)
}

endalke September 28, 2012 02:54

fluent codding error
 
dear fluent users, i am a new user of fluent. trying to solve a 2D cross flow turbine. i use a UDF for the 2D model. my code is

/*This code is written in "C"*/
/*UDF starts for the rotor*/
#inc1ude "udf.h"
#inc1ude "dynamesh_tools.h"
/*UDF starts for Rotational Speed of rotor*/
DEFINE_CG_MOTION(rotor,dt,vel,omega,time,dtime)
{
NY_S(vel,=,0.0);
NY_S(omega,=,0.0);
/*Linear Velocity for blade and pipe*/
vel[O]=0.0;
vel[l]=0.0;
vel[2]=0.0;
/*Angular Velocity for blade and pipe*/
omega[O]=0;
omega[l]=0;
omega[2]=12;
/*Messages for Display*/
Message("\nThis is the rotor\n");
Message("\nCG_Omega for rotor: %g, %g, %g\n",omega[O],omega[1],omega[2]);
Message("\nCG_Position for rotor: %g, %g, %g\n",NV_LIST(DT_CG(dt)));
Message("\nCG_Orientation for rotor: %g, %g, %g\n",NY_LIST(DT_THETA(dt)));
}
/*UDF ends for Rotational Speed of blade and pipe*/

but when i try to compile the UDF i found an error message follow below

1 file(s) copied.
(system "copy C:\Fluent.Inc\fluent6.3.26\src\makefile_nt.udf libudf\ntx86\2ddp\makefile")
1 file(s) copied.
(chdir "libudf")()
(chdir "ntx86\2ddp")()
'nmake' is not recognized as an internal or external command,
operable program or batch file.
'nmake' is not recognized as an internal or external command,
operable program or batch file.

Done.

"D:/model"

Opening library "libudf"...
Error: open_udf_library: The system cannot find the file specified.

Error Object: ()

is any one knows what it mean? and how to solve it, please help me.

mactech001 October 8, 2012 04:46

UDF parse error with DEFINE_PROFILE
 
Quote:

Originally Posted by Ajay Rao
;109092
Have your case file and UDF in c:\fluent.inc\ntbin\ntx86 folder ... It will run then ! -Ajay

Dear Ajay,

Thx to your comments here.

I met a similar problem while using DEFINE_PROFILE (My code attached below. it is actuall an example from Help). The error points to line #1, which is the comment line.


/* Wall Heat Generation Rate Profile UDF */
#include "udf.h"
DEFINE_PROFILE(wallheatgenerate,thread,i)
{
real source = 0.001;
face_t f;
begin_f_loop(f,thread)
F_PROFILE(f,thread,i) = source;
end_f_loop(f,thread)
}

i copied the Case file and the C-code shown above into the folder directory: C:\Program Files\ANSYS Inc\v130\fluent\ntbin\ntx86

But the same error occurs while interpreting.

What else could be incorrect please?

Hope to obtain your guidance/comments as soon as possible. Thx!

Regards,
Mactech001
Using: ANSYS WB v13

nkme2007 October 10, 2012 06:22

Hello All,

I want to do analysis of heat transfer from water flowing through pipes submerged inside concrete. I am modelling in GAMBIT and wish to analyse it on Ansys FLUENT.

Can anybody help me out, how to model and simulate?

Does any tutorials exist?

Payam89 October 31, 2012 11:50

#include "udf.h"

#define Q 1.0;
#define e 1.0;
#define er 3.0;
#define pi 3.1;
#define s 0.0187;

DEFINE_SOURCE(xmom_source,c,t,ds,eqn)
{
real source;
real x[ND_ND];
ds[eqn]=-(Q/2.*pi*e)*(1./x + 1./s-x);

return source;
}



Error: C:\Users\USER\Desktop\ss.c: line 13: parse error.
Error: C:\Users\USER\Desktop\ss.c: line 13: parse error.
Error: C:\Users\USER\Desktop\ss.c: line 13: invalid type for pointer dereference: float.


??????????

thanks

vmtlv November 30, 2012 22:18

static void f_valve(int valveNo, void *dt, real *cg_vel, real *cg_omega, real time, real dtime)
{
#if !RP_HOST
real tmp[ND_ND], dv, current_vel[ND_ND], CG[ND_ND], force[3], moment[3], stretch;
real aero_force[ND_ND], aero_force_axis, spring_force, net_force, r_rp_new[NO_OF_VALVES][ND_ND];
int i;
Thread * tf;
Domain * domain;
/************************************************** ****************/
static real cg_vel_saved[NO_OF_VALVES][ND_ND];
/************************************************** ****************/
/* Do the calculation if the new time step */
if(fabs(previous_time[valveNo]-time)>0.2*dtime)
{
/* reset velocities */
NV_S (cg_vel, =, 0.0);
NV_S (cg_omega, =, 0.0);
/* Check to see if there is data */
if (!Data_Valid_P ())
{
Message0("\n\nNo data->No mesh motion!!!\n\n");
return;
}
/*Calculate force*/
domain = THREAD_DOMAIN (DT_THREAD ((Dynamic_Thread *)dt));
i=0;
NV_S(aero_force,=,0);
while(valveid[valveNo][i]>=0)
{
tf=Lookup_Thread(domain, valveid[valveNo][i]);
NV_S (CG, =, 0.0);
Compute_Force_And_Moment (domain, tf, CG, force, moment, FALSE);
NV_V(aero_force,+=,force);
i++;
}
aero_force_axis=NV_DOT(aero_force, axis[valveNo]);
NV_VV(tmp,=,r_rp_closed[valveNo],-,cur_r_rp[valveNo]);
stretch = (stretch_at_closed[valveNo]+NV_DOT(tmp,axis[valveNo]));
spring_force=stiffness[valveNo]*stretch;
net_force=spring_force+aero_force_axis+9.81*mass[valveNo]*NV_DOT(gravity_direction, axis[valveNo]);
dv=net_force/mass[valveNo]*dtime;

/* Calculate the C.G location and velocity if it does not hit the boundary */
NV_VS(current_vel,=,axis[valveNo],*,current_vel_mag[valveNo]);
NV_VS(tmp,=,current_vel,*,dtime);
NV_VV(r_rp_new[valveNo],=,cur_r_rp[valveNo],+,tmp);
/* Update velocity */
current_vel_mag[valveNo]+=dv;
/* debug info */
#ifdef DEBUG
Message0("\n\n*********************** DEBUG INFO ***************************\n");
Message0("\nvalveNo=%3d\n", valveNo);
Message0("\ncur_r_rp[%d]=(%10.3e, %10.3e, %10.3e)\n",
valveNo, cur_r_rp[valveNo][0], cur_r_rp[valveNo][1], cur_r_rp[valveNo][ND_ND-1]);
Message0("\naero force=(%10.3e, %10.3e, %10.3e)\n",
aero_force[0], aero_force[1], aero_force[ND_ND-1]);
Message0("\n(stretching at closed, stretching, force)=(%10.3e, %10.3e, %10.3e)\n",
stretch_at_closed[valveNo], stretch, spring_force);
Message0("\n(net_force, spring force, aero force)=(%10.3e, %10.3e, %10.3e)\n",
net_force, spring_force, aero_force_axis);
Message0("\nvel(cur)=%11.3e vel(next wo limit)=%11.3e ",
current_vel_mag[valveNo]-dv, current_vel_mag[valveNo]);
#endif
/* if it hits the lift_min boundary then it stays at lift_min*/
NV_VV(tmp,=,r_rp_closed[valveNo],-,r_rp_new[valveNo]);
if(NV_DOT(tmp,axis[valveNo])<(lift_min[valveNo]))
{
NV_V_VS(r_rp_new[valveNo],=,r_rp_closed[valveNo],-,axis[valveNo],*,lift_min[valveNo]);
current_vel_mag[valveNo]=-rest_conts[valveNo]*fabs(current_vel_mag[valveNo]);
}
/* if it hits the lift_max boundary then it stays at lift_max*/
NV_VV(tmp,=,r_rp_closed[valveNo],-,r_rp_new[valveNo]);
if(NV_DOT(tmp,axis[valveNo])>(lift_max[valveNo]))
{
NV_V_VS(r_rp_new[valveNo],=,r_rp_closed[valveNo],-,axis[valveNo],*,lift_max[valveNo]);
current_vel_mag[valveNo]=rest_conts[valveNo]*fabs(current_vel_mag[valveNo]);
}
/* set valve velocity */
NV_VV(tmp,=,r_rp_new[valveNo],-,cur_r_rp[valveNo]);
NV_VS(cg_vel,=,tmp,/,dtime);
/* Update location and velocity */
NV_V(cur_r_rp[valveNo],=,r_rp_new[valveNo]);
NV_V(cg_vel_saved[valveNo],=,cg_vel);
previous_time[valveNo]=time;
/* debug info */
#ifdef DEBUG
Message0("vel(next w limit)=%11.3e\n", current_vel_mag[valveNo]);
Message0("\nvelocity(CG)=(%10.3e, %10.3e, %10.3e)\n",
cg_vel[0], cg_vel[1], cg_vel[ND_ND-1]);
Message0("\nr_rp_new[%d]=(%10.3e, %10.3e, %10.3e)\n",
valveNo, r_rp_new[valveNo][0], r_rp_new[valveNo][1], r_rp_new[valveNo][ND_ND-1]);
Message0("\n*********************** DEBUG INFO ***************************\n\n");
#endif
}
else
{
NV_V(cg_vel,=,cg_vel_saved[valveNo]);
}
#endif
node_to_host_real(current_vel_mag, NO_OF_VALVES);
node_to_host_real(cur_r_rp[0], NO_OF_VALVES*ND_ND);
node_to_host_real(previous_time, NO_OF_VALVES);
}
/* Add more valves if necessary. For instance, if two valves, then
{
f_valve(0, dt, cg_vel, cg_omega, time, dtime);
}
{
f_valve(1, dt, cg_vel, cg_omega, time, dtime);
}


Hi, I can't understand "valveNo" that was most used in "f_valve" , how value does it has ?

Thanks for reading !

ghost82 December 2, 2012 11:35

Quote:

Originally Posted by Payam89 (Post 389511)
#include "udf.h"

#define Q 1.0;
#define e 1.0;
#define er 3.0;
#define pi 3.1;
#define s 0.0187;

DEFINE_SOURCE(xmom_source,c,t,ds,eqn)
{
real source;
real x[ND_ND];
ds[eqn]=-(Q/2.*pi*e)*(1./x + 1./s-x);

return source;
}



Error: C:\Users\USER\Desktop\ss.c: line 13: parse error.
Error: C:\Users\USER\Desktop\ss.c: line 13: parse error.
Error: C:\Users\USER\Desktop\ss.c: line 13: invalid type for pointer dereference: float.


??????????

thanks

you need to specify x[0], which is the x coordinate, or x[1], which is the y coordinate, or x[2], the z coordinate.

mactech001 January 11, 2013 00:52

UDF code understanding
 
dear all,

does the code below applies a constant heat flux of 0.001W/m^2 to the wall please?

/* Wall Heat Generation Rate Profile UDF */#include "udf.h" DEFINE_PROFILE(wallheatgenerate,thread,i) { real source = 0.001; face_t f; begin_f_loop(f,thread) F_PROFILE(f,thread,i) = source; end_f_loop(f,thread) } Regards,mactech001

samcfd February 18, 2013 01:05

Udf help
 
Dear Ajay,

I'm writing a C program for Flapping of a 3D wing. I'm unable to compile it in TURBO C. I' attaching the program along with the errors that r generated. kindly have a look and help me debug it.
# include <math.h>
# include "udf.h"
# include "dynamesh_tools.h"
# define DEFINE_CG_MOTION(wing,dt,vel,omega,time,dtime) {\
double Freq, pi, w, degree, phimax, thmax, phi, dphi, dtheta;\
degree = 20; /*degree step set by journal file*/ \
Freq=1.0/(dtime*degree); /*dtime is the physical time step defined in the journal file*/ \
pi = 3.141592654;\
w=2*pi*Freq; /*Omega (radians)*/\
phimax = 30.0*pi/180; /*flapping amplitude set by journal file*/\
thmax = 30.0*pi/180; /*feathering amplitude set by journal file*/\
phi = -phimax*sin(w*time); /*flapping angle*/\
dphi = -phimax*w*cos(w*time); /*flapping speed*/\
dtheta = thmax*w*sin(w*time); /*feathering speed*/\
vel[0] = 0;\
vel[1] = 0;\
vel[2] = 0;\
omega[0] = dphi;\
omega[1] = dtheta*cos(phi);\
omega[2] = dtheta*sin(phi);\
}


The errors are as follows

Error C:\ TC\ Airfoil 1.c : unable to open include file ' DYNAMESH_TOOLS.H'

Error C:\ TC\ include\udf.h : unexpected end of file in conditional started on line 0



Quote:

Originally Posted by Ajay
;109106
Hi, The error means that you cant use Interpreted UDF you have to use compiled UDF. compiled udf are bit more difficult to set up , you need to build the libraries and then load them. You should have an external compiler , VC++ compiler, thats the way i do it. Let me know if you need more help with it. -Ajay


prishor February 28, 2013 00:11

hi ajay,

in your post you have mentioned to make directory for compiled UDF in x86 system. i am using x64 system. how can i make the directory and compile the UDF in x64 system.
whether i have to install visual c++ or visual studio prior.

please help me

thanks and regards,
prishor

ashar_md2001 May 21, 2013 18:05

Help with the UDF
 
Hi there fellow fluent users.I get an error message when trying to interpret the UDF in Fluent see below

ashar_md2001 May 24, 2013 14:57

Help with the error in UDF
 
Hi fluent users,
I get an error message when trying to interpret the UDF in Fluent. The following message appears: line 124: parse error. I even tried
c:\fluent.inc\ntbin\ntx86 folder ... as suggested by Ajay.
Also if there is any correction in the UDF it could be suggested


#include "udf.h" /* must be the bginning of every UDF you write */
#include "sg_pb.h"
#include "sg_mphase.h"

DEFINE_PB_Nucleation_Rate(nuc_rate,cell,thread)
{
real J,S;
real Kn=1.0e36; /* Nucleation rate constant */
real Nn=2686.; /* Nucleation law power index */
real T,solute_mass_fract,solvent_mass_frac,solute_mol_f rac,solubility;
real solute_mol_wt, solvent_mol_wt;

Thread *tc=THREAD_SUPER_THREAD(thread); /* obtain mixture thread */
Thread **pt=THREAD_SUB_THREADS(tc); /* pointer to sub_threads thread */
Thread **tp=pt[P_PHASE]; /* primary phase thread */


solute_mol_wt=224.00; /* molecular weight of barium sulphate */
solvent_mol_wt=18.; /* molecular weight of water */
solute_mass_frac=C_YI(cell,tp,o); /* mass fraction of solute in primary phase (solvent)*/
solvent_mass_frac=1.0-solute_mass_frac;
solute_mass_frac=(solute_mass_frac/solute_mol_wt)/
((solute_mass_frac/solute_mol_wt)+(solvent_mass_frac/solvent_mol_wt));

T=C_T(cell,tp); /* Temperature of primary phase in kelvin */
solubility=0.0005*T-0.0794; /* Solubility Law relating equilibrium solute mole fraction to Temperature */

s=solute_mol_frac/solubilty; /* Definition of Supersaturation */
if (S=1.)
{
J=0.;
}
else
{
J=Kn*exp-((Nn)/(pow((lnS),2.0)));
}
return J;
}

the equation is J=Kn exp (-Nn/(lnS)^2)

Hi guys any help or guidance will be appreciated

bradlee March 18, 2015 22:53

Hi, ashar

Did you solve this error??

If you are, can you explain how to solve the error??


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