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/)
-   -   Using DPM_Output and DPM_Scalar together? (https://www.cfd-online.com/Forums/fluent-udf/216692-using-dpm_output-dpm_scalar-together.html)

bloodflow April 16, 2019 10:19

Using DPM_Output and DPM_Scalar together?
 
Hi All,

I have a DPM UDF using DEFINE_DPM_OUTPUT which prints the positions and velocities of particles. If I hook this to the interior of my fluid domain (Sample trajectories), it reports this for all the particles, at every time step.

Now I have this UDF working, I would like to refine it, so that it only outputs the positions and velocities of particles that have a certain position and velocity within the domain. I had done this previously with DEFINE_SCALAR_UPDATE, but was unable to get it to print the location/velocities of the particles, it only removed them in a certain area.

Simply put, I need to refine my working UDF to only act on particles with certain positions/velocities.

My working UDF to print their locations within my domain is:

/*** DPM UDF to write particle positions to file (Apply to interior Blood) ******/

#include "udf.h"
#include "dpm.h"
#include "math.h"
#define REMOVE_PARTICLES TRUE
DEFINE_DPM_OUTPUT(discrete_phase_sample,header,fp, p,t,plane)
{
if(header)
{
par_fprintf_head(fp,"X-Position Y-Position Z-Position X-Velocity Y-Velocity Z-Velocity Time \n ");
}
if(NULLP(p))
return;
par_fprintf(fp,"%d %" int64_fmt " %e %e %e %e %e %e %e \n",
P_INJ_ID(P_INJECTION(p)),p->part_id,P_POS(p)[0],P_POS(p)[1],P_POS(p)[2],P_VEL(p)[0],P_VEL(p)[1],P_VEL(p)[2],P_TIME(p));
#if REMOVE_PARTICLES
MARK_PARTICLE(p, P_FL_REMOVED);
#endif
}

My idea is to use something like this

DEFINE_DPM_SCALAR_UPDATE(adhesion,cell,thread,init ialize,p)
{
real rad_pos;
rad_pos=sqrt(P_POS(p)[1]*P_POS(p)[1]+P_POS(p)[2]*P_POS(p)[2]);
if (rad_pos>0.001)
{
execute the above UDF
}
}

If I add an if statement to my working UDF I just get SIGSEV errors whcih I dont understand so I'm trying to do it other ways.


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