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? |
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:
|
Quote:
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) |
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, |
Quote:
|
All times are GMT -4. The time now is 04:18. |