CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > ANSYS > FLUENT

pointer 'p' in UDF

Register Blogs Members List Search Today's Posts Mark Forums Read

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   June 17, 2003, 17:42
Default pointer 'p' in UDF
  #1
Umesh Shah
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

  Reply With Quote

Old   June 18, 2003, 12:05
Default Re: pointer 'p' in UDF
  #2
rookie
Guest
 
Posts: n/a
Umesh, I think you may use loop(p, I->p)

Hope it helps.

Rookie
  Reply With Quote

Old   June 18, 2003, 14:11
Default Re: pointer 'p' in UDF
  #3
Allan Walsh
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.
  Reply With Quote

Old   June 18, 2003, 14:49
Default Re: pointer 'p' in UDF
  #4
Umesh Shah
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
  Reply With Quote

Old   June 18, 2003, 19:01
Default Re: pointer 'p' in UDF
  #5
Allan Walsh
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.
  Reply With Quote

Old   June 19, 2003, 13:29
Default Re: pointer 'p' in UDF
  #6
kulwinder
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
  Reply With Quote

Old   June 19, 2003, 14:38
Default Re: pointer 'p' in UDF
  #7
Umesh Shah
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
  Reply With Quote

Old   June 19, 2003, 15:00
Default Re: pointer 'p' in UDF
  #8
kulwinder
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 );

} }
  Reply With Quote

Old   June 20, 2003, 08:36
Default Re: pointer 'p' in UDF
  #9
Umesh Shah
Guest
 
Posts: n/a
Thank u very much Kulwinder.
  Reply With Quote

Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Dynamic Mesh UDF Qureshi FLUENT 7 March 23, 2017 07:37
UDF parallel error: chip-exec: function not found????? shankara.2 Fluent UDF and Scheme Programming 1 January 16, 2012 22:14
How to add a UDF to a compiled UDF library kim FLUENT 3 October 26, 2011 21:38
thread pointer comparison crash in Fluent UDF Miriam Main CFD Forum 0 August 31, 2008 16:40
UDF, UDF, UDF, UDF Luc SEMINEL Main CFD Forum 0 November 25, 2002 04:01


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