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

3.2.5 Connectivity Macros

ANSYS FLUENT provides macros that allow the vectors connecting cell centroids and the vectors connecting cell and face centroids to be readily defined. These macros return information that is helpful in evaluating face values of scalars which are generally not stored, as well as the diffusive flux of scalars across cell boundaries. The geometry and gradients involved with these macros are summarized in Figure  3.2.2.

To better understand the parameters that are returned by these macros, it is best to consider how the aforementioned calculations are evaluated. Assuming that the gradient of a scalar is available, the face value of a scalar, $\phi$, can be approximated by


 \phi_f = \phi_0 + \nabla \phi \cdot \vec{dr} (3.2-1)

where $\vec{dr}$ is the vector that connects the cell centroid with the face centroid. The gradient in this case is evaluated at the cell centroid where $\phi_0$ is also stored.

The diffusive flux , $D_f$, across a face, $f$, of a scalar $\phi$ is given by,


 D_f = \Gamma_f \nabla \phi \cdot \vec{A} (3.2-2)

where $\Gamma_f$ is the diffusion coefficient at the face. In ANSYS FLUENT's unstructured solver, the gradient along the face normal direction may be approximated by evaluating gradients along the directions that connect cell centroids and along a direction confined within the plane of the face. Given this, $D_f$ may be approximated as,


 D_f = \Gamma_f \frac{(\phi_1 - \phi_0)} {ds} \frac{\vec{A} \... ... \frac{\vec{A} \cdot \vec{A}}{\vec{A} \cdot \vec{e_s}} \right) (3.2-3)

where the first term on the right hand side represents the primary gradient directed along the vector $\vec{e_s}$ and the second term represents the `cross' diffusion term. In this equation, $A$ is the area normal vector of face $f$ directed from cell c0 to c1, $ds$ is the distance between the cell centroids, and $\vec{e_s}$ is the unit normal vector in this direction. $\overline{\nabla} \phi$ is the average of the gradients at the two adjacent cells. (For boundary faces, the variable is the gradient of the c0 cell.) This is shown in Figure  3.2.2.

Figure 3.2.2: Adjacent Cells c0 and c1 with Vector and Gradient Definitions
figure



Adjacent Cell Index ( F_C0, F_C1)


The cells on either side of a face may or may not belong to the same cell thread. Referring to Figure  3.2.2, if a face is on the boundary of a domain, then only c0 exists. ( c1 is undefined for an external face). Alternatively, if the face is in the interior of the domain, then both c0 and c1 exist.

There are two macros, F_C0(f,t) and F_C1(f,t), that can be used to identify cells that are adjacent to a given face thread t. F_C0 expands to a function that returns the index of a face's neighboring c0 cell (Figure  3.2.2), while F_C1 returns the cell index for c1 (Figure  3.2.2), if it exists.


Table 3.2.24: Adjacent Cell Index Macros Defined in mem.h
Macro Argument Types Returns
F_C0(f,t) face_t f, Thread *t cell_t c for cell c0
F_C1(f,t) face_t f, Thread *t cell_t c for cell c1

See Section  2.7.3 for an example UDF that utilizes F_C0.



Adjacent Cell Thread ( THREAD_T0, THREAD_T1)


The cells on either side of a face may or may not belong to the same cell thread. Referring to Figure  3.2.2, if a face is on the boundary of a domain, then only c0 exists. ( c1 is undefined for an external face). Alternatively, if the face is in the interior of the domain, then both c0 and c1 exist.

There are two macros, THREAD_T0(t) and THREAD_T1(t), that can be used to identify cell threads that are adjacent to a given face f in a face thread t. THREAD_T0 expands to a function that returns the cell thread of a given face's adjacent cell c0, and THREAD_T1 returns the cell thread for c1 (if it exists).


Table 3.2.25: Adjacent Cell Thread Macros Defined in mem.h
Macro Argument Types Returns
THREAD_T0(t) Thread *t cell thread pointer for cell c0
THREAD_T1(t) Thread *t cell thread pointer for cell c1



Interior Face Geometry ( INTERIOR_FACE_GEOMETRY)


INTERIOR_FACE_GEOMETRY(f,t,A,ds,es,A_by_es,dr0,dr1) expands to a function that outputs the following variables to the solver, for a given face f, on face thread t. The macro is defined in the sg.h header file which is not included in udf.h. You will need to include this file in your UDF using the #include directive.


real A[ND_ND] the area normal vector
real ds distance between the cell centroids
real es[ND_ND] the unit normal vector in the direction from cell c0 to c1
real A_by_es the value $\frac{\vec{A}\cdot\vec{A}}{\vec{A}\cdot\vec{e_s}}$
real dr0[ND_ND] vector that connects the centroid of cell c0 to the face centroid
real dr1[ND_ND] the vector that connects the centroid of cell c1 to the face centroid
   

Note that INTERIOR_FACE_GEOMETRY can be called to retrieve some of the terms needed to evaluate Equations  3.2-1 and 3.2-3.



Boundary Face Geometry ( BOUNDARY_FACE_GEOMETRY)


BOUNDARY_FACE_GEOMETRY(f,t,A,ds,es,A_by_es,dr0) expands to a function that outputs the following variables to the solver, for a given face f, on face thread t. It is defined in the sg.h header file which is not included in udf.h. You will need to include this file in your UDF using the #include directive.

BOUNDARY_FACE_GEOMETRY can be called to retrieve some of the terms needed to evaluate Equations  3.2-1 and 3.2-3.


real A[ND_ND] area normal vector
real ds distance between the cell centroid and the face centroid
real es[ND_ND] unit normal vector in the direction from centroid
  of cell c0 to the face centroid
real A_by_es value $\frac{\vec{A}\cdot\vec{A}}{\vec{A}\cdot\vec{e_s}}$
real dr0[ND_ND] vector that connects the centroid of cell c0 to the face centroid
   



Boundary Face Thread ( BOUNDARY_FACE_THREAD)


BOUNDARY_FACE_THREAD_P(t) expands to a function that returns TRUE if Thread *t is a boundary face thread. The macro is defined in threads.h which is included in udf.h. See Section  2.7.3 for an example UDF that utilizes BOUNDARY_FACE_THREAD_P.



Boundary Secondary Gradient Source ( BOUNDARY_SECONDARY_GRADIENT_SOURCE)


BOUNDARY_SECONDARY_GRADIENT_SOURCE(source,n,dphi,dx,A_by_es,k) expands to a function that outputs the following variables to the solver, for a given face and face thread. It is defined in the sg.h header file which is not included in udf.h. You will need to include this file in your UDF using the #include directive.

figure   

The use of BOUNDARY_SECONDARY_GRADIENT_SOURCE first requires that cell geometry information be defined, which can be readily obtained by the use of the BOUNDARY_FACE_GEOMETRY macro (described previously in this section). See Section  8.2.5 for an example.

BOUNDARY_SECONDARY_GRADIENT_SOURCE can be called to retrieve some of the terms needed to evaluate Equation  3.2-3.


real source the cross diffusion term of the diffusive flux (i.e., the second term
  on the right side of Equation  3.2-3)
real n the average of the facial gradient ( $\overline{\nabla}\phi$ in Equation  3.2-3)
real dphi[ND_ND] a dummy scratch variable array that stores the facial gradient
  value during the computation
real dx[ND_ND] the unit normal vector in the direction from centroid of cell c0
  to the face centroid
real A_by_es the value $\frac{\vec{A}\cdot\vec{A}}{\vec{A}\cdot\vec{e_s}}$
real k the diffusion coefficient at the face ( $\Gamma_f$ in Equation  3.2-3)
   

figure   

Note that the average of the facial gradient (supplied for n) is not always allocated, and so your UDF must verify its status (using the NULLP or NNULLP function, as described in Section  3.8) and assign a value as necessary. See Section  8.2.5 for an example.


next up previous contents index Previous: 3.2.4 Face Macros
Up: 3.2 Data Access Macros
Next: 3.2.6 Special Macros
Release 12.0 © ANSYS, Inc. 2009-01-14