Geometry and indexing

Indexing

For a block whose nodes have shape (ni, nj, nk), all arrays take one of five shapes depending on where the quantity is located.

Location

Shape

Description

Examples

Node

(ni, nj, nk)

Vertices at corners of cell control volumes

Coordinates,
conserved variables

Cell

(ni-1, nj-1, nk-1)

Hexahedral cell (i,j,k) is enclosed by the nodes i, i+1, j, j+1, k, k+1

Volumes,
residual

\(i\)-face

(ni, nj-1, nk-1)

Constant-\(i\) boundaries of each cell

Face areas,
fluxes

\(j\)-face

(ni-1, nj, nk-1)

Constant-\(j\) boundaries of each cell

Face areas,
fluxes

\(k\)-face

(ni-1, nj-1, nk)

Constant-\(k\) boundaries of each cell

Face areas,
fluxes

The indexing conventions are illustrated graphically in the following diagram, showing node, cell, and face indices for a single hexahedral cell.

Diagram of a single hexahedral cell showing node indices at each corner and the three face types (i-face, j-face, k-face) with their outward normals.

Multi-component quantities append a trailing dimension so that the each component is contiguous in memory with Fortran column-major ordering. For example, nodal velocity vector has shape (ni, nj, nk, 3) with the coordinate direction on the last axis, and cell residuals have shape (ni-1, nj-1, nk-1, 5) with the equation index on the last axis.

Coordinate system

Grids are described in cylindrical polar coordinates \((x, r, \theta)\) where \(x\) is the axial direction, \(r\) the radial direction, and \(\theta\) the circumferential angle measured clockwise when looking upstream, giving a left-handed system opposite to the right-handed convention common in general CFD codes. A consequence is that cell volumes computed from the divergence theorem are positive when the index triple \((i, j, k)\) is a left-handed set, i.e.when \(i\), \(j\), and \(k\) increase in the \(x\), \(r\), and \(\theta\) directions respectively. The polar system is related to a standard right-handed Cartesian frame by

\[y = r \cos\theta, \qquad z = -r \sin\theta\]

so that the \(\theta = 0\) datum lies along \(+y\) and the minus sign on \(z\) produces the clockwise sense of increasing \(\theta\), as illustrated in the diagram.

Left-handed polar coordinate system viewed looking upstream, showing the axial x, radial r, and circumferential r-theta directions at a point, with a circular arrow marking the clockwise sense of increasing theta.

Face areas

A face of a hexahedral cell is a quadrilateral with four corner nodes \(A, B, C, D\), which in general are not coplanar. Its area vector \(\delta\mathbf{A}\) is defined so that each component is the signed area of the projection of the quadrilateral perpendicular to that component’s direction.

First, we convert to pseudo-Cartesian coordinates. Subtract the mean angle of all four nodes so that \(\theta\) is measured from the centre of the face. This allows us to locally linearise the circumferential direction by replacing \(\theta\) with \(r\theta\) to give a pseudo-Cartesian coordinate system and use standard vector operations. Then, we cross the diagonals of the quadrilateral to get the area vector.

\[\delta\mathbf{A} = \tfrac{1}{2}\, \overrightarrow{BD} \times \overrightarrow{AC}\]

Note that the sign convention is index-aligned. For example, \(\delta\mathbf{A}_i\) is positive when the face normal points in the increasing \(i\) direction. The area vector is shared between cells and so is not outward with respect to any particular cell.

Cell volumes

Cell volumes are obtained from the divergence theorem applied to the vector field \(\mathbf{F} = (x,\, r/2,\, r\theta)\), for which \(\nabla \cdot \mathbf{F} = 3\) in cylindrical coordinates. The angle \(\theta\) in \(\mathbf{F}\) is measured from the mean angle of the eight corner nodes of the cell. Although the origin of \(\theta\) is arbitrary, this choice reduces round-off error and guarantees that the volume is independent of circumferential shifts of the cell.

The volume of a cell is

\[\delta\mathcal{V} = \frac{1}{3} \oint \mathbf{F} \cdot \mathrm{d}\mathbf{A} = \frac{1}{3} \sum_{d \,\in\, \{i,\,j,\,k\}} \bigl( \mathbf{F}_{d}^{+} \cdot \delta\mathbf{A}_{d}^{+} - \mathbf{F}_{d}^{-} \cdot \delta\mathbf{A}_{d}^{-} \bigr)\]

where \(\mathbf{F}\) is evaluated at the face centre, taken as the average of the four corner nodes of each face, and the superscripts \(\mp\) denote the lower and upper face of the cell in each index direction. The lower face contributions are subtracted because, by the convention of the previous section, every \(\delta\mathbf{A}\) points along the increasing index direction and so the lower face vectors point into the cell rather than out of it.