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/)
-   -   What’s the problem with this udf? (https://www.cfd-online.com/Forums/fluent-udf/124556-what-s-problem-udf.html)

nikiii October 8, 2013 07:30

What’s the problem with this udf?
 
What’s the problem with this udf?

#include "udf.h"
#define K 1.38e-23
#define e 1.6e-19
#define T 293
#define ci 240
#define E0 8.854e-12
#define pi 3.141593
#define KP 2.5 /* relative permittivity-particle dielectric constatnt */
#define Dp 4e-6 /* diameter of particles */
#define bi 0.00015 /* ion mobility */
DEFINE_DPM_BODY_FORCE(particle_body_force, p, i)
{
Domain*d;
real bforcex,bforcey, Qs, E, Q, tow, towc, Qp;
real bforce=0;
Thread *t;
cell_t c;
face_t f;
d=Get_Domain(2);
thread_loop_c(t,d)
{
begin_c_loop(c,t)
{
E=sqrt(ND_SUM(pow(C_UDMI(c,t,0),2),pow(C_UDMI(c,t, 1),2)));
Qs=(3*pi*E0*KP*pow(Dp,2)*E)/(KP+2);
tow=(4*E0)/(C_UDSI(c,t,1)*bi);
towc=(8*E0*K*T)/(Dp*e*ci*C_UDSI(c,t,1));
Qp=Qs*(P_TIME(p)/(P_TIME(p)+tow))+(2*pi*E0*Dp*K*T/e)*log(1+(P_TIME(p)/C_UDMI(c,t,2)));
C_UDMI(c,t,3)=Qp;
bforcex=Qp*C_UDMI(c,t,0);
bforcey=Qp*C_UDMI(c,t,1);
bforce=sqrt(ND_SUM(pow(bforcex,2),pow(bforcey,2))) ;
C_UDMI(c,t,4)=bforce;
}
end_c_loop(c,t)
}
I consider 2 uds and 5 udm in define/user define/scalars or memories.
It compiled successfully but when I want track particle in fluent, this error appear.
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: ()

If anybody know what should I do please help me. Thank you.

A CFD free user October 8, 2013 09:39

Hi dude
The problem which many guys encounter when working with UDF. You have probably forgot to set UDM in Fluent. This error shows when someone forgets to set UDM or even less than the numbers used in UDF. For instance, you have three UDMs but set only two. Here, the error comes.

nikiii October 8, 2013 10:25

I set 6 UDHs in define/user-define/memories. but this error appears again.

A CFD free user October 8, 2013 18:39

Hi!
I suppose that the problem is due to not invoking UDM(s) and UDS(s) that you already defined and you're gonna use. If you have a look at your UDF, you can see that you've using UDS(s) and UDM(s) that have not invoked in this UDF. For instance, UDS(c,t,0)? It's undefined. Try it, it works.


All times are GMT -4. The time now is 15:39.