[ANSYS, Inc. Logo] return to home search
next up previous contents index

2.5.8 DEFINE_DPM_OUTPUT



Description


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 this chapter in the separate User's Guide for details).



Usage



DEFINE_DPM_OUTPUT( name, header, fp, p, t, plane)


Argument Type Description
symbol name UDF name.
int header Variable that is equal to 1 at the first call of the function
  before particles are tracked and set to 0 for subsequent calls.
FILE *fp Pointer to the file to or from which you are writing or reading.
Tracked_Particle *p Pointer to the Tracked_Particle data structure which
  contains data related to the particle being tracked.
Thread *t 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 t is NULL.
Plane *plane Pointer to the Plane structure (see dpm.h) if the sampling
  device is defined as a planar slice (line in 2d). If a mesh surface
  is used by the sampler, then plane is NULL.
   
Function returns  
void  
   

There are six arguments to DEFINE_DPM_OUTPUT: name, header, fp, p, t, and plane. You supply name, the name of the UDF. header, fp, p, 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.

figure   

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).



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 $x$. For 3d simulations, the sampling planes correspond to constant $z$.

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 don't wish to track the particles further downstream.

figure   

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,p,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(p))
    return;

  if (rp_axi && (sg_swirl || rp_ke))
    y = MAX(sqrt(SQR(P_POS(p)[1]) + SQR(P_POS(p)[2])),DPM_SMALL);
  else
    y = P_POS(p)[1];

  par_fprintf(fp,"%d %d  %e %f %f  %f  %f  %e  %e  %f  %e  %f  \n",
       P_INJ_ID(P_INJECTION(p)),p->part_id, P_TIME(p),y,P_VEL(p)[0],
       P_VEL(p)[1],P_VEL(p)[2],P_DIAM(p),P_N(p),
       P_T(p), P_INIT_DIAM(p),p->time_of_birth);

#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(p))
    return;

  x = P_POS(p)[0];
  y = P_POS(p)[1];
  r = sqrt(SQR(x) + SQR(y));

  par_fprintf(fp,"%d %d %e %f  %f %f  %f %e %e %f %e %f \n",
	 P_INJ_ID(P_INJECTION(p)), p->part_id, P_TIME(p), r,P_VEL(p)[0],
         P_VEL(p)[1],P_VEL(p)[2],P_DIAM(p),P_N(p),
         P_T(p), P_INIT_DIAM(p), p->time_of_birth);

#endif

#if REMOVE_PARTICLES
  p->stream_index=-1;
#endif
}



Hooking a DPM Output UDF to ANSYS FLUENT


After the UDF that you have defined using DEFINE_DPM_OUTPUT 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 Sample Trajectories dialog box in ANSYS FLUENT. See Section  6.4.8 for details on how to hook your DEFINE_DPM_OUTPUT UDF to ANSYS FLUENT.


next up previous contents index Previous: 2.5.7 DEFINE_DPM_LAW
Up: 2.5 Discrete Phase Model
Next: 2.5.9 DEFINE_DPM_PROPERTY
Release 12.0 © ANSYS, Inc. 2009-01-14