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

4.3.12 DEFINE_PROFILE

Description

You can use the DEFINE_PROFILE macro to define a custom boundary profile that varies as a function of spatial coordinates or time. Some of the variables you can customize at a boundary are:

Note that DEFINE_PROFILE allows you to modify only a single value for wall heat flux. Single values are used in the explicit source term which FLUENT does not linearize. If you want to linearize your source term for wall heat flux and account for conductive and radiative heat transfer separately, you will need to use DEFINE_HEAT_FLUX to specify your UDF.

Some examples of boundary profile UDFs are provided below.

Usage


   
Macro: DEFINE_PROFILE ( name, t, i)
   
Argument types: Thread *t
  int i
   
Function returns: void
   

There are three arguments to DEFINE_PROFILE: name, t, and i. You will supply name, the name of the UDF. t and i are variables that are passed by the FLUENT solver to your UDF.

The passed variable t is a pointer to the thread on which the boundary condition is to be applied. i is an index that identifies the variable that is to be defined. i is set when you hook the UDF with a variable in a boundary condition panel through the graphical user interface. This index is subsequently passed to your UDF by the FLUENT solver, so that your function knows which variable to operate on.

While DEFINE_PROFILE is usually used to specify a profile condition on a boundary face zone, it can also be used to specify, or fix, flow variables that are held constant during computation in a cell zone. (See Section 6.26 of the User's Guide for more information on fixing values in a cell zone boundary condition.) For these cases, the arguments of the macro will change accordingly.

Note that unlike source term and property UDFs, profile UDFs (defined using DEFINE_PROFILE) are not called by FLUENT from within a loop on threads in the boundary zone. The solver passes only the pointer to the thread associated with the boundary zone to the DEFINE_PROFILE macro. Your UDF will need to do the work of looping over all of the faces in the thread, computing the face value for the boundary variable, and then storing the value in memory. Fluent has provided you with a face looping macro to loop over all faces in a thread ( begin_f_loop...). See Chapter  6 for details about face looping macro utilities.

F_PROFILE is typically used along with DEFINE_PROFILE and is a predefined macro supplied by Fluent. F_PROFILE stores a boundary condition in memory for a given face and thread and is nested within the face loop as shown in the examples below. It is important to note that the index i that is an argument to DEFINE_PROFILE is the same argument to F_PROFILE. F_PROFILE uses the thread pointer t, face identifier f, and index i to set the appropriate boundary face value in memory. See Section  6.4 for a description of F_PROFILE.

In multiphase cases a DEFINE_PROFILE UDF may be called more than once (particularly if the profile is used in a mixture domain thread). If this needs to be avoided, then add the prefix MP_ to the UDF name. The function will then be called only once even if it is used for more than one profile.

Example 1 - Pressure Profile

The following UDF, named pressure_profile, generates a parabolic pressure profile according to the equation


\begin{displaymath}p(y) = 1.1 \times 10^5 - 0.1 \times 10^5 \left( \frac{y} {0.0745}\right)^{2} \end{displaymath}

Note that this UDF assumes that the grid is generated such that the origin is at the geometric center of the boundary zone to which the UDF is to be applied. $y$ is 0.0 at the center of the inlet and extends to $\pm 0.0745$ at the top and bottom of the inlet. The source code can be interpreted or compiled in FLUENT.

/***********************************************************************
   UDF for specifying steady-state parabolic pressure profile boundary 
   profile for a turbine vane                                          
************************************************************************/

#include "udf.h"

DEFINE_PROFILE(pressure_profile, t, i)
{
  real x[ND_ND];                /* this will hold the position vector */
  real y;
  face_t f;

  begin_f_loop(f, t)
    {
      F_CENTROID(x,f,t);
      y = x[1];
      F_PROFILE(f, t, i) = 1.1e5 - y*y/(.0745*.0745)*0.1e5;
    }
  end_f_loop(f, t)
}

The function named pressure_profile has two arguments: t and i. t is a pointer to the face's thread, and i is an integer that is a numerical label for the variable being set within each loop.

Within the function body variable f is declared as a face. A one-dimensional array x and variable y are declared as real data types. Following the variable declarations, a looping macro is used to loop over each face in the zone to create a profile, or an array of data. Within each loop, F_CENTROID returns the value of the face centroid (array x) for the face with index f that is on the thread pointed to by t. The $y$ coordinate stored in x[1] is assigned to variable y, and is then used to calculate the pressure. This value is then assigned to F_PROFILE which uses the integer i (passed to it by the solver, based on your selection of the UDF as the boundary condition for pressure in the Pressure Inlet panel) to set the pressure face value in memory.

Example 2 - Velocity, Turbulent Kinetic Energy, and Turbulent Dissipation Rate Profiles

In the following example, DEFINE_PROFILE is used to generate profiles for the $x$ velocity, turbulent kinetic energy, and dissipation rate, respectively, for a 2D fully-developed duct flow. Three separate UDFs named x_velocity, k_profile, and dissip_profile are defined. These functions are concatenated in a single C source file and can be interpreted or compiled in FLUENT.

The 1/7th power law is used to specify the $x$ velocity component:


\begin{displaymath}v_x = v_{x,\rm free} \left( \frac{y}{\delta} \right) ^{1/7} \end{displaymath}

A fully-developed profile occurs when $\delta$ is one-half the duct height. In this example, the mean $x$ velocity is prescribed and the peak (free-stream) velocity is determined by averaging across the channel.

The turbulent kinetic energy is assumed to vary linearly from a near-wall value of


\begin{displaymath}k_{\rm nw} = \frac{u_{\tau}^{2}}{\sqrt{C_{\mu}}} \end{displaymath}

to a free-stream value of


\begin{displaymath}k_{\rm inf} = 0.002 u_{\rm free}^{2} \end{displaymath}

The dissipation rate is given by


\begin{displaymath}\epsilon = \frac{C_{\mu}^{3/4} (k^{3/2})} {\ell} \end{displaymath}

where the mixing length $\ell$ is the minimum of $\kappa y$ and 0.085 $\delta$. ( $\kappa$ is the von Karman constant = 0.41.)

The friction velocity and wall shear take the forms:


\begin{displaymath}u_{\tau} = \sqrt{\tau_{w}/\rho} \end{displaymath}


\begin{displaymath}\tau_{w} = \frac{f \rho u_{\rm free}^{2}} {2} \end{displaymath}

The friction factor is estimated from the Blasius equation:


\begin{displaymath}f = 0.045 \left( \frac{u_{\rm free} \delta}{\nu} \right)^{-1/4} \end{displaymath}

/**********************************************************************
     Concatenated UDFs for fully-developed turbulent inlet profiles  
***********************************************************************/

/*#include "udf.h"*/

#define YMIN 0.0                        /* constants  */
#define YMAX 0.4064
#define UMEAN 1.0
#define B 1./7.
#define DELOVRH 0.5
#define VISC 1.7894e-05
#define CMU 0.09
#define VKC 0.41


/*  profile for x-velocity    */


DEFINE_PROFILE(x_velocity, t, i)
{
  real y, del, h, x[ND_ND], ufree;      /* variable declarations */
  face_t f;

  h = YMAX - YMIN;
  del = DELOVRH*h;
  ufree = UMEAN*(B+1.);

  begin_f_loop(f, t)
    {
      F_CENTROID(x,f,t);
      y = x[1];

      if (y <= del)
         F_PROFILE(f,t,i) = ufree*pow(y/del,B);
      else
         F_PROFILE(f,t,i) = ufree*pow((h-y)/del,B);
    }
  end_f_loop(f, t)
}


/*  profile for kinetic energy  */


DEFINE_PROFILE(k_profile, t, i)
{
  real y, del, h, ufree, x[ND_ND];
  real ff, utau, knw, kinf;
  face_t f;

  h = YMAX - YMIN;
  del = DELOVRH*h;
  ufree = UMEAN*(B+1.);
  ff = 0.045/pow(ufree*del/VISC,0.25);
  utau=sqrt(ff*pow(ufree,2.)/2.0);
  knw=pow(utau,2.)/sqrt(CMU);
  kinf=0.002*pow(ufree,2.);


  begin_f_loop(f, t)
    {
      F_CENTROID(x,f,t);
      y=x[1];

      if (y <= del)
        F_PROFILE(f,t,i)=knw+y/del*(kinf-knw);
      else
        F_PROFILE(f,t,i)=knw+(h-y)/del*(kinf-knw);
    }
  end_f_loop(f, t)
}
/* profile for dissipation rate  */


DEFINE_PROFILE(dissip_profile, t, i)
{
  real y, x[ND_ND], del, h, ufree;
  real ff, utau, knw, kinf;
  real mix, kay;
  face_t f;

  h = YMAX - YMIN;
  del = DELOVRH*h;
  ufree = UMEAN*(B+1.);
  ff = 0.045/pow(ufree*del/VISC,0.25);
  utau=sqrt(ff*pow(ufree,2.)/2.0);
  knw=pow(utau,2.)/sqrt(CMU);
  kinf=0.002*pow(ufree,2.);

  begin_f_loop(f, t)
    {
      F_CENTROID(x,f,t);
      y=x[1];

      if (y <= del)
        kay=knw+y/del*(kinf-knw);
      else 
        kay=knw+(h-y)/del*(kinf-knw);

      if (VKC*y < 0.085*del)
        mix = VKC*y;
      else
        mix = 0.085*del;

      F_PROFILE(f,t,i)=pow(CMU,0.75)*pow(kay,1.5)/mix;
    }
  end_f_loop(f,t)
}

Example 3 - Fixed Velocity UDF

In the following example DEFINE_PROFILE is used to fix flow variables that are held constant during computation in a cell zone. Three separate UDFs named fixed_u, fixed_v, and fixed_ke are defined in a single C source file. They specify fixed velocities that simulate the transient startup of an impeller in an impeller-driven mixing tank. The physical impeller is simulated by fixing the velocities and turbulence quantities using the fix option in FLUENT. See Section 6.26 of the User's Guide for more information on fixing variables.

/***********************************************************************
   Concatenated UDFs for simulating an impeller using fixed velocity   
************************************************************************/

/*#include "udf.h"*/

#define FLUID_ID 1
#define ua1 -7.1357e-2
#define ua2 54.304
#define ua3 -3.1345e3
#define ua4 4.5578e4
#define ua5 -1.9664e5

#define va1 3.1131e-2
#define va2 -10.313
#define va3 9.5558e2
#define va4 -2.0051e4
#define va5 1.1856e5

#define ka1 2.2723e-2
#define ka2 6.7989
#define ka3 -424.18
#define ka4 9.4615e3
#define ka5 -7.7251e4
#define ka6 1.8410e5

#define da1 -6.5819e-2
#define da2 88.845
#define da3 -5.3731e3
#define da4 1.1643e5
#define da5 -9.1202e5
#define da6 1.9567e6




DEFINE_PROFILE(fixed_u, t, i)
{
  cell_t c;
  real x[ND_ND];
  real r;

  begin_c_loop (c,t)
    {
/* centroid is defined to specify position dependent profiles*/

      C_CENTROID(x,c,t);
      r =x[1];
      F_PROFILE(c,t,i) =
ua1+(ua2*r)+(ua3*r*r)+(ua4*r*r*r)+(ua5*r*r*r*r);
}
  end_c_loop (c,t)
}


DEFINE_PROFILE(fixed_v, t, i)
{
  cell_t c;
  real x[ND_ND];
  real r;

  begin_c_loop (c,t)
    {
/* centroid is defined to specify position dependent profiles*/

      C_CENTROID(x,c,t);
      r =x[1];
      F_PROFILE(c,t,i) =
va1+(va2*r)+(va3*r*r)+(va4*r*r*r)+(va5*r*r*r*r);
}
  end_c_loop (c,t)
}
DEFINE_PROFILE(fixed_ke, t, i)
{
  cell_t c;
  real x[ND_ND];
  real r;

  begin_c_loop (c,t)
    {
/* centroid is defined to specify position dependent profiles*/
      C_CENTROID(x,c,t);
      r =x[1];
      F_PROFILE(c,t,i) =
ka1+(ka2*r)+(ka3*r*r)+(ka4*r*r*r)+(ka5*r*r*r*r)+(ka6*r*r*r*r*r);
    }
  end_c_loop (c,t)
}

Example 4 - Wall Heat Generation Rate Profile

The following UDF, named wallheatgenerate, generates a heat generation rate profile for a planar conduction wall. Once interpreted or compiled, you can activate this UDF in the Wall boundary condition panel in FLUENT.

/*  Wall Heat Generation Rate Profile UDF  */
/*#include "udf.h"*/

DEFINE_PROFILE(wallheatgenerate,thread,i)
{
  real source = 0.001;
  face_t f;

  begin_f_loop(f,thread)
    F_PROFILE(f,thread,i) = source;
  end_f_loop(f,thread)
}

Hooking a Boundary Profile UDF to FLUENT

After the UDF that you have defined using DEFINE_PROFILE is interpreted or compiled(see Chapter  7 for details), the name that you specified in the DEFINE macro argument will become visible in the appropriate boundary condition panel (e.g., the Velocity Inlet panel) in FLUENT. See Section  8.2.12 for details on how to hook your DEFINE_PROFILE UDF to FLUENT.


next up previous contents index Previous: 4.3.11 DEFINE_PRANDTL
Up: 4.3 Model-Specific DEFINE Macros
Next: 4.3.13 DEFINE_PROPERTY
© Fluent Inc. 2003-01-22