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

2.7.2 DEFINE_ANISOTROPIC_DIFFUSIVITY



Description


You can use DEFINE_ANISOTROPIC_DIFFUSIVITY to specify an anisotropic diffusivity for a user-defined scalar (UDS) transport equation. See this section in the separate User's Guide for details about anisotropic diffusivity material properties in ANSYS FLUENT.



Usage



DEFINE_ANISOTROPIC_DIFFUSIVITY( name, c, t, i, dmatrix)


Argument Type Description
symbol name UDF name.
cell_t c Cell index.
Thread *t Pointer to cell thread on which the anisotropic
  diffusivity function is to be applied.
int i Index that identifies the user-defined scalar.
real dmatrix[ND_ND][ND_ND] Anisotropic diffusivity matrix to be
  filled in by user.
   
Function returns  
void  
   

There are five arguments to DEFINE_ANISOTROPIC_DIFFUSIVITY: name, c, t, i, and dmatrix. You will supply name, the name of the UDF. c, t, i, and dmatrix are variables that are passed by the ANSYS FLUENT solver to your UDF. Your function will compute the diffusivity tensor for a single cell and fill dmatrix with it. Note that anisotropic diffusivity UDFs are called by ANSYS FLUENT from within a loop on cell threads. Consequently, your UDF will not need to loop over cells in a thread since ANSYS FLUENT is doing it outside of the function call.



Example


The following UDF, named cyl_ortho_diff computes the anisotropic diffusivity matrix for a cylindrical shell which has different diffusivities in radial, tangential, and axial directions. This function can be executed as a compiled UDF.

/***************************************************************
   Example UDF that demonstrates DEFINE_ANISOTROPIC_DIFFUSIVITY 
***************************************************************/
#include "udf.h"

/* Computation of anisotropic diffusivity matrix for 
 * cylindrical orthotropic diffusivity */

/* axis definition for cylindrical diffusivity */
static const real origin[3] = {0.0, 0.0, 0.0};
static const real axis[3]   = {0.0, 0.0, 1.0};

/* diffusivities in radial, tangential and axial directions */
static const real diff[3] = {1.0, 0.01, 0.01};

DEFINE_ANISOTROPIC_DIFFUSIVITY(cyl_ortho_diff,c,t,i,dmatrix)
{
    real x[3][3]; /* principal direction matrix for cell in 
cartesian coords. */
    real xcent[ND_ND];
    real R;

    C_CENTROID(xcent,c,t);

    NV_VV(x[0],=,xcent,-,origin);
#if RP_3D
    NV_V(x[2],=,axis);
#endif
#if RP_3D
    R = NV_DOT(x[0],x[2]);
    NV_VS(x[0],-=,x[2],*,R);
#endif
    R = NV_MAG(x[0]);
    if (R > 0.0)
      NV_S(x[0],/=,R);
#if RP_3D
    N3V_CROSS(x[1],x[2],x[0]);
#else
    x[1][0] = -x[0][1];
    x[1][1] =  x[0][0];
#endif
    
    /* dmatrix is computed as xT*diff*x */
    dmatrix[0][0] = diff[0]*x[0][0]*x[0][0]
      + diff[1]*x[1][0]*x[1][0]
#if RP_3D
      + diff[2]*x[2][0]*x[2][0]
#endif
      ;
    dmatrix[1][1] = diff[0]*x[0][1]*x[0][1]
      + diff[1]*x[1][1]*x[1][1]
#if RP_3D
      + diff[2]*x[2][1]*x[2][1]
#endif
      ;
    dmatrix[1][0] = diff[0]*x[0][1]*x[0][0]
      + diff[1]*x[1][1]*x[1][0]
#if RP_3D
      + diff[2]*x[2][1]*x[2][0]
#endif
      ;
    dmatrix[0][1] = dmatrix[1][0];

#if RP_3D
    dmatrix[2][2] = diff[0]*x[0][2]*x[0][2]
      + diff[1]*x[1][2]*x[1][2]
      + diff[2]*x[2][2]*x[2][2]
      ;
    dmatrix[0][2] = diff[0]*x[0][0]*x[0][2]
      + diff[1]*x[1][0]*x[1][2]
      + diff[2]*x[2][0]*x[2][2]
      ;
    dmatrix[2][0] = dmatrix[0][2];

    dmatrix[1][2] = diff[0]*x[0][1]*x[0][2]
      + diff[1]*x[1][1]*x[1][2]
      + diff[2]*x[2][1]*x[2][2]
      ;
    dmatrix[2][1] = dmatrix[1][2];
#endif
}



Hooking an Anisotropic Diffusivity UDF to ANSYS FLUENT


After the UDF that you have defined using DEFINE_ANISOTROPIC_DIFFUSIVITY is interpreted (Chapter  4) or compiled (Chapter  5), the name of the argument that you supplied as the first DEFINE macro argument (e.g., cyl_ortho_diff) will become selectable via the UDS Diffusion Coefficients dialog box. You'll first need to select defined-per-uds for UDS Diffusivity in the Create/Edit Materials dialog box, then select the user-defined-anisotropic option for Coefficient from the UDS Diffusion Coefficients dialog box for a particular user-defined scalar diffusion equation (e.g., uds-0). See Section  6.6.1 for details.


next up previous contents index Previous: 2.7.1 Introduction
Up: 2.7 User-Defined Scalar (UDS)
Next: 2.7.3 DEFINE_UDS_FLUX
Release 12.0 © ANSYS, Inc. 2009-01-14