CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   Fluent UDF and Scheme Programming (https://www.cfd-online.com/Forums/fluent-udf/)
-   -   DPM Output Problem (Again...) (https://www.cfd-online.com/Forums/fluent-udf/92019-dpm-output-problem-again.html)

DLINSA August 30, 2011 09:59

DPM Output Problem (Again...)
 
Hello everybody,

I'm on a UV water treatment reactor case, using a DPM feature to measure the UV Dose received by particles.

My problem is quiet simple and common according to other related topics(SANDIA lab uv dose files) but I still can't find the problem in my UDF :

I use a SCALAR_UPDATE macro to increase the uv dose at each time step(using a DPM scalar) which is working well at the only exception that (and I do not know why) the "initialize" variable (int) given by Fluent is always on the 1 value and this implies the program to enter always in the initialization condition and then my scalar are always reset to zero.

I solved this problem by bypassing the initialization part (I know it's bad but I didn't find any solution... Anyway scalar initialization at zero seems to be automatic when adding it in the DPM menu). If you have explanation about this they are welcome but it is not the real problem.

Here it is : the DPM_OUTPUT macro. I run this simulation on a parallel mode and when I put the "%s" for name(char variable) at the end of the par_printf() the solver crashes when a particle is sampled. When I do not put the "%s" the solver doesn't crash but I have totaly non sense values written like these :

(X):5.17004e+08 (Y) :-2.85269e+28 (Z) : 2 (my scalar 1):-4.89611e-145 (my scalar2):-1.48809e+89 etc...

Wether I'm in serial or in parallel mode, the fprintf in the dpm scal update macro works fine but that was just for testing. In the file it writes well all variables but for each interpolated positions and this is not easily exploitable. I don't know if there is a way to write in the file only if a particle is removed of the domain, with a particular condition. If it is possible that will help me because the fprintf works.

Here is the UDF:
DEFINE_ON_DEMAND(open_file)
{
fs=fopen(
"his.txt","a");
fprintf(fs,
"(%10s %10s %10s %10s %10s %10s %s ) \n","DT","X","Y","Z","Age","Dose","ID");
}
DEFINE_DPM_SCALAR_UPDATE(part_dose,cell,thread,ini tialize,p)
{
int id;
if (initialize)
{
/*P_USER_REAL(p,0) = 0.;
P_USER_REAL(p,1) = 0.;
uv_intensity_0 = C_UDMI(cell,thread,0);
Message("%d",initialize);*/
}
else
{
id=p->part_id;
P_USER_REAL(p,0) += P_DT(p) * .5 * (uv_intensity_0 + C_UDMI(cell,thread,0));
P_USER_REAL(p,1) += P_DT(p);
uv_intensity_0 = C_UDMI(cell,thread,0);


if(fs!=NULL)
{
fprintf(fs,"((%d %e %f %e %e %f %f\n",id, C_UDMI(cell,thread,0), P_DT(p), P_USER_REAL(p,0), P_USER_REAL(p,1), P_TIME(p) - p->time_of_birth, P_POS(p)[2]);
}
}
}

DEFINE_DPM_OUTPUT(output_part_dose,header,fp,p,thr ead,plane)
{
char name[100];
if (header)
{
if (NNULLP(thread))

par_fprintf_head(fp,
"(%s %d)\n",THREAD_HEAD(thread)->dpm_summary.sort_file_name,11);


else

par_fprintf_head(fp,
"(%s %d)\n",plane->sort_file_name,11);

par_fprintf_head(fp,
"(%10s %10s %10s %10s %10s %10s %10s %s)\n","X","Y","Z","Dose","Age","Time","ID","Blabla");


}

else
{

int id_out;
id_out=p->part_id;
sprintf(name,
"%s:%d",P_INJECTION(p)->name,id_out);
Message(
"\n\n\n%d %s\n\n\n",id_out,name); /*well displayed in the solver window)*/


#if PARALLEL

par_fprintf(fp,
"%d %d %10.6g %10.6g %10.6g %10.6g %10.6g %10.6g %d %s\n", P_INJ_ID(P_INJECTION(p)), p->part_id, P_POS(p)[0], P_POS(p)[1], P_POS(p)[2], P_USER_REAL(p,0), P_USER_REAL(p,1), P_TIME(p) - p->time_of_birth, id_out, name);


#else

par_fprintf(fp,
"((%e %e %e %e) %s)\n", P_USER_REAL(p,0), P_USER_REAL(p,1), P_TIME(p) - p->time_of_birth, name);

#endif
}
}
Configuration : Ansys Workbench 13, Win XP/ I7 860 (8 threads) 3GB

Thanks a lot in advance!

PS : The intensity field is stored in an UDM (it doesn't change with the simulation)

cdf_user March 16, 2012 01:45

So whats your question in one line?


All times are GMT -4. The time now is 12:58.