CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   FLUENT (https://www.cfd-online.com/Forums/fluent/)
-   -   Problem with getting the particle position using UDF (https://www.cfd-online.com/Forums/fluent/71831-problem-getting-particle-position-using-udf.html)

Ananth Pai January 17, 2010 01:11

Problem with getting the particle position using UDF
 
I am trying to get the particle positions at the end of each time step into a csv or text file. I am using DEFINE_DPM_SCALAR_UPDATE to get the positions. I am injecting 10000 particles initially and later on there is no injections. The csv file is written after each time step but there r 140000 entries into it with the no of particles bieng only 10000(i have checked it through Particle tracks). Below given is the UDF code

#include "udf.h"
#include "dpm.h"


/* update the user scalar variables */


DEFINE_DPM_SCALAR_UPDATE(follow_particle, cell, thread, initialize, p)
{
char n[18];

FILE *pf;
sprintf(n,"particle%f.csv",CURRENT_TIME);
pf = fopen ("n", "a");
fprintf(pf,"%g %g\n",P_POS(p)[0], P_POS(p)[1]);

fclose(pf);

}

Kindly help.


All times are GMT -4. The time now is 09:40.