CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   FLUENT (https://www.cfd-online.com/Forums/fluent/)
-   -   Error while compliling an UDF (https://www.cfd-online.com/Forums/fluent/67937-error-while-compliling-udf.html)

Kappe September 1, 2009 08:20

Error while compliling an UDF
 
Hi I have written an UDF to oscillate my geometry. When i complie it i have the fluent says:
1 file(s) copied. ( the UDF.c file)
1 file(s) copied.( udf.h)
1 file(s) copied.(metric.h)
(system "copy C:\Fluent.Inc\fluent6.2.16\src\makefile_nt.udf libudf\ntx86\2ddp\makefile") 1 file(s) copied.
0
(chdir "libudf")()
(chdir "ntx86\2ddp")()
UDF.c
e:\shreyas\naca0012\unstructured\libudf\src\udf.c( 27) : warning C4700: uninitialized local variable 'node' used
# Generating udf_names.c because of makefile UDF.obj

Done.


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

Error Object: ()

THE LOG FILE SAYS:
sed' is not recognized as an internal or external command,
operable program or batch file.
NMAKE : U1077: 'C:\WINDOWS\system32\cmd.exe' : return code '0x1'
Stop.
PLZ HELP!!!!! :confused:




my UDF is


#include "udf.h"
#include "metric.h"

DEFINE_CG_MOTION(Oscillation, dt, vel, omega, time, dtime)

{


face_t f;
Thread *tf = DT_THREAD(dt);
real xn, yn, r, sin_theta, cos_theta;
int n;

begin_f_loop(f,tf) /* Loops over all faces in the thread passed in the DEFINE macro argument */

{
f_node_loop(f,tf,n) /* Loops over all nodes in the face */

{
Node *node;
xn = NODE_X(node); // calculate x-coordinate of a grid point on wall
yn = NODE_Y(node); // calculate y-coordinate of a grid point on wall
r = sqrt(pow(xn,2)+pow(yn,2)); // calculate radial coordinate of the grid point on wall
sin_theta = yn/r;
cos_theta = xn/r;
vel[1]=cos(3.14159*time)*cos_theta*0.087266463*3.14159*r ; //y-component of velocity
vel[0]= cos(3.14159*time)*sin_theta*0.087266463*3.14159*r; //x-component of velocity


}
}

end_f_loop(f,tf);

}

aleisia June 23, 2011 17:53

Hi, have you figured out the way to eliminate the "warning C4700: uninitialized local variable 'node' used"?
I have the same problem in mu UDF, can you please share your experience with me?

Thanks!

Quote:

Originally Posted by Kappe (Post 228107)
Hi I have written an UDF to oscillate my geometry. When i complie it i have the fluent says:
1 file(s) copied. ( the UDF.c file)
1 file(s) copied.( udf.h)
1 file(s) copied.(metric.h)
(system "copy C:\Fluent.Inc\fluent6.2.16\src\makefile_nt.udf libudf\ntx86\2ddp\makefile") 1 file(s) copied.
0
(chdir "libudf")()
(chdir "ntx86\2ddp")()
UDF.c
e:\shreyas\naca0012\unstructured\libudf\src\udf.c( 27) : warning C4700: uninitialized local variable 'node' used
# Generating udf_names.c because of makefile UDF.obj

Done.


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

Error Object: ()

THE LOG FILE SAYS:
sed' is not recognized as an internal or external command,
operable program or batch file.
NMAKE : U1077: 'C:\WINDOWS\system32\cmd.exe' : return code '0x1'
Stop.
PLZ HELP!!!!! :confused:




my UDF is


#include "udf.h"
#include "metric.h"

DEFINE_CG_MOTION(Oscillation, dt, vel, omega, time, dtime)

{


face_t f;
Thread *tf = DT_THREAD(dt);
real xn, yn, r, sin_theta, cos_theta;
int n;

begin_f_loop(f,tf) /* Loops over all faces in the thread passed in the DEFINE macro argument */

{
f_node_loop(f,tf,n) /* Loops over all nodes in the face */

{
Node *node;
xn = NODE_X(node); // calculate x-coordinate of a grid point on wall
yn = NODE_Y(node); // calculate y-coordinate of a grid point on wall
r = sqrt(pow(xn,2)+pow(yn,2)); // calculate radial coordinate of the grid point on wall
sin_theta = yn/r;
cos_theta = xn/r;
vel[1]=cos(3.14159*time)*cos_theta*0.087266463*3.14159*r ; //y-component of velocity
vel[0]= cos(3.14159*time)*sin_theta*0.087266463*3.14159*r; //x-component of velocity


}
}

end_f_loop(f,tf);

}


p4lm0r3 June 24, 2011 09:04

To me it looks like the variable node has not been declared properly. I think your code should look something like this:

Node *node;
begin_f_loop(f,tf) /* Loops over all faces in the thread passed in the DEFINE macro argument */

{
f_node_loop(f,tf,node) /* Loops over all nodes in the face */

{
xn = NODE_X(node); // calculate x-coordinate of a grid point on wall
yn = NODE_Y(node); // calculate y-coordinate of a grid point on wall
...

tobino June 27, 2011 20:59

Hi,
I am too using UDF, your code not problem may be you not complete in creating environment for Fluent to connect with C programme.

colaktu June 28, 2011 17:34

Problem with six_dof.h
 
Dear Friends;
I'd faced a problem with my six_dof.h file. I'd build an UDF file that used sdof_properties macro, fluent returned a parse error. I've checked some other macros such as velocity, boundary it works fine. But when i used dynamic mesh macros, get parse errors. I tried "#include six_dof.h" option and received parse error at line 69. Is there any body faced with this before or knows solution.
thanks..

AdrienL June 30, 2011 09:46

Hi,

here is your UDF (corrected from line 21 to 26) and it s working on my computer.

UDF :

#include "udf.h"
#include "metric.h"

DEFINE_CG_MOTION(Oscillation, dt, vel, omega, time, dtime)

{


face_t f;
Thread *tf = DT_THREAD(dt);
real xn, yn, r, sin_theta, cos_theta;
int n;

begin_f_loop(f,tf) /* Loops over all faces in the thread passed in the DEFINE macro argument */

{
f_node_loop(f,tf,n) /* Loops over all nodes in the face */

{
Node *node;
xn = NODE_X(node); /* calculate x-coordinate of a grid point on wall */
yn = NODE_Y(node); /* calculate y-coordinate of a grid point on wall */
r = sqrt(pow(xn,2)+pow(yn,2)); /* calculate radial coordinate of the grid point on wall */
sin_theta = yn/r;
cos_theta = xn/r;
vel[1]=cos(3.14159*time)*cos_theta*0.087266463*3.14159*r ; /*y-component of velocity */
vel[0]= cos(3.14159*time)*sin_theta*0.087266463*3.14159*r; /*x-component of velocity */


}
}

end_f_loop(f,tf);

}

(DON'T FORGET TO USE dos2unix fonction if using Unix)

Sincerly

Adrien



Plz add reputation if the answer is correct :D

aleisia July 1, 2011 00:14

Hi AdrienL,
Can you please take a look at my UDF?I want to model a filter (but not modeling it as a porous media), in a room I have SO2 and air mixture. First I want to get the SO2 mass flow rate at the inlet surface of the filter, then multiply it by 0.999989, and set the sink rate of the filter volume as -0.999989*(SO2 mass flow rate at the inlet surface)/(Volume of filter). For the outlet of the filter, I set it as "interior", and my simulation is always transient.

The error I got for parallel computing is:

999999 (..\src\mpsystem.c@1149): mpt_read: failed: errno = 10054

999999: mpt_read: error: read failed trying to read 4 bytes: No such file or directory
MPI Application rank 0 exited before MPI_Finalize() with status -1073741819

If I switched to serial computing, the error I got is:
Error:
FLUENT received fatal signal (ACCESS_VIOLATION)
1. Note exact events leading to error.
2. Save case/data under new name.
3. Exit program and restart to continue.
4. Report error to your distributor.

Error:
FLUENT received fatal signal (ACCESS_VIOLATION)
1. Note exact events leading to error.
2. Save case/data under new name.
3. Exit program and restart to continue.
4. Report error to your distributor.
Error Object: #f

I don't know what I wrote wrong,,,

#include "udf.h"

#define inlet_surface_ID 70
#define filter_volume_ID 3

DEFINE_ADJUST(my_adjust, d)
{
int i=0;
real massflowrate=0.;
real vol=0.;
#if !RP_HOST
/* real A[ND_ND]; */
/* real flux[ND_ND]; */
real NV_VEC(flux);
real NV_VEC(A); /* declaring vectors flux and A */
real source;

/* real ti = RP_Get_Real("flow-time"); */ /* ti = CURRENT_TIME;*/
face_t f;
cell_t c;
Thread *t;
Thread *thread;

/* vol=0.0; */
/* massflowrate=0.0; */

t = Lookup_Thread(d, inlet_surface_ID); /* defining the inlet surface thread by specifying the Zone_ID*/
thread= Lookup_Thread(d, filter_volume_ID); /* defining the filter volume thread by specifying the Zone_ID*/



/* Send the ID value to all the nodes */
/* host_to_node_real_4(f, t, c, thread); Does nothing in serial, t is the thread of inlet surface, thread is the thread of the filter volume */

/*Start to calculate the mass flow rate through the inlet surface and store it in UDM*/

begin_f_loop(f,t)
if PRINCIPAL_FACE_P(f,t) /* tests if the face is the principle face FOR COMPILED UDFs ONLY */
{
/* NV_D(flux, =, F_U(f,t), F_V(f,t), F_W(f,t)); */ /* defining flux in terms of velocity field */
/* NV_S(flux, *=, F_R(f,t)); */ /* multiplying density to get flux vector */
/* F_AREA(A,f,t); */ /* face normal vector returned from F_AREA */
/* i is being used uninitialized. Please fix this */
massflowrate += F_FLUX(f,t)*F_YI(f,t,i); /* dot product of the inlet surface flux and area vector, multiplied by the mass fraction of species i */
}
end_f_loop(f,t)

# if RP_NODE /* Perform node synchronized actions here, Does nothing in Serial */
massflowrate = PRF_GRSUM1(massflowrate);
# endif /* RP_NODE */


begin_f_loop(f,t)
if PRINCIPAL_FACE_P(f,t) /* tests if the face is the principle face FOR COMPILED UDFs ONLY */
{
F_UDMI(f, t, 0)= massflowrate; /* YOU MAY NEED TO CHECK THE NODE AS THE SUMMED UP VALUE OF massflowrate IS DONE AT node0. */
}
end_f_loop(f,t)
#if RP_NODE0
Message0("Inlet TEP Mass Flow Rate through %d is: %g \n", inlet_surface_ID, massflowrate);
#endif
/*Start to calculate the total volume of filter volume and store it in UDM */
begin_c_loop(c,thread)
{
vol += C_VOLUME(c,thread); /* get cell volume */
}
end_c_loop_int(c,thread)

#if RP_NODE /* Perform node synchronized actions here, Does nothing in Serial */
vol= PRF_GRSUM1(vol);
# endif /* RP_NODE */

begin_c_loop_int(c,thread)
{
C_UDMI(c, thread, 1)= vol; /* YOU MAY NEED TO CHECK THE NODE AS THE SUMMED UP VALUE OF massflowrate IS DONE AT node0. */
}
end_c_loop_int(c,thread)

#if RP_NODE0
Message0("Sink Volume in %d is: %g \n", filter_volume_ID, vol);
#endif

#endif
}

DEFINE_SOURCE(cell_tepmass_source, c, thread, dS, eqn)
{
real source=0.;
real tepflowrate=0.;
real vol_tot=0.;
#if !RP_HOST
/* real ti = RP_Get_Real("flow-time"); /\* ti = CURRENT_TIME;*\/ */
face_t f=0;
Thread *t;
/* Thread *thread; */
Domain *d = Get_Domain(1);
t= Lookup_Thread(d, inlet_surface_ID); /* defining the inlet surface thread by specifying the Zone_ID*/
thread= Lookup_Thread(d, filter_volume_ID); /* defining the filter volume thread by specifying the Zone_ID*/

/* f is being utilized without initialization. This will lead to errors.Please fix this issue */
/* instead of F_UDMI, you can store data in C_UDMI */
tepflowrate= F_UDMI(f, t, 0);
vol_tot = C_UDMI(c, thread, 1);

#endif

/* Pass the node's TEP mass flow rate and volume to the Host for calculating source */
node_to_host_real_2(tepflowrate, vol_tot); /* Does nothing in SERIAL */
#if !RP_NODE
source=0.999989*tepflowrate/vol_tot;
dS[eqn]=0.;
Message("Sink Rate in Filter %d is %g (kg/m^3/s)\n", filter_volume_ID,source);
#endif
return source;
}


Quote:

Originally Posted by AdrienL (Post 314237)
Hi,

here is your UDF (corrected from line 21 to 26) and it s working on my computer.

UDF :

#include "udf.h"
#include "metric.h"

DEFINE_CG_MOTION(Oscillation, dt, vel, omega, time, dtime)

{


face_t f;
Thread *tf = DT_THREAD(dt);
real xn, yn, r, sin_theta, cos_theta;
int n;

begin_f_loop(f,tf) /* Loops over all faces in the thread passed in the DEFINE macro argument */

{
f_node_loop(f,tf,n) /* Loops over all nodes in the face */

{
Node *node;
xn = NODE_X(node); /* calculate x-coordinate of a grid point on wall */
yn = NODE_Y(node); /* calculate y-coordinate of a grid point on wall */
r = sqrt(pow(xn,2)+pow(yn,2)); /* calculate radial coordinate of the grid point on wall */
sin_theta = yn/r;
cos_theta = xn/r;
vel[1]=cos(3.14159*time)*cos_theta*0.087266463*3.14159*r ; /*y-component of velocity */
vel[0]= cos(3.14159*time)*sin_theta*0.087266463*3.14159*r; /*x-component of velocity */


}
}

end_f_loop(f,tf);

}

(DON'T FORGET TO USE dos2unix fonction if using Unix)

Sincerly

Adrien



Plz add reputation if the answer is correct :D



All times are GMT -4. The time now is 20:36.