![]() |
![]() ![]() ![]() ![]() ![]() ![]() ![]() |
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,
, can be approximated by
where
is the vector that connects the cell centroid
with the face centroid. The gradient in this case is evaluated at the cell centroid where
is also stored.
The diffusive flux
,
, across a face,
, of a scalar
is given by,
where
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,
may be approximated as,
where the first term on the right hand side represents the primary gradient directed along the vector
and the second term represents the `cross' diffusion term. In this equation,
is the area normal vector of face
directed from cell
c0 to
c1,
is the distance between the cell centroids, and
is the unit normal vector in this direction.
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.
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.
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).
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
![]() |
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
![]() |
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.
|
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 (
![]() |
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
![]() |
real k | the diffusion coefficient at the face (
![]() |
|
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.
|