Spatial discretization
the u[I]
instead of u[i, j]
or u[i, j, k]
).
For the discretization scheme, we use a staggered Cartesian grid as proposed by Harlow and Welch [13]. Consider a rectangular domain
It can be interpreted as a discrete equivalent of the continuous operator
Finite volume discretization of the Navier-Stokes equations
We now define the unknown degrees of freedom. The average pressure in
Using the pressure control volume
Note how dividing by the volume size results in a discrete equation resembling the continuous one (since
Similarly, choosing an
where we made the assumption that
Boundary conditions
Storage convention
We use the column-major convention (Julia, MATLAB, Fortran), and not the row-major convention (Python, C). Thus the
Fourth order accurate discretization
The above discretization is second order accurate. A fourth order accurate discretization can be obtained by judiciously combining the second order discretization with itself on a grid with three times larger cells in each dimension [14] [15]. The coarse discretization is identical, but the mass equation is derived for the three times coarser control volume
while the momentum equation is derived for its shifted variant
and
where
Matrix representation
We can write the mass and momentum equations in matrix form. We will use the same matrix notation for the second- and fourth order accurate discretizations. The discrete mass equation becomes
where
The discrete momentum equations become
where
Volume normalization
All the operators have been divided by the velocity volume sizes. As a result, the operators have the same units as their continuous counterparts.
Discrete pressure Poisson equation
Instead of directly discretizing the continuous pressure Poisson equation, we will rededuce it in the discrete setting, thus aiming to preserve the discrete divergence freeness instead of the continuous one. Applying the discrete divergence operator
where
Unsteady Dirichlet boundary conditions
If the equations are prescribed with unsteady Dirichlet boundary conditions, for example an inflow that varies with time, the term
Uniqueness of pressure field
Unless pressure boundary conditions are present, the pressure is only determined up to a constant, as
Pressure projection
The pressure field
The momentum equations then become
The matrix
Discrete output quantities
Kinetic energy
The local kinetic energy is defined by
Vorticity
In 2D, the vorticity is a scalar. We define it as
The 3D vorticity is a vector field
Stream function
In 2D, the stream function is defined at the corners with the vorticity. Integrating the stream function Poisson equation over the vorticity volume yields
Replacing the integrals with the mid-point quadrature rule and the spatial derivatives with central finite differences yields the discrete Poisson equation for the stream function at the vorticity point: