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/)
-   -   a define_source problem (http://www.cfd-online.com/Forums/fluent-udf/73595-define_source-problem.html)

danielchen37 March 11, 2010 22:06

a define_source problem
 
dear all:
i come across a udf problem. the case ran well without the udfs. but when the udfs were compiled, built and loaded, the error signal would appear and the interation would not process a bit.
here is the error signal:

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: ()

the udfs are compiled and loaded successfully as:
xforce.c
yforce.c
zforce.c
uds.c
Generating Code...
# Generating udf_names.c because of makefile xforce.obj yforce.obj zforce.obj uds.obj
udf_names.c
# Linking libudf.dll because of makefile user_nt.udf udf_names.obj xforce.obj yforce.obj zforce.obj uds.obj
Microsoft (R) Incremental Linker Version 6.00.8168
Copyright (C) Microsoft Corp 1992-1998. All rights reserved.
Creating library libudf.lib and object libudf.exp
Done.
"E:/hyc/hyc/RE1000"
Opening library "E:\hyc\hyc\RE1000\libudf"...
Library "E:\hyc\hyc\RE1000\libudf\ntx86\3d\libudf.dll" opened
xforce_source
yforce_source
zforce_source
uds_source
Done.

and here is one code of my udfs and the rest of the udfs all share with the same structure:
#include"udf.h"
#include"mem.h"
#include"metric.h"
DEFINE_SOURCE(xforce_source,c,t,dS,eqn)
{
real dens;
real u;
real v;
real w;
real ux;
real uy;
real uz;
real cp;
real A;
real con;
real tx;
real tgx;
real source;
real x[ND_ND];
real ur;
real sc;
real sp;
C_CENTROID(x,c,t);
dens=C_R(c,t);
u=C_U(c,t);
v=C_V(c,t);
w=C_W(c,t);
ux=C_DUDX(c,t);
uy=C_DUDY(c,t);
uz=C_DUDZ(c,t);
A=C_UDSI(c,t,0);
tx=C_T_G(c,t)[0];
con=-0.02;
ur=v*uy+u*uz;
sc=dens*ur+con*A*tx;
sp=dens*ux;
source=sp*u+sc;
dS[eqn]=sp;
return source;
}

please tell me what's wrong with my udf and how could i correct it.
thank you!

gearboy March 12, 2010 01:14

Quote:

Originally Posted by danielchen37 (Post 249632)
dear all:
i come across a udf problem. the case ran well without the udfs. but when the udfs were compiled, built and loaded, the error signal would appear and the interation would not process a bit.
here is the error signal:

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: ()

the udfs are compiled and loaded successfully as:
xforce.c
yforce.c
zforce.c
uds.c
Generating Code...
# Generating udf_names.c because of makefile xforce.obj yforce.obj zforce.obj uds.obj
udf_names.c
# Linking libudf.dll because of makefile user_nt.udf udf_names.obj xforce.obj yforce.obj zforce.obj uds.obj
Microsoft (R) Incremental Linker Version 6.00.8168
Copyright (C) Microsoft Corp 1992-1998. All rights reserved.
Creating library libudf.lib and object libudf.exp
Done.
"E:/hyc/hyc/RE1000"
Opening library "E:\hyc\hyc\RE1000\libudf"...
Library "E:\hyc\hyc\RE1000\libudf\ntx86\3d\libudf.dll" opened
xforce_source
yforce_source
zforce_source
uds_source
Done.

and here is one code of my udfs and the rest of the udfs all share with the same structure:
#include"udf.h"
#include"mem.h"
#include"metric.h"
DEFINE_SOURCE(xforce_source,c,t,dS,eqn)
{
real dens;
real u;
real v;
real w;
real ux;
real uy;
real uz;
real cp;
real A;
real con;
real tx;
real tgx;
real source;
real x[ND_ND];
real ur;
real sc;
real sp;
C_CENTROID(x,c,t);
dens=C_R(c,t);
u=C_U(c,t);
v=C_V(c,t);
w=C_W(c,t);
ux=C_DUDX(c,t);
uy=C_DUDY(c,t);
uz=C_DUDZ(c,t);
A=C_UDSI(c,t,0);
tx=C_T_G(c,t)[0];
con=-0.02;
ur=v*uy+u*uz;
sc=dens*ur+con*A*tx;
sp=dens*ux;
source=sp*u+sc;
dS[eqn]=sp;
return source;
}

please tell me what's wrong with my udf and how could i correct it.
thank you!

Note that gradient variables are
available only when the equation for that variable is being solved. For example, if you
are defining a source term for energy, your UDF can access the cell temperature gradient
(using C_T_G), but it cannot get access to the x-velocity gradient (using C_U_G). The reason for this is that the solver continually removes data from memory that it doesn't need. In order to retain the gradient data (when you want to set up user-defined scalar transport equations, for example), you can prevent the solver from freeing up memory by issuing the text command

solve/set/expert

and then answering yes to the question Keep temporary solver memory from being freed?.

Note that when you do this, all of the gradient data is retained, but the calculation requires more memory to run.

danielchen37 March 12, 2010 03:13

thank you so much, gearboy!
 
dear gear boy:
thank you so much for solving my problem!
i'll try and wish it could work!

danielchen37 March 12, 2010 23:48

the error remains
 
dear all
the error remains. help me!


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