CFD Online Discussion Forums

CFD Online Discussion Forums (http://www.cfd-online.com/Forums/)
-   Fluent UDF and Scheme Programming (http://www.cfd-online.com/Forums/fluent-udf/)
-   -   Urgent: Looping over all particles in unsteady flow (http://www.cfd-online.com/Forums/fluent-udf/86871-urgent-looping-over-all-particles-unsteady-flow.html)

orland April 4, 2011 20:59

Urgent: Looping over all particles in unsteady flow
 
I have an unsteady flow with one single injection that produces only 1 particle.
I want to know its position at every fluid time step.
is there a udf that can loop over all particles (or two separate udf's, one for looping over all injection threads, and the other over all particles in each injection thread)?
thanks

johnwinter May 19, 2011 07:46

hi,
DEFINE_DPM_SCALAR_UPDATE(track_dpm_particles,c,t,i nitialize,p)
{
if (RP_Get_Boolean("dpm/unsteady-tracking?"))
{
float time = RP_Get_Real("flow-time");
float x = p->state.pos[0];
float y = p->state.pos[1];
float u = p->state.V[0];
float v = p->state.V[1];
#if RP_3D
float z = p->state.pos[2];
float w = p->state.V[2];
#endif
FILE *fd;
int id = p->part_id;
char whoru[80];
sprintf(whoru,"dpm_positions%f.out",time);
fd = fopen(whoru, "a");
#if RP_3D
fprintf(fd, "%i %f %e %e %e %e %e %e %e %e %e \n", id, time, x, y, z, u, v, w, P_T(p), P_MASS(p), P_RHO(p));
#else
fprintf(fd, "%i %f %e %e %e %e %e %e %e \n", id, time, x, y, u, v, P_T(p), P_MASS(p), P_RHO(p));
#endif
fclose(fd);
}

orland May 23, 2011 07:33

thanks,
 
I'll get right on it


All times are GMT -4. The time now is 23:07.