Author Topic: How to calculate volume of particles in each cell using Fluent UDF?  (Read 6105 times)

Offline piso

  • Newbie
  • *
  • Posts: 13
  • Reputation: +3/-0
  • Searching for solution
    • View Profile
Advertisement
I want to calculate the volume occupied by particles in each cell. I know it can be done using UDF, but I can not figure out how to do it. Can any one guide me?

Thanks.


Offline william

  • Full Member
  • ***
  • Posts: 159
  • Reputation: +15/-0
  • Know it, share it.
    • View Profile
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;
}
}
}

Offline piso

  • Newbie
  • *
  • Posts: 13
  • Reputation: +3/-0
  • Searching for solution
    • View Profile
Thank you.