CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   FLUENT (https://www.cfd-online.com/Forums/fluent/)
-   -   DEFIND_SOURCE with looping through DPM particles (https://www.cfd-online.com/Forums/fluent/93628-defind_source-looping-through-dpm-particles.html)

mfren October 21, 2011 02:43

DEFIND_SOURCE with looping through DPM particles
 
help!

I run a simulation with Discrete Phase model. The Defind_Source macro is used for the continuity, and I want to relate it with DPM particles, so how to write the UDF with Looping over the particles in the cell?

Amir October 21, 2011 03:55

Hi,
Loop over all particles and check whether it is in your desired cell and thread or not with P_CELL and P_THREAD commands:

Quote:

loop over cells
{
loop over particles
{
.......
}
}

mfren October 24, 2011 22:00

Quote:

Originally Posted by Amir (Post 328855)
Hi,
Loop over all particles and check whether it is in your desired cell and thread or not with P_CELL and P_THREAD commands:

dear Amir, many thanks for your reply.
A main difficult to loop over all particles in Define_Source macro is that I can't get the tracked particle thread.
My test UDF is as following:

# include "udf.h"
DEFINE_SOURCE(chg_source,c,t,dS,eqn)
{
int I=0;
real xc[ND_ND];
real source;

Tracked_Particle *p;
cell_t cell;

loop(p,I->p)
{
cell = P_CELL(p);
if (c==cell)
{
C_CENTROID(xc,c,t);
Message("P_POS(p)[0]: %g\n", P_POS(p)[0]);
Message("P_POS(p)[1]: %g\n", P_POS(p)[1]);
Message("xc[0]: %g\n", xc[0]);
Message("xc[1]: %g\n", xc[1]);
}
dS[eqn] = 0;
source = 0;
return source;
}

compiling Error is in line: loop(p,I->p)

Amir October 25, 2011 04:06

Hi,

First of all, I don't think "I" is defined properly, is it integer?! But I think if there would be a problem in this procedure, it's better to change order of loops; i.e., use a DPM macro which automatically have a loop over particles; maybe "SCALAR_UPDATE" is proper; then store effect of each particle in its temporary cell memories and then use that memory in your source macro. I can elaborate it more if it's not clear.

Bests,

mfren November 8, 2011 02:24

Quote:

Originally Posted by Amir (Post 329299)
Hi,

...... i.e., use a DPM macro which automatically have a loop over particles; maybe "SCALAR_UPDATE" is proper; then store effect of each particle in its temporary cell memories and then use that memory in your source macro. I can elaborate it more if it's not clear.

Bests,

it's a good idea. I'll try it. thanks for your advice.


All times are GMT -4. The time now is 04:18.