1 Introduction

Multiple numerical methods for the incompressible Navier-Stokes equations have been suggested in the past. Among the popular ones are fractional step projection methods [1,2,3], where an approximation of the velocity field is computed and then corrected in a following step to impose the divergence free condition. Used together with staggered grids [4] this type of method has achieved great success and is probably the most commonly used today. However, although flexible (in principle any method can be used for the spatial discretization) and efficient (the velocity and pressure computations are decoupled), it exhibits some issues in terms of temporal accuracy and boundary conditions. Another common approach is to rewrite the problem in terms of the streamfunction and vorticity of the velocity field, which results in the streamfunction-vorticity formulation [5]. This approach has achieved efficient and stable incompressible flow simulations in two spatial dimensions. However, the benefits are not retained in three dimensions, particularly due to computational costs and the complexity of boundary conditions [6]. In this paper we consider the velocity-pressure formulation of the incompressible Navier-Stokes equations. The main benefit of this formulation is that there are no theoretical order barriers and that it is equally applicable in two and three spatial dimensions. The downsides to the velocity-pressure formulation are that special care needs to be taken with regards to the incompressibility constraint and that additional pressure boundary conditions have to be derived.

It is well known that high-order methods can be used to more efficiently resolve fine structures in flow simulations, compared to more widely used low-order (first and second-order accurate) methods. The main difficulty when constructing high order schemes is the imposition of boundary conditions such that the discretization is stable for long-time simulations. One way to achieve this is to use high-order finite difference methods satisfying a summation-by-parts (SBP) property [7,8,9], together with either the simultaneous approximation term (SAT) or the projection (P) method to impose boundary conditions. Using either SBP-SAT or SBP-P allows one to prove stability using the energy method. Examples of the SBP-SAT and SBP-P methods can be found in [10,11,12] and [13,14,15] respectively. Furthermore, the SBP-SAT approach have successfully been applied to problems with complex and non-smooth geometries, see for example [16, 17].

The primary focus of this paper is to compare SBP-SAT and SBP-P for imposing Dirichlet boundary conditions in general, and no-slip wall boundary conditions in particular. We present stable SBP-P and SBP-SAT discretizations of the incompressible Navier-Stokes equations with Dirichlet boundary conditions, including procedures for enforcing the divergence free condition and deriving consistent pressure boundary data. Numerical experiments show that the two methods are similar in terms of accuracy and convergence, but that fluid dynamical effects close to walls require less grid-points to develop if the homogeneous Dirichlet boundary conditions are imposed strongly (SBP-P) rather than weakly (SBP-SAT).

Recent developments have shown that a significant improvement of accuracy can be gained by employing so-called optimal first derivative SBP operators over traditional SBP operators for hyperbolic problems [12, 18]. The optimal operators are optimized for boundary accuracy by allowing a non-equidistant distribution of grid points close to the boundaries. In this paper we derive novel narrow-stencil second-derivative SBP operators that are compatible with the optimal diagonal-norm first-derivative SBP operators presented in [18]. The new operators are compared numerically to traditional SBP operators and shown to be highly superior in terms of accuracy, convergence, and efficiency. This is the second main result of the present study.

The paper is organized as follows: in Sect. 2 we present the continuous analysis including derivation of the velocity-pressure formulation and energy stability of the momentum equation. Section 3 covers the corresponding analysis in the semi-discrete setting and describes the divergence and pressure boundary procedures with SBP-P and SBP-SAT. The new narrow-stencil optimal second-derivative SBP operators are also presented in Sect. 3. In Sect. 4 the numerical experiments and results are presented. Conclusions are drawn in Sect. 5.

2 Continuous Analysis

The dimensionless incompressible Navier-Stokes equations are given by

$$\begin{aligned} \begin{aligned} {{\mathbf {V}}}_t + ({{\mathbf {V}}} \cdot \nabla ) {{\mathbf {V}}}&= -\nabla p + \frac{1}{{\mathrm {Re}}} \Delta {{\mathbf {V}}}, \quad&x,y \in \Omega ,&t \ge 0, \\ \nabla \cdot {{\mathbf {V}}}&= 0,&x,y \in \Omega ,&t \ge 0, \\ B({{\mathbf {V}}},p)&= {{\mathbf {G}}},&x,y \in \partial \Omega , \quad&t \ge 0, \\ ({{\mathbf {V}}},p)&= {{\mathbf {H}}},&x,y \in \Omega ,&t = 0, \end{aligned} \end{aligned}$$
(1)

where \({{\mathbf {V}}}\) is the velocity field, p the pressure, \({\mathrm {Re}}\) the Reynolds number, \({{\mathbf {G}}}\) the boundary data and \({{\mathbf {H}}}\) the initial data. In two spatial dimensions we have \({{\mathbf {V}}} = (u,v)^T\), where u and v are the velocities in the x- and y-direction, respectively. The boundary operator B and boundary data \({{\mathbf {G}}}\) determine the boundary conditions. The spatial domain is \(\Omega \in {\mathbb {R}}^2\) and its boundary \(\partial \Omega \). We refer to the first equation in (1) as the momentum equation and the second equation as the divergence free condition.

Taking the divergence of the momentum equation leads to

$$\begin{aligned} \phi _t + {{\mathbf {V}}} \cdot \nabla \phi = - u_x^2 - 2 u_y v_x - v_y^2 - \Delta p + \frac{1}{{\mathrm {Re}}} \Delta \phi , \end{aligned}$$
(2)

where \(\phi = \nabla \cdot {{\mathbf {V}}}\). Here subscripts denote partial differentiation. Substituting the divergence free condition \(\phi = 0\) leads to the pressure Poisson equation (PPE),

$$\begin{aligned} \Delta p = - u_x^2 - 2 u_y v_x - v_y^2. \end{aligned}$$
(3)

Note that (3) by itself is not enough to replace the divergence free condition. This is seen by substituting (3) in (2) and not imposing \(\phi = 0\). We get

$$\begin{aligned} \phi _t + {{\mathbf {V}}} \cdot \nabla \phi = \frac{1}{{\mathrm {Re}}} \Delta \phi , \end{aligned}$$
(4)

i.e. the divergence satisfies an advection-diffusion equation. For \(\phi \) to be non-growing boundary conditions for the divergence are required, here we use homogeneous Dirichlet boundary conditions. See [19] for a derivation of maximally dissipative boundary conditions to this problem. Additionally, for the divergence to be zero for all time the initial divergence has to be zero. Finally, we arrive at the velocity-pressure formulation of (1):

$$\begin{aligned} \begin{aligned} {{\mathbf {V}}}_t + ({{\mathbf {V}}} \cdot \nabla ) {{\mathbf {V}}}&= -\nabla p + \frac{1}{{\mathrm {Re}}} \Delta {{\mathbf {V}}},&x,y \in \Omega ,&t \ge 0, \\ \Delta p&= - u_x^2 - 2 u_y v_x - v_y^2, \quad&x,y \in \Omega ,&t \ge 0, \\ \nabla \cdot {{\mathbf {V}}}&= 0,&x,y \in \partial \Omega , \quad&t \ge 0, \\ B({{\mathbf {V}}},p)&= {{\mathbf {G}}},&x,y \in \partial \Omega , \quad&t \ge 0, \\ ({{\mathbf {V}}},p)&= {{\mathbf {H}}},&x,y \in \Omega ,&t = 0, \\ \nabla \cdot {{\mathbf {V}}}&= 0,&x,y \in \Omega , \quad&t = 0, \end{aligned} \end{aligned}$$
(5)

Note that the divergence free condition in (1) has been replaced by the PPE and a homogeneous Dirichlet boundary condition for the divergence.

2.1 Energy of the Momentum Equation

Let \((u,v) = \int _\Omega u v\) denote the \(L^2\)-inner product of two real-valued functions uv and \(\vert \vert u \vert \vert ^2 = (u,u)\) the corresponding norm. Taking the inner product of \({{\mathbf {V}}}\) and the momentum Eq. in (5) (the energy method) leads to

$$\begin{aligned} \frac{\partial E}{\partial t} + \frac{2}{{\mathrm {Re}}} (\vert \vert \nabla u \vert \vert ^2 + \vert \vert \nabla v \vert \vert ^2) = BT + \int _\Omega (2p + u^2 + v^2)\nabla \cdot {{\mathbf {V}}} \, dx, \end{aligned}$$
(6)

where E is an energy defined by \(E = \vert \vert u \vert \vert ^2 + \vert \vert v \vert \vert ^2\) and the boundary terms are given by

$$\begin{aligned} BT = -\int _{\partial \Omega } (2p + u^2 + v^2)(un^{(x)}+vn^{(y)}) - \frac{2}{{\mathrm {Re}}} (u \frac{\partial u}{\partial n} + v \frac{\partial v}{\partial n}) \, dS, \end{aligned}$$
(7)

where \(n = (n^{(x)},n^{(y)})\) is the normal vector to the boundary. To arrive at (6) the following identities are used:

$$\begin{aligned} \begin{aligned} u u_x&= \frac{1}{2} (u^2)_x, \quad&v u_y&= \frac{1}{2} (v u_y + (uv)_y - v_y u), \\ u v_x&= \frac{1}{2} (u v_x + (uv)_x - u_x v), \quad&v v_y&= \frac{1}{2} (v^2)_y. \end{aligned} \end{aligned}$$
(8)

From (6) it is clear that the energy is decreasing if the boundary terms are taken care by suitable (i.e. the correct number of) boundary conditions such that \(BT \le 0\) (for homogeneous data) and the divergence free condition \(\nabla \cdot {{\mathbf {V}}} = 0\) is fulfilled.

2.2 Characteristic Boundary Conditions

In this paper we use characteristic boundary conditions (CBC) as non-reflecting outflow boundary conditions and as interface conditions for the backwards facing step problem in Sect. 4.3. They are derived for the incompressible Navier-Stokes equations in [19], look there for more details.

Boundary characteristic variables to the incompressible Navier-Stokes equations are given by

$$\begin{aligned} \begin{aligned} C^{(1)}&= -\lambda _1 V_t + \frac{1}{{\mathrm {Re}}} \frac{\partial V_t}{\partial n}, \\ C^{(2)}&= -\lambda _2 V_t + \frac{1}{{\mathrm {Re}}} \frac{\partial V_t}{\partial n}, \\ C^{(3)}&= \frac{1}{{\mathrm {Re}}} \frac{\partial V_n}{\partial n} + p, \\ C^{(4)}&= -\lambda _4 V_n + \frac{1}{{\mathrm {Re}}} \frac{\partial V_n}{\partial n} - p, \\ C^{(5)}&= -\lambda _5 V_n + \frac{1}{{\mathrm {Re}}} \frac{\partial V_n}{\partial n} - p, \end{aligned} \end{aligned}$$
(9)

where

$$\begin{aligned} \lambda _{1,2} = \frac{V_n \pm \sqrt{V_n^2+4}}{2}, \quad {\lambda _3 = 0,} \quad \text {and} \quad \lambda _{4,5} = \frac{V_n \pm \sqrt{V_n^2+8}}{2}, \end{aligned}$$
(10)

and \(V_n = u n_x + v n_y\) denotes the normal velocity and \(V_t = -un_y + v n_x\) the tangential velocity. Since \(\lambda _{2,5} < 0\) the CBC are

$$\begin{aligned} C^{(2)} = -\lambda _2 V_t + \frac{1}{{\mathrm {Re}}} \frac{\partial V_t}{\partial n} = g_2, \quad C^{(5)} = -\lambda _5 V_n + \frac{1}{{\mathrm {Re}}} \frac{\partial V_n}{\partial n} - p = g_5, \end{aligned}$$
(11)

where \(g_{2}\) and \(g_5\) are boundary data. With these boundary conditions the energy Eq. (6) becomes

$$\begin{aligned} \frac{\partial E}{\partial t} + \frac{2}{{\mathrm {Re}}} (\vert \vert \nabla u \vert \vert ^2 + \vert \vert \nabla v \vert \vert ^2) + c_{\partial \Omega }^2 \le g_{\partial \Omega }^2 + \int _\Omega (2p + u^2 + v^2)\nabla \cdot {{\mathbf {V}}} \, dx, \end{aligned}$$
(12)

where

$$\begin{aligned} c_{\partial \Omega }^2 = \int _{\partial \Omega } \sum _{i=1,3,4} \vert \lambda _i \vert C_i^2 \, dS, \quad g_{\partial \Omega }^2 = \int _{\partial \Omega } \sum _{i=2,5} \vert \lambda _i \vert g_i^2 \, dS. \end{aligned}$$
(13)

With \(g_{2,5} = 0\) it is clear that these boundary conditions leads to additional energy dissipation.

2.3 Dirichlet Boundary Conditions

If we use Dirichlet boundary conditions for no-slip walls and inflow boundaries, then an energy estimate can easily be obtained if the divergence free condition is fulfilled. Assuming zero data or a wall (\({{\mathbf {V}}} = {{\mathbf {G}}} = 0\)) the boundary terms (7) are zero and the energy Eq. (6) becomes

$$\begin{aligned} \frac{\partial E}{\partial t} + \frac{2}{{\mathrm {Re}}} (\vert \vert \nabla u \vert \vert ^2 + \vert \vert \nabla v \vert \vert ^2) = \int _\Omega (2p + u^2 + v^2)\nabla \cdot {{\mathbf {V}}} \, dx. \end{aligned}$$
(14)

3 Discrete Analysis

3.1 Definitions

The spatial discretization is done using high order finite difference SBP operators. Here we include a short description of the operators required for this problem. For more details on SBP finite differences, see [8, 9, 20, 21].

The two-dimensional domain is discretized using m points in each dimension (the extension to rectangular domains is straightforward):

$$\begin{aligned} {{\mathbf {x}}} = [x_1,x_2,\ldots ,x_m]^T, \quad {{\mathbf {y}}} = [y_1,y_2,\ldots ,y_m]^T, \end{aligned}$$
(15)

where \({{\mathbf {x}}}\) and \({{\mathbf {y}}}\) are vectors containing the grid points. For an equidistant grid we have

$$\begin{aligned} \begin{aligned} x_i&= x_l + (i-1)h_x, \quad i = 1,2,\ldots ,m, \quad h_x = \frac{x_r - x_l}{m-1}, \\ y_i&= y_l + (j-1)h_y, \quad j = 1,2,\ldots ,m, \quad h_y = \frac{y_r - y_l}{m-1}, \end{aligned} \end{aligned}$$
(16)

where \(h_{x,y}\) are the grid sizes and \(x_{l,r}, y_{l,r}\) are the domain limits. Let v denote a semi-discrete solution vector so that \(v^T = [v^{(1)},v^{(2)},\ldots ,v^{(m)}]\), where \(v^{(i)} = [v_1^{(i)},v_2^{(i)},\ldots ,v_m^{(i)}]\) contains the solution points at \(x_i\) along the y-axis, see Fig. 1. Here we have three such solution vectors: u, v and p corresponding to the discrete values of x-velocity, y-velocity and pressure respectively. Note that u, v and p previously denoted the space-continuous solutions, to avoid cluttered notation we use the same symbols for the semi-discrete solution vectors in the coming sections.

Fig. 1
figure 1

Computational domain showing the orientation of the solution vectors

The incompressible Navier-Stokes equations require first and second derivative SBP operators, the following definitions are central:

Definition 1

A difference operator \(D_1 = H^{-1} Q\) approximating \(\partial /\partial x\), using a pth-order accurate narrow-stencil, is said to be a pth-order accurate narrow-stencil diagonal-norm first derivative SBP operator if H is diagonal and positive definite and \(Q + Q^T = B = diag(-1, 0,\ldots , 0, 1)\).

Definition 2

A difference operator \(D_2 = H^{-1}(-M + BS)\) approximating \(\partial ^2/\partial x^2\), using a pth-order accurate narrow-stencil, is said to be a pth-order accurate narrow-stencil diagonal-norm second derivative SBP operator if H is diagonal and positive definite, M is symmetric and positive semi-definite, S approximates the first derivative operator at the boundaries and \(B = diag(-1, 0,\ldots , 0, 1)\).

The matrix B can be expressed in terms of the frequently used vectors

$$\begin{aligned} e_1 = [1,0,\ldots ,0]^T \quad \text {and} \quad e_m = [0,\ldots ,0,1]^T, \end{aligned}$$
(17)

as \(B = -e_1 e_1^T + e_m e_m^T\). Additionally, the matrix S is often written in terms of one sided first-derivative operators \(d_1\) and \(d_m\), approximating the first derivative at the left and right boundary respectively, as \(BS = -e_1 d_1 + e_m d_m\). The extension of the one-dimensional SBP operators to two dimensions is done using the following relationships:

$$\begin{aligned} \begin{aligned}&D_x = (D_1 \otimes I_m), \quad&D_y = (I_m \otimes D_1),\\&D_{2x} = (D_2 \otimes I_m),&D_{2y} = (I_m \otimes D_2)\\&H_x = (H \otimes I_m),&H_y = (I_m \otimes H),\\&e_w = (e_1 \otimes I_m),&e_e = (e_m \otimes I_m),\\&e_s = (I_m \otimes e_1),&e_n = (I_m \otimes e_m), \\&d_w = (d_1 \otimes I_m),&d_e = (d_m \otimes I_m),\\&d_s = (I_m \otimes d_1),&d_n = (I_m \otimes d_m), \end{aligned} \end{aligned}$$
(18)

where \(\otimes \) denotes the Kronecker product and \(I_m\) is the \(m \times m\) identity matrix. The discrete Laplace operator is given by

$$\begin{aligned} D_L = D_{2x} + D_{2y}. \end{aligned}$$
(19)

We also define the following discrete inner products and corresponding norms:

$$\begin{aligned} \begin{aligned} (u,v)_H&= u^T H v, \quad&\vert \vert u \vert \vert ^2_H = (u,u)_H, \quad&u,v \in {\mathbb {R}}^m, \\ (u,v)_{{\bar{H}}}&= u^T {\bar{H}} v,&\vert \vert u \vert \vert ^2_{{\bar{H}}} = (u,u)_{{\bar{H}}},&u,v \in {\mathbb {R}}^{m^2}, \\ (u,v)_{\bar{{\bar{H}}}}&= u^T \bar{{\bar{H}}} v,&\vert \vert u \vert \vert ^2_{\bar{{\bar{H}}}} = (u,u)_{\bar{{\bar{H}}}},&u,v \in {\mathbb {R}}^{2m^2}, \end{aligned} \end{aligned}$$
(20)

where \({\bar{H}} = H_x H_y = (H \otimes H)\) and \(\bar{{\bar{H}}} = \begin{bmatrix} {\bar{H}} &{} 0 \\ 0 &{} {\bar{H}} \end{bmatrix}\). In this paper we consider two types of narrow-stencil diagonal-norm SBP operators: traditional and optimal. The main difference is in the distribution of grid points. The traditional operators are designed to act on standard equidistant Cartesian grids. And the optimal operators on non-equidistant grids where the distribution of grid points near the boundaries are chosen to maximize the accuracy of the operators. See [12, 18] for more details. Note that we do not map the PDE in the usual sense, we simply discretize it on different grids and use operators designed for those grids. In the present study we use 6th and 8th order accurate operators of both types.

3.2 Compatible Second Derivative Operators

The derivation of the discrete PPE (see Sect. 3.5) necessitates that the discrete Laplace operators in the momentum equation are given by the discrete divergence of the discrete gradient operator, i.e.

$$\begin{aligned} D_L^{(w)} = \begin{bmatrix} D_x&D_y \end{bmatrix} \begin{bmatrix} D_x \\ D_y \end{bmatrix} = D_x D_x + D_y D_y. \end{aligned}$$
(21)

The superscript in (21) indicates that this is a wide operator (wide internal stencil) constructed from the wide second derivative operator \(D_2^{(w)} = D_1 D_1\). However, since central first derivative operators do not resolve the highest frequency mode (the \(\pi \)-mode) that can exist on the grid, the induced second derivative operator \(D_2^{(w)}\) will not either. This can lead to odd-even decoupled oscillations in the solution [22]. To rectify this we combine \(D_2^{(w)}\) with artificial dissipation to obtain narrow-stencil second derivative operators that are compatible. The following definition, first introduced in [22], is central:

Definition 3

Let \(D_1\) and \(D_2^{(n)}\) be pth-order accurate narrow-stencil diagonal-norm first- and second-derivative SBP operators. If

$$\begin{aligned} D_2^{(n)} = H^{-1} (-D_1^T H D_1 - R^{(p)} + B D_1), \end{aligned}$$
(22)

and the remainder \(R^{(p)}\) is positive semi-definite, \(D_1\) and \(D_2^{(n)}\) are called compatible.

The narrow discrete Laplace operator \(D_L^{(n)}\), constructed according to (19) using \(D_2^{(n)}\), is given by

$$\begin{aligned} D_L^{(n)} = D_L^{(w)} + AD^{(p)}, \end{aligned}$$
(23)

where

$$\begin{aligned} AD^{(p)} = -(H^{-1} R^{(p)} \otimes I_m) - (I_m \otimes H^{-1} R^{(p)}). \end{aligned}$$
(24)

The remainders \(R^{(p)}\) for \(p = 6,8\) were first derived for constant coefficient traditional operators in [22]. To find them for the optimal operators we take inspiration from [23], where narrow-stencil variable coefficient second-derivative SBP operators were derived, and make the ansatz

$$\begin{aligned} \begin{aligned} R^{(6)}&= \frac{h^7}{80} (D_4^{(6)})^T D_4^{(6)} + \frac{h^9}{600}(D_5^{(6)})^T D_5^{(6)} + \frac{h^{11}}{3600}(D_6^{(6)})^T D_6^{(6)}, \\ R^{(8)}&= \frac{h^9}{350}(D_5^{(8)})^T D_5^{(8)} + \frac{h^{11}}{2520}(D_6^{(8)})^T D_6^{(8)} \\&\quad + \frac{h^{13}}{14700}(D_7^{(8)})^T D_7^{(8)} + \frac{h^{15}}{78400} (D_8^{(8)})^T D_8^{(8)}. \end{aligned} \end{aligned}$$
(25)

The internal stencils in \(D_i^{(p)}\) are narrow-stencil approximations of the ith derivative using the same non-equidistant grid point distribution as \(D_1\). Note that \(R^{(p)}\) is symmetric and positive semi-definite by construction and that the term \(-H^{-1} R^{(p)}\) in (22) constitutes artificial dissipation (since it is an even derivative approximation in the interior). To achieve non-stiff second derivative SBP operators, we zero out the first few rows in \(D_i^{(p)}\). For more details see [22, 23]. See also [24], where a similar technique is used to construct general artificial dissipation operators for SBP operators.

The optimal SBP operators, including the new second-derivative operators, are available online at https://github.com/guer7/sbp.

Remark

The compatible second derivative SBP operators can be made more or less narrow by including or excluding terms in (25), each term corresponds to canceling out one additional value on each side of the inner stencil. The choices in (25) are those that yield second-derivative operators with minimal stencil width, referred to as narrow-stencil second-derivative operators. Numerical experiments have shown that excluding the terms corresponding to the lowest order derivatives in (25) has some favorable properties. Compared to the minimally narrow scheme, this choice was found to be slightly more accurate and allow for slightly larger time steps. Presently, the reason for this is not fully understood. It may be related to the accuracy of the boundary closures, but a thorough investigation is out of scope of the current work. The numerical results presented in Sect. 4 utilize this slightly wider operator, since it leads to a more efficient scheme.

3.3 Semi-discrete Momentum Equation

Let

$$\begin{aligned} w = \begin{bmatrix} u \\ v \end{bmatrix}, \end{aligned}$$
(26)

define the semi-discrete velocity field. Ignoring boundary conditions for now, a consistent semi-discrete approximation of the momentum equation is given by

$$\begin{aligned} w_t = D(u,v,p), \end{aligned}$$
(27)

where the right-hand-side is given by

$$\begin{aligned} D(u,v,p) = \begin{bmatrix} -D_x^{(s)} u - D_y^{(s)} u - D_x p + \frac{1}{{\mathrm {Re}}} D_L^{(n)} u \\ -D_x^{(s)} v - D_y^{(s)} v - D_y p + \frac{1}{{\mathrm {Re}}} D_L^{(n)} v \end{bmatrix}. \end{aligned}$$
(28)

Here

$$\begin{aligned} D_x^{(s)} = \frac{1}{2} ({\bar{u}} D_x + D_x {\bar{u}} - \bar{u_x}) \quad \text {and} \quad D_y^{(s)} = \frac{1}{2} ({\bar{v}} D_y + D_y {\bar{v}} - \bar{v_y}), \end{aligned}$$
(29)

are the skew-symmetric split advection operators (see (8)) and \({\bar{u}}\), \({\bar{v}}\), \({\bar{u}}_x\) and \({\bar{v}}_y\) denote diagonal matrices with the elements of u, v, \(D_x u\) and \(D_y v\) respectively on the diagonal.

3.4 Discrete Energy Estimate

To make the stability analysis more readable, we only present boundary terms corresponding to the western and eastern boundaries. The southern and northern boundaries are done analogously. Taking the inner product of w and (27) and using Definitions 1 and 2 gives

$$\begin{aligned} \frac{\partial E}{\partial t} + DI = BT + RT, \end{aligned}$$
(30)

where

$$\begin{aligned} E = \vert \vert u \vert \vert _H^2 + \vert \vert v \vert \vert _H^2, \end{aligned}$$
(31)

is the discrete energy,

$$\begin{aligned} \begin{aligned} DI&= \frac{2}{{\mathrm {Re}}} (\vert \vert D_x u \vert \vert _H^2 + \vert \vert D_y u \vert \vert _H^2 + \vert \vert D_x v \vert \vert _H^2 + \vert \vert D_y v \vert \vert _H^2 \\&\quad + u^T (R^{(p)} \otimes H + H \otimes R^{(p)}) u + v^T (R^{(p)} \otimes H + H \otimes R^{(p)}) v)) \ge 0, \end{aligned} \end{aligned}$$
(32)

the dissipation (the second row in (32) is due to the artificial dissipation \(AD^{(p)}\)),

$$\begin{aligned} \begin{aligned} BT&= (u_w,{\bar{u}}_w u_w + 2 p_w - \frac{2}{{\mathrm {Re}}} d_w u)_H + (v_w,{\bar{u}}_w v_w - \frac{2}{{\mathrm {Re}}} d_w v)_H \\&\quad - (u_e,{\bar{u}}_e u_e + 2p_e - \frac{2}{{\mathrm {Re}}} d_e u)_H - (v_e,{\bar{u}}_e v_e - \frac{2}{{\mathrm {Re}}} d_e v)_H, \end{aligned} \end{aligned}$$
(33)

the boundary terms where \({\bar{u}}_{w,e}\) denote diagonal matrices with the elements of \(u_{w,e}\) on the diagonal and

$$\begin{aligned} \begin{aligned} RT&= (u, ({\bar{u}}_x+{\bar{v}}_y) u)_{{\bar{H}}} + (v,({\bar{u}}_x+{\bar{v}}_y) v)_{{\bar{H}}} + 2(D_x u + D_y v, p)_{{\bar{H}}}, \end{aligned} \end{aligned}$$
(34)

the remainder terms proportional to the discrete divergence.

The energy Eq. (30) is the discrete equivalent to the continuous Eq. (6). To obtain a discrete energy estimate we need to fulfill two things: (i) impose the correct number of boundary conditions such that \(BT \le 0\) (with zero boundary data); and (ii) ensure that the discrete divergence converges towards zero as the grid is refined, so that \(RT = 0\) as \(h \rightarrow 0\).

3.5 Semi-discrete Pressure Poisson Equation

Regarding the PPE one has two options: (i) derive the continuous PPE (3) first and then discretize; or (ii) discretize the momentum equation first and then derive a discrete PPE. To ensure that the semi-discrete momentum equation and PPE are compatible, we take the second approach.

As in the continuous analysis, the first step in deriving a semi-discrete PPE is to multiply (27) by \(\begin{bmatrix} D_x&D_y \end{bmatrix} \) from the left (take the discrete divergence of the semi-discrete momentum equation). We get

$$\begin{aligned} \phi _t = -D_L^{(w)} p + F + \frac{1}{{\mathrm {Re}}} D_L^{(w)} \phi , \end{aligned}$$
(35)

where \(\phi = D_x u + D_y v\) denotes the discrete divergence and

$$\begin{aligned} F = D_x (-D_x^{(s)} - D_y^{(s)} + \frac{1}{{\mathrm {Re}}} AD^{(p)}) u + D_y (-D_x^{(s)} - D_y^{(s)} + \frac{1}{{\mathrm {Re}}} AD^{(p)}) v. \end{aligned}$$
(36)

The following lemma is one of the main results of this paper:

Lemma 3.1

The norm of the discrete divergence \(\phi \) is non-increasing if the semi-discrete momentum Eq. (27) holds, the discrete divergence satisfies

$$\begin{aligned} (D_x u + D_y v)_{w,e,s,n} = 0, \end{aligned}$$
(37)

and the pressure satisfies the discrete PPE

$$\begin{aligned} D_L^{(w)} p = F. \end{aligned}$$
(38)

Proof

Taking the inner product of \(\phi \) and (35) and using Definitions 1 and 2 lead to

$$\begin{aligned} \frac{d}{d t} \vert \vert \phi \vert \vert _H^2 + \frac{2}{{\mathrm {Re}}} (\vert \vert D_x \phi \vert \vert _H^2 + \vert \vert D_y \phi \vert \vert _H^2) = BT + 2(\phi ,-D_L^{(w)} p + F)_{{\bar{H}}}, \end{aligned}$$
(39)

where

$$\begin{aligned} BT = \frac{2}{{\mathrm {Re}}} ((\phi _w, d_w \phi )_H - (\phi _e,d_e \phi )_H + (\phi _s,d_s \phi )_H - (\phi _n,d_n \phi )_H). \end{aligned}$$
(40)

If \(\phi _{w,e,s,n} = 0\) and \(D_L^{(w)} p = F\) the right-hand-side of (39) is zero and

$$\begin{aligned} \frac{d}{d t} \vert \vert \phi \vert \vert _H^2 \le 0. \end{aligned}$$
(41)

\(\square \)

Lemma 3.1 shows that the H-norm of the discrete divergence will decrease over time if the boundary condition (37) holds. For the discrete divergence to be zero at all times, we also require that the initial condition satisfies

$$\begin{aligned} D_x u + D_y v = 0, \quad t = 0. \end{aligned}$$
(42)

Remark

The derivation of the discrete PPE leads to a wide Laplace operator in (38). One may consider using the narrow operator instead since it includes dissipation that does not allow for \(\pi \)-mode oscillations. However, numerical experiments have shown that this has no clear benefits in practice. Compared to the narrow options, the scheme with the wide operators is slightly more accurate and allows for slightly larger time steps. As for the Laplace operator in the momentum equation, the differences are minor and an extensive study of the reasons for this is beyond the scope of the current work. But we point out that the derivation of the discrete PPE presented in Sect. 3.5 directly leads to a wide Laplace operator. Adding the dissipative term to construct the narrow operator makes the discrete PPE in one sense inconsistent with the discrete momentum equation. Which could be a reason for the small decrease in accuracy.

3.6 Semi-Discrete Problem

We are now ready to formulate the semi-discrete problem:

$$\begin{aligned} \begin{aligned} w_t&= D(u,v,p), \quad&t> 0, \\ D_L^{(w)} p&= F,&t> 0, \\ (D_x u + D_y v)_{w,e,s,n}&= 0,&t> 0, \\ {\hat{B}}(u,v,p)&= {{\hat{\mathbf {G}}}},&t > 0, \\ (u,v,p)&= {{\hat{\mathbf {H}}}},&t = 0, \\ D_x u + D_y v&= 0,&t = 0. \end{aligned} \end{aligned}$$
(43)

Here D(uvp) is given by (28), F is given by (36) and \({\hat{B}}\), \({{\hat{\mathbf {G}}}}\) and \({{\hat{\mathbf {H}}}}\) define the discretized boundary and initial conditions. In this paper we consider two methods to solve (43) with Dirichlet boundary conditions: projection and SAT. Both methods augment the momentum equation and PPE to impose the boundary conditions, resulting in provably stable systems of ODEs. In Sects. 3.7 and 3.8 the two methods are presented separately, including procedures for deriving and imposing consistent pressure boundary conditions.

Remark

We use CBC as outflow and interface conditions for the numerical experiments on the backwards facing step problem (presented in Sect. 4.3). An SBP-SAT discretization of these conditions including energy estimates is presented in [19].

3.7 Projection Method

In this section SBP-P discretizations of the momentum and pressure Poisson equations are presented. In Sect. 3.7.3 the method is summarized step-by-step for wall boundary conditions.

3.7.1 Momentum Equation

The Dirichlet velocity and divergence boundary conditions can be represented discretely as

$$\begin{aligned} L w = g, \end{aligned}$$
(44)

where

$$\begin{aligned} \begin{alignedat}{2} L = \begin{bmatrix} L_w \\ L_e \\ L_{div} \end{bmatrix} \quad \text {and} \quad g = \begin{bmatrix} g_w \\ g_e \\ 0 \end{bmatrix}, \end{alignedat} \end{aligned}$$
(45)

with

$$\begin{aligned} \begin{alignedat}{2} L_{w,e} = \begin{bmatrix} e_{w,e} &{} 0 \\ 0 &{} e_{w,e} \end{bmatrix} \quad \text {and} \quad L_{div} = \begin{bmatrix} d_w &{} D_1 e_w \\ d_e &{} D_1 e_e \\ \end{bmatrix}. \end{alignedat} \end{aligned}$$
(46)

Here \(L_{w,e} w = g_{w,e}\) corresponds to the Dirichlet boundary conditions and \(L_{div} w = 0\) to the divergence boundary condition on the western and eastern boundaries. A consistent semi-discrete approximation of the momentum equation with (44) imposed using the projection method is given by

$$\begin{aligned} w_t = P D({{\hat{u}}}, {{\hat{v}}}, p) + (I - P) {\tilde{g}}_t, \end{aligned}$$
(47)

where \(\begin{bmatrix} {{\hat{u}}} \\ {{\hat{v}}} \end{bmatrix} = {{\hat{w}}} = P w + (I - P) {\tilde{g}}\). Here

$$\begin{aligned} P = I - \bar{{\bar{H}}}^{-1} L^T (L \bar{{\bar{H}}}^{-1} L^T)^{-1} L, \end{aligned}$$
(48)

is a projection operator, \({\tilde{g}}\) satisfies \(L {\tilde{g}} = g\) and I is the identity matrix. Note that P is self-adjoint with respect to the inner product \((\cdot ,\cdot )_{\bar{{\bar{H}}}}\), i.e.

$$\begin{aligned} (Pu,v)_{\bar{{\bar{H}}}} = (u,Pv)_{\bar{{\bar{H}}}}, \quad u,v \in {\mathbb {R}}^{2m^2}, \end{aligned}$$
(49)

and that \({\tilde{g}}\) never has to be computed explicitly since it only appears as \(L {\tilde{g}}\) in the equations (the same is true for \({\tilde{g}}_t\)). See [13] for more details on the projection method.

The following lemma is one of the main results in this paper:

Lemma 3.2

The system (47) is a stable approximation of the momentum equation with Dirichlet boundary conditions if the projection operator P is given by (48).

Proof

Taking the inner product of w and (47) with zero data, using Definitions 1 and 2 and using (49) leads to boundary terms

$$\begin{aligned} \begin{aligned} BT&= ({\hat{u}}_w,{\bar{u}}_w {\hat{u}}_w + 2 p_w - \frac{2}{{\mathrm {Re}}} d_w {\hat{u}})_H + ({\hat{v}}_w,{\bar{u}}_w {\hat{v}}_w - \frac{2}{{\mathrm {Re}}} d_w {\hat{v}})_H \\&\quad - ({\hat{u}}_e,{\bar{u}}_e {\hat{u}}_e + 2p_e - \frac{2}{{\mathrm {Re}}} d_e {\hat{u}})_H - ({\hat{v}}_e,{\bar{u}}_e {\hat{v}}_e - \frac{2}{{\mathrm {Re}}} d_e {\hat{v}})_H, \end{aligned} \end{aligned}$$
(50)

where \({\bar{u}}_{w,e}\) denote diagonal matrices with the elements of \({\hat{u}}_{w,e}\) on the diagonal. Since \(L {{\hat{w}}} = L P w = 0\), and thus \({{\hat{u}}}_{w,e} = {{\hat{v}}}_{w,e} = 0\), we get \(BT = 0\). \(\square \)

Note that with the projection method both the velocity and divergence boundary conditions are imposed simultaneously, thus solving (47) with a pressure satisfying \(D_L p = F\) is sufficient to ensure that the divergence is zero.

Remark

The projection method can be used to project zero divergence everywhere (not only on the boundaries), this may be useful as pre- or post-processing step. Then the divergence boundary operator becomes

$$\begin{aligned} L_{div} = \begin{bmatrix} D_x&D_y \end{bmatrix}. \end{aligned}$$
(51)

3.7.2 Pressure Equation

If no pressure boundary data is available, consistent pressure values have to be derived numerically. Here we extract the gradient of the pressure on the boundaries from the normal component of the momentum equation. For example, on the western boundary we have

$$\begin{aligned} g^{(p_x)}_w = e_w (-D_x^{(s)} + \frac{1}{{\mathrm {Re}}} D_L u - u_t). \end{aligned}$$
(52)

The validity of these boundary conditions has been a topic of discussion for a long time, see for example [25,26,27,28,29]. In our view no consistency requirements are violated as long as the velocities in (52) satisfy the divergence boundary conditions. The Neumann pressure boundary conditions are given by \(L p = g_p\), where

$$\begin{aligned} L = \begin{bmatrix} d_w \\ d_e \\ d_s \\ d_n \end{bmatrix} \quad \text {and} \quad g_p = \begin{bmatrix} g_w^{(p_x)} \\ g_e^{(p_x)} \\ g_s^{(p_y)} \\ g_n^{(p_y)} \end{bmatrix}. \end{aligned}$$
(53)

The PPE with Neumann boundary conditions imposed using the projection method is given by

$$\begin{aligned} {\bar{H}} P D_L^{(w)} (P p + (I - P){\tilde{g}}_p) - \sigma {\bar{H}} (I - P) (p - {\tilde{g}}_p) = {\bar{H}} P F, \end{aligned}$$
(54)

where \(\sigma \) is a positive scalar, \(L {\tilde{g}}_p = g_p\) and

$$\begin{aligned} P = I - {\bar{H}}^{-1} L^\top (L {\bar{H}}^{-1} L^\top )^{-1} L. \end{aligned}$$
(55)

The term \(\sigma {\bar{H}} (I - P) (p - {\tilde{g}}_p)\) in (54) is required to remove zero eigenvalues due to the projection. A similar term is used in [13] to rectify inconsistent initial and boundary data for PDEs. The parameter \(\sigma \) should be chosen proportional to \((h_x h_y)^{-1}\) so that the term \(\sigma {\bar{H}} (I - P) (p - {\tilde{g}}_p)\) does not go to zero as we grid refine. From numerical experiments (not presented here) we found that

$$\begin{aligned} \sigma = \frac{1}{h_x h_y}, \end{aligned}$$
(56)

is a good choice in terms of accuracy and robustness.

By rearranging (54) we get the system

$$\begin{aligned} A_N p = b_N, \end{aligned}$$
(57)

where

$$\begin{aligned} \begin{aligned} A_N&= {\bar{H}} P D_L^{(w)} P - \sigma {\bar{H}} (I - P), \\ b_N&= {\bar{H}} P F - {\bar{H}} P D_L (I - P) {\tilde{g}}_p - \sigma {\bar{H}} (I - P) {\tilde{g}}_p. \end{aligned} \end{aligned}$$
(58)

Note that \(A_N\) is singular (even with \(\sigma \ne 0)\). Since any constant vector p is a solution to \(A_N p = 0\) (since \(D_L^{(w)} p = Lp = 0\)), any solution to (57) is unique up to an arbitrary constant. To avoid this singularity we impose the additional constraint that the average pressure across the whole domain is zero. A simple numerical formulation of the resulting system is

$$\begin{aligned} \begin{bmatrix} A_N &{} {{\mathbf {1}}} \\ {{\mathbf {1}}}^T &{} 0 \end{bmatrix} \begin{bmatrix} p \\ c \end{bmatrix} = \begin{bmatrix} b_N \\ 0 \end{bmatrix}, \end{aligned}$$
(59)

where \({{\mathbf {1}}}\) is a vector with all components equal to one [30].

3.7.3 Summary

We summarize the projection approach by describing the procedure for computing the right-hand side of (47) with wall boundary conditions:

  1. 1.

    Project the velocities so that (37) holds.

  2. 2.

    Compute the pressure normal derivative using (52).

  3. 3.

    Solve the pressure Eq. (59) using the pressure normal derivative as data.

  4. 4.

    Compute (47).

3.8 SAT Method

In this section SBP-SAT discretizations of the momentum and pressure Poisson equations are presented. In Sect. 3.8.3 the method is summarized step-by-step for wall boundary conditions

3.8.1 Momentum Equation

The ODE system (27) augmented with Dirichlet boundary conditions imposed using SAT is given by

$$\begin{aligned} w_t = D(u,v,p) + \begin{bmatrix} SAT^{(u)} \\ SAT^{(v)} \end{bmatrix}, \end{aligned}$$
(60)

where

$$\begin{aligned} \begin{aligned} SAT^{(u)}&= H_x^{-1} {\bar{\tau }}_w^{(u)} (u_w - g_w^{(u)}) - H_x^{-1} e_w^T (p_w - g_w^{(p)}) \\&\quad +H_x^{-1} {\bar{\tau }}_e^{(u)} (u_e - g_e^{(u)}) + H_x^{-1} e_e^T (p_e - g_e^{(p)}), \\ SAT^{(v)}&= H_x^{-1} {\bar{\tau }}_w^{(v)} (v_w - g_w^{(v)}) \\&\quad + H_x^{-1} {\bar{\tau }}_e^{(v)} (v_e - g_e^{(v)}), \end{aligned} \end{aligned}$$
(61)

and

$$\begin{aligned} \begin{aligned} {\bar{\tau }}_w^{(u)}&= -e_w^T {\bar{\sigma }}_w^{(u)} + \frac{1}{{\mathrm {Re}}} d_w^T, \quad {\bar{\tau }}_e^{(u)}&= e_e^T {\bar{\sigma }}_e^{(u)} - \frac{1}{{\mathrm {Re}}} d_e^T, \\ {\bar{\tau }}_w^{(v)}&= -e_w^T {\bar{\sigma }}_w^{(v)} + \frac{1}{{\mathrm {Re}}} d_w^T, \quad {\bar{\tau }}_e^{(v)}&= e_e^T {\bar{\sigma }}_e^{(v)} - \frac{1}{{\mathrm {Re}}} d_e^T. \end{aligned} \end{aligned}$$
(62)

Here \({\bar{\sigma }}_{w,e}^{(u,v)} \in {\mathbb {R}}^{m \times m}\) are chosen so that an energy estimate is obtained. Note that the pressure terms in (61) are necessary to obtain an energy estimate due to the pressure terms in (33). The following lemma is one of the main results of this paper:

Lemma 3.3

The system (60) is a stable approximation of the momentum equation with Dirichlet boundary conditions if the discrete divergence free condition is fulfilled (so that \(RT = 0\)),

$$\begin{aligned} {\bar{\sigma }}_w^{(u,v)} = \frac{{\bar{u}}_w}{2} \quad \text {and} \quad {\bar{\sigma }}_e^{(u,v)} = \frac{{\bar{u}}_e}{2}. \end{aligned}$$
(63)

Proof

Taking the inner product of w and (60) with zero data and using Definitions 1 and 2 leads to boundary terms

$$\begin{aligned} \begin{aligned} BT&= (u_w,({\bar{u}}_w - 2 {\bar{\sigma }}_w^{(u)}) u_w)_H + (v_w,({\bar{u}}_w - 2 {\bar{\sigma }}_w^{(v)}) v_w)_H \\&\quad - (u_e,({\bar{u}}_e - 2 {\bar{\sigma }}_e^{(u)}) u_e)_H - (v_e,({\bar{u}}_e - 2 {\bar{\sigma }}_e^{(u)}) v_e)_H. \end{aligned} \end{aligned}$$
(64)

Choosing

$$\begin{aligned} {\bar{\sigma }}_w^{(u,v)} = \frac{{\bar{u}}_w}{2} \quad \text {and} \quad {\bar{\sigma }}_e^{(u,v)} = \frac{{\bar{u}}_e}{2}, \end{aligned}$$
(65)

yields \(BT = 0\). Thus, if \(RT = 0\), an energy estimate is obtained and (60) is a stable ODE system. \(\square \)

To impose the divergence boundary conditions with SAT we employ the same technique as in [19]. With this approach the boundary values of the velocity in the normal direction are modified so that the divergence free condition (37) is fulfilled exactly. For example, using Matlab index notation, on the western boundary we strongly enforce

$$\begin{aligned} u_w = \mathtt{inv}(d_w(\mathtt{:,1:m})) (-e_w D_y v - d_w(\mathtt{:,m+1:end})u(\mathtt{m+1:end})). \end{aligned}$$
(66)

3.8.2 Pressure Equation

An issue with the SAT method for Dirichlet velocity boundary conditions is the pressure data required in (61). As a consequence (52) can not be used directly as pressure boundary data since it only provides the normal derivative. Here we use a numerical trick where the current pressure is used to compute the boundary pressure values so that the normal derivative equals \(g_w^{(p_x)}\) given by (52). For example, using Matlab notation, on the western boundary we use

$$\begin{aligned} g_w^{(p)} = \mathtt{inv}(d_w(\mathtt{:,1:m})) (g_w^{(p_x)} - d_w(\mathtt{:,m+1:end})p(\mathtt{m+1:end})). \end{aligned}$$
(67)

The PPE with Dirichlet boundary conditions imposed using SAT is given by

$$\begin{aligned} D_L^{(w)} p = F + SAT_D, \end{aligned}$$
(68)

where

$$\begin{aligned} \begin{aligned} SAT_D&= - H_x^{-1} d_w^T (p_w - g_w^{(p)}) + H_x^{-1} d_e^T (p_e - g_e^{(p)}) \\&\quad - H_y^{-1} d_s^T (p_s - g_s^{(p)}) + H_y^{-1} d_n^T (p_n - g_n^{(p)}), \end{aligned} \end{aligned}$$
(69)

We get the system

$$\begin{aligned} A_D p = b_D, \end{aligned}$$
(70)

where

$$\begin{aligned} \begin{aligned} A_D&= D_L^{(w)} + H_x^{-1} d_w^T e_w^T - H_x^{-1} d_e^T e_e^T + H_y^{-1} d_s^T e_s^T - H_y^{-1} d_n^T e_n^T, \\ b_D&= F + H_x^{-1} d_w^T g_w^{(p)} - H_x^{-1} d_e^T g_e^{(p)} + H_y^{-1} d_s^T g_s^{(p)} - H_y^{-1} d_n^T g_n^{(p)}. \end{aligned} \end{aligned}$$
(71)

3.8.3 Summary

We summarize the SAT approach by describing the procedure for computing the right-hand side of (60) with wall boundary conditions:

  1. 1.

    Modify the boundary values of the normal velocity using (66) so that (37) holds.

  2. 2.

    Compute the normal derivative pressure data using (52).

  3. 3.

    Compute pressure boundary values using (67).

  4. 4.

    Solve the pressure Eq. (70) using the pressure boundary values as data.

  5. 5.

    Compute (60).

4 Numerical Experiments

To verify and compare the projection and SAT methods for Dirichlet boundary conditions we apply the methods to two problems: (i) The Taylor-Green vortex flow (analytical solution) and (ii) the lid-driven cavity problem. The first problem focuses on the accuracy and convergence properties of the methods and SBP operators. The second problem compares SAT and projection for wall boundary conditions in particular. Additionally, we solve the backwards-facing step problem and compare the results to experimental benchmark data. To integrate the ODE systems (47) and (60) in time we use the classical 4th order explicit Runge-Kutta method with time step \(\Delta t \propto \frac{h^2}{{\mathrm {Re}}}\), where h is the minimum spatial grid interval. The pressure systems (59) and (70) are solved using LU-factorization.

4.1 Convergence Study

An analytical solution to the incompressible Navier-Stokes equations in two dimensions is the Taylor-Green vortex flow:

$$\begin{aligned} \begin{aligned}&u(x,y,t) = -\cos (\pi \alpha ) \sin (\pi \beta ) e^{\frac{-2\pi ^2}{{\mathrm {Re}}} t} + u_\infty \cos (\theta ), \\&v(x,y,t) = \sin (\pi \alpha ) \cos (\pi \beta ) e^{\frac{-2\pi ^2}{{\mathrm {Re}}} t} + u_\infty \sin (\theta ), \\&p(x,y,t) = -\frac{1}{4} (\cos (2\pi \alpha ) + \cos (2\pi \beta )) e^{\frac{-4 \pi ^2}{{\mathrm {Re}}} t}, \\&\alpha = x - x_0 - u_\infty \cos (\theta )t, \quad \beta = y - y_0 - u_\infty \sin (\theta )t, \end{aligned} \end{aligned}$$
(72)

where \((x_0,y_0)\) are the starting coordinates of the vortices, \(\theta \) is the angle at which they are moving and \(u_\infty \) is their speed. We use a square domain \(x,y \in [-1,1]\) with total degrees of freedom \(N = m^2\) where m is the number of grid points in each dimension. The problem parameters in (72) are chosen to \({\mathrm {Re}}=100\), \(u_\infty =1\), \((x_0,y_0)=(0,0)\) and \(\theta = \frac{\pi }{4}\). The initial and boundary data are given by the analytical solution (72) (for this problem we use exact pressure data). The errors of the approximations are measured in the H-norms given by (20) of the difference between approximated and analytical solution, denoted \(\epsilon ^{(w,p)}\), at \(t = 1\). The convergence rate is estimated as

$$\begin{aligned} q^{(w,p)} = \frac{\text {log}(\frac{\vert \vert \epsilon ^{(w,p)}_1 \vert \vert _{\bar{{\bar{H}}}}}{\vert \vert \epsilon _2^{(w,p)} \vert \vert _{\bar{{\bar{H}}}}})}{\text {log}\left( (\frac{N_2}{N_1})^{1/d} \right) }, \end{aligned}$$
(73)

where \(N_1 \ne N_2\) are the degrees of freedom of two separate solutions and d is the spatial dimension, here \(d = 2\).

The theoretical rate of convergence for this problem is \(\min {(p,r+2)}\), where p is the internal stencil order and r the boundary closure order of the least accurate SBP operator in the scheme [31]. With a diagonal norm the closure order of the first derivative operator is half that of the internal order, \(r = p/2\). Furthermore, the wide-stencil second derivative operator \(D_2^{(w)}\) yields a scheme with one order of accuracy less at the boundaries, \(r = p/2-1\) [9]. The decreased boundary order of the second derivative operators is not rectified by the artificial dissipation discussed in Sect. 3.2, and thus it limits the convergence rates of the full schemes to \(\min {(p,p/2+1)}\) for both the traditional and optimal SBP operators. We get for the 6th and 8th order operators (\(p = 6,8\)) the theoretical convergence rates 4 and 5 respectively.

In Fig. 2 the velocity and pressure errors are plotted versus grid resolution for Dirichlet boundary conditions imposed using projection and SAT. The results show that projection and SAT are very similar in terms of accuracy and achieve close to or slightly above the expected convergence rates. Furthermore, the results demonstrate a significant difference in efficiency between the traditional and optimal SBP operators. For example, the optimal 8th order SBP operators yield a more accurate solution with \(51 \times 51\) grid points than the traditional 8th order SBP operators with \(151 \times 151\) grid points. We also emphasize that the gain in accuracy when going from 6th to 8th order operators is much higher with the optimal operators compared to the traditional, this is particularly clear for the pressure.

Fig. 2
figure 2

Error versus grid resolution for the Taylor-Green vortex flow problem solved with traditional and optimal 6th and 8th order SBP operators. Top row: Dirichlet boundary conditions imposed using the projection method. Bottom row: Dirichlet boundary conditions imposed using SAT. The dashed lines indicate the theoretical convergence rates 4 and 5 for the 6th and 8th order SBP operators respectively. The labels indicate the convergence rate of each method and operator, estimated by (73) using the two finest grid resolutions

4.2 Lid-Driven Cavity

The lid-driven cavity is one of the most common benchmark problems for viscous incompressible flows. The problem setup consists of a two-dimensional unit square domain with walls at each boundary where the top wall is moving at a constant tangential velocity, see Fig. 3. The velocity field and pressure are initiated from zero and simulated until the velocity field has approximately converged towards a steady-state solution. We define the stopping criteria as

$$\begin{aligned} \frac{\vert \vert w^{n} - w^{n-1} \vert \vert _\infty }{\vert \vert w^{n} \vert \vert _\infty } \le \Delta t \epsilon , \end{aligned}$$
(74)

where \(w^{n}\) is the velocity field at time step n and \(\epsilon = 10^{-8}\). To avoid temporal discontinuities the non-zero boundary condition at the top wall is smoothly brought into the domain using a hyperbolic tangent function of time. All results presented here are obtained using the optimal 8th order SBP operators with m grid points in each dimension.

Fig. 3
figure 3

Boundary conditions for the lid-driven cavity problem. The primary vortex in the center of the cavity and the secondary vortices in the bottom corners are indicated

Fig. 4
figure 4

Centerline velocities of the lid-driven cavity problem with Dirichlet boundary conditions using projection and SAT with \(Re = 100\) and \(m = 151\). The results are compared to benchmark data provided in [32]. Left: x-component of the velocity along the vertical line through the geometrical center of the cavity. Right: y-component of the velocity along the horizontal line through the geometrical center of the cavity

Fig. 5
figure 5

Steady-state solutions to the lid-driven cavity problem with \(Re=100\) and \(m = 31,91,151\), where \(m \times m\) is the number of degrees of freedom. Left column: using projection to impose Dirichlet boundary conditions. Right column: using SAT to impose Dirichlet boundary conditions

In Fig. 5 the streamlines of steady state solutions to the lid-driven cavity problem with Dirichlet boundary conditions imposed using projection (left column) and SAT (right column) are plotted. With the projection method the secondary corner vortices are visible already at \(m = 31\), whereas with the SAT method the corner vortices require significantly more degrees of freedom to develop, even with \(m = 151\) the vortex in the bottom left corner is not clear. This suggests that strong enforcement of physical boundary conditions (projection) is preferable over weak enforcement methods (SAT) when effects close to the boundaries are of primary interest. We hypothesize that this is a consequence of these effects requiring a clear distinction between boundary and inner domain to develop. Therefore, since the accuracy of the boundary conditions with SAT scales with the spatial resolution, one has to grid refine until this distinction is sufficiently large. Grid refinement with projection this is not required since the boundary conditions are fulfilled exactly, independently of grid resolution, and thus the distinction is always there.

Fig. 6
figure 6

Domain for the backward-facing step problem. The in- and outflow velocity profiles and recirculation zones are indicated

Fig. 7
figure 7

Boundary and interface conditions for the backwards facing step problem with the domain decomposed into five blocks. Dirichlet boundary conditions (DBC) on the inflow and walls, characteristic boundary conditions (CBC) on the outflow and characteristic interface conditions (CIC) on the interfaces

To verify the accuracy of the SAT and projection methods for the lid-driven cavity problem we compare the results with \(m = 151\) to benchmark solutions provided in [32]. In Fig. 4 the velocities in the x- and y-directions along the vertical and horizontal centerlines of the cavity are plotted, indicating good agreement with the benchmark data for both methods.

Remark

We do not stretch the grid by mapping the PDE, which is usually done with finite difference methods to better resolve the boundary layer. The non-equidistant grid point distribution inherent to the optimal operators is in this case enough to capture the boundary effects.

4.3 Backward-Facing Step

The third problem we consider is the backward-facing step problem. The domain consists of an inflow pipe connected to an outflow pipe with larger radius, forming a step where the flow is disrupted and interesting effects occur, see Fig. 6. Here we use \(H_i = 0.5\) and \(H_o = 0.97\) which determines the expansion ratio of the step to \(\frac{H_o}{H_i} = 1.94\). To solve this problem with the SBP finite difference operators used here the computational domain has to be split into at least three rectangular blocks (one for the inflow and at least two for the outflow). Here we couple the blocks together by weakly imposing (using SAT) that the ingoing characteristic variables are equal on each side of the interfaces. This procedure has proven to be accurate and stable in the past, see for example [17].

Since we solve a local PPE in each block we benefit greatly in terms of efficiency by utilizing many smaller blocks as compared to a few larger ones. Therefore we set a fixed block size in the outflow channel of width 4 and height 0.5 or 0.47 (for top and bottom block respectively) with \(168 \times 21\) grid points in each direction. The length of the outflow channel is determined by the number of such blocks. The inflow consists of one block of width 1 and height 0.5 with \(42 \times 21\) grid points in each direction. As boundary conditions for the inflow we specify the normal velocity to be the theoretical solution of fully developed laminar flow in an infinitely long pipe, given by

$$\begin{aligned} u(r) = V_{max} (1 - \frac{r^2}{R^2}), \quad -R \le r \le R, \end{aligned}$$
(75)

where \(V_{max}\) is the velocity in the center of the pipe and R is its radius. Homogeneous characteristic boundary conditions imposed using SAT are used at the outflow. The Dirichlet boundary conditions (inflow and walls) are imposed using the projection method. In Fig. 7 the boundary and interface conditions are presented for a five-block domain. As for the lid-driven cavity problem we use the optimal 8th order SBP operators and a stopping criteria given by (74).

In Fig. 8 the velocity field of the steady-state solution to the backwards-facing step problem with \(Re = 600\) is shown. The primary and secondary vortices are clearly visible in the streamlines plot. Additionally, one can see the tendencies towards a parabolic flow in the outflow channel.

Fig. 8
figure 8

Steady-state solution to the backward-facing step problem for \(Re = 600\) with expansion ratio 1.94. The number of unknowns are 29106. Top: streamlines of velocity field. Bottom: profiles of the x-component of the velocity, the dashed lines indicate zero velocity

We verify the accuracy by comparing the reattachment and detachment lengths, denoted \(x_{1,2,3}\) in Fig. 6, of our results to experimental data provided in [33]. For these results the outflow pipe is chosen sufficiently long so that the considered lengths are unaffected. In Fig. 9 the comparison is presented for Reynold’s numbers up to \(Re = 1000\) with good agreement up until the secondary vortex is developed at around \(Re = 400\). As pointed out in [33], above approximately this Reynold’s number the flow becomes three-dimensional and thus the modeling error of the two-dimensional equations becomes dominant.

Fig. 9
figure 9

Reattachment and detachment lengths for varying Reynold’s numbers. Dotted lines: present study. Circles: experimental data from [33]

5 Conclusions

A high-order SBP finite difference method is developed for the velocity-pressure formulation of the incompressible Navier-Stokes equations. Two boundary procedures for imposing Dirichlet boundary conditions are presented based on the projection and SAT methods. The resulting schemes are proven to be stable using the energy method. Furthermore, new optimal second-derivative SBP operators are derived and shown to be highly efficient compared to traditional SBP operators.

The methods are evaluated on three benchmark problems: the Taylor-Green vortex flow, the lid-driven cavity and the backwards-facing step. The accuracy and convergence properties of the schemes are verified for the traditional and novel optimal SBP operators. For the lid-driven cavity and backwards-facing step problems good agreement with benchmark data is achieved. Additionally, imposing wall boundary conditions strongly (projection) rather than weakly (SAT) is shown to be more efficient in the sense that corner vortices for the lid-driven cavity problem requires less degrees of freedom to appear.

Interesting future extensions include expanding the methods to curvilinear grids in three spatial dimensions and proving multiblock stability using the projection method.