Elliptic solvers
The elliptic problem for the pressure
The 3D non-hydrostatic pressure field is obtained by taking the divergence of the horizontal component of the momentum equations and invoking the vertical component to yield an elliptic Poisson equation for the non-hydrostatic kinematic pressure
along with homogenous Neumann boundary conditions
Dividing small timesteps
In practice, in order to avoid division by extremely small numbers when
Hydrostatic approximation
For problems in which the hydrostatic approximation is invoked, the Poisson equation for pressure above only needs to be solved for the vertically integrated flow and the pressure field is a two dimensional term
Direct method
Discretizing elliptic problems that can be solved via a classical separation-of-variables approach, such as Poisson's equation, results in a linear system of equations
The method can be explained easily by taking the Fourier transform of both sides of
where
The eigenvalues are given by Schumann and Sweet (1988) and can also be tediously derived by plugging in the definition of the discrete Fourier transform into
where
There is also an ambiguity in the solution to Poisson's equation as it's only defined up to a constant. To resolve this ambiguity we choose the solution with zero mean by setting the zeroth Fourier coefficient
The Fast Fourier transforms are computed using FFTW.jl [(Frigo and Johnson, 1998) and (Frigo and Johnson, 2005)] on the CPU and using the cuFFT library on the GPU. Along wall-bounded dimensions, the cosine transform is used. In particular, as the transforms are performed on a staggered grid, DCT-II (REDFT10) is used to perform the forward cosine transform and DCT-III (REDFT01) is used to perform the inverse cosine transform.
Direct method with a vertically stretched grid
Using Fourier transforms for all three dimensions results in a method requiring
Furthermore, the FACR algorithm removes the restriction that the grid is uniform in one of the dimensions so it can be utilized to implement a fast Poisson solver for vertically stretched grids if the cyclic reduction is applied in the along the vertical dimension.
Expanding
and recalling that Fourier transforms do
Discretizing the
Cosine transforms on the GPU
Unfortunately cuFFT does not provide cosine transforms and so we must write our own fast cosine transforms for the GPU. We implemented the fast 1D and 2D cosine transforms described by Makhoul (1980) which compute it by applying the regular Fourier transform to a permuted version of the array.
In this section we will be using the DCT-II as the definition of the forward cosine transform for a real signal of length
and the DCT-III as the definition of the inverse cosine transform
and will use
1D fast cosine transform
To calculate
where
1D fast inverse cosine transform
The inverse
after which the inverse permutation of
2D fast cosine transform
Unfortunately, the 1D algorithm cannot be applied dimension-wise so the 2D algorithm is more complicated. Thankfully, the permutation
where
2D fast inverse cosine transform
The inverse can be computed using
where
Due to the extra steps involved in calculating the cosine transform in 2D, running with two wall-bounded dimensions typically slows the model down by a factor of 2. Switching to the FACR algorithm may help here as a 2D cosine transform won't be necessary anymore.
Iterative Solvers
For problems with irregular grids the eigenvectors of the discrete Poisson operator are no longer simple Fourier series sines and cosines. This means discrete Fast Fourier Transforms can't be used to generate the projection of the equation right hand side onto eigenvectors. So an eigenvector based approach to solving the Poisson equation is not computationally efficient.
For problems with grids that are non uniform in multiple directions, we use instead a pre-conditioned conjugate gradient iterative solver. Such cases include curvilinear grids on the sphere and also telescoping cartesian grids that stretch along more than one dimension. There are two forms of the pressure operator in this approach. One is rigid lid form and one is an implicit free-surface form.
Rigid lid pressure operator
The rigid lid operator is based on the same continuous form as is used in the Direct Method solver.
Implicit free surface pressure operator
The implicit free surface solver solves for the free-surface,
where
To form a linear system that can be solved implicitly we recast the vertically-integrated continuity equation
and summing it vertically to get:
In equations
We can now apply the velocity fractional step equation (discussed in the Time-stepping section) for the hydrostatic model:
We impose that the
Substituting
The left-hand-side of