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.
/* 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) */
Domain *domain = Get_Domain(1);
Injection *I, *Ilist = Get_dpm_injections();
real cell_particle_volume = 0.0;
/* Reset UDM to zero */
C_UDMI(c, tc, P_TOTAL_VOLUME)= 0.0;
/* Loop through all injections */
/* Loop through all particles */
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;