CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   FLUENT (https://www.cfd-online.com/Forums/fluent/)
-   -   about the macro P_USER_REAL(p,i) (https://www.cfd-online.com/Forums/fluent/69066-about-macro-p_user_real-p-i.html)

haigangwang October 10, 2009 21:05

about the macro P_USER_REAL(p,i)
 
I have written one udf programe about DPM,but when I hook them,it is giving me a error:P_USER_REAL(p,0): undeclared variable.Please help me!

my programe:

#include "udf.h"
#include "models.h"
#include "dpm.h"
#include "surf.h"
#include "threads.h"
#include "math.h"
#include "mem.h"
DEFINE_DPM_SCALAR_UPDATE(particle_depostion,c,t,in itialize,p)
{
int i = 0;
face_t f;
Thread *th;
real A[ND_ND];
real area=0,vol=0;

int wall_ID=4;
if (initialize)
P_USER_REAL(p, 0) = 0;
c_face_loop(c,t,i)
{
if(THREAD_ID(C_FACE_THREAD(c,t,i)) == wall_ID)
{

f=C_FACE(c,t,i);
th=C_FACE_THREAD(c,t,i);
F_AREA(A,f, th);
area = NV_MAG(A);
vol=C_VOLUME(c,t);

if(P_DIAM(p)<0.01)
{

C_UDMI(c, t, 0) +=P_DIAM(p);
P_USER_REAL(p,0) = 1.; /* "Evaporate" */


}

}
}

}

DEFINE_DPM_LAW(stop_dpm_law,p,if_cpld)
{
if (0. < P_USER_REAL(p,0))
P_MASS(p) = 0.; /* "Evaporate" */
}
DEFINE_INIT(my_init_func,d)
{
cell_t c;
Thread *t;

thread_loop_c(t,d)
{

begin_c_loop_all(c,t)
{
C_UDMI(c,t,0)=0;

}
end_c_loop_all(c,t)
}
}



Häwimeddel October 12, 2009 04:00

Try to access the user memory of the particle in this way:

Code:

p->user[0] = ...
Do´t forget to enable as many user variables as you need (in your case it would be only one so far) in the UDF panel of the discrete phase model menu!

haigangwang October 22, 2009 21:50

thank you
 
I have understood your mean.Tnanks.
Quote:

Originally Posted by Häwimeddel (Post 232196)
Try to access the user memory of the particle in this way:

Code:

p->user[0] = ...
Do´t forget to enable as many user variables as you need (in your case it would be only one so far) in the UDF panel of the discrete phase model menu!


roopesh99 April 4, 2016 00:52

I am using macros DEFINE_DPM_SCALAR_UPDATE. Can any one tell the means of P_USER_REAL(p,0) = P_USER_REAL(p,0) + 1.
P_USER_REAL(p,1) = 1.;
::::::::::::
some part of my UDF is
if (P_POS(p)[2]<0.03) //particle pos in z direction less then 3 cm
{
P_USER_REAL(p,1) = 0.;
}

if (P_POS(p)[2]>0.9 && P_USER_REAL(p,1) == 0.) //particle pos in z direction greater then 90 cm
{

P_USER_REAL(p,0) = P_USER_REAL(p,0) + 1.
P_USER_REAL(p,1) = 1.;
etc

roopesh99 April 4, 2016 00:59

Dear friend
can you tell the means of P_USER_REAL(p,0) = P_USER_REAL(p,0) + 1.
P_USER_REAL(p,1) = 1. in the macros DEFINE_DPM_SCALAR_UPDATE.

`e` April 4, 2016 17:14

Quote:

Originally Posted by roopesh99 (Post 593188)
can you tell the means of P_USER_REAL(p,0) = P_USER_REAL(p,0) + 1.
P_USER_REAL(p,1) = 1. in the macros DEFINE_DPM_SCALAR_UPDATE.

P_USER_REAL(p,i) is used for storing real data type values for each particle, where i is an integer for identifying each array.

Your first example increments the array of the current particle by one:

Code:

P_USER_REAL(p,0) = P_USER_REAL(p,0) + 1.;
The second example sets the second array to one:

Code:

P_USER_REAL(p,1) = 1.;
I've noticed these snippets are from my code in this thread and I've explained these macros here.


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