You can use DEFINE_DPM_OUTPUT to modify
what is written to the sampling device output. This function allows
access to the variables that are written as a particle passes through
a sampler (see Modeling Discrete Phase in the User's
Guide for details).
DEFINE_DPM_OUTPUT (name, header, fp, tp, t, plane)
|
Argument Type |
Description |
|---|---|
|
|
UDF name. |
|
|
Variable that is equal to |
|
|
Pointer to the file to or from which you are writing or reading. |
|
|
Pointer to the |
|
|
Pointer
to the thread that the particle is passing through if the sampler
is represented by a mesh surface. If the sampler is not defined as
a mesh surface, then the value of |
|
|
Pointer to the |
Function returns
void
There are six arguments to DEFINE_DPM_OUTPUT: name, header, fp, tp, t, and plane. You supply name, the name of the UDF. header, fp, tp, t, and plane are variables that are passed
by the ANSYS Fluent solver to your UDF. The output of your UDF will be
written to the file indicated by fp.
Important: Pointer tp can be used as an argument
to the macros defined in DPM Macros to
obtain information about particle properties (for example, injection
properties).
When using DEFINE_DPM_OUTPUT to write
sample files, certain special file operations must be performed by ANSYS Fluent.
Therefore, the usual C output function fprintf cannot be used. Instead, you must use the macros par_fprintf and par_fprintf_head. For details on the
use of these macros, refer to The par_fprintf_head and par_fprintf Macros and the following Example.
The following UDF named discrete_phase_sample samples the size and velocity of discrete phase particles at selected
planes downstream of an injection. For 2D axisymmetric simulations,
it is assumed that droplets/particles are being sampled at planes
(lines) corresponding to constant . For 3D simulations, the sampling
planes correspond to constant
.
To remove particles from the domain after they have been sampled,
change the value of REMOVE_PARTICLES to TRUE. In this case, particles will be deleted following
the time step in which they cross the plane. This is useful when you
want to sample a spray immediately in front of an injector and you
do not want to track the particles further downstream.
Important: This UDF works with unsteady and steady simulations that include droplet break-up or collisions. Note that the discrete phase must be traced in an unsteady manner.
#include "udf.h"
/******************************************************************/
/* UDF that samples discrete phase size and velocity distributions*/
/* within the domain. */
/******************************************************************/
#define REMOVE_PARTICLES FALSE
DEFINE_DPM_OUTPUT(discrete_phase_sample,header,fp,tp,t,plane)
{
#if RP_2D
real y;
if(header)
{
par_fprintf_head(fp," #Time[s] R [m] X-velocity[m/s]");
par_fprintf_head(fp," W-velocity[m/s] R-velocity[m/s] ");
par_fprintf_head(fp,"Drop Diameter[m] Number of Drops ");
par_fprintf_head(fp,"Temperature [K] Initial Diam [m] ");
par_fprintf_head(fp,"Injection Time [s] \n");
}
if(NULLP(tp))
return;
if (rp_axi && (sg_swirl || rp_ke))
y = MAX(sqrt(SQR(TP_POS(tp)[1]) + SQR(TP_POS(tp)[2])),DPM_SMALL);
else
y = TP_POS(tp)[1];
par_fprintf(fp,"%d %" int64_fmt " %e %f %f %f %f %e %e %f %e %f \n",
P_INJ_ID(TP_INJECTION(tp)),TP_ID(tp), TP_TIME(tp),y,TP_VEL(tp)[0],
TP_VEL(tp)[1],TP_VEL(tp)[2],TP_DIAM(tp),TP_N(tp),
TP_T(tp), TP_INIT_DIAM(tp),TP_TIME_OF_BIRTH(tp));
#else
real r, x, y;
if(header)
{
par_fprintf_head(fp," #Time[s] R [m] x-velocity[m/s] ");
par_fprintf_head(fp,"y-velocity[m/s] z-velocity[m/s] ");
par_fprintf_head(fp,"Drop Diameter[m] Number of Drops ");
par_fprintf_head(fp,"Temperature [K] Initial Diam [m] ");
par_fprintf_head(fp,"Injection Time [s] \n");
}
if(NULLP(tp))
return;
x = TP_POS(tp)[0];
y = TP_POS(tp)[1];
r = sqrt(SQR(x) + SQR(y));
par_fprintf(fp,"%d %" int64_fmt " %e %f %f %f %f %e %e %f %e %f \n",
P_INJ_ID(TP_INJECTION(tp)), TP_ID(tp), TP_TIME(tp), r,TP_VEL(tp)[0],
TP_VEL(tp)[1],TP_VEL(tp)[2],TP_DIAM(tp),TP_N(tp),
TP_T(tp), TP_INIT_DIAM(tp), TP_TIME_OF_BIRTH(tp));
#endif
#if REMOVE_PARTICLES
MARK_TP(tp, P_FL_REMOVED);
#endif
}
After the UDF that you have defined using DEFINE_DPM_OUTPUT is interpreted (Interpreting UDFs)
or compiled (Compiling UDFs), the name
of the argument that you supplied as the first DEFINE macro argument will become visible in the Sample Trajectories dialog box in ANSYS Fluent. See Hooking DEFINE_DPM_OUTPUT UDFs for details on how to hook your DEFINE_DPM_OUTPUT UDF to ANSYS Fluent.