CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   FLUENT (https://www.cfd-online.com/Forums/fluent/)
-   -   User defined memory value changing (https://www.cfd-online.com/Forums/fluent/189516-user-defined-memory-value-changing.html)

minhoabc June 21, 2017 11:53

User defined memory value changing
 
1 Attachment(s)
Hi guys,

In my UDF code, I'm trying to #define a value and use it as one of the factors to be included in DPM body force. However, when I set that defined value as C_UDMI (user defined memory 40) and check in the CFD-post to see if it really did stay constant, it shows me that the value have fluctuated. Anyone knows why the Fluent would change the #defined C_UDMI value on its own? Or should I use other methods to check the #defined value?

Thanks in advance,

james Kim

and Here's my code!

#include "udf.h"

#define TSTART 0.0 /* field applied at t = tstart */
#define pi 3.14159265359
#define mu0 pi*4E2
#define gravity 3.2997E-6
#define mobility 4.15E-6

DEFINE_DPM_BODY_FORCE(particle_body_force,p,i)
{
cell_t c = RP_CELL(&(p->cCell));
Thread *t = RP_THREAD(&(p->cCell));



real bforce = 0.0000000000000000;


if (P_TIME(p) >= TSTART)
{

C_UDMI(c,t,40) = mobility;
C_UDMI(c,t,39) = pi;
if (i == 0)
bforce = 0.5*mobility*C_UDMI(c,t,1)/mu0 + gravity + P_VEL(p)[0];
else if (i == 1)
bforce = 0.5*mobility*C_UDMI(c,t,2)/mu0;
}
else
bforce = 0.0000000000000000;
/* an acceleration should be returned */
return (bforce);


}

KaLium June 22, 2017 05:50

That is very odd. Try to remove this part from code:

Code:

C_UDMI(c,t,40) = mobility;
C_UDMI(c,t,39) = pi;

Then patch the correct values in Fluent.

https://www.sharcnet.ca/Software/Flu...g/node1035.htm

divergence June 22, 2017 06:28

A complete code noobie embarrassing myself here:

Should the

Code:

(P_TIME(p) >= TSTART)
actually be

Code:

(TP_TIME(p) >= TSTART)
I found the "P_TIME" function via a search engine but the udf manual of Fluent R18 wouldn't have any of it. Instead it would suggest the following:

Code:

DEFINE_DPM_BODY_FORCE(particle_body_force,tp,i)
{
real bforce=0;
if(TP_TIME(tp)>=TSTART)
{
if(i==0) bforce=Q*BZ*TP_VEL(tp)[1];
else if(i==1) bforce=-Q*BZ*TP_VEL(tp)[0];
}
else
bforce=0.0;
/* an acceleration should be returned */
return (bforce/TP_MASS(tp));
}

Naturally I wouldn't know which version of Fluent you are using but this might be a good thing to try.


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