CFD Online Discussion Forums

CFD Online Discussion Forums (
-   FLUENT (
-   -   DPM UDF particle position (

Tom October 29, 2004 10:25

DPM UDF particle position

I try to find the particle position using macro P_POS(p)[i]. But when Fluent interpret the source code, an error "undeclared variable" occurred.

Why? How to solve this problem?

Thank you in advance. Tom

Umesh October 29, 2004 13:18

Re: DPM UDF particle position
It is hard to tell with the given details.

It could be because of any variable, which hasn't been declared before its use.

One other thing i get in mind is, does your UDF supplies the pointer p access? If not, you need to provide that with the argument ' Tracked_Particle *p '.

Tom October 29, 2004 13:30

Re: DPM UDF particle position
Hello, Umesh, Thank you. I found out it is not necessary to provide the argument ' Tracked_Particle *p '. The following is a very simple UDF. But the error still exists.

#include "udf.h"

DEFINE_DPM_BODY_FORCE(particle_body_force, p, i) {

real bforce = 0.0;

real x = P_POS(p)[1];

return (bforce/P_MASS(p)); }

Waiting for your reply. Thanks. Tom.

Umesh October 29, 2004 14:08

Re: DPM UDF particle position
Hi Tom,

I think the problem is with the definition of x. I think, P_POS(p)[i] is a position vector and so you need to define x as a vector with syntax, 'real x[ND_ND]'. Then, you can access the x component of the position with, x[1] = P_POS(p)[1]. Try this out. It may solve yr problem.

David November 1, 2004 16:22

Re: DPM UDF particle position

I would like to get the face area the particle is crossing to get the volume flux.

But I'm not sure which variable I should use and how:


#include "udf.h"

#include "dpm.h"

#include "surf.h"


#define P_CELL(P) RP_CELL(&((P)->cCell)) /* Non-standard macros */

#define P_CELL_THREAD(P) RP_THREAD(&((P)->cCell))

real volume;

real face;

Particle *p;

cell_t cell;

face_t f;

Thread *cthread;

real r, x, y;

DEFINE_DPM_OUTPUT(Discrete_phase_sample,header,fp, p,t,plane)


#if RP_3D

real flow_time = solver_par.flow_time;

cell = P_CELL(p); /* Get the cell and thread that the particle

is currently in */

cthread = P_CELL_THREAD(p);

face = C_FACE(cell,cthread);


cxprintf(fp," #R [m] x-velocity[m/s] y-velocity[m/s] z-velocity[m/s] Drop Diameter[m] face \n");



x = p->state.pos[0];

y = p->state.pos[1];

r = sqrt(SQR(x) + SQR(y));

cxprintf(fp," %e %f %f %f %e %e \n",







Can anyone help?

thank you


annie November 5, 2004 08:59

Re: DPM UDF particle position
i think, when you use UDF in DPM, you must compile the UDF, rather than interpret the file.

When you compile any udf, you muss install the VC++ in your computer, then all is ok.

Tom November 5, 2004 18:46

Re: DPM UDF particle position
Hello, Annie, Thank you. It works. Tom

NH_Aus December 25, 2010 03:39

I need to know the shortest distance of wall from the particle location. I know I can use C_WALL_DIST(c,t) this, but how do I connect from:
px=P_POS(p)[0] ;
py=P_POS(p)[1] ;
pz=P_POS(p)[2] ;

Parham Vatankhah July 25, 2015 12:30

Hi all,

By interpreting UDFs you can not access particles position.
Generally, it's better to compile complex UDFs.

best regards,


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