|
[Sponsors] |
June 17, 2003, 18:42 |
pointer 'p' in UDF
|
#1 |
Guest
Posts: n/a
|
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, Umesh |
|
June 18, 2003, 13:05 |
Re: pointer 'p' in UDF
|
#2 |
Guest
Posts: n/a
|
Umesh, I think you may use loop(p, I->p)
Hope it helps. Rookie |
|
June 18, 2003, 15:11 |
Re: pointer 'p' in UDF
|
#3 |
Guest
Posts: n/a
|
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. |
|
June 18, 2003, 15:49 |
Re: pointer 'p' in UDF
|
#4 |
Guest
Posts: n/a
|
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, Umesh |
|
June 18, 2003, 20:01 |
Re: pointer 'p' in UDF
|
#5 |
Guest
Posts: n/a
|
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.
|
|
June 19, 2003, 14:29 |
Re: pointer 'p' in UDF
|
#6 |
Guest
Posts: n/a
|
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 |
|
June 19, 2003, 15:38 |
Re: pointer 'p' in UDF
|
#7 |
Guest
Posts: n/a
|
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. Umesh |
|
June 19, 2003, 16:00 |
Re: pointer 'p' in UDF
|
#8 |
Guest
Posts: n/a
|
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; for(i=0;i<3;i++) 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. ) { for(i=0;i<3;i++) u_mean[i] /= mass_mean; for(i=0;i<3;i++) 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 ); } } |
|
June 20, 2003, 09:36 |
Re: pointer 'p' in UDF
|
#9 |
Guest
Posts: n/a
|
Thank u very much Kulwinder.
|
|
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Dynamic Mesh UDF | Qureshi | FLUENT | 7 | March 23, 2017 08:37 |
UDF parallel error: chip-exec: function not found????? | shankara.2 | Fluent UDF and Scheme Programming | 1 | January 16, 2012 23:14 |
How to add a UDF to a compiled UDF library | kim | FLUENT | 3 | October 26, 2011 22:38 |
thread pointer comparison crash in Fluent UDF | Miriam | Main CFD Forum | 0 | August 31, 2008 17:40 |
UDF, UDF, UDF, UDF | Luc SEMINEL | Main CFD Forum | 0 | November 25, 2002 05:01 |