KR85: How to calculate volume of particles in each cell and store in user defined memory (UDM)?


The following sample code shows how to calculate volume of particles in each cell and store result in user defined memory.

#include "udf.h`

/* Define user defined memory location index (i.e. first user defined memory location) */
#define P_TOTAL_VOLUME 0 /* Total particle volume in each cell (m^3) */

DEFINE_EXECUTE_AT_END(test)
{
Domain *domain = Get_Domain(1);
Injection *I, *Ilist = Get_dpm_injections();
Particle *p;
Thread *tc;
cell_t c;
real cell_particle_volume = 0.0;

/* Reset UDM to zero */
thread_loop_c(tc, domain)
{
begin_c_loop(c, tc)
{
C_UDMI(c, tc, P_TOTAL_VOLUME)= 0.0;
}
end_c_loop(c, tc);
}

/* Loop through all injections */
loop(I, Ilist)
{
/* Loop through all particles */
loop(p, I->p)
{
Thread *t0 = P_CELL_THREAD(p);
cell_t c = P_CELL(p);
cell_particle_volume = M_PI * (P_DIAM(p) * P_DIAM(p) * P_DIAM(p)) * p->number_in_parcel / 6.0;
C_UDMI(c, t0, P_TOTAL_VOLUME) += cell_particle_volume;
}
}
}





Show Form
No comments yet. Be the first to add a comment!