![]() |
![]() ![]() ![]() ![]() ![]() ![]() ![]() |
Description
You can use DEFINE_DPM_SCALAR_UPDATE to update scalar quantities every time a particle position is updated. The function allows particle-related variables to be updated or integrated over the life of the particle. Particle values can be stored in an array associated with the Tracked_Particle (accessed with the macro P_USER_REAL(p,i)). Values calculated and stored in the array can be used to color the particle trajectory.
During
ANSYS FLUENT execution, the
DEFINE_DPM_SCALAR_UPDATE function is called at the start of particle integration (when
initialize is equal to
) and then after each time step for the particle trajectory integration.
Usage
DEFINE_DPM_SCALAR_UPDATE( name, c, t, initialize, p) |
Argument Type | Description |
symbol name | UDF name. |
cell_t c | Index that identifies the cell that the particle is currently in. |
Thread *t | Pointer to the thread the particle is currently in. |
int initialize | Variable that has a value of
![]() |
at the start of the particle integration, and
![]() | |
Tracked_Particle *p | Pointer to the Tracked_Particle data structure which |
contains data related to the particle being tracked. | |
Function returns | |
void | |
There are five arguments to DEFINE_DPM_SCALAR_UPDATE: name, c, t, initialize, and p. You supply name, the name of the UDF. c, t, initialize, and p are variables that are passed by the ANSYS FLUENT solver to your UDF.
|
Pointer
p can be used as an argument to the macros defined in Section
3.2.7 to obtain information about particle properties (e.g., injection properties). Also, the
real array
user is available for storage. The size of this array should be set in the
Discrete Phase Model dialog box in the
Number of Scalars field.
|
Example
The following compiled UDF computes the melting index along a particle trajectory. The DEFINE_DPM_SCALAR_UPDATE function is called at every particle time step in ANSYS FLUENT and requires a significant amount of CPU time to execute.
The melting index is computed from
![]() |
(2.5-1) |
Also included in this UDF is an initialization function DEFINE_INIT that is used to initialize the scalar variables. DPM_OUTPUT is used to write the melting index at sample planes and surfaces. The macro NULLP, which expands to ((p) == NULL), checks if its argument is a null pointer.
/********************************************************************* UDF for computing the melting index along a particle trajectory **********************************************************************/ #include "udf.h" DEFINE_INIT(melt_setup,domain) { /* if memory for the particle variable titles has not been * allocated yet, do it now */ if (NULLP(user_particle_vars)) Init_User_Particle_Vars(); /* now set the name and label */ strcpy(user_particle_vars[0].name,"melting-index"); strcpy(user_particle_vars[0].label,"Melting Index"); strcpy(user_particle_vars[1].name,"melting-index-0"); strcpy(user_particle_vars[1].label,"Melting Index 0"); } /* update the user scalar variables */ DEFINE_DPM_SCALAR_UPDATE(melting_index,cell,thread,initialize,p) { cphase_state_t *c = &(p->cphase); if (initialize) { /* this is the initialization call, set: * P_USER_REAL(p,0) contains the melting index, initialize to 0 * P_USER_REAL(p,1) contains the viscosity at the start of a time step*/ P_USER_REAL(p,0) = 0.; P_USER_REAL(p,1) = c->mu; } else { /* use a trapezoidal rule to integrate the melting index */ P_USER_REAL(p,0) += P_DT(p) * .5 * (1/P_USER_REAL(p,1) + 1/c->mu); /* save current fluid viscosity for start of next step */ P_USER_REAL(p,1) = c->mu; } } /* write melting index when sorting particles at surfaces */ DEFINE_DPM_OUTPUT(melting_output,header,fp,p,thread,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" " %10s %10s %10s %10s %s)\n", "X","Y","Z","U","V","W","diameter","T","mass-flow", "time","melt-index","name"); } else { sprintf(name,"%s:%d",P_INJECTION(p)->name,p->part_id); /* add P_INJ_ID(P_INJECTION(p)) and part_id for sorting in parallel */ par_fprintf(fp, "%d %d ((%10.6g %10.6g %10.6g %10.6g %10.6g %10.6g " "%10.6g %10.6g %10.6g %10.6g %10.6g) %s)\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_DIAM(p), P_T(p), P_FLOW_RATE(p), P_TIME(p), P_USER_REAL(p,0), name); } } |
Hooking a DPM Scalar Update UDF to
ANSYS FLUENT
After the UDF that you have defined using
DEFINE_DPM_SCALAR_UPDATE is interpreted (Chapter
4) or compiled (Chapter
5), the name of the argument that you supplied as the first
DEFINE macro argument will become visible in the
Discrete Phase Model dialog box in
ANSYS FLUENT.
See Section 6.4.10 for details on how to hook your DEFINE_DPM_SCALAR_UPDATE UDF to ANSYS FLUENT.