Looping over all the particles in a domain
There is a loop available for looping over all the particles in a cell. But it does not work if used directly. Actually the array to bin the particles in the cell is not allocated by default. It has to be done before using this loop and then it will run ok.
So, at the top of the routine, please put,
Alloc_Storage_Vars(domain, SV_DPM_PARTICLE_BIN, SV_NULL);
and at the botton, free up the memory with,
Free_Storage_Vars(domain, SV_DPM_PARTICLE_BIN, SV_NULL);
I am attaching my test UDF. It worked nicely for a simple 2d case in Linux.
Thread *c_thread=Lookup_Thread(d,2); /*In my case 2 was the id of the fluid thread. Please change this number accordingly */
Alloc_Storage_Vars(d, SV_DPM_PARTICLE_BIN, SV_NULL);
Message(" cell index=%d part_id=%d ",c,id);
Free_Storage_Vars(d, SV_DPM_PARTICLE_BIN, SV_NULL);