CFD Online Discussion Forums

CFD Online Discussion Forums (
-   FLUENT (
-   -   pointer 'p' in UDF (

Umesh Shah June 17, 2003 17:42

pointer 'p' in UDF
Hi everyone,

I use DEFINE_SOURCE(name,c,t,dS,eqn) udf for my application.

Now in that UDF, i need to access DPM particles information and so want to access DPM macros e.g.,P_MASS(p),P_TIME(p)... Now to do so, i need to have access to the pointer 'p' in my above UDF.But that UDf doesn't pass the pointer p.

Does anybody know, how to get access of the particles' data in an UDF which does not pass 'p' with it?

Thanks for your time,


rookie June 18, 2003 12:05

Re: pointer 'p' in UDF
Umesh, I think you may use loop(p, I->p)

Hope it helps.


Allan Walsh June 18, 2003 14:11

Re: pointer 'p' in UDF
If I understand your question correctly, you can follow the example in the Fluent 6.0 UDF Manual which starts on Page 4-96.

Include the "surf.h" header file to access the RP_Cell() and RP_Thread() macros.

Then like in the condenshumidlaw macro on the next page, you can access the particle structure.

I have used a similar approach, that works ok.

Umesh Shah June 18, 2003 14:49

Re: pointer 'p' in UDF
Hi Walse,

Thanx for your time. U r very near to my question. Now u know, to use RP_CELL() AND RP_THREAD(), I need to have access to the pointer 'p' to write,

RP_CELL(&p->cCell) and so.

But the UDF I m using is DEFINE_SOURCE(name, c, t, dS, eqn) . IT DOES NOT PASS THE POINTER VALUE 'p'.

So the question is, How to get the access to that pointer value in an UDF which does not pass the same? I hope u hv any idea regarding this.

Thanx again,


Allan Walsh June 18, 2003 19:01

Re: pointer 'p' in UDF
Ok, I was thinking about DEFINE_DPM_SOURCE rather than DEFINE_SOURCE, which doesn't help you out. Or maybe you could use it - otherwise I don't have an answer.

kulwinder June 19, 2003 13:29

Re: pointer 'p' in UDF
hi umesh,

In udf manual , checkout the exmaple of macro Define_DPM_SPRAY_COLLIDE. In this example there is a loop over all the particles in the cell.So you need to have the cell index and cell thread pointer and then you can access the properties of all the particles in that cell.I hope this helps you out.

Regards kulwinder

Umesh Shah June 19, 2003 14:38

Re: pointer 'p' in UDF
Hi Kulwinder,

Thanks for your time and response. I will look into that. But I am using Fluent 6.0. Is your said example there in that 6.0 manual? Because, I have gone thru almost all of the examples and it is not there. May be I m missing but can u help me saying where it is.I guess it is in 6.1 manual.

Thanks again.


kulwinder June 19, 2003 15:00

Re: pointer 'p' in UDF
umesh here is the macro checkout the particle loop in it

Regards kulwinder

/************************************************** *********

Example UDF that demonstrates DEFINE_DPM_SPRAY_COLLIDE ************************************************** **********/ #include "udf.h" #include "dpm.h" #include "surf.h"

DEFINE_DPM_SPRAY_COLLIDE(udf_man_spray_collide, tp, p) { /* non-physical collision UDF that relaxes the particle */ /* velocity and diameter in a cell to the mean over the */ /* specified time scale t_relax */

const real t_relax = 0.001; /* seconds */

/* get the cell and Thread that the particle is currently in */ cell_t c = RP_CELL(&(tp->cCell)); Thread *t = RP_THREAD(&(tp->cCell));

/* Particle index for looping over all particles in the cell */ Particle *pi;

/* loop over all particles in the cell to find their mass */ /* weighted mean velocity and diameter */ int i; real u_mean[3]={0.}, mass_mean=0.; real d_orig = tp->state.diam; real decay = 1. - exp(-t_relax); begin_particle_cell_loop(pi,c,t)


mass_mean += pi->state.mass;


u_mean[i] += pi->state.V[i]*pi->state.mass;

} end_particle_cell_loop(pi,c,t)

/* relax particle velocity to the mean and diameter to the */ /* initial diameter over the relaxation time scale t_relax */ if( mass_mean > 0. )



u_mean[i] /= mass_mean;


tp->state.V[i] += decay*( u_mean[i] - tp->state.V[i] );

tp->state.diam += decay*( P_INIT_DIAM(tp) - tp->state.diam );

/* adjust the number in the droplet parcel to conserve mass */

tp->number_in_parcel *= CUB( d_orig/tp->state.diam );

} }

Umesh Shah June 20, 2003 08:36

Re: pointer 'p' in UDF
Thank u very much Kulwinder.

All times are GMT -4. The time now is 12:54.