1 Introduction

The governing three-dimensional equations describing free-surface flows of an incompressible fluid are the well known Navier–Stokes equations which express the conservation of momentum and mass. Such equations in Cartesian coordinates have the following form (see, e.g., [1,2,3])

$$\begin{aligned} \left\{ \begin{array}{l} u_t+(uu)_x+(vu)_y+(wu)_z=-p_x+(\nu u_x)_x+(\nu u_y)_y+(\nu u_z)_z \\ v_t+(uv)_x+(vv)_y+(wv)_z=-p_y+(\nu v_x)_x+(\nu v_y)_y+(\nu v_z)_z \\ w_t+(uw)_x+(vw)_y+(ww)_z=-p_z+(\nu w_x)_x+(\nu w_y)_y+(\nu w_z)_z-g \ \ \ \\ u_x+v_y+w_z=0 \end{array} \right. \end{aligned}$$
(1)

where u(xyzt), v(xyzt) and w(xyzt) are the velocity components in the horizontal x, y and vertical z-directions; t is the time; p is the normalized pressure, that is the pressure divided by the constant density; g is the gravitational acceleration and \(\nu \) is an eddy viscosity coefficient. Hereafter it is assumed that fluid flow is always confined between a prescribed solid bottom and a free-surface (see Fig. 1).

Fig. 1
figure 1

An \(x-z\) section of the flow domain

Assuming that the free-surface can be expressed as a single valued function \(z=\eta (x,y,t)\), the free-surface equation, also known as the kinematic condition of the free-surface, is given by

$$\begin{aligned} \eta _t+u^s \eta _x+v^s \eta _y=w^s \end{aligned}$$
(2)

where \(u^s=u(x,y,\eta ,t)\), \(v^s=v(x,y,\eta ,t)\) and \(w^s=w(x,y,\eta ,t)\) are the velocity components at the free-surface.

Under the assumption that the bottom profile can be expressed as a single valued function \(z=-h(x,y)\), the total water depth is \(H(x,y,\eta )=h(x,y)+\eta (x,y,t)\) and a kinematic condition at the bottom boundary is

$$\begin{aligned} u^b h_x+v^b h_y+w^b=0 \end{aligned}$$
(3)

where \(u^b=u(x,y,-h,t)\), \(v^b=v(x,y,-h,t)\) and \(w^b=w(x,y,-h,t)\) are the velocity components at the bottom. Condition (3) states that the velocity component perpendicular to the solid boundaries must vanish.

The tangential stress boundary conditions at the free-surface are specified by the prescribed wind stresses as follows

$$\begin{aligned}&\nu (u_z - u_x \eta _x - u_y \eta _y)\big \vert _{z=\eta } =\gamma _{_T}(u_a-u^s) \end{aligned}$$
(4)
$$\begin{aligned}&\nu (v_z - v_x \eta _x - v_y \eta _y)\big \vert _{z=\eta } =\gamma _{_T}(v_a-v^s) \end{aligned}$$
(5)

where \(u_a\) and \(v_a\) are the horizontal wind velocity components and \(\gamma _{_T}\) is a nonnegative wind stress coefficient. Typically, \(\gamma _{_T}\) is taken to be \(\gamma _{_T}=C_D\frac{\rho _a}{\rho }\sqrt{u^2_a+v^2_a}\) where \(\rho _a\) is the density of the air, \(\rho \) is the water density, \(\frac{\rho _a}{\rho }=1.25\times 10^{-3}\) and \(C_D=1.4\times 10^{-3}\) is a drag coefficient.

The tangential boundary conditions at the sediment-water interface are given by specifying the bottom stress as follows

$$\begin{aligned}&\nu (u_z + u_x h_x + u_y h_y)\big \vert _{z=-h} =\gamma _{_B} u^b \end{aligned}$$
(6)
$$\begin{aligned}&\nu (v_z + v_x h_x + v_y h_y)\big \vert _{z=-h} =\gamma _{_B} v^b \end{aligned}$$
(7)

where \(\gamma _{_B}\) is a nonnegative bottom friction coefficient. Typically, \(\gamma _{_B}\) is taken to be \(\gamma _{_B}=g\frac{\sqrt{(u^b)^2+(v^b)^2}}{C^2_z}\) and \(C_z\) is the Chezy friction coefficient which can be a constant (e.g., \(C_z=50\)), or related to a Manning’s constant \(\hbox {n}\) by \(C_z=\frac{H^\frac{1}{6}}{\hbox {n}}\).

Integration of the mass conservation equation over the depth yields

$$\begin{aligned}&\int _{-h}^{\eta } u_x dz +\int _{-h}^{\eta } v_y dz +\int _{-h}^{\eta } w_z dz \\&\quad = \Big [\int _{-h}^{\eta }u dz\Big ]_x-u^s \eta _x +u^b (-h)_x\\&\qquad + \Big [\int _{-h}^{\eta }v dz\Big ]_y-v^s \eta _y +v^b (-h)_y +w^s-w^b = 0 \end{aligned}$$

thus, by using the kinematic boundary conditions (2)–(3) the following conservative form of the free-surface equation is obtained

$$\begin{aligned} \eta _t+\bigg [\int _{-h}^{\eta }udz\bigg ]_x+\bigg [\int _{-h}^{\eta }vdz\bigg ]_y=0 \end{aligned}$$

or, equivalently,

$$\begin{aligned} H_t+\bigg [\int _{-h}^{\eta }udz\bigg ]_x+\bigg [\int _{-h}^{\eta }vdz\bigg ]_y=0 \end{aligned}$$
(8)

Equation (8) will replace (2) in the model formulations to be presented in the next Section (see, e.g., [4,5,6,7]).

2 Simplified mathematical models

In most environmental flows the vertical acceleration, as well as the vertical viscosity forces, are small when compared to the gravity acceleration and to the pressure gradient. Consequently, by neglecting the advective and the viscous terms in the third momentum equation, a simplified equation for pressure results

$$\begin{aligned} p_z=-g \end{aligned}$$

This equation readily yields the following expression for the hydrostatic pressure

$$\begin{aligned} p(x,y,z,t)=p_a(x,y,t)+g[\eta (x,y,t) - z] \end{aligned}$$
(9)

where \(p_a(x,y,t)\) is the atmospheric pressure at the free-surface which, without loss of generality, will be assumed to be a constant.

Substitution of (9) into the Navier–Stokes equations yields the following simplified three-dimensional hydrostatic model (see, e.g., [4,5,6,7])

$$\begin{aligned} \left\{ \begin{array}{l} u_t+(uu)_x+(vu)_y+(wu)_z=-g\eta _x+(\nu u_x)_x+(\nu u_y)_y+(\nu u_z)_z\\ v_t+(uv)_x+(vv)_y+(wv)_z=-g\eta _y+(\nu v_x)_x+(\nu v_y)_y+(\nu v_z)_z\\ u_x+v_y+w_z=0 \\ H_t+\bigg [\int _{-h}^{\eta }udz\bigg ]_x+\bigg [\int _{-h}^{\eta }vdz\bigg ]_y=0 \end{array} \right. \end{aligned}$$
(10)

With properly specified initial and boundary conditions, Eq. (10) describe three-dimensional, hydrostatic flows. Semi-implicit methods for the numerical treatment of this hydrostatic 3D model will be described in Sect. 6.

In lieu of solutions of the complete three-dimensional equations, the flow and circulation in a class of well-mixed estuaries, lakes and coastal embayments can be satisfactorily represented by the solution of a set of vertically averaged shallow water equations. The system of vertically averaged momentum equations can be derived by integrating vertically the momentum equations in (10) from the bottom \(z=-h\) to the free-surface \(z=\eta \). Specifically, since \(H(x,y,\eta )=h(x,y)+\eta (x,y,t)\) is the total water depth, the vertically averaged velocities U and V are defined to be \(U=\frac{1}{H}\int _{-h}^{\eta }udz\) and \(V=\frac{1}{H}\int _{-h}^{\eta }vdz\), respectively. Thus, by using the kinematic conditions (2)–(3), vertical integration of the left-hand side of the u momentum equation in (10) yields

$$\begin{aligned}&\int _{-h}^{\eta }[u_t+(uu)_x+(uv)_y+(uw)_z]dz\\ \nonumber \\&\quad =(HU)_t+(HUU)_x+(HVU)_y \\&\qquad + \left[ \int _{-h}^{\eta }(u-U)^2dz \right] _x +\left[ \int _{-h}^{\eta }(u-U)(v-V)dz \right] _y \end{aligned}$$

Similarly, by using the tangential stress boundary conditions (4) and (6), the vertical integration of the viscous terms yields

$$\begin{aligned}&\int _{-h}^{\eta }[ (\nu u_x)_x + (\nu u_y)_y + (\nu u_z)_z ]dz\\&\quad =(\bar{\nu }H U_x)_x+(\bar{\nu }H U_y)_y +\gamma _{_T}(u_a-U)-\gamma _{_B}U \\&\qquad +\left[ \int _{-h}^{\eta }\nu (u-U)_x dz \right] _x+\left[ \int _{-h}^{\eta }\nu (u-U)_y dz \right] _y -\gamma _{_T}(u^s-U)-\gamma _{_B}(u^b-U) \end{aligned}$$

where \(\bar{\nu }=\frac{1}{H}\int _{-h}^{\eta }\nu dz\) is the vertically averaged viscosity coefficient.

Analogous results are obtained by vertically integrating the left-hand side and the viscous terms in the v-momentum equation in (10). Thus, the two-dimensional, vertically averaged shallow water equations are obtained from the free-surface equation (8) and from the vertical integration of the momentum equations in (10) which, after standard approximations of local velocities with their vertically average, yields the following \(2D_{xy}\) model (see, e.g., [8,9,10])

$$\begin{aligned} \left\{ \begin{array}{l} (HU)_t+(HUU)_x+(HVU)_y=-gH \eta _x+ (\bar{\nu }H U_x)_x+(\bar{\nu }H U_y)_y +\gamma _{_T} u_a-\gamma U\\ (HV)_t+(HUV)_x+(HVV)_y=-gH \eta _y+ (\bar{\nu }H V_x)_x+(\bar{\nu }H V_y)_y +\gamma _{_T} v_a-\gamma V\\ H_t+(HU)_x + (HV)_y=0 \end{array} \right. \nonumber \\ \end{aligned}$$
(11)

where the overall friction coefficient \(\gamma =\gamma _{_B}+\gamma _{_T}\) must be nonnegative and can be reformulated to compensate for the specified approximations.

Equation (11) constitute a system of three partial differential equations with three unknown functions U(xyt), V(xyt) and \(\eta (x,y,t)\). A semi-implicit numerical method for solving these equations will be discussed in Sect. 5.

Another alternative to the fully three-dimensional equations, is a simplified \(2D_{xz}\) model for narrow and deep estuaries which can be derived from the 3D equations under the assumption that the circulation of interest takes place in the vertical x-z plane. To this purpose let \(y=\ell (x,z)\) and \(y=-r(x,z)\) be single value functions representing the left and the right walls, respectively, so that \(B(x,z)=\ell (x,z)+r(x,z)\ge 0\) represents the width of the estuary (see Fig. 2).

Fig. 2
figure 2

Flow domain

The laterally averaged u-momentum equation can be derived by integrating u-momentum equation in (10) from the right \(y=-r(x,z)\) to the left wall \(y=\ell (x,z)\). To this purpose the laterally averaged velocities U and W, and the laterally averaged free-surface \(\bar{\eta }\) are defined to be \(U=\frac{1}{B}\int _{-r}^{\ell }udy\), \(W=\frac{1}{B}\int _{-r}^{\ell }wdy\) and \(\bar{\eta }=\frac{1}{B}\int _{-r}^{\ell }\eta dy\), respectively. Thus, by using appropriate boundary conditions, and after standard approximations of the local variables with their laterally averaged quantities, the lateral integration of the u-momentum equation in (10) yields

$$\begin{aligned} (BU)_t+(BUU)_x+(BWU)_z= -gB \bar{\eta }_x+ (\bar{\nu }B U_x)_x+(\bar{\nu }B U_z)_z-\gamma U \end{aligned}$$
(12)

where \(\bar{\nu }=\frac{1}{B}\int _{-r}^{\ell }\nu dy\) is the laterally averaged viscosity coefficient and the wall friction coefficient \(\gamma \) must be nonnegative and can be reformulated to partially compensate for the specified approximations.

Similarly, the lateral integral of the incompressibility condition in (10) yields

$$\begin{aligned} (BU)_x+(BW)_z=0 \end{aligned}$$
(13)

Finally, upon integration of the free-surface equation in (10), one gets

$$\begin{aligned} A_t+ \left( \int _{-h}^{\bar{\eta }}BUdz \right) _x=0 \end{aligned}$$
(14)

where \(A(x,\bar{\eta })=\int _{-r}^{\ell }H dy\) is the cross section area.

In summary, then, the two-dimensional laterally averaged model is given by eqs. (12), (13) and (14), that is,

$$\begin{aligned} \left\{ \begin{array}{l} (BU)_t+(BUU)_x+(BWU)_z= -gB \bar{\eta }_x+ (\bar{\nu }B U_x)_x+(\bar{\nu }B U_z)_z-\gamma U \\ (BU)_x+(BW)_z=0 \\ A_t+ \left( \int _{-h}^{\bar{\eta }}BUdz \right) _x=0 \end{array} \right. \end{aligned}$$
(15)

With properly specified initial and boundary conditions, Eq. (15) form a \(2D_{xz}\) model that can be used to simulate water circulation in estuarine environment. A semi-implicit numerical method for solving these equations will be described in Sect. 4.

Finally, the one-dimensional shallow water equations for unsteady flows in open channel can be derived from either the two-dimensional models, or directly from the three-dimensional equations (10) by performing an average over the cross section. These equations, also known as the de Saint–Venant equations [10] are given by

$$\begin{aligned} \left\{ \begin{array}{l} (AU)_t+(AUU)_x= -g A \bar{\eta }_x+( \bar{\nu }A U_x)_x+\gamma _{_T}U_a-\gamma U \\ A_t+(A U)_x=0 \end{array} \right. \end{aligned}$$
(16)

where, U(xt) is the fluid velocity averaged over the cross section; \(\bar{\eta }(x,t)\) is the laterally averaged free-surface elevation; \(A(x,\bar{\eta }(x,t))\) is the cross section area; and the overall friction coefficient \(\gamma =\gamma _{_B}+\gamma _{_T}\) must be nonnegative and can be reformulated to compensate for the specified approximations. Typically, \(\gamma _{_B}\) is taken to be \(\gamma _{_B}=\frac{g \hbox { n}^2 \vert U \vert }{R^{1/3}}\), where R is the hydraulic radius defined as the ratio of the cross section area and the wetted perimeter.

Equations (16) constitute a system of two partial differential equations with two unknown functions U(xt) and \(\bar{\eta }(x,t)\). A semi-implicit numerical method for solving these equations will be discussed in the next Section. Figure 3 shows a schematic representation of the four differential models described above.

Fig. 3
figure 3

Differential models

3 Numerical methods for the 1D model

There are several methods that can be used to solve numerically the shallow water equations. These methods can be explicit or implicit, finite differences, finite volumes or finite elements (see, e.g., [2,3,4,5,6,7,8,9,10,11]).

In solving numerically the differential equations (16) with simple explicit methods the occurrence of instability is a relatively common and disturbing event. Of course, a fully implicit discretization of these equations may lead to methods which are unconditionally stable. Implicit methods, however, may turn out to be unnecessarily complex. As a compromise, this Section will focus on the development of simple semi-implicit numerical methods which easily extend to multidimensional problems.

For the time being, the channel under consideration is assumed to have a rectangular cross section of constant width \(B=1\) so that the cross sectional area A simplifies to \(A(x,\eta )=H(x,\eta )\). Moreover, by using the lower case symbol u to denote the cross sectional average velocity, equations (16) in non conservative form are

$$\begin{aligned} \left\{ \begin{array}{l} u_t+u u_x +g \eta _x=\frac{1}{H}(\nu H u_x)_x+\frac{\gamma _{_T}u_a-\gamma u}{H} \\ \eta _t+u \eta _x + H u_x=-u h_x \end{array} \right. \end{aligned}$$
(17)

A severe limitation of standard explicit numerical methods for equations (17) is due to the stability restriction imposed by the Courant–Friedrichs–Lewy (CFL) condition [8,9,10,11]. Our first objective is to identify those terms in equations (17) whose implicit discretization enables to circumvent the CFL stability restriction of explicit methods.

Equations (17) in matrix notation can be written as

$$\begin{aligned} \mathbf{W}_t+\mathbf{A} \mathbf{W}_x =\mathbf{b} \end{aligned}$$
(18)

where

$$\begin{aligned} \mathbf{W}=\left( \begin{array}{c}u \\ \eta \\ \end{array}\right) , \quad \mathbf{A}=\left( \begin{array}{cc}\ u\ &{} g \\ H &{}\ u\ \\ \end{array}\right) , \quad \mathbf{b}=\left( \begin{array}{c}\frac{1}{H}(\nu H u_x)_x+\frac{\gamma _{_T}u_a-\gamma u}{H} \\ -u h_x\\ \end{array}\right) \end{aligned}$$

In open channel flows the horizontal viscosity term \(\frac{1}{H}(\nu H u_x)_x\) is usually neglected. When \(\nu =0\) system (18) is strictly hyperbolic and the corresponding characteristic equation is given by

$$\begin{aligned} det(\mathbf{A}-\lambda \mathbf{I})=0 \end{aligned}$$
Fig. 4
figure 4

Characteristic lines and CFL limitation

whose solutions are \(\lambda _{1,2}=u \pm \sqrt{gH}\). Note that when \(\vert u \vert <\sqrt{gH}\) the flow is subcritical and the characteristic speeds \(\lambda _{1,2}\) have opposite directions (see Fig. 4). More importantly, the dominant term \(\sqrt{gH}\) arises from the off diagonal terms g and H in matrix \(\mathbf{A}\). These are the coefficient of \(\eta _x\) in the momentum equation and the coefficient of \(u_x\) in the continuity equation. Therefore these derivatives must be discretized implicitly in order for the stability of the method to be independent of the celerity \(\sqrt{gH}\). The viscosity term and the non-linear advective term in the momentum equation will be discretized explicitly. However, for stability, the friction term in the momentum equation will be discretized implicitly, but the friction coefficient \(\frac{\gamma }{H}\) will be evaluated explicitly so that the resulting approximation will be linear. The continuity equation will be considered in its original conservative form so that the differential equations being solved are

$$\begin{aligned} \left\{ \begin{array}{l} u_t+u u_x =-g \eta _x+\frac{1}{H}(\nu H u_x)_x+\frac{\gamma _{_T}u_a-\gamma u}{H} \\ H_t+(Hu)_x=0 \end{array} \right. \end{aligned}$$
(19)

Next, a staggered grid of \(N_x\) equally spaced grid points is introduced. Let \(\Delta x^{}\) and \(\Delta t\) be the space and the time steps, respectively. The discrete variables u and \(\eta \) are defined at alternate locations as shown in Fig. 5. Additionally, assuming that the bottom profile is prescribed everywhere, the discrete total water depths at the n-th time level are enforced to be nonnegative and are taken to be

$$\begin{aligned}&H_i(\eta ^n_i)=max(0,h_i+\eta ^n_i) \end{aligned}$$
(20)
$$\begin{aligned}&H_{i+\frac{1}{2}}\left( \eta ^n_{i+\frac{1}{2}}\right) =max\left( 0,h_{i+\frac{1}{2}}+\eta ^n_{i+\frac{1}{2}}\right) \end{aligned}$$
(21)

where \(\eta ^n_{i+\frac{1}{2}}\) is determined from the nearest grid values by taking, e.g., the average, the upwind or the maximum between \(\eta ^n_{i}\) and \(\eta ^n_{i+1}\).

Then, a general semi-implicit discretization of equations (19) takes the form

$$\begin{aligned} u^{n+1}_{i+\frac{1}{2}}= & {} Fu^{n}_{i+\frac{1}{2}}-g\frac{\Delta t^{}}{\Delta x^{}}\left( \eta ^{n+1}_{i+1}-\eta ^{n+1}_i\right) +\Delta t \frac{\gamma ^{n}_{_T}u^{n+1}_{a}-\gamma ^{n}_{i+\frac{1}{2}}u^{n+1}_{i+\frac{1}{2}}}{H^n_{i+\frac{1}{2}}} \end{aligned}$$
(22)
$$\begin{aligned} H_i(\eta ^{n+1}_{i})= & {} H_i(\eta ^{n}_{i})-\frac{\Delta t^{}}{\Delta x^{}}\left( H^n_{i+\frac{1}{2}}u^{n+1}_{i+\frac{1}{2}}-H^n_{i-\frac{1}{2}}u^{n+1}_{i-\frac{1}{2}}\right) \end{aligned}$$
(23)

where

$$\begin{aligned} H^n_{i\pm \frac{1}{2}}=H_{i\pm \frac{1}{2}}\left( \eta ^n_{i\pm \frac{1}{2}}\right) , \qquad \gamma ^{n}_{i+\frac{1}{2}} =\gamma ^{n}_{_{B,i+\frac{1}{2}}}+\gamma ^{n}_{_T}=g \hbox {n}^2 \left[ \frac{\vert u^* \vert }{R^{1/3}} \right] ^n_{i+\frac{1}{2}}+\gamma ^{n}_{_T} \end{aligned}$$

and \(u^*_{i+\frac{1}{2}}=Fu^{n}_{i+\frac{1}{2}}-g\frac{\Delta t^{}}{\Delta x^{}}\left( \eta ^{n}_{i+1}-\eta ^{n}_i\right) \) is an explicit guess for the new velocity.

Of course, Eq. (22) is defined only on wet grid points, i.e., where \(H^{n}_{i+\frac{1}{2}}> 0\). On dry grid points \(u^{n+1}_{i+\frac{1}{2}} =0\) is assumed.

Fig. 5
figure 5

Staggered grid

In Eq. (22) F is any stable non-linear difference operator that includes a spatial discretization of the advective and viscous terms. A particular form for F can be chosen in a variety of ways thus, for example, by using a simple explicit upwind formula, or a more accurate and stable Eulerian–Lagrangian approach (for details see [4,5,6,7,8,9,10,11] and the references therein).

For any structure given to F, Eqs. (22)–(23) now constitute a piecewise linear system of equations with unknowns \(u^{n+1}_{i+\frac{1}{2}}\) and \(\eta ^{n+1}_{i}\) over the entire mesh configuration. The nonlinearity resides in the definition of \(H_i(\eta ^{n+1}_i)\) as specified by equation (20). This system has to be solved at each time step in order to determine the new values of the field variables from given initial data.

From a computational point of view, the system formed by Eqs. (22)–(23) is first reduced to a smaller one in which \(\eta ^{n+1}_{i}\) are the only unknowns. Specifically, where \(H^{n}_{i\pm \frac{1}{2}}> 0\) the expressions of unknowns \(u^{n+1}_{i\pm \frac{1}{2}}\) from the discretized momentum equation (22) is substituted into the continuity equation (23) to yield

$$\begin{aligned} H_i(\eta ^{n+1}_i) -g\frac{\Delta t^2}{\Delta x^2}\Bigg [ \! \! \left( \! \frac{H^2}{H+\gamma \Delta t} \right) ^{\! \! n}_{\! \! i+\frac{1}{2}} \! \! \! \big (\eta ^{n+1}_{i+1}\! -\eta ^{n+1}_i\big ) - \left( \! \frac{H^2}{H+\gamma \Delta t}\right) ^{\! \! n}_{\! \! i-\frac{1}{2}} \! \! \! \big (\eta ^{n+1}_i\! -\eta ^{n+1}_{i-1}\big )\Bigg ]=b^n_i \nonumber \\ \end{aligned}$$
(24)

where, by setting \(G^n_{i\pm \frac{1}{2}}=H^n_{i\pm \frac{1}{2}}Fu^n_{i\pm \frac{1}{2}}+\Delta t \gamma ^{n}_{_T}u^{n+1}_{a}\), the known right-hand side \(b^n_i\) is given by

$$\begin{aligned} b^n_i=H_i(\eta ^n_i)-\frac{\Delta t}{\Delta x} \Bigg [ \left( \frac{H G}{H+\gamma \Delta t} \right) ^n_{i+\frac{1}{2}} -\left( \frac{H G}{H+\gamma \Delta t} \right) ^n_{i-\frac{1}{2}} \Bigg ] \end{aligned}$$

Equation (24) can be assembled into a sparse, piecewise linear system of \(N_x\) equations in which \(\eta ^{n+1}_i,\ i=1,2,\dots ,N_x \) are the only unknowns. This system takes the following form

$$\begin{aligned} \mathbf{H}({\varvec{\zeta }}) + \mathbf{T}{\varvec{\zeta }}= \mathbf{b} \end{aligned}$$
(25)

where

$$\begin{aligned} {\varvec{\zeta }}= \left[ \begin{array}{c} \eta ^{n+1}_1 \\ \eta ^{n+1}_2 \\ \vdots \\ \eta ^{n+1}_{_{N_x}} \end{array} \right] , \qquad \mathbf{H}({\varvec{\zeta }})= \left[ \begin{array}{c} max(0,h_1+\zeta _1) \\ max(0,h_2+\zeta _2) \\ \vdots \\ max(0,h_{_{N_x}}+\zeta _{_{N_x}}) \end{array} \right] , \qquad \mathbf{b} = \left[ \begin{array}{c} b^n_1 \\ b^n_2 \\ \vdots \\ b^n_{_{N_x}} \end{array} \right] \end{aligned}$$

and \(\mathbf{T}\) is the sparse, symmetric and tridiagonal matrix that arises from the linear terms in Eq. (24).

At every time step, system (25) can be solved iteratively by a Newton type method in order to determine the new free-surface elevations \(\eta _i^{n+1}\). To this purpose note that the Jacobian matrix associated to system (25) is \(\mathbf{D({\varvec{\zeta }})+T}\) where \(\mathbf{D({\varvec{\zeta }})}\) is a diagonal matrix whose diagonal entries are

$$\begin{aligned} d_{i}(\zeta _i) =\left\{ \begin{array}{cl} 1 &{}\ \ \hbox {if}~ h_i+\zeta _i>0\\ 0 &{}\ \ \hbox {otherwise,}\end{array}\right. \qquad i=1,2,\dots ,N_x \end{aligned}$$

Thus, a converging Newton type method for solving system (25) can be formulated as follows (see [12] for details): guess \(\zeta ^0_i>-h_i\) for all \(i=1,2,\dots ,N_x\). Then, until convergence, compute

$$\begin{aligned} {\varvec{\zeta }}^{\ell +1}={\varvec{\zeta }}^\ell -[\mathbf{D}^\ell +\mathbf{T}]^{-1}[\mathbf{H}({\varvec{\zeta }}^\ell ) + \mathbf{T}{\varvec{\zeta }}^\ell -\mathbf{b}], \quad \ell =0,1,2,\dots \end{aligned}$$
(26)

where the superscript \(\ell \) denotes the iteration step (not to be confused with the time level n), \(\mathbf{D}^\ell =\mathbf{D}({\varvec{\zeta }}^\ell )\) and the vector \({\varvec{\delta }}^\ell =[\mathbf{D}^\ell +\mathbf{T}]^{-1}[\mathbf{H}({\varvec{\zeta }}^\ell ) + \mathbf{T}{\varvec{\zeta }}^\ell -\mathbf{b}]\) at the right-hand side of (26), regarded as the solution of the linear system \([\mathbf{D}^\ell +\mathbf{T}]{\varvec{\delta }}^\ell = \mathbf{H}({\varvec{\zeta }}^\ell ) + \mathbf{T}{\varvec{\zeta }}^\ell -\mathbf{b}\), can be easily determined by a direct method.

Once the new free-surface location has been determined, Eq. (22) yields readily and uniquely the new velocity field \(u^{n+1}_{i+\frac{1}{2}}\) throughout the flow domain and the simulation can then proceed to the next time step.

4 Numerical methods for the \(2D_{xz}\) model

The governing equations of a \(2D_{xz}\) model are the two-dimensional laterally averaged equations (15) in which, for simplicity, a constant width \(B=1\) is assumed. With this assumption equations (15) can also be written as follows

$$\begin{aligned} \left\{ \begin{array}{l} u_t+u u_x+w u_z= -g \eta _x+(\nu u_x)_x+(\nu u_z)_z-\gamma u\\ u_x+w_z=0 \\ H_t+\bigg [\int _{-h}^{\eta }udz\bigg ]_x=0 \end{array} \right. \end{aligned}$$
(27)

The simplified free-surface boundary condition is given by prescribing the wind stress as

$$\begin{aligned} \nu u_z=\gamma _{_T}(u_a-u^s) \end{aligned}$$
(28)

and the simplified boundary condition at the sediment-water interface is specified by prescribing the bottom stress as

$$\begin{aligned} \nu u_z=\gamma _{_B} u^b \end{aligned}$$
(29)

where \(\gamma \), \(\gamma _{_B}\) and \(\gamma _{_T}\) are nonnegative friction coefficients.

Based on the characteristic analysis carried on the one-dimensional model, for stability, the gradient of surface elevation in the momentum equation and the velocity in the free-surface equation will be discretized implicitly. Moreover, in order to allow the use of arbitrarily small vertical resolution without compromising the stability of the resulting method, the vertical viscosity will also be discretized implicitly. An explicit discretization will be used for advection and for the horizontal viscosity.

The spatial mesh consists of rectangular cells of length \(\Delta x^{}\) and height \(\Delta z_k=z_{k+\frac{1}{2}}-z_{k-\frac{1}{2}}\). Each cell is numbered at its center with indices i and k. The discrete u velocity is then defined at half integer i and integer k; w is defined at integer i and half integer k (see Fig. 6). Finally, \(\eta \) is defined at integer i.

Fig. 6
figure 6

Flow domain and staggered locations

As in the one-dimensional model, nonnegativity of the total water depth at discrete level is enforced by specifying

$$\begin{aligned}&H_i(\eta ^n_i)=max(0,h_i+\eta ^n_i) \end{aligned}$$
(30)
$$\begin{aligned}&H_{i+\frac{1}{2}}\left( \eta ^n_{i+\frac{1}{2}}\right) =max\left( 0,h_{i+\frac{1}{2}}+\eta ^n_{i+\frac{1}{2}}\right) \end{aligned}$$
(31)

At every time step the local vertical increments \(\Delta z^n_{i+\frac{1}{2},k}\) are preliminarily set to be the wetted distance between \(z_{k+\frac{1}{2}}\) and \(z_{k-\frac{1}{2}}\) at \(x_{i+\frac{1}{2}}\). Thus, \(0\le \Delta z^n_{i+\frac{1}{2},k} \le \Delta z_k\) and \(H_{i+\frac{1}{2}}(\eta ^n_{i+\frac{1}{2}}) =\sum _{k=1}^{N_z}{\Delta z^n_{i+\frac{1}{2},k}}\) . Of course, some of the \(\Delta z^n_{i+\frac{1}{2},k}\) are allowed to be zero and, accordingly, the corresponding new velocity is taken to be \(u^{n+1}_{i+\frac{1}{2},k}=0\).

Along wet vertical sides of the grid one has \(\Delta z^n_{i+\frac{1}{2},k}>0\). Here the momentum equation in (27) applies and is discretized as follows

$$\begin{aligned} u^{n+1}_{i+\frac{1}{2},k}= & {} Fu^n_{i+\frac{1}{2},k}- g\frac{\Delta t}{\Delta x}\left( \eta ^{n+1}_{i+1}-\eta ^{n+1}_{i}\right) \nonumber \\&+\Delta t \frac{\nu ^{n+1}_{i+\frac{1}{2},k+\frac{1}{2}}\frac{u^{n+1}_{i+\frac{1}{2},k+1} -u^{n+1}_{i+\frac{1}{2},k}}{\Delta z^n_{i+\frac{1}{2},k+\frac{1}{2}}} -\nu ^{n+1}_{i+\frac{1}{2},k-\frac{1}{2}}\frac{u^{n+1}_{i+\frac{1}{2},k} -u^{n+1}_{i+\frac{1}{2},k-1}}{\Delta z^n_{i+\frac{1}{2},k-\frac{1}{2}}}}{\Delta z^n_{i+\frac{1}{2},k}}\nonumber \\&-\Delta t \gamma ^{n}_{i+\frac{1}{2},k} u^{n+1}_{i+\frac{1}{2},k} \nonumber \\&\quad k=m_{i+\frac{1}{2}},m_{i+\frac{1}{2}}+1,\dots ,M^n_{i+\frac{1}{2}} \end{aligned}$$
(32)

where \(m_{i+\frac{1}{2}}\) and \(M^n_{i+\frac{1}{2}}\) denote the limit of k-index representing the bottom and the top finite-difference stencil, respectively. As indicated, m and M depend on their spatial location and M may also change with the time level to account for the free-surface dynamics. For notational simplicity, subscript and superscript on \(m_{i+\frac{1}{2}}\) and \(M^n_{i+\frac{1}{2}}\) may be omitted in the following development.

In Eq. (32) F is an explicit, nonlinear finite difference operator which includes the contributions arising from the spatial discretization of the advective and the horizontal viscosity terms. A particular form for F can be chosen in a variety of ways thus, for example, by using a simple explicit upwind formula, or a more accurate and stable Eulerian–Lagrangian approach.

The values of u above free-surface and below bottom in (32) are eliminated by means of the boundary conditions (28)–(29) which are written in difference form as

$$\begin{aligned} \nu ^{n+1}_{i+\frac{1}{2},M+\frac{1}{2}}\frac{u^{n+1}_{i+\frac{1}{2},M+1}- u^{n+1}_{i+\frac{1}{2},M}}{\Delta z^n_{i+\frac{1}{2},M+\frac{1}{2}}} =\gamma _{_T}^{n}\left( u_a^{n+1}-u^{n+1}_{i+\frac{1}{2},M}\right) \end{aligned}$$
(33)

and

$$\begin{aligned} \nu ^{n+1}_{i+\frac{1}{2},m-\frac{1}{2}}\frac{u^{n+1}_{i+\frac{1}{2},m}- u^{n+1}_{i+\frac{1}{2},m-1}}{\Delta z^n_{i+\frac{1}{2},m-\frac{1}{2}}} =\gamma _{_B}^{n} u^{n+1}_{i+\frac{1}{2},m} \end{aligned}$$
(34)

where \(\gamma _{_B}^{n} =\frac{g}{C_z^2} \vert u^*_{i+\frac{1}{2},m} \vert \) and \(u^*_{i+\frac{1}{2},m}=Fu^n_{i+\frac{1}{2},m}-g\frac{\Delta t}{\Delta x}(\eta ^n_{i+1}-\eta ^n_{i})\).

A semi-implicit finite difference discretization for the free-surface equation in (27) in conservative form is taken to be

$$\begin{aligned} H_i(\eta ^{n+1}_{i})=H_i(\eta ^n_{i})- \frac{\Delta t}{\Delta x}\left[ \sum ^{M^n_{i+\frac{1}{2}}}_{k=m_{i+\frac{1}{2}}}\!\!\! \Delta z^n_{i+\frac{1}{2},k} u^{n+1}_{i+\frac{1}{2},k}-\!\!\! \sum ^{M^n_{i-\frac{1}{2}}}_{k=m_{i-\frac{1}{2}}}\!\!\! \Delta z^n_{i-\frac{1}{2},k} u^{n+1}_{i-\frac{1}{2},k}\right] \end{aligned}$$
(35)

Assuming that the computational domain is covered by a set of \(N_x\times N_z\) computational cells, equations (32) and (35) constitute a piecewise linear system of at most \(N_x(N_z+1)\) equations. The nonlinearity resides in the definition of the total water depth \(H_i(\eta ^{n+1}_{i})\). This system has to be solved at each time step in order to calculate the new field variables \(u^{n+1}_{i+\frac{1}{2},k}\) and \(\eta ^{n+1}_{i}\) throughout the flow domain.

The system of \(N_x(N_z+1)\) equations formed by (32) and (35) can be conveniently decomposed into a set of \(N_x\) independent linear tridiagonal systems of \(N_z\) equations, and one piecewise linear system of \(N_x\) equations. Specifically, Eqs. (32) and (35) are first written in matrix form as

$$\begin{aligned} \mathbf{A}^n_{i+\frac{1}{2}}{} \mathbf{U}^{n+1}_{i+\frac{1}{2}}= & {} \mathbf{G}^n_{i+\frac{1}{2}}-g\frac{\Delta t}{\Delta x}(\eta ^{n+1}_{i+1} -\eta ^{n+1}_{i}){\varvec{\Delta } \mathbf{Z}}^n_{i+\frac{1}{2}} \end{aligned}$$
(36)
$$\begin{aligned} H_i(\eta ^{n+1}_{i})= & {} H_i(\eta ^n_{i}) -\frac{\Delta t}{\Delta x}\bigg [\Big ({\varvec{\Delta } \mathbf{Z}}^n_{i+\frac{1}{2}}\Big )^\top \mathbf{U}^{n+1}_{i+\frac{1}{2}}-\Big ({\varvec{\Delta }{} \mathbf{Z}}^n_{i-\frac{1}{2}}\Big )^\top \mathbf{U}^{n+1}_{i-\frac{1}{2}}\bigg ] \end{aligned}$$
(37)

where, along each water column the vectors \(\mathbf{U}\), \(\varvec{\Delta } {Z}\), \(\mathbf{G}\) and the tridiagonal matrix \(\mathbf{A}\) are defined as follows:

$$\begin{aligned} \mathbf{U}= & {} \left( \begin{array}{c}u_{_{M}}\\ u_{_{M-1}}\\ u_{_{M-2}}\\ \vdots \\ u_{m+1}\\ u_{m}\\ \end{array}\right) ,\qquad \varvec{\Delta } \mathbf{Z}=\left( \begin{array}{cc}\Delta z_{_{M}}\\ \Delta z_{_{M-1}}\\ \Delta z_{_{M-2}}\\ \vdots \\ \Delta z_{m+1}\\ \Delta z_{m}\\ \end{array}\right) ,\qquad \mathbf{G}=\left( \begin{array}{c} \Delta z_{_{M}} Fu_{_{M}}+\Delta t\gamma _{_T}u_a\\ \Delta z_{_{M-1}}Fu_{_{M-1}}\\ \Delta z_{_{M-2}}Fu_{_{M-2}}\\ \vdots \\ \Delta z_{m+1}Fu_{m+1}\\ \Delta z_{m} Fu_{m}\\ \end{array}\right) \\ \mathbf{A}= & {} \left( \begin{array}{cccc}d_{_M}+ a_{_{M-\frac{1}{2}}}+\gamma _{_T}\Delta t&{} -a_{_{M-\frac{1}{2}}}&{} &{} 0 \\ &{} &{} &{} \\ -a_{_{M-\frac{1}{2}}}&{} d_{_{M-1}}+ a_{_{M-\frac{1}{2}}}+a_{_{M-\frac{3}{2}}}&{} \ \ \ -a_{_{M-\frac{3}{2}}}\ \ \ &{} \\ .&{}.&{}.&{} \\ &{}.&{}.&{}.\\ 0&{} &{} \ \ \ -a_{m+\frac{1}{2}}&{} \ \ \ d_{m}+ a_{m+\frac{1}{2}}+\gamma _{_B}\Delta t\\ \end{array}\right) \end{aligned}$$

with \(d_k=\displaystyle {\Delta z_{k}\big (1+\gamma _{k}\Delta t\big )}\) and \(a_{k\pm \frac{1}{2}}=\Delta t\displaystyle {\frac{\nu _{k\pm \frac{1}{2}}}{\Delta z_{k\pm \frac{1}{2}}}},\ k=m,m+1,\dots ,M\).

Then, formal substitution of the expressions for \(\mathbf{U}^{n+1}_{i\pm \frac{1}{2}}\) from (36) into (37) yields a discrete wave equation for \( \eta ^{n+1}\) which is given by

$$\begin{aligned}&H_i(\eta ^{n+1}_{i})-g\frac{\Delta t^2}{\Delta x^2}\Bigg \{ \Big [\big ({\varvec{\Delta } \mathbf{Z}}\big )^\top \mathbf{A}^{-1}{\varvec{\Delta } \mathbf{Z}}\Big ]^n _{i+\frac{1}{2}}\big (\eta ^{n+1}_{i+1}-\eta ^{n+1}_{i}\big )\nonumber \\&\quad -\Big [\big ({\varvec{\Delta } \mathbf{Z}}\big )^\top \mathbf{A}^{-1}{\varvec{\Delta } \mathbf{Z}}\Big ]^n _{i-\frac{1}{2}}\big (\eta ^{n+1}_{i}-\eta ^{n+1}_{i-1}\big )\Bigg \} =b^n_i \end{aligned}$$
(38)

where

$$\begin{aligned} b^n_i=H_i(\eta ^n_{i})-\frac{\Delta t}{\Delta x}\Bigg \{ \Big [\big ({\varvec{\Delta } \mathbf{Z}}\big )^\top \mathbf{A}^{-1}{} \mathbf{G}\Big ]^n _{i+\frac{1}{2}} -\Big [\big ({\varvec{\Delta } \mathbf{Z}}\big )^\top \mathbf{A}^{-1}\mathbf{G}\Big ]^n _{i-\frac{1}{2}}\Bigg \} \end{aligned}$$

Since \(\mathbf{A}\) is positive definite, \(\mathbf{A}^{-1}\) is also positive definite and therefore \(({\varvec{\Delta } \mathbf{Z}})^\top \mathbf{A}^{-1}\mathbf{\Delta Z}\) is a non-negative scalar. Hence Eq. (38) constitute a well posed piecewise linear system of \(N_x\) equations for \(\eta ^{n+1}_{i}\) which has the same size and structure as the corresponding system that was derived in Sect. 3 for the one-dimensional model. Thus, its unique solution can be determined by a converging Newton type method as described in Sect. 3.

Once the new free-surface location has been determined, Eq. (36) constitute a set of \(N_x\) linear, tridiagonal systems with \(N_z\) equations each. All these systems are independent from each other, symmetric and positive definite. Thus, they can be conveniently solved by a direct method.

Finally, by discretizing the continuity equation in (27) the new vertical component of the velocity in each water column can be computed recursively from bottom to top as

$$\begin{aligned} w^{n+1}_{i,m-\frac{1}{2}}= & {} 0;\nonumber \\ w^{n+1}_{i,k+\frac{1}{2}}= & {} w^{n+1}_{i,k-\frac{1}{2}}- \frac{\Delta z^{n}_{i+\frac{1}{2},k}u^{n+1}_{i+\frac{1}{2},k}- \Delta z^{n}_{i-\frac{1}{2},k}u^{n+1}_{i-\frac{1}{2},k}}{\Delta x} \nonumber \\&\quad k=m_i,m_i+1,\ldots ,M^n_i-1 \end{aligned}$$
(39)

Thus every time step can be summarized as a simple algorithm which is as follows

  1. (a)

    set up and solve the piecewise linear system (38) to obtain simultaneously the new water levels \(\eta ^{n+1}\) and the resulting total water depths \(H(\eta ^{n+1})\) throughout the horizontal flow domain;

  2. (b)

    solve the \(N_x\) linear tridiagonal systems (36) to determine the new horizontal velocities \(u^{n+1}\);

  3. (c)

    diagnostically obtain the new vertical velocity \(w^{n+1}\) from (39).

5 Numerical methods for the \(2D_{xy}\) model

When \(\nu =0\) the two-dimensional shallow water equations (11) form a quasilinear hyperbolic system of partial differential equations with three unknown functions, namely u, v and \(\eta \), and three independent variables, x, y and t. When \(\nu >0\) this system is no longer hyperbolic but the stability of any explicit numerical scheme will still depend on its hyperbolic part, and hence on the celerity \(\sqrt{g H}\). In order to determine an efficient semi-implicit method whose stability is independent on the celerity, a characteristic analysis of the hyperbolic part of (11) is preliminarily investigated (see [8, 9]). Thus Eq. (11) in non-conservative form are written as

$$\begin{aligned} \left\{ \begin{array}{l} u_t+u u_x+v u_y+g \eta _x= \frac{1}{H}\left[ (\nu H u_x)_x+(\nu H u_y)_y\right] +\frac{\gamma _{_T}u_a - \gamma u}{H}\\ v_t+u v_x+v v_y+g \eta _y= \frac{1}{H}\left[ (\nu H v_x)_x+(\nu H v_y)_y\right] +\frac{\gamma _{_T}v_a - \gamma v}{H}\\ \eta _t+u \eta _x +v \eta _y+H[u_x+v_y]=-u h_x-v h_y \end{array} \right. \end{aligned}$$
(40)

or, in matrix notation,

$$\begin{aligned} \mathbf{W}_t +\mathbf{A}{} \mathbf{W}_x +\mathbf{B}{} \mathbf{W}_y=\mathbf{D} \end{aligned}$$
(41)

where

$$\begin{aligned} \mathbf{W}= & {} \left( \begin{array}{c}u \\ v \\ \eta \\ \end{array}\right) , \ \ \ \ \mathbf{A}=\left( \begin{array}{ccc}u &{} 0 &{} g \\ 0 &{} u &{} 0 \\ H &{} 0 &{} u \\ \end{array}\right) , \ \ \ \ \mathbf{B}=\left( \begin{array}{ccc}v &{} 0 &{} 0 \\ 0 &{} v &{} g \\ 0 &{} H &{} v \\ \end{array}\right) \\ \mathbf{D}= & {} \left( \begin{array}{c}\frac{1}{H}\left[ (\nu H u_x)_x+(\nu H u_y)_y\right] +\frac{\gamma _{_T}u_a - \gamma u}{H} \\ \frac{1}{H}\left[ (\nu H v_x)_x+(\nu H v_y)_y\right] +\frac{\gamma _{_T}v_a - \gamma v}{H} \\ -u h_x-v h_y\end{array}\right) \end{aligned}$$

The characteristic equation of system (41) is given by

$$\begin{aligned} det(q \mathbf{I}+r\mathbf{A}+s\mathbf{B})=0 \end{aligned}$$

that is,

$$\begin{aligned} (q+ru+sv)[(q+ru+sv)^2-gH(r^2+s^2)]=0 \end{aligned}$$
(42)
Fig. 7
figure 7

Characteristic cone

The triples (rsq) satisfying Eq. (42) are directions normal to the characteristic cone at its vertex (see Fig. 7). Equation (42) decomposes as follows

$$\begin{aligned} (q+ru+sv)=0 \end{aligned}$$
(43)

and

$$\begin{aligned} (q+ru+sv)^2-gH(r^2+s^2)=0 \end{aligned}$$
(44)

The local characteristic cone with vertex in \(({\bar{x}},\bar{y},{\bar{t}}) \) consists of the line through \(({\bar{x}},{\bar{y}},{\bar{t}}) \) and parallel to the vector (uv, 1) and the cone whose equation is

$$\begin{aligned} {[}(x-{\bar{x}})-u(t-{\bar{t}})]^2+[(y-{\bar{y}})-v(t-\bar{t})]^2-gH(t-{\bar{t}})^2=0 \end{aligned}$$
(45)

in fact, on the cone surface, the gradient of the left-hand side of (45) satisfies (44).

Note that, whereas the first part of the characteristic cone depends only on the fluid velocity u and v, the second part, which is defined by Eq. (44), depends also upon the celerity \(\sqrt{gH}\). Note also that the term gH in Eq. (42) arises from the off diagonal terms g and H in the matrices \(\mathbf{A}\) and \(\mathbf{B}\). These are the coefficient of \(\eta _x\) in the first momentum equation, the coefficient of \( \eta _y\) in the second momentum equation, and the coefficient of \(u_x\) and \(v_y\) in the continuity equation of system (40). Consequently, these derivatives must be discretized implicitly in order to obtain a method whose stability is independent of the celerity [9].

Based on the above analysis, the semi-implicit method derived in Sect. 3 will be extended to the following \(2D_{xy}\) model:

$$\begin{aligned} \left\{ \begin{array}{l} u_t+u u_x+v u_y=-g \eta _x+ \frac{1}{H}\left[ (\nu H u_x)_x+(\nu H u_y)_y\right] +\frac{\gamma _{_T}u_a - \gamma u}{H}\\ v_t+u v_x+v v_y=-g \eta _y+ \frac{1}{H}\left[ (\nu H v_x)_x+(\nu H v_y)_y\right] +\frac{\gamma _{_T}v_a - \gamma v}{H}\\ H_t+(Hu)_x +(Hv)_y=0 \end{array} \right. \end{aligned}$$
(46)

A staggered mesh of \(N_x\times N_y\) rectangular cells of length \(\Delta x\) and width \(\Delta y\) is introduced. Each cell is numbered at its center with indices i and j. The discrete u velocity is then defined at half integer i and integer j; v is defined at integer i and half integer j; \(\eta \) is defined at integer i and integer j (see Fig. 8). Additionally, assuming that the bottom profile h(xy) is prescribed everywhere, the discrete total water depths at the grid locations are enforced to be nonnegative and are taken to be

$$\begin{aligned}&H_{i,j}(\eta ^n_{i,j})=max(0,h_{i,j}+\eta ^n_{i,j}) \end{aligned}$$
(47)
$$\begin{aligned}&H_{i+\frac{1}{2},j}(\eta ^n_{i+\frac{1}{2},j})=max(0,h_{i+\frac{1}{2},j}+\eta ^n_{i+\frac{1}{2},j}) \end{aligned}$$
(48)
$$\begin{aligned}&H_{i,j+\frac{1}{2}}(\eta ^n_{i,j+\frac{1}{2}})=max(0,h_{i,j+\frac{1}{2}}+\eta ^n_{i,j+\frac{1}{2}}) \end{aligned}$$
(49)

where \(\eta ^n_{i+\frac{1}{2},j}\) and \(\eta ^n_{i,j+\frac{1}{2}}\) are determined from the nearest grid values by taking, e.g., the average, the upwind or the maximum. Then, a stable semi-implicit scheme for equations (46), is derived by using an implicit discretization for the gradient of surface elevation in the momentum equations and for the velocity in the continuity equation. Moreover, for stability, the friction terms in the momentum equations are discretized implicitly, but the friction coefficients \(\gamma \) and \(\gamma _{_T}\) will be evaluated explicitly. The remaining terms are discretized explicitly [8, 9]. The basic semi-implicit algorithm is

$$\begin{aligned} u^{n+1}_{i+\frac{1}{2},j}= & {} F u^{n}_{i+\frac{1}{2},j}-g\frac{\Delta t}{\Delta x}\Bigg (\eta ^{n+1}_{i+1,j}-\eta ^{n+1}_{i,j}\Bigg ) + \Delta t \frac{\gamma ^{n}_{_T}u^{n+1}_a-\gamma ^{n}_{i+\frac{1}{2},j} u^{n+1}_{i+\frac{1}{2},j}}{H^n_{i+\frac{1}{2},j}} \nonumber \\ \end{aligned}$$
(50)
$$\begin{aligned} v^{n+1}_{i,j+\frac{1}{2}}= & {} F v^{n}_{i,j+\frac{1}{2}} -g\frac{\Delta t}{\Delta y}\Bigg (\eta ^{n+1}_{i,j+1}-\eta ^{n+1}_{i,j}\Bigg ) +\Delta t \frac{\gamma ^{n}_{_T}v^{n+1}_a-\gamma ^{n}_{i,j+\frac{1}{2}}v^{n+1}_{i,j+\frac{1}{2}}}{H^n_{i,j+\frac{1}{2}}}\nonumber \\ \end{aligned}$$
(51)
$$\begin{aligned} H_{i,j}(\eta ^{n+1}_{i,j})= & {} H_{i,j}(\eta ^{n}_{i,j}) -\frac{\Delta t}{\Delta x}\Bigg ( H^{n}_{i+\frac{1}{2},j}u^{n+1}_{i+\frac{1}{2},j}- H^{n}_{i-\frac{1}{2},j}u^{n+1}_{i-\frac{1}{2},j}\Bigg ) \nonumber \\&-\frac{\Delta t}{\Delta y}\Bigg ( H^{n}_{i,j+\frac{1}{2}}v^{n+1}_{i,j+\frac{1}{2}}- H^{n}_{i,j-\frac{1}{2}}v^{n+1}_{i,j-\frac{1}{2}}\Bigg ) \end{aligned}$$
(52)
Fig. 8
figure 8

Flow domain and computational grid

where \(H^n_{i+\frac{1}{2},j}\! \! = H_{i+\frac{1}{2},j}(\eta ^n_{i+\frac{1}{2},j})\), \(H^n_{i,j+\frac{1}{2}}\! \! =H_{i,j+\frac{1}{2}}(\eta ^n_{i,j+\frac{1}{2}})\) and \(\gamma ^{n}\! =\frac{g}{C_z^2}\sqrt{(u^*)^2+(v^*)^2}\).

Of course, Eq. (50) is defined only on wet grid points, i.e., where \(H^{n}_{i+\frac{1}{2},j}> 0\). On dry grid points \(u^{n+1}_{i+\frac{1}{2},j} =0\) is assumed. Likewise, Eq. (51) is defined where \(H^{n}_{i,j+\frac{1}{2}}> 0\). On dry grid points \(v^{n+1}_{i,j+\frac{1}{2}} =0\) is assumed.

In Eqs. (50)–(51) F is an explicit, finite difference operator corresponding to the explicit spatial discretization of the advective and the viscous terms. A particular form for F can be chosen in a variety of ways thus, for example, by using an explicit upwind formula, or a more accurate and stable Eulerian–Lagrangian approach.

For any structure given to F Eqs. (50)–(52) constitute a piecewise linear system of \(3 N_x N_y\) equations and \(3 N_x N_y\) unknowns \(u^{n+1}_{i+\frac{1}{2},j}\), \(v^{n+1}_{i,j+\frac{1}{2}}\) and \(\eta ^{n+1}_{i,j}\). The nonlinearity resides in the definition of \(H_{i,j}(\eta ^{n+1}_{i,j})\) as specified by Eq. (47). This system has to be solved at each time step to determine, recursively, values of the field variables from given initial and boundary conditions.

From a computational point of view, since most of the computational effort is devoted to solve system (50)–(52), this system will be reduced to a smaller one in which \(\eta ^{n+1}_{i,j}\) are the only unknowns. Specifically, where \(H^{n}_{i\pm \frac{1}{2},j}> 0\) and \(H^{n}_{i,j\pm \frac{1}{2}}> 0\) \(u^{n+1}_{i\pm \frac{1}{2},j}\) and \(v^{n+1}_{i,j\pm \frac{1}{2}}\) are eliminated from the continuity equation (52) to yield

$$\begin{aligned}&H_{i,j}(\eta ^{n+1}_{i,j})-g\frac{\Delta t^2}{\Delta x^2}\Bigg [ \Big (\frac{H^2}{H+\gamma \Delta t}\Big )^n_{i+\frac{1}{2},j} \big (\eta ^{n+1}_{i+1,j}-\eta ^{n+1}_{i,j}\big )- \Big (\frac{H^2}{H+\gamma \Delta t}\Big )^n_{i-\frac{1}{2},j} \big (\eta ^{n+1}_{i,j}-\eta ^{n+1}_{i-1,j}\big ) \! \Bigg ] \nonumber \\&\qquad -g\frac{\Delta t^2}{\Delta y^2}\Bigg [ \Big (\frac{H^2}{H+\gamma \Delta t}\Big )^n_{i,j+\frac{1}{2}} \big (\eta ^{n+1}_{i,j+1}-\eta ^{n+1}_{i,j}\big )- \Big (\frac{H^2}{H+\gamma \Delta t}\Big )^n_{i,j-\frac{1}{2}} \big (\eta ^{n+1}_{i,j}-\eta ^{n+1}_{i,j-1}\big )\Bigg ]\nonumber \\&\quad =b^{n}_{i,j} \end{aligned}$$
(53)

where, by setting

$$\begin{aligned} G^n_{i\pm \frac{1}{2},j}= & {} H^n_{i\pm \frac{1}{2},j} Fu^n_{i\pm \frac{1}{2},j}+\Delta t \gamma ^{n}_{_T}u^{n+1}_a \quad \hbox {and} \\ G^n_{i,j\pm \frac{1}{2}}= & {} H^n_{i,j\pm \frac{1}{2}} Fv^n_{i,j\pm \frac{1}{2}}+\Delta t \gamma ^{n}_{_T}v^{n+1}_a \end{aligned}$$

the right hand side \(b^{n}_{i,j}\) can be written as

$$\begin{aligned} b^{n}_{i,j}= & {} H_{i,j}(\eta ^{n}_{i,j})-\frac{\Delta t}{\Delta x} \Bigg [\Big (\frac{H G}{H+\gamma \Delta t}\Big )^n_{i+\frac{1}{2},j} -\Big (\frac{H G}{H+\gamma \Delta t}\Big )^n_{i-\frac{1}{2},j} \Bigg ] \\&-\frac{\Delta t}{\Delta y} \Bigg [\Big (\frac{H G }{H+\gamma \Delta t}\Big )^n_{i,j+\frac{1}{2}} -\Big (\frac{H G}{H+\gamma \Delta t}\Big )^n_{i,j-\frac{1}{2}} \Bigg ] \end{aligned}$$

Equations (53) constitute a well posed piecewise linear system of \(N_x N_y\) equations with unknowns \(\eta ^{n+1}_{i,j}\). This system can be written in a more compact matrix form as

$$\begin{aligned} \mathbf{H}({{\varvec{\zeta }}}) + \mathbf{T}{{\varvec{\zeta }}}= \mathbf{b} \end{aligned}$$
(54)

where \({{\varvec{\zeta }}}\) is a vector containing the unknowns \(\eta ^{n+1}_{i,j}\); the piecewise linear vector function \(\mathbf{H}({{\varvec{\zeta }}})\) represents the corresponding total water depths \(H_{i,j}(\zeta _{i,j})\); \(\mathbf{T}\) is the five-diagonal, symmetric and at least positive semi-definite matrix that arises from the linear terms in Eq. (53); and b is a known vector with the right-hand sides \(b^{n}_{i,j}\) of Eq. (53).

A converging Newton type method for solving system (54) is formulated as follows (see [12] for details): Guess \(\zeta ^0_{i,j}>-h_{i,j}\) for all i and for all j. Then, until convergence, compute

$$\begin{aligned} {{\varvec{\zeta }}}^{\ell +1}={{\varvec{\zeta }}}^\ell -[\mathbf{D}^\ell +\mathbf{T}]^{-1}[\mathbf{H}({{\varvec{\zeta }}}^\ell ) + \mathbf{T}{{\varvec{\zeta }}}^\ell -\mathbf{b}], \quad \ell =0,1,2,\dots \end{aligned}$$
(55)

where the superscript \(\ell \) denotes the iteration step (not to be confused with the time level n) and \(\mathbf{D}^\ell \) is a diagonal matrix whose diagonal entries are

$$\begin{aligned} d^\ell _{i,j} =\left\{ \begin{array}{cl} 1 &{}\ \ \hbox {if}~ h_{i,j}+\zeta ^\ell _{i,j}>0\\ 0 &{}\ \ \hbox {otherwise}\end{array}\right. \end{aligned}$$

Note that the vector \({\varvec{\delta }}^\ell =[\mathbf{D}^\ell +\mathbf{T}]^{-1}[\mathbf{H}(\varvec{\zeta }^\ell ) + \mathbf{T} \varvec{\zeta }^\ell -\mathbf{b}]\) at the right-hand side of (55) can be regarded as the solution of the linear system \([\mathbf{D}^\ell +\mathbf{T}]{\varvec{\delta }}^\ell =\mathbf{H}(\varvec{\zeta }^\ell ) + \mathbf{T}\varvec{\zeta }^\ell -\mathbf{b}\) which can be efficiently solved by a preconditioned conjugate gradient method.

Once the new free-surface location has been determined, Eqs. (50) and (51) yield readily and uniquely the new velocity field \(u^{n+1}_{i+\frac{1}{2},j}\) and \(v^{n+1}_{i,j+\frac{1}{2}}\) throughout the flow domain.

6 Numerical methods for the 3D model

The semi-implicit finite difference methods described in Sections 4 and 5 can be further generalized to yield a practical algorithm for solving the fully three-dimensional equations (10) [4,5,6,7]. These equations can be written as

$$\begin{aligned} \left\{ \begin{array}{l} u_t+u u_x+v u_y+w u_z=-g \eta _x+(\nu u_x)_x+(\nu u_y)_y+(\nu u_z)_z\\ v_t+u v_x+v v_y+w v_z=-g \eta _y+(\nu v_x)_x+(\nu v_y)_y+(\nu v_z)_z\\ u_x+v_y+w_z=0\\ H_t+\bigg [\int _{-h}^{\eta }udz\bigg ]_x+\bigg [\int _{-h}^{\eta }vdz\bigg ]_y=0 \end{array} \right. \end{aligned}$$
(56)

The spatial mesh consists of boxes with length \(\Delta x^{}\), width \(\Delta y\) and height \(\Delta z_k\). Each box is numbered at its center with indices i, j and k. The discrete u velocity is then defined at half integer i and integers j and k; v is defined at integers i, k and half integer j; w is defined at integers i, j and half integer k. Finally, \(\eta \) is defined at integers i, j.

Then, on wet vertical faces perpendicular to the x-axis the discrete u momentum equation in matrix form can be written as

$$\begin{aligned} \mathbf{A}^n_{i+\frac{1}{2},j}\mathbf{U}^{n+1}_{i+\frac{1}{2},j}= \mathbf{G}^n_{i+\frac{1}{2},j}-g\frac{\Delta t}{\Delta x} (\eta ^{n+1}_{i+1,j} -\eta ^{n+1}_{i,j}){\varvec{\Delta }{} \mathbf{Z}}^n_{i+\frac{1}{2},j} \end{aligned}$$
(57)

Similarly, on wet vertical faces perpendicular to the y-axis the discrete v momentum equation is given by

$$\begin{aligned} \mathbf{A}^n_{i,j+\frac{1}{2}}\mathbf{V}^{n+1}_{i,j+\frac{1}{2}}= \mathbf{G}^n_{i,j+\frac{1}{2}}-g\frac{\Delta t}{\Delta y} (\eta ^{n+1}_{i,j+1} -\eta ^{n+1}_{i,j})\varvec{\Delta Z}^n_{i,j+\frac{1}{2}} \end{aligned}$$
(58)

Finally, for all i and for all j the discrete free-surface equation is taken to be

$$\begin{aligned} H_{i,j}(\eta ^{n+1}_{i,j})= & {} H_{i,j}(\eta ^n_{i,j}) -\frac{\Delta t}{\Delta x}\bigg [\Big ({\varvec{\Delta }{} \mathbf{Z}}^n_{i+\frac{1}{2},j}\Big )^\top \mathbf{U}^{n+1}_{i+\frac{1}{2},j}-\Big ({\varvec{\Delta }{} \mathbf{Z}}^n_{i-\frac{1}{2},j}\Big )^\top \mathbf{U}^{n+1}_{i-\frac{1}{2},j}\bigg ] \nonumber \\&-\frac{\Delta t}{\Delta y}\bigg [\Big ({\varvec{\Delta }{} \mathbf{Z}}^n_{i,j+\frac{1}{2}}\Big )^\top {\varvec{\Delta }{} \mathbf{Z}}^{n+1}_{i,j+\frac{1}{2}}-\Big (\varvec{\Delta Z}^n_{i,j-\frac{1}{2}}\Big )^\top \mathbf{V}^{n+1}_{i,j-\frac{1}{2}}\bigg ] \end{aligned}$$
(59)

A two-dimensional discrete wave equation for \(\eta ^{n+1}\) is derived after formal substitution of the expressions for \(\mathbf{U}^{n+1}_{i\pm \frac{1}{2},j}\) and \(\mathbf{V}^{n+1}_{i,j\pm \frac{1}{2}}\) from (57) and (58) into (59) which yields

$$\begin{aligned}&H_{i,j}(\eta ^{n+1}_{i,j})-g\frac{\Delta t^2}{\Delta x^2}\Bigg \{ \Big [\big ({\varvec{\Delta }{} \mathbf{Z}}\big )^\top \mathbf{A}^{-1}{\varvec{\Delta }{} \mathbf{Z}}\Big ]^n _{i+\frac{1}{2},j}\big (\eta ^{n+1}_{i+1,j}-\eta ^{n+1}_{i,j}\big )\nonumber \\&\quad -\Big [\big ({\varvec{\Delta }{} \mathbf{Z}}\big )^\top \mathbf{A}^{-1}{\varvec{\Delta }{} \mathbf{Z}}\Big ]^n _{i-\frac{1}{2},j}\big (\eta ^{n+1}_{i,j}-\eta ^{n+1}_{i-1,j}\big )\Bigg \}\nonumber \\&\quad -g\frac{\Delta t^2}{\Delta y^2}\Bigg \{ \Big [\big ({\varvec{\Delta }{} \mathbf{Z}}\big )^\top \mathbf{A}^{-1}{\varvec{\Delta }{} \mathbf{Z}}\Big ]^n _{i,j+\frac{1}{2}}\big (\eta ^{n+1}_{i,j+1}-\eta ^{n+1}_{i,j}\big )\nonumber \\&\quad -\Big [\big ({\varvec{\Delta }{} \mathbf{Z}}\big )^\top \mathbf{A}^{-1}\varvec{\Delta Z}\Big ]^n _{i,j-\frac{1}{2}}\big (\eta ^{n+1}_{i,j}-\eta ^{n+1}_{i,j-1}\big )\Bigg \} = b^n_{i,j} \end{aligned}$$
(60)

where

$$\begin{aligned} b^n_{i,j}= & {} H_{i,j}(\eta ^n_{i,j}) -\frac{\Delta t}{\Delta x}\Bigg \{ \Big [\big ({\varvec{\Delta }{} \mathbf{Z}}\big )^\top \mathbf{A}^{-1}{} \mathbf{G}\Big ]^n _{i+\frac{1}{2},j} -\Big [\big ({\varvec{\Delta }{} \mathbf{Z}}\big )^\top \mathbf{A}^{-1}{} \mathbf{G}\Big ]^n _{i-\frac{1}{2},j}\Bigg \} \\&-\frac{\Delta t}{\Delta y}\Bigg \{ \Big [\big ({\varvec{\Delta }{} \mathbf{Z}}\big )^\top \mathbf{A}^{-1}{} \mathbf{G}\Big ]^n _{i,j+\frac{1}{2}} -\Big [\big ({\varvec{\Delta }{} \mathbf{Z}}\big )^\top \mathbf{A}^{-1}{} \mathbf{G}\Big ]^n _{i,j-\frac{1}{2}}\Bigg \} \end{aligned}$$

Since \(\mathbf{A}\) is positive definite, \(\mathbf{A}^{-1}\) is also positive definite and therefore \(({\varvec{\Delta }{} \mathbf{Z}})^\top \mathbf{A}^{-1}{\varvec{\Delta }{} \mathbf{Z}}\) is a non-negative scalar. Hence equations (60) constitute a well posed piecewise linear system of \(N_x N_y\) equations for \(\eta ^{n+1}_{i,j}\) which has the same size and structure as the corresponding system that was derived in Sect. 5 for the \(2D_{xy}\) model. Thus, its unique solution can be determined by a converging Newton type method as described in Sect. 5.

Once the new free-surface location has been computed, equations (57) and (58) constitute a set of simple \(2N_x N_y\) linear, tridiagonal systems with \(N_z\) equations each. All these systems are independent from each other, symmetric and positive definite. Thus, they can be conveniently solved by a direct method.

Finally, by discretizing the continuity equation in (56), the new vertical component of the velocity in each water column can be computed recursively from bottom to top as

$$\begin{aligned} w^{n+1}_{i,j,m-\frac{1}{2}}= & {} 0;\nonumber \\ w^{n+1}_{i,j,k+\frac{1}{2}}= & {} w^{n+1}_{i,j,k-\frac{1}{2}}- \frac{\Delta z^n_{i+\frac{1}{2},j,k}u^{n+1}_{i+\frac{1}{2},j,k}- \Delta z^n_{i-\frac{1}{2},j,k}u^{n+1}_{i-\frac{1}{2},j,k}}{\Delta x} \nonumber \\&-\frac{\Delta z^n_{i,j+\frac{1}{2},k}v^{n+1}_{i,j+\frac{1}{2}, k}- \Delta z^n_{i,j-\frac{1}{2},j,k}v^{n+1}_{i,j-\frac{1}{2},k}}{\Delta y}, \nonumber \\&\quad k=m_{i,j},m_{i,j}+1,\ldots ,M^n_{i,j}-1 \end{aligned}$$
(61)

Thus every time step can be summarized as a simple algorithm which is as follows

  1. (a)

    set up and solve the piecewise linear system (60) to obtain simultaneously the new water levels \(\eta ^{n+1}\) and the resulting total water depths \(H(\eta ^{n+1})\) throughout the horizontal flow domain;

  2. (b)

    solve the linear tridiagonal systems (57) and (58) to determine the new horizontal velocities \(u^{n+1}\) and \(v^{n+1}\);

  3. (c)

    diagnostically obtain the new vertical velocity \(w^{n+1}\) from (61).

Interestingly enough, if the vertical spacing \(\Delta z\) is taken to be so large that both the bottom and the free-surface always fall within one vertical layer, this three-dimensional algorithm reduces to the \(2D_{xy}\) model described in Sect. 5. In this particular case, in fact, the k index is always 1 and therefore it can be omitted from the notation. Moreover, \({\varvec{\Delta } \mathbf{Z}}\) reduces everywhere to H and the discrete momentum equations (57)–(58) simplify to (50)–(51). Additionally, the discrete free-surface equation (59) simplifies to (52).

Fig. 9
figure 9

A multidimensional numerical model

The above three-dimensional method also reduces to the two-dimensional \(2D_{xz}\) model derived in Sect. 4 when it is applied to simulate the flow into a deep and narrow estuary. In this case, if \(\Delta y\) denotes the estuary width, the j index is always 1 and therefore can be omitted from the notation. Moreover, by assuming zero water depth \(H^n_{i,j\pm \frac{1}{2}}=0\) everywhere along the left and the right walls, respectively, one has \(\mathbf{V}^{n+1}_{i,j\pm \frac{1}{2}}={\varvec{\Delta } \mathbf{Z}}^n_{i,j\pm \frac{1}{2}}=0\), and Eqs. (57) and (59) reduce to (36) and (37) already derived in Section 4 for the \(2D_{xz}\) model.

In turn, the one-dimensional model derived in Sect. 3 can be regarded either as a particular case of the \(2D_{xz}\) model where \(N_z=1\) is assumed, or as a particular case of the \(2D_{xy}\) model where \(N_y=1\) is assumed (see Fig. 9).

The fact that one- and two-dimensional methods can be derived from the present 3D model as particular cases is an interesting feature of the present formulation. This property leads to a single, and yet very efficient multidimensional computer model, that applies to arbitrarily complex flow regions.

7 Conclusions

The methods described above represent a solid backbone of a more general algorithm that may apply to unstructured grids possibly including non-hydrostatic pressure [1,2,3] and sub-grid details [13,14,15]. Moreover, an extension of this algorithm that includes saturated as well as variable saturated flows in a groundwater environment was recently documented in [12, 16,17,18]. A large numbers of applications worldwide have demonstrated the capability of the proposed methods to simulate environmental free-surface flows (see, e.g., [19,20,21,22,23,24,25]).