1 Introduction

The theory of shallow water is widely applied in engineering such as in offshore engineering, ship engineering and environmental engineering; because of its importance, it has been studied extensively [1,2,3]. A great number of theoretical models have been proposed for simulating shallow water problems, such as the KdV equation, Saint–Venant equation (SVE) and Boussinesq equation [2, 4,5,6,7]. However, all these equations are based on the Eulerian coordinate system. The shallow water equations constructed using the Eulerian coordinate system consist of convective and source terms. The inclusion of the convective term means that the numerical scheme should be designed carefully. The most widely used numerical method for solving the Eulerian shallow water equations may be the finite volume method [8], because its discrete scheme can preserve the mass and momentum well. However, the source term often destroy the conservativeness of the finite volume method [9]. Moreover, the source term produced by the sloping water bottom often results in a numerical imbalance problem, i.e., the numerical still water cannot stay motionless [6, 10]. Numerical methods, which can preserve the motionless steady states, are often called well-balanced methods. The use of a numerical method that cannot preserve this property may lead to the spurious numerical waves [11]. The need for an adequate discretization of the topographical source term to preserve the “well-balanced” property has long been an important issue in computational shallow water dynamics [6, 10, 12]. Many researchers have developed well-balanced methods for the shallow water problems, see, for example, [10, 12,13,14,15,16]. Another difficult issue often encountered in the numerical approximation of the shallow water problem is how to address the wetting/drying condition. This issue is essentially a moving boundary problem and often leads to some numerical problems, such as mass loss and a negative water depth [17]. Because in the Euler framework the unknown variable is the flow velocity, it is inconvenient to exactly capture the transient position of the moving boundary, which involves the displacement of the water particles at the moving boundary.

The motion of water can also be described by the trajectories of particles that are carried along with the fluid flow. This description is commonly referred to as the Lagrange method [18]. In the Lagrange method, the displacements of the individual water particles are determined with respect to the time and the initial positions of the particles [19]. Using these displacements, the sloping water bottom and the moving boundary can be described exactly and easily [20, 21]. Motivated by this advantage, there have been many reports discussing the use of the Lagrange method in hydrodynamics. In [20], Tao applied the Lagrangian coordinate system to discuss the sudden starting of a floating body in deep water. In [21], Tao and Shi applied the Lagrangian coordinate system to discuss the problem of the hydrodynamic pressure on a suddenly starting vessel. In [22], Shi employed the Lagrangian coordinate system to discuss a nonlinear wave induced by the acceleration of a cylindrical tank.

Using the Lagrange method, the nonlinear boundary condition on the free surface can be exactly satisfied [20,21,22]. By using the theory of classical mechanics, it is easy to establish the Hamilton variational principle for the hydrodynamics problem in the Lagrangian description. Finding the Hamilton variational principle for the hydrodynamics problem is undoubtedly important, and there have been many excellent works published on this topic [23,24,25,26,27]. Based on the Hamilton variational principle, numerical methods that have been successfully developed and widely applied in structural dynamics, such as the finite element method [28] and the symplectic method [29, 30], can be applied to simulate the shallow water problem. For a Hamilton system with the displacement \(q\left( t \right)\) and momentum \(p\left( t \right)\), the symplecticity means that \({\text{d}}p(t) \wedge {\text{d}}q(t) = {\text{d}}p(0) \wedge {\text{d}}q(0)\) holds for any time \(t\). The symplecticity is the intrinsic geometric symmetry of the Hamilton dynamic system. If the algorithm can maintain the geometric symmetry of the symplecticity, it is called the symplectic method. The symplectic method can avoid the flaw of artificial dissipation and, hence, performs better than the traditional non-symplectic method, especially for problems that require extensive numerical simulation [29].

Recently, Wu and Zhong [31] proposed a constrained Hamilton variational principle for the shallow water problem. In the constrained Hamilton variational principle, the incompressible condition is treated as the constraint, and the pressure is seen as the Lagrangian multiplier. According to the constrained Hamilton variational principle, a shallow water equation based on displacement and pressure (SWE-DP) is developed. To numerically solve the SWE-DP, they developed a hybrid numerical method combining the finite element method for spatial discretization and the symplectic Zu-class method for time integration. Their method is symplectic and can preserve the total energy and mass of the shallow water system well. However, in Ref. [31], the authors only considered shallow water with an even bottom; the wetting/drying condition and the sloping water bottom were not discussed.

In this study, the theory proposed in Ref. [31] is extended to shallow water with a sloping bottom and wet-dry interface. In Sect. 2, a SWE-DP for the shallow water system with a sloping bottom and wet-dry interface is derived. In Sect. 3, a hybrid numerical scheme combining the finite element method for spatial discretization and the symplectic Zu-class method for time integration is established for the proposed SWE-DP. In Sect. 4, three classical numerical examples are evaluated to verify the correction of the proposed SWE-DP and the effectiveness of the proposed numerical scheme. In the last section, some conclusions are presented.

2 Shallow water equation based on displacement and pressure

Consider the shallow water model shown by Fig. 1. The water bottom is defined by \(z + h(x) = 0\). The initial water surface is defined by \(z - \eta_{0} (x) = 0\), while \(u(x,z,t)\) and \(w(x,z,t)\) represent the displacements of a certain particle in the water in the \(x\)- and \(z\)-directions at time \(t\), respectively. The particle is localized at \((x,z)\) initially and at \((\xi ,\;\zeta )\) at time \(t\), where

$$\xi = x + u(x,z,t),\;\;\zeta = z + w(x,z,t).$$
(1)

\(d\left( {x,t} \right)\) represents the water depth at time \(t\), and \(d_{0} \left( x \right)\) the water depth at the initial time.

Fig. 1
figure 1

The considered model with variable bottom topography

We assume that the water is inviscid and incompressible. Along the free surface, the pressure is zero, and the surface-energy effects are negligible. The need is to predict the evolution of water for \(0 \le x \le L\). At \(x = L\) is the wet-dry interface. The water depth at the wet-dry interface is zero, i.e., \(d\left( {L,t} \right) = 0\). For \(x = 0\), we suppose that the horizontal displacement \(u\left( {0,t} \right)\), or the water depth \(d\left( {0,t} \right)\), has been measured.

According to the theory of classical mechanics, the action of the water system in two space dimensions can be written as

$$S = \int_{0}^{t} {\left( {T - U + R} \right)} {\text{d}}s,$$
(2)

where \(T\), \(U\) and \(R\) are the kinetic energy, potential energy and constrained term, i.e.,

$$T = \int_{0}^{L} {\int_{ - h\left( x \right)}^{{\eta_{0} \left( x \right)}} {\frac{1}{2}\rho \left( {\dot{u}^{2} + \dot{w}^{2} } \right)} } {\text{d}}z{\text{d}}x,$$
(3)
$$U = \int_{0}^{L} {\int_{ - h\left( x \right)}^{{\eta_{0} \left( x \right)}} {\rho g\left( {z + w} \right)}} {\text{d}}z{\text{d}}x,$$
(4)

and

$$R = \int_{0}^{L} {\int_{ - h\left( x \right)}^{{\eta_{0} \left( x \right)}} {P\theta }}{\text{d}}z{\text{d}}x.$$
(5)

Here, \(P\) is the pressure, the dot represents the derivative with respect to time, and \(\theta\) is the water volume strain, which can be written as

$$\theta = u_{x} + w_{z} + u_{x} w_{z} - u_{z} w_{x} .$$
(6)

For the shallow water problem, it can be assumed that the horizontal displacement is independent of the vertical coordinate \(z\), i.e., \(u\left( {x,t} \right) = u\left( {x,z,t} \right)\), and hence the water volume strain can be simplified as

$$\theta = u_{x} + w_{z} + u_{x} w_{z}.$$
(7)

According to the incompressible condition, the water volume strain should be rigorously zero \(\theta = 0\), and hence we have

$$\left( {1 + w_{z} } \right)\left( {1 + u_{x} } \right) = 1,\;\;\;{\text{or}}\;\;\;w_{z} \left( {x,z} \right) = \frac{{ - u_{x} \left( x \right)}}{{1 + u_{x} \left( x \right)}}.$$
(8)

Equation (8) shows that the vertical displacement distributes linearly along the vertical coordinate \(z\). As shown in Fig. 1, the initial horizontal positions of the particle \(P_{\text{s}}\) at the surface and the particle \(P_{\text{b}}\) at the bottom are the same. Let the vertical displacements of particles \(P_{\text{b}}\) and \(P_{\text{s}}\) be denoted by

$$w\left( {x, - h,t} \right) = \varphi \left( {x,t} \right),\;\;\;w\left( {x,\eta_{0} ,t} \right) = \eta \left( {x,t} \right).$$
(9)

The vertical displacement can be written as

$$w\left( {x,z,t} \right) = \frac{z + h}{{d_{0} }}\eta \left( {x,t} \right) + \frac{{\eta_{0} - z}}{{d_{0} }}\phi \left( {x,t} \right).$$
(10)

Taking the derivative of Eq. (10) with respect to \(z\), and combining the result with Eq. (8) gives

$$w_{z} \left( {x,z,t} \right) = \frac{{ - u_{x} \left( x \right)}}{{1 + u_{x} \left( x \right)}} = \frac{{\eta \left( {x,t} \right) - \phi }}{{d_{0} }}.$$
(11)

As shown in Fig. 1, the initial position of particle \(P_{\text{b}}\) at the bottom is \(\left( {x,\; - h(x)} \right)\), and its position at time \(t\) is \(\left( {x + u,\; - h(x + u)} \right)\). Hence, the vertical displacement is

$$\varphi \left( {x,t} \right) = h\left( x \right) - h\left( {x + u} \right).$$
(12)

Substituting Eq. (12) into Eq. (10) yields

$$w\left( {x,z,t} \right) = \frac{z + h}{{d_{0} }}d - z - h\left( {x + u} \right)$$
(13)

where \(d\left( {x,t} \right)\) is the water depth at time \(t\). \(d\left( {x,t} \right)\) can be expressed as

$$d\left( {x,t} \right) = \eta \left( {x,t} \right) + h\left( {x + u} \right) + d_{0} \left( x \right) - h\left( x \right).$$
(14)

Substituting Eq. (13) into Eq. (4), the potential energy is rewritten as

$$U = \int_{0}^{L} {\int_{ - h\left( x \right)}^{{\eta_{0} \left( x \right)}} {\rho g\left( {z + w} \right)} } {\text{d}}z{\text{d}}x = \frac{1}{2}\int_{0}^{L} {\rho gd_{0} d} {\text{d}}x - \int_{0}^{L} {\rho gd_{0} h\left( {x + u} \right)} {\text{d}}x.$$
(15)

In terms of Eq. (13), the vertical velocity is

$$\dot{w}\left( {x,z,t} \right) = \frac{z + h}{{d_{0} }}\dot{d}\left( {x,t} \right) - \bar{h}_{x} \dot{u},\quad \bar{h}_{x} = \left. {\frac{\partial h\left( a \right)}{\partial a}} \right|_{a = x + u} = h_{x} \left( x \right) + h_{xx} \left( x \right)u + \cdots .$$
(16)

For the shallow water problem, the nonlinear effect of the vertical velocity is negligible [32,33,34], and hence we make the approximation \(\bar{h}_{x} \approx h_{x} \left( x \right)\) and obtain

$$\dot{w}\left( {x,z,t} \right) = \frac{z + h}{{d_{0} }}\dot{d}\left( {x,t} \right) - h_{x} \left( x \right)\dot{u}.$$
(17)

Then, substituting Eq. (17) into Eq. (3) yields

$$T = \frac{1}{2}\int_{0}^{L} {\int_{ - h\left( x \right)}^{{\eta_{0} \left( x \right)}} {\rho \left( {\dot{u}^{2} + \dot{w}^{2} } \right)} {\text{d}}z{\text{d}}x} = T_{1} + T_{2} ,$$
(18)

where

$$T_{1} = \frac{1}{2}\int_{0}^{L} {\left( {\rho d_{0} \dot{u}^{2} } \right)} {\text{d}}x,\;\;\;T_{2} = \frac{1}{2}\int_{0}^{L} {\rho \left( {\frac{{d_{0} }}{3}\dot{d}^{2} - d_{0} h_{x} \dot{u}\dot{d} + d_{0} h_{x}^{2} \dot{u}^{2} } \right)} {\text{d}}x.$$
(19)

Here, \(T_{1}\) represents the kinetic energy produced by the horizontal velocity and \(T_{2}\) the kinetic energy produced by the vertical velocity. In the shallow water long wave problem, \(T_{2}\) is negligible relative to \(T_{1}\) [19, 35].

The pressure at the water surface is zero. Let the pressure at the bottom be denoted by

$$P\left( {x, - h\left( x \right),t} \right) = \beta \left( {x,t} \right).$$
(20)

Making an assumption that the pressure distributes linearly along the vertical coordinate \(z\), we have

$$P\left( {x,z,t} \right) = \frac{{\eta_{0} - z}}{{d_{0} }}\beta \left( {x,t} \right).$$
(21)

Substituting Eq. (13) into the expression (7) of the water volume strain yields

$$\theta = u_{x} + \left( {1 + u_{x} } \right)\left( {\frac{d}{{d_{0} }} - 1} \right).$$
(22)

Substituting Eqs. (21) and (22) into Eq. (5) yields

$$R = \frac{1}{2}\int_{0}^{L} {\beta \left[ {d\left( {1 + u_{x} } \right) - d_{0} } \right]} {\text{d}}x.$$
(23)

In terms of Eqs. (15), (18) and (23), the action of the shallow water system can be written as

$$\begin{aligned} S & = \frac{1}{2}\int_{0}^{t} {\int_{0}^{L} {\rho \left( {d_{0} \dot{u}^{2} + \frac{{d_{0} }}{3}\dot{d}^{2} - d_{0} h_{x} \dot{u}\dot{d} + d_{0} h_{x}^{2} \dot{u}^{2} } \right)}{\text{d}}x}{\text{d}}s - \int_{0}^{t} {\frac{1}{2}\int_{0}^{L} {\rho gd_{0} d}{\text{d}}x}{\text{d}}s \\ & \quad + \int_{0}^{t} {\int_{0}^{L} {\rho gd_{0} h\left( {x + u} \right)}{\text{d}}x}{\text{d}}s + \frac{1}{2}\int_{0}^{t} {\int_{0}^{L} {\beta \left[ {d\left( {1 + u_{x} } \right) - d_{0} } \right]}{\text{d}}x}{\text{d}}s. \\ \end{aligned}$$
(24)

The action \(S\) is a functional based on \(u\), \(d\) and \(\beta\). According to the Hamilton variational principle, the true solution, i.e., \(\left( {u,\;\;d,\;\;\beta } \right)\), is the stationary point of the action functional. Taking the first variation of the action \(S\) with respect to \(\left( {u,\;\;d,\;\;\beta } \right)\) yields

$$\begin{aligned} \delta S & = \frac{1}{2}\int_{0}^{t} {\int_{0}^{L} {\rho \left[ \begin{gathered} d_{0} 2\left( {\delta \dot{u}} \right)\dot{u} + \frac{{d_{0} }}{3}2\left( {\delta \dot{d}} \right)\dot{d} - d_{0} h_{x} \left( {\delta \dot{u}} \right)\dot{d} \hfill \\ - d_{0} h_{x} \dot{u}\left( {\delta \dot{d}} \right) + d_{0} h_{x}^{2} 2\left( {\delta \dot{u}} \right)\dot{u} \hfill \\ \end{gathered} \right]} {\text{d}}x}{\text{d}}s \\ & \quad - \int_{0}^{t} {\frac{1}{2}\int_{0}^{L} {\rho gd_{0} \delta d} {\text{ d}}x}{\text{d}}s + \int_{0}^{t} {\int_{0}^{L} {\rho gd_{0} \bar{h}_{x} \left( {\delta u} \right)} {\text{d}}x}{\text{d}}s \\ & \quad + \frac{1}{2}\int_{0}^{t} {\int_{0}^{L} {\beta \left[ {\left( {\delta d} \right)\left( {1 + u_{x} } \right)} \right]} {\text{d}}x}{\text{d}}s + \frac{1}{2}\int_{0}^{t} {\int_{0}^{L} {\left( {\delta \beta } \right)\left[ {d\left( {1 + u_{x} } \right) - d_{0} } \right]} {\text{d}}x}{\text{d}}s \\ & \quad + \frac{1}{2}\int_{0}^{t} {\int_{0}^{L} {\beta d\left( {\delta u_{x} } \right) } {\text{d}}x}{\text{d}}s \\ \end{aligned}$$
(25)

where \(\delta\) represents the variational operator. According to classical mechanics, \(\delta u\), \(\delta d\) and \(\delta \beta\) in Eq. (25) are arbitrary function, which can be called the virtual displacement, virtual depth, and virtual pressure, respectively. Applying integration by parts to the first integral term on right-hand side of Eq. (25), we have

$$\begin{aligned} \frac{1}{2}\int_{0}^{t} {\int_{0}^{L} {\rho \left[ {d_{0} 2\left( {\delta \dot{u}} \right)\dot{u}} \right]} {\text{d}}x}{\text{d}}s \hfill \\ = \int_{0}^{L} {\rho d_{0} \left[ {\int_{0}^{t} {\left( {\delta \dot{u}} \right)\dot{u}{\text{d}}s} } \right]{\text{d}}x} = \int_{0}^{L} {\rho d_{0} \left[ {\int_{0}^{t} {\dot{u}{\text{d}}\left( {\delta u} \right)} } \right]{\text{d}}x} \hfill \\ = \int_{0}^{L} {\rho d_{0} \left[ {\dot{u}\left( {\delta u} \right)} \right]_{0}^{t} {\text{d}}x} - \int_{0}^{L} {\rho d_{0} \left[ {\int_{0}^{t} {\left( {\delta u} \right)\ddot{u}{\text{d}}s} } \right]{\text{d}}x} . \hfill \\ \end{aligned}$$
(26)

If the horizontal displacement at times 0 and \(t\) are given, that is, \(\delta u\left( {x,0} \right) = \delta u\left( {x,t} \right) = 0\) which causes the first term on the right-hand side of Eq. (26) to vanish, we have

$$\frac{1}{2}\int_{0}^{t} {\int_{0}^{L} {\rho \left[ {d_{0} 2\left( {\delta \dot{u}} \right)\dot{u}} \right]} {\text{ d}}x}{\text{d}}s = - \int_{0}^{L} {\rho d_{0} \left[ {\int_{0}^{t} {\left( {\delta u} \right)\ddot{u}{\text{d}}s} } \right]{\text{d}}x}.$$
(27)

Analogously, if the water depth \(d\) at times 0 and \(t\) are given, we have

$$\begin{gathered} \frac{1}{2}\int_{0}^{t} {\int_{0}^{L} {\rho \left[ \begin{gathered} d_{0} 2\left( {\delta \dot{u}} \right)\dot{u} + \frac{{d_{0} }}{3}2\left( {\delta \dot{d}} \right)\dot{d} - d_{0} h_{x} \left( {\delta \dot{u}} \right)\dot{d} \hfill \\ - d_{0} h_{x} \dot{u}\left( {\delta \dot{d}} \right) + d_{0} h_{x}^{2} 2\left( {\delta \dot{u}} \right)\dot{u} \hfill \\ \end{gathered} \right]} {\text{d}}x} {\text{d}}s \hfill \\ = \frac{1}{2}\int_{0}^{t} {\int_{0}^{L} {\rho \left( { - 2\left( {\delta u} \right)d_{0} \ddot{u} - 2\left( {\delta d} \right)\frac{{d_{0} }}{3}\ddot{d} + d_{0} h_{x} \left( {\delta u} \right)\ddot{d} + d_{0} h_{x} \ddot{u}\left( {\delta d} \right) - 2\left( {\delta u} \right)d_{0} h_{x}^{2} \ddot{u}} \right)} {\text{d}}x} {\text{d}}s \hfill \\ \end{gathered}$$
(28)

Applying integration by parts to the last integral term on right-hand side of Eq. (25), we have

$$\begin{aligned} \frac{1}{2}\int_{0}^{t} {\int_{0}^{L} {\beta d\left( {\delta u_{x} } \right)} {\text{d}}x}{\text{d}}s = \frac{1}{2}\int_{0}^{t} {\left[ {\int_{0}^{L} {\beta d} {\text{d}}\left( {\delta u} \right)} \right]}{\text{d}}s \hfill \\ = \frac{1}{2}\int_{0}^{t} {\left[ {\left[ {\beta d\left( {\delta u} \right)} \right]_{x = 0}^{x = L} - \int_{0}^{L} {\left( {\delta u} \right)\frac{{\partial \left( {\beta d} \right)}}{\partial x}}{\text{d}}x} \right]}{\text{d}}s \hfill \\ = - \frac{1}{2}\int_{0}^{t} {\int_{0}^{L} {\frac{{\partial \left( {\beta d} \right)}}{\partial x}\delta u} {\text{d}}x}{\text{d}}s + \frac{1}{2}\int_{0}^{t} {\left[ {\beta d\delta u} \right]_{x = 0}^{x = L} } {\text{d}}s. \hfill \\ \end{aligned}$$
(29)

Substituting Eqs. (28) and (29) into Eq. (25) yields

$$\begin{aligned} \delta S & = \frac{1}{2}\int_{0}^{t} {\int_{0}^{L} {\rho \left( { - 2\delta ud_{0} \ddot{u} - 2\delta d\frac{{d_{0} }}{3}\ddot{d} + d_{0} h_{x} \delta u\ddot{d} + d_{0} h_{x} \ddot{u}\delta d - 2\delta ud_{0} h_{x}^{2} \ddot{u}} \right)} {\text{d}}x} {\text{d}}s \\ & \quad - \int_{0}^{t} {\frac{1}{2}\int_{0}^{L} {\rho gd_{0} \delta d} {\text{d}}x} {\text{d}}s + \int_{0}^{t} {\int_{0}^{L} {\rho gd_{0} \bar{h}_{x} \delta u} {\text{d}}x} \;{\text{d}}s \\ & \quad + \frac{1}{2}\int_{0}^{t} {\int_{0}^{L} {\beta \delta d\left( {1 + u_{x} } \right)} {\text{d}}x} \;{\text{d}}s + \frac{1}{2}\int_{0}^{t} {\int_{0}^{L} {\delta \beta \left[ {d\left( {1 + u_{x} } \right) - d_{0} } \right]} {\text{d}}x} \;{\text{d}}s \\ & \quad - \frac{1}{2}\int_{0}^{t} {\int_{0}^{L} {\frac{{\partial \left( {\beta d} \right)}}{{\partial x}}\delta u} {\text{d}}x} \;{\text{d}}s + \frac{1}{2}\int_{0}^{t} {\left[ {\beta d\delta u} \right]_{{x = 0}}^{{x = L}} } {\text{d}}s \\ \end{aligned}$$
(30)

Noting that the water depth at the wet-dry interface is rigorously zero, that is \(d\left( {L,s} \right) = 0\), if the horizontal displacement at \(x = 0\) is given, we have

$$\delta u\left( {0,s} \right) = 0,\;\;0 \le s \le t .$$
(31)

Hence the last term on the right-hand side of Eq. (30) equals to zero. The right-hand side of Eq. (30) can thus be rewritten as

$$\begin{aligned} \delta S & = \int_{0}^{t} {\int_{0}^{L} {\left( { - \delta u} \right)\left( {\rho d_{0} \ddot{u} - \frac{1}{2}\rho d_{0} h_{x} \ddot{d} + \rho d_{0} h_{x}^{2} \ddot{u} - \rho gd_{0} \bar{h}_{x} + \frac{1}{2}\frac{{\partial \left( {\beta d} \right)}}{{\partial x}}} \right)} {\text{d}}x}{\text{d}}s \\ & \quad + \int_{0}^{t} {\int_{0}^{L} {\left( { - \delta d} \right)\left( {\rho \frac{{d_{0} }}{3}\ddot{d} - \frac{1}{2}\rho d_{0} h_{x} \ddot{u} + \frac{1}{2}\rho gd_{0} - \frac{1}{2}\beta \left( {1 + u_{x} } \right)} \right)} {\text{d}}x}{\text{d}}s \\ & \quad + \frac{1}{2}\int_{0}^{t} {\int_{0}^{L} {\left( {\delta \beta } \right)\left[ {d\left( {1 + u_{x} } \right) - d_{0} } \right]} {\text{d}}x} {\text{d}}s \\ \end{aligned}$$
(32)

Noting that the virtual functions \(\delta u\), \(\delta d\) and \(\delta \beta\) are arbitrary, we obtain

$$\left\{ \begin{aligned} \rho d_{0} \ddot{u} - \frac{1}{2}\rho d_{0} h_{x} \ddot{d} + \rho d_{0} h_{x}^{2} \ddot{u} - \rho gd_{0} \bar{h}_{x} + \frac{1}{2}\frac{{\partial \left( {\beta d} \right)}}{\partial x} = 0 \hfill \\ \rho \frac{{d_{0} }}{3}\ddot{d} - \frac{1}{2}\rho d_{0} h_{x} \ddot{u} + \frac{1}{2}\rho gd_{0} - \frac{1}{2}\beta \left( {1 + u_{x} } \right) = 0 \hfill \\ d\left( {1 + u_{x} } \right) = d_{0} , \hfill \\ \end{aligned} \right.$$
(33)

which is the shallow water equation based on displacement and pressure (SWE-DP). The third equation in Eq. (33) is the incompressible condition of the shallow water system.

In the above steps from Eq. (30) to (32), we use the boundary condition \(\delta u\left( {x,s} \right) = 0\) for \(0 \le s \le t\), which holds on only when the horizontal displacement at \(x = 0\) is given. If boundary condition at \(x = 0\) is replaced with giving the water depth \(d\left( {0,\;s} \right)\) for \(0 \le s \le t\), introduce the following force

$$f\left( s \right) = \frac{1}{2}\beta d\left( {0,s} \right),\;\;0 \le s \le t$$
(34)

which is actually a pressure applied at \(x = 0\). In this case, the potential energy should be modified to

$$U = \frac{1}{2}\int_{0}^{L} {\rho gd_{0} d} {\text{d}}x - \int_{0}^{L} {\rho gd_{0} h\left( {x + u} \right)} {\text{d}}x - fu\left( {0,s} \right).$$
(35)

Correspondingly, the action should be modified to

$$\begin{aligned} S & = \frac{1}{2}\int_{0}^{t} {\int_{0}^{L} {\rho \left( {d_{0} \dot{u}^{2} + \frac{{d_{0} }}{3}\dot{d}^{2} - d_{0} h_{x} \dot{u}\dot{d} + d_{0} h_{x}^{2} \dot{u}^{2} } \right)} {\text{d}}x}{\text{d}}s - \int_{0}^{t} {\frac{1}{2}\int_{0}^{L} {\rho gd_{0} d} {\text{d}}x}{\text{d}}s \\ & \quad + \int_{0}^{t} {\int_{0}^{L} {\rho gd_{0} h\left( {x + u} \right)} {\text{d}}x}{\text{d}}s + \frac{1}{2}\int_{0}^{t} {\int_{0}^{L} {\beta \left[ {d\left( {1 + u_{x} } \right) - d_{0} } \right]} {\text{d}}x}{\text{d}}s + \int_{0}^{t} {fu\left( {0,s} \right)} {\text{d}}s \\ \end{aligned}$$
(36)

Taking the first variation of \(S\), and setting \(\delta S = 0\) will yield Eqs. (33) and (34).

If the effect of the vertical velocity is ignored, the kinetic energy is \(T_{1}\), and the SWE-DP (33) can be simplified as

$$\left\{ \begin{gathered} \rho d_{0} \ddot{u} - \rho gd_{0} \bar{h}_{x} + \frac{1}{2}\frac{{\partial \left( {\beta d} \right)}}{{\partial x}} = 0 \hfill \\ \rho gd_{0} - \beta \left( {1 + u_{x} } \right) = 0 \hfill \\ d\left( {1 + u_{x} } \right) = d_{0} \hfill \\ \end{gathered} \right.$$
(37)

Combining the second and third equations in Eq. (37), we obtain

$$\beta = \frac{{\rho gd_{0} }}{{1 + u_{x} }} = \rho gd.$$
(38)

Noting that \(\beta\) is the pressure at the water bottom and \(d\) is the water depth, Eq. (38) reflects the assumption of the hydrostatic pressure, which is the fundamental assumption in the SVE. Indeed, Eq. (37) is mathematically equivalent to the SVE, which will be proven in the appendix. Hence, some analytical solutions to the SVE can be employed to test the validity of the numerical scheme to the SWE-DP proposed in the next section.

3 Numerical scheme

The proposed SWE-DP is nonlinear, and it is hard to solve this equation by purely analytical methods. In this section, with the help of the discretized constrained Hamilton variational principle, a hybrid method combining the finite element for the spatial discretization and the symplectic Zu-class method for the time integration is presented for this equation.

3.1 Discretization in space

The proposed SWE-DP (33) is derived in terms of the constrained Hamilton variational principle. Hence, it is a natural choice to use the finite element method for spatial discretization. Let the region \(\left[ {0,L} \right]\) be divided into \(N_{\text{e}}\) basic elements with \(N_{\text{d}}\) nodes; see Fig. 2.

Fig. 2
figure 2

The finite element mesh

On the nth element, the horizontal displacement \(u\left( x \right)\) is approximated by the linear function, and \(d\left( x \right)\) and \(\beta \left( x \right)\) are treated as constant values, i.e.,

$$u\left( x \right) = \frac{{x_{n + 1} - x}}{{\Delta x_{n} }}u_{n} + \frac{{x - x_{n} }}{{\Delta x_{n} }}u_{n + 1} ,\;\;d\left( x \right) = d_{n} ,\;\;\beta \left( x \right) = \beta_{n} ,$$
(39)

where \(x_{n}\) is the node location on the \(x\)-axis, \(\Delta x_{n}\) is the length of the nth element, \(u_{n}\) is the horizontal displacement of the nth node, \(d_{n}\) is the water depth evaluated at the mid-point of the nth element, and \(\beta_{n}\) is the pressure of the water bottom evaluated at the mid-point of the nth element. In terms of Eqs. (33) and (39), the incompressible condition on the nth element can be approximated as

$$d_{n} \Delta x_{n} \left( {1 + \frac{{u_{n + 1} - u_{n} }}{{\Delta x_{n} }}} \right) = \Delta x_{n} d_{0,n}.$$
(40)

The kinetic energy can be approximated as

$$T = \frac{ 1}{ 2}{\dot{\mathbf{u}}}^{\text{T}} {\mathbf{M}}_{u} {\dot{\mathbf{u}}} + \frac{1}{2}{\dot{\mathbf{d}}}^{\text{T}} {\mathbf{M}}_{d} {\dot{\mathbf{d}}} - {\dot{\mathbf{d}}}^{\text{T}} {\mathbf{M}}_{du} {\dot{\mathbf{u}}},$$
(41)

in which

$$\rho_{u} = \rho d_{0} \left( {1 + h_{x}^{2} } \right),\;\;\;\rho_{d} = \frac{{\rho d_{0} }}{3},\;\;\;\rho_{ud} = \rho h_{x} d_{0} ,$$
(42)
$$\begin{aligned} {\mathbf{u}} & = \left( {\begin{array}{*{20}c} {u_{1} } & {u_{2} } & \ldots & {u_{{N_{\text{d}} }} } \\ \end{array} } \right)^{\text{T}} ,\;\;\;{\mathbf{d}} = \left( {\begin{array}{*{20}c} {d_{1} } & {d_{2} } & \ldots & {d_{{N_{\text{e}} }} } \\ \end{array} } \right)^{\text{T}} \\ {\mathbf{M}}_{u} & = {\text{diag}}\left\{ {\begin{array}{*{20}c} {M_{u,1} } & \ldots & {M_{u,n} } & \ldots & {M_{{u,N_{\text{d}} }} } \\ \end{array} } \right\} \\ {\mathbf{M}}_{d} & = {\text{diag}}\left\{ {\begin{array}{*{20}c} {\rho_{d,1} \Delta x_{1} } & {\rho_{d,2} \Delta x_{2} } & \ldots & {\rho_{{d,N_{\text{e}} }} \Delta x_{{N_{\text{e}} }} } \\ \end{array} } \right\} \\ {\mathbf{M}}_{du} & = \frac{1}{4}\left[ {\begin{array}{*{20}c} {\Delta x_{1} \rho_{ud,1} } & {\Delta x_{1} \rho_{ud,1} } & 0 & \cdots & 0 \\ 0 & {\Delta x_{2} \rho_{ud,2} } & {\Delta x_{2} \rho_{ud,2} } & \ddots & \vdots \\ \vdots & \ddots & \ddots & \ddots & 0 \\ 0 & \cdots & 0 & {\Delta x_{{N_{\text{e}} }} \rho_{{ud,N_{\text{e}} }} } & {\Delta x_{{N_{\text{e}} }} \rho_{{ud,N_{\text{e}} }} } \\ \end{array} } \right], \\ \end{aligned}$$
(43)

and

$$\begin{aligned} M_{u,1} & = \frac{{\Delta x_{1} \rho_{u,1} }}{2},\;\;\;M_{u,n} = \frac{{\Delta x_{n - 1} \rho_{u,n - 1} + \Delta x_{n} \rho_{u,n} }}{2},\;\;M_{{u,N_{\text{d}} }} = \frac{{\Delta x_{{N_{\text{e}} }} \rho_{{u,N_{\text{e}} }} }}{2} \\ \rho_{u,n} & = \rho_{u} \left( {\frac{{x_{n} + x_{n + 1} }}{2}} \right),\;\;\;\rho_{d,n} = \rho_{d} \left( {\frac{{x_{n} + x_{n + 1} }}{2}} \right),\;\;\;\rho_{ud,n} = \rho_{ud} \left( {\frac{{x_{n} + x_{n + 1} }}{2}} \right). \\ \end{aligned}$$
(44)

The potential energy can be approximated as

$$U = {\mathbf{g}}_{d}^{\text{T}} {\mathbf{d}} - {\mathbf{g}}_{h}^{\text{T}} {\mathbf{h}}$$
(45)

where

$$\begin{aligned} {\mathbf{g}}_{h}^{\text{T}} & = \left( {\frac{{\Delta x_{1} }}{2}g_{u,1} ,\left( {\frac{{\Delta x_{n} }}{2} + \frac{{\Delta x_{n - 1} }}{2}} \right)g_{u,n} ,\frac{{\Delta x_{{N_{e} }} }}{2}g_{{u,N_{d} }} } \right)^{\text{T}} \\ {\mathbf{g}}_{d}^{\text{T}} & = \left( {\begin{array}{*{20}c} {\frac{{\left( {g_{d,1} + g_{d,2} } \right)\Delta x_{1} }}{2}} & {\frac{{\left( {g_{d,2} + g_{d,3} } \right)\Delta x_{2} }}{2}} & \ldots & {\frac{{\left( {g_{{d,N_{\text{d}} - 1}} + g_{{d,N_{\text{d}} }} } \right)\Delta x_{{N_{\text{e}} }} }}{2}} \\ \end{array} } \right)^{\text{T}} \\ {\mathbf{h}}^{\text{T}} & = \left( {h\left( {x_{1} + u_{1} } \right),h\left( {x_{n} + u_{n} } \right),h\left( {x_{{N_{d} }} + u_{{N_{d} }} } \right)} \right)^{\text{T}} \\ g_{d,n} & = \frac{\rho g}{2}d_{0} \left( {x_{n} } \right),\;\;\;g_{u,n} = \rho gd_{0} \left( {x_{n} } \right). \\ \end{aligned}$$
(46)

The Lagrangian modified term can be approximated as

$$R = 0.5{\varvec{\upbeta}}^{\text{T}} {\mathbf{\Delta d}} + 0.5{\mathbf{d}}^{\text{T}} {\mathbf{BCu}} - 0.5{\varvec{\upbeta}}^{\text{T}} {\mathbf{s}}\; = 0.5{\varvec{\upbeta}}^{\text{T}} {\mathbf{\Delta d}} + 0.5{\varvec{\upbeta}}^{\text{T}} {\mathbf{DCu}} - 0.5{\varvec{\upbeta}}^{\text{T}} {\mathbf{s}}$$
(47)

where

$$\begin{aligned} {\mathbf{s}}^{\text{T}} & = \left( {\begin{array}{*{20}c} {\Delta x_{1} d_{0,1} } & {\Delta x_{n} d_{0,2} } & {\Delta x_{{N_{\text{e}} }} d_{{0,N_{\text{e}} }} } \\ \end{array} } \right) \\ {\mathbf{D}} & = {\text{diag}}\left\{ {\mathbf{d}} \right\},\quad {\varvec{\Delta}} = {\text{diag}}\left\{ {\Delta x_{1} ,\Delta x_{2} , \ldots } \right\} \\ {\varvec{\upbeta}}^{\text{T}} & = \left( {\begin{array}{*{20}c} {\beta_{1} } & {\beta_{2} } & \ldots & {\beta_{{N_{\text{e}} }} } \\ \end{array} } \right),\quad {\mathbf{B}} = {\text{diag}}\left\{ {\varvec{\upbeta}} \right\} \\ {\mathbf{C}} & = \left[ {\begin{array}{*{20}c} { - 1} & 1 & 0 & \cdots & 0 \\ 0 & { - 1} & 1 & \ddots & \vdots \\ \vdots & \ddots & \ddots & \ddots & 0 \\ 0 & \ldots & 0 & { - 1} & 1 \\ \end{array} } \right]. \\ \end{aligned}$$
(48)

In terms of Eqs. (41), (45) and (47), the action can be approximated as

$$S = \int_{0}^{t} {\left[ \begin{aligned} \frac{ 1}{ 2}{\dot{\mathbf{u}}}^{\text{T}} {\mathbf{M}}_{u} {\dot{\mathbf{u}}} + \frac{1}{2}{\dot{\mathbf{d}}}^{\text{T}} {\mathbf{M}}_{d} {\dot{\mathbf{d}}} - {\dot{\mathbf{d}}}^{\text{T}} {\mathbf{M}}_{du} {\dot{\mathbf{u}}} - {\mathbf{g}}_{d}^{\text{T}} {\mathbf{d}} + {\mathbf{g}}_{h}^{\text{T}} {\mathbf{h}} \\ + \frac{1}{2}{\varvec{\upbeta}}^{\text{T}} {\mathbf{\Delta d}} + \frac{1}{2}{\varvec{\upbeta}}^{\text{T}} {\mathbf{DCu}} - \frac{1}{2}{\varvec{\upbeta}}^{\text{T}} {\mathbf{s}} \hfill \\ \end{aligned} \right]} {\text{d}}s,$$
(49)

in which \({\mathbf{u}}\) and \({\mathbf{d}}\) are the horizontal displacement vector and the water depth vector, respectively, and \({\varvec{\upbeta}}\) is the bottom pressure vector.

In the integrand of Eq. (49), the summation of the first three terms represents the kinetic energy, the summation of the fourth and fifth terms represents the potential energy, and the summation of the last three terms represents the constrained term.

According to the constrained Hamilton variational principle, \(\delta S = 0\). If \({\mathbf{u}}\) and \({\mathbf{d}}\) at times 0 and \(t\) are given, i.e., \(\delta {\mathbf{u}}\left( 0 \right) = \delta {\mathbf{u}}\left( t \right) = {\mathbf{0}}\) and \(\delta {\mathbf{d}}\left( 0 \right) = \delta {\mathbf{d}}\left( t \right) = {\mathbf{0}}\), \(\delta S = 0\) causes the following equations:

$$\left\{\begin{aligned} {\mathbf{M}}_{u} \ddot{{\mathbf{u}}} - {\mathbf{M}}_{du}^{\text{T}} \ddot{{\mathbf{d}}} - {\mathbf{h}}_{{\mathbf{x}}} {\mathbf{g}}_{h} - 0.5{\mathbf{C}}^{T} {\mathbf{Bd}} = {\mathbf{0}} \hfill \\ {\mathbf{M}}_{d} \ddot{{\mathbf{d}}} - {\mathbf{M}}_{du} \ddot{{\mathbf{u}}} + {\mathbf{g}}_{d} - 0.5{\boldsymbol{\Delta \beta}} - 0.5{\mathbf{BCu}} = {\mathbf{0}} \hfill \\ {\boldsymbol{\Delta}} d + {\mathbf{DCu}} - {\mathbf{s}} = {\mathbf{0}} \hfill \\ \end{aligned} \right.,$$
(50)

which constitutes a system of differential algebraic equations (DAEs).

3.2 The Zu-class method

The nonlinear DAEs (50) are obtained from the first variation of Eq. (49), which corresponds to a constrained Hamiltonian system. For the Hamiltonian system, the symplecticity is a characteristic property [29]. As the symplectic method can preserve the property of symplecticity and the approximate energy necessary for a long time computation, it often is preferable to simulate the Hamiltonian dynamical system [27]. However, for the constrained Hamiltonian system, it is required for a time integration method to preserve not only the symplectic structure of the Hamiltonian system but also all the constraints. In Ref. [36], a method preserving all the constraints was developed by Zhong et al. The numerical experiment of the double pendulum presented in [36] shows that this method can preserve energy well. In Ref. [37], it was named the Zu-class method. In Ref. [38], this method was proven to be symplectic. The symplectic Zu-class method is based on the discretized Hamilton variational principle. In the symplectic Zu-class method, the constraint conditions are satisfied strictly at the integration points, and the orbit is treated as geodesic in the state space and is therefore approximated by using the time finite element method. In this sub-section, the symplectic Zu-class method will be employed to solve the DAEs (50).

In the steps from Eq. (49) to Eq. (50), \({\mathbf{u}}\) and \({\mathbf{d}}\) at times 0 and \(t\) are assumed to be known, which causes \(\delta {\mathbf{u}}\left( 0 \right) = \delta {\mathbf{u}}\left( t \right) = {\mathbf{0}}\) and \(\delta {\mathbf{d}}\left( 0 \right) = \delta {\mathbf{d}}\left( t \right) = {\mathbf{0}}\). However this assumption is unnecessary according to classical mechanics [31, 35, 39]. Let action (49) be modified as

$$\begin{aligned} S & = \int_{0}^{t} {\left[ \begin{gathered} \frac{{\text{1}}}{{\text{2}}}{\dot{\mathbf{u}}}^{{\text{T}}} {\mathbf{M}}_{u} {\dot{\mathbf{u}}} + \frac{1}{2}{\dot{\mathbf{d}}}^{{\text{T}}} {\mathbf{M}}_{d} {\dot{\mathbf{d}}} - {\dot{\mathbf{d}}}^{{\text{T}}} {\mathbf{M}}_{{du}} {\dot{\mathbf{u}}} - {\mathbf{g}}_{d}^{{\text{T}}} {\mathbf{d}} + {\mathbf{g}}_{h}^{{\text{T}}} {\mathbf{h}} \hfill \\ + \frac{1}{2}{\boldsymbol{\beta }}^{{\text{T}}} {\boldsymbol{\Delta d}} + \frac{1}{2}{\boldsymbol{\beta }}^{{\text{T}}} {\mathbf{DCu}} - \frac{1}{2}{\boldsymbol{\beta }}^{{\text{T}}} {\mathbf{s}} \hfill \\ \end{gathered} \right]} {\text{d}}s \\ & \quad + {\mathbf{u}}^{{\text{T}}} \left( 0 \right){\mathbf{p}}_{u} \left( 0 \right) - {\mathbf{u}}^{{\text{T}}} \left( t \right){\mathbf{p}}_{u} \left( t \right) \\ & \quad + {\mathbf{d}}^{{\text{T}}} \left( 0 \right){\mathbf{p}}_{d} \left( 0 \right) - {\mathbf{d}}^{{\text{T}}} \left( t \right){\mathbf{p}}_{d} \left( t \right) \\ \end{aligned}$$
(51)

where \({\mathbf{p}}_{u} \left( t \right)\) and \({\mathbf{p}}_{d} \left( t \right)\) are the momentum vectors. Letting the first variation of Eq. (51) be zero will not yields Eq. (50), but rahter the following equation:

$${\mathbf{p}}_{u} = {\mathbf{M}}_{u} {\dot{\mathbf{u}}} - {\mathbf{M}}_{du}^{\text{T}} {\dot{\mathbf{d}}},\;\;\;{\mathbf{p}}_{d} = {\mathbf{M}}_{d} {\dot{\mathbf{d}}} - {\mathbf{M}}_{du} {\dot{\mathbf{u}}}.$$
(52)

The Zu-class method is based on Eq. (51). Let the time domain be discretized as

$$t = t_{0} ,\;t_{1} , \ldots ,t_{k} , \ldots ,\quad t_{k} = k \times \Delta t,$$
(53)

where \(\Delta t\) is the time step, which should be limited by the usual CFL (Courant–Friedrichs–Lewy) condition [1, 3] to guarantee the convergence of the numerical results. Let the velocities in \(\left[ {t_{k} ,\;t_{k + 1} } \right]\) be approximated as

$${\dot{\mathbf{u}}}_{k} \left( t \right) = \frac{{{\mathbf{u}}_{k + 1} - {\mathbf{u}}_{k} }}{\Delta t},\;\;\;{\dot{\mathbf{d}}}_{k} \left( t \right) = \frac{{{\mathbf{d}}_{k + 1} - {\mathbf{d}}_{k} }}{\Delta t},\quad t \in \left[ {t_{k} ,\;t_{k + 1} } \right],$$
(54)

where \({\mathbf{\# }}_{k} = {\mathbf{\# }}\left( {t_{k} } \right)\), and the displacements be approximated as

$${\mathbf{u}}\left( t \right) = \frac{{{\mathbf{u}}_{k + 1} + {\mathbf{u}}_{k} }}{2},\;\;\;{\mathbf{d}}\left( t \right) = \frac{{{\mathbf{d}}_{k + 1} + {\mathbf{d}}_{k} }}{2},\quad t \in \left[ {t_{k} ,\;t_{k + 1} } \right].$$
(55)

The bottom pressure is approximated to be a constant in \(\left[ {t_{k} ,\;t_{k + 1} } \right]\), i.e.,

$${\varvec{\upbeta}}\left( t \right) = {\varvec{\upbeta}}_{k} ,\quad t \in \left[ {t_{k} ,\;t_{k + 1} } \right].$$
(56)

In terms of Eqs. (51), and (54)–(56), the action for \(t \in \left[ {t_{k} ,\;t_{k + 1} } \right]\) can be written as

$$S = \int_{{t_{k} }}^{{t_{k + 1} }} T {\text{d}}s - \int_{{t_{k} }}^{{t_{k + 1} }} U {\text{d}}s + \int_{{t_{k} }}^{{t_{k + 1} }} R {\text{d}}s + {\mathbf{u}}_{k}^{\text{T}} {\mathbf{p}}_{u,k} - {\mathbf{u}}_{k + 1}^{\text{T}} {\mathbf{p}}_{u,k + 1} + {\mathbf{d}}_{k}^{\text{T}} {\mathbf{p}}_{d,k} - {\mathbf{d}}_{k + 1}^{\text{T}} {\mathbf{p}}_{d,k + 1}$$
(57)

where

$$\begin{aligned} \int_{{t_{k} }}^{{t_{k + 1} }} T {\text{d}}s & = \frac{1}{2}\left( {{\mathbf{u}}_{k + 1}^{\text{T}} - {\mathbf{u}}_{k}^{\text{T}} } \right){\mathbf{M}}_{u} \left( {\frac{{{\mathbf{u}}_{k + 1} - {\mathbf{u}}_{k} }}{\Delta t}} \right) + \frac{1}{2}\left( {{\mathbf{d}}_{k + 1}^{\text{T}} - {\mathbf{d}}_{k}^{\text{T}} } \right){\mathbf{M}}_{d} \frac{{{\mathbf{d}}_{k + 1} - {\mathbf{d}}_{k} }}{\Delta t} \\ \quad - \left( {{\mathbf{d}}_{k + 1}^{\text{T}} - {\mathbf{d}}_{k}^{\text{T}} } \right){\mathbf{M}}_{du} \left( {\frac{{{\mathbf{u}}_{k + 1} - {\mathbf{u}}_{k} }}{\Delta t}} \right) \\ \int_{{t_{k} }}^{{t_{k + 1} }} U {\text{d}}s & = \frac{\Delta t}{2}{\mathbf{g}}_{d}^{\text{T}} \left( {{\mathbf{d}}_{k} + {\mathbf{d}}_{k + 1} } \right) - \frac{\Delta t}{2}{\mathbf{g}}_{h}^{\text{T}} \left[ {{\mathbf{h}}\left( {{\mathbf{u}}_{k} } \right) + {\mathbf{h}}\left( {{\mathbf{u}}_{k + 1} } \right)} \right] \\ \int_{{t_{k} }}^{{t_{k + 1} }} R {\text{d}}s & = \frac{1}{2}{\varvec{\upbeta}}_{k}^{\text{T}} {\varvec{\Delta}}\frac{\Delta t}{2}\left( {{\mathbf{d}}_{k} + {\mathbf{d}}_{k + 1} } \right) + \frac{1}{2}{\varvec{\upbeta}}_{k}^{\text{T}} \frac{\Delta t}{2}\left( {{\mathbf{D}}_{k} {\mathbf{Cu}}_{k} + {\mathbf{D}}_{k + 1} {\mathbf{Cu}}_{k + 1} } \right) - \frac{1}{2}\Delta t{\varvec{\upbeta}}_{k}^{\text{T}}\; {\mathbf{s}} \\ \end{aligned}$$
(58)

Substituting Eq. (58) into the action integral and taking the first variation gives

$$\begin{aligned} \delta S & = \delta \left( {{\mathbf{u}}_{{k + 1}}^{{\text{T}}} - {\mathbf{u}}_{k}^{{\text{T}}} } \right){\mathbf{M}}_{u} \left( {\frac{{{\mathbf{u}}_{{k + 1}} - {\mathbf{u}}_{k} }}{{\Delta t}}} \right) + \delta \left( {{\mathbf{d}}_{{k + 1}}^{{\text{T}}} - {\mathbf{d}}_{k}^{{\text{T}}} } \right){\mathbf{M}}_{d} \frac{{{\mathbf{d}}_{{k + 1}} - {\mathbf{d}}_{k} }}{{\Delta t}} \\ & \quad - \delta \left( {{\mathbf{d}}_{{k + 1}}^{{\text{T}}} - {\mathbf{d}}_{k}^{{\text{T}}} } \right){\mathbf{M}}_{{du}} \left( {\frac{{{\mathbf{u}}_{{k + 1}} - {\mathbf{u}}_{k} }}{{\Delta t}}} \right) - \delta \left( {{\mathbf{u}}_{{k + 1}}^{{\text{T}}} - {\mathbf{u}}_{k}^{{\text{T}}} } \right){\mathbf{M}}_{{du}}^{{\text{T}}} \left( {\frac{{{\mathbf{d}}_{{k + 1}} - {\mathbf{d}}_{k} }}{{\Delta t}}} \right) \\ & \quad - \left[ {\frac{{\Delta t}}{2}\delta \left( {{\mathbf{d}}_{k}^{{\text{T}}} + {\mathbf{d}}_{{k + 1}}^{{\text{T}}} } \right){\mathbf{g}}_{d} - \frac{{\Delta t}}{2}\left( {\delta {\mathbf{u}}_{k}^{{\text{T}}} {\mathbf{h}}_{{{\mathbf{u}}_{k} }} {\mathbf{g}}_{h} + \delta {\mathbf{u}}_{{k + 1}}^{{\text{T}}} {\mathbf{h}}_{{{\mathbf{u}}_{{k + 1}} }} {\mathbf{g}}_{h} } \right)} \right] \\ & \quad + \left( {\delta {\mathbf{\beta }}_{k}^{{\text{T}}} } \right)\frac{{\Delta t}}{4}{\mathbf{\Delta }}\left( {{\mathbf{d}}_{k} + {\mathbf{d}}_{{k + 1}} } \right) + \delta \left( {{\mathbf{d}}_{k}^{{\text{T}}} + {\mathbf{d}}_{{k + 1}}^{{\text{T}}} } \right)\frac{{\Delta t}}{4}{\mathbf{\Delta \beta }}_{k} \\ & \quad + \left( {\delta {\mathbf{\beta }}_{k}^{{\text{T}}} } \right)\frac{{\Delta t}}{4}\left( {{\mathbf{D}}_{k} {\mathbf{Cu}}_{k} + {\mathbf{D}}_{{k + 1}} {\mathbf{Cu}}_{{k + 1}} } \right) + \frac{{\Delta t}}{4}\left[ {\left( {\delta {\mathbf{d}}_{k}^{{\text{T}}} } \right){\mathbf{B}}_{k} {\mathbf{Cu}}_{k} + \left( {\delta {\mathbf{d}}_{{k + 1}}^{{\text{T}}} } \right){\mathbf{B}}_{k} {\mathbf{Cu}}_{{k + 1}} } \right] \\ & \quad + \frac{{\Delta t}}{4}\left[ {\left( {\delta {\mathbf{u}}_{k}^{{\text{T}}} } \right){\mathbf{C}}^{{\text{T}}} {\mathbf{D}}_{k} {\mathbf{\beta }}_{k} + \left( {\delta {\mathbf{u}}_{{k + 1}}^{{\text{T}}} } \right){\mathbf{C}}^{{\text{T}}} {\mathbf{D}}_{{k + 1}} {\mathbf{\beta }}_{k} } \right] - \left( {\delta {\mathbf{\beta }}_{k}^{{\text{T}}} } \right)\frac{1}{2}\Delta t{\mathbf{s}} \\ & \quad + \delta {\mathbf{u}}_{k}^{{\text{T}}} {\mathbf{p}}_{{u,k}} - \delta {\mathbf{u}}_{{k + 1}}^{{\text{T}}} {\mathbf{p}}_{{u,k + 1}} + \delta {\mathbf{d}}_{k}^{{\text{T}}} {\mathbf{p}}_{{d,k}} - \delta {\mathbf{d}}_{{k + 1}}^{{\text{T}}} {\mathbf{p}}_{{d,k + 1}} \\ \end{aligned}$$
(59)

where

$${\mathbf{h}}_{{{\mathbf{u}}_{k} }} = \frac{{\partial {\mathbf{h}}^{\text{T}} \left( {{\mathbf{u}}_{k} } \right)}}{{\partial {\mathbf{u}}_{k} }},\quad {\mathbf{h}}_{{{\mathbf{u}}_{{k{ + }1}} }} = \frac{{\partial {\mathbf{h}}^{\text{T}} \left( {{\mathbf{u}}_{{k{ + }1}} } \right)}}{{\partial {\mathbf{u}}_{{k{ + }1}} }}$$
(60)

Equation (59) can be further simplified as

$$\begin{aligned} \delta S & = \left( {\delta {\mathbf{u}}_{k + 1}^{\text{T}} } \right)\left[ {{\mathbf{M}}_{u} \left( {\frac{{{\mathbf{u}}_{k + 1} - {\mathbf{u}}_{k} }}{\Delta t}} \right) - {\mathbf{M}}_{du}^{\text{T}} \left( {\frac{{{\mathbf{d}}_{k + 1} - {\mathbf{d}}_{k} }}{\Delta t}} \right) + \frac{\Delta t}{2}{\mathbf{h}}_{{{\mathbf{u}}_{k + 1} }} {\mathbf{g}}_{h} + \frac{\Delta t}{4}{\mathbf{C}}^{\text{T}} {\mathbf{D}}_{k + 1} {\varvec{\upbeta}} - {\mathbf{p}}_{u,k + 1} } \right] \\ \quad + \left( {\delta {\mathbf{u}}_{k}^{\text{T}} } \right)\left[ { - {\mathbf{M}}_{u} \left( {\frac{{{\mathbf{u}}_{k + 1} - {\mathbf{u}}_{k} }}{\Delta t}} \right) + {\mathbf{M}}_{du}^{\text{T}} \left( {\frac{{{\mathbf{d}}_{k + 1} - {\mathbf{d}}_{k} }}{\Delta t}} \right) + \frac{\Delta t}{2}{\mathbf{h}}_{{{\mathbf{u}}_{k} }} {\mathbf{g}}_{h} + \frac{\Delta t}{4}{\mathbf{C}}^{\text{T}} {\mathbf{D}}_{k} {\varvec{\upbeta}} + {\mathbf{p}}_{u,k} } \right] \\ \quad + \left( {\delta {\mathbf{d}}_{k + 1}^{\text{T}} } \right)\left[ {{\mathbf{M}}_{d} \frac{{{\mathbf{d}}_{k + 1} - {\mathbf{d}}_{k} }}{\Delta t} - {\mathbf{M}}_{du} \left( {\frac{{{\mathbf{u}}_{k + 1} - {\mathbf{u}}_{k} }}{\Delta t}} \right) + \frac{\Delta t}{4}{\mathbf{\Delta \beta }} - \frac{\Delta t}{2}{\mathbf{g}}_{d} + \frac{\Delta t}{4}{\mathbf{BCu}}_{k + 1} - {\mathbf{p}}_{d,k + 1} } \right] \\ \quad + \left( {\delta {\mathbf{d}}_{k}^{\text{T}} } \right)\left[ { - {\mathbf{M}}_{d} \frac{{{\mathbf{d}}_{k + 1} - {\mathbf{d}}_{k} }}{\Delta t} + {\mathbf{M}}_{du} \left( {\frac{{{\mathbf{u}}_{k + 1} - {\mathbf{u}}_{k} }}{\Delta t}} \right) + \frac{\Delta t}{4}{\mathbf{\Delta \beta }} - \frac{\Delta t}{2}{\mathbf{g}}_{d} + \frac{\Delta t}{4}{\mathbf{BCu}}_{k} + {\mathbf{p}}_{d,k} } \right] \\ \quad + \left( {\delta {\varvec{\upbeta}}^{\text{T}} } \right)\frac{\Delta t}{4}\left[ {\left( {{\mathbf{\Delta d}}_{k} + {\mathbf{D}}_{k} {\mathbf{Cu}}_{k} - {\mathbf{s}}} \right) + \left( {{\mathbf{\Delta d}}_{k + 1} + {\mathbf{D}}_{k + 1} {\mathbf{Cu}}_{k + 1} - {\mathbf{s}}} \right)} \right] \\ \end{aligned}$$
(61)

Noting that \(\delta S = 0\) and \({\mathbf{\Delta d}}_{k} + {\mathbf{D}}_{k} {\mathbf{Cu}}_{k} - {\mathbf{s}} = {\mathbf{0}}\) in terms of Eq. (50), we have

$$\left\{ \begin{gathered} \frac{{{\mathbf{M}}_{u} }}{{\Delta t}}\left( {{\mathbf{u}}_{{k + 1}} - {\mathbf{u}}_{k} } \right) - {\mathbf{M}}_{{du}}^{{\text{T}}} \left( {\frac{{{\mathbf{d}}_{{k + 1}} - {\mathbf{d}}_{k} }}{{\Delta t}}} \right) + \frac{{\Delta t}}{2}{\mathbf{h}}_{{{\mathbf{u}}_{{k + 1}} }} {\mathbf{g}}_{h} + \frac{{\Delta t}}{4}{\mathbf{C}}^{{\text{T}}} {\mathbf{D}}_{{k + 1}} {\mathbf{\beta }}_{k} - {\mathbf{p}}_{{u,k + 1}} = {\mathbf{0}} \hfill \\ - \frac{{{\mathbf{M}}_{u} }}{{\Delta t}}\left( {{\mathbf{u}}_{{k + 1}} - {\mathbf{u}}_{k} } \right) + {\mathbf{M}}_{{du}}^{{\text{T}}} \left( {\frac{{{\mathbf{d}}_{{k + 1}} - {\mathbf{d}}_{k} }}{{\Delta t}}} \right) + \frac{{\Delta t}}{2}{\mathbf{h}}_{{{\mathbf{u}}_{k} }} {\mathbf{g}}_{h} + \frac{{\Delta t}}{4}{\mathbf{C}}^{{\text{T}}} {\mathbf{D}}_{k} {\mathbf{\beta }}_{k} + {\mathbf{p}}_{{u,k}} = {\mathbf{0}} \hfill \\ {\mathbf{M}}_{d} \frac{{{\mathbf{d}}_{{k + 1}} - {\mathbf{d}}_{k} }}{{\Delta t}} - {\mathbf{M}}_{{du}} \left( {\frac{{{\mathbf{u}}_{{k + 1}} - {\mathbf{u}}_{k} }}{{\Delta t}}} \right) - \frac{{\Delta t}}{2}{\mathbf{g}}_{d} + \frac{{\Delta t}}{4}{\mathbf{\Delta \beta }}_{k} + \frac{{\Delta t}}{4}{\mathbf{B}}_{k} {\mathbf{Cu}}_{{k + 1}} - {\mathbf{p}}_{{d,k + 1}} = {\mathbf{0}} \hfill \\ - {\mathbf{M}}_{d} \frac{{{\mathbf{d}}_{{k + 1}} - {\mathbf{d}}_{k} }}{{\Delta t}} + {\mathbf{M}}_{{du}} \left( {\frac{{{\mathbf{u}}_{{k + 1}} - {\mathbf{u}}_{k} }}{{\Delta t}}} \right) - \frac{{\Delta t}}{2}{\mathbf{g}}_{d} + \frac{{\Delta t}}{4}{\mathbf{\Delta \beta }}_{k} + \frac{{\Delta t}}{4}{\mathbf{B}}_{k} {\mathbf{Cu}}_{k} + {\mathbf{p}}_{{d,k}} = {\mathbf{0}} \hfill \\ {\mathbf{\Delta d}}_{{k + 1}} + {\mathbf{D}}_{{k + 1}} {\mathbf{Cu}}_{{k + 1}} - {\mathbf{s}} = {\mathbf{0}} \hfill \\ \end{gathered} \right.$$
(62)

Equation (62) is a system of nonlinear algebraic equations that can be solved using Newton’s iteration method. If \({\mathbf{M}}_{d}\) and \({\mathbf{M}}_{du}\) in Eq. (62) are replaced with \({\mathbf{M}}_{d} \varepsilon\) and \({\mathbf{M}}_{du} \varepsilon\) (\(\varepsilon \ll 1\)), Eq. (62) can be used to analyze the shallow water problem ignoring the effect of the vertical velocity. In this case, the results are in agreement with the SVE solution.

4 Numerical examples

In this section, three classical numerical examples are used to verify the reliability of the proposed SWE-DP and the effectiveness of the proposed numerical method. These examples have been used frequently by many researchers to test different numerical methods [40,41,42].

4.1 Evolution of shorelines over a parabolic topography

The first example is a perturbed shallow water flow in a one-dimensional container with a parabolic bed profile, which provides a perfect test for the proposed method in dealing with bed sloping source term and wetting/drying condition. The analytical solutions for this problem were derived by Sampson et al. [40]. The initial water domain is shown in Fig. 3.

Fig. 3
figure 3

The water profile at \(t = 0\;{\text{s}}\)

The bed profile is defined by

$$h\left( x \right) = h_{0} - h_{0} \left( {\frac{x}{a}} \right)^{2}$$
(63)

where \(h_{0} = 10\;{\text{m}}\), and \(a = 3000\;{\text{m}}\). According to Ref. [40], the analytical horizontal displacement and water surface are shown as

$$u\left( {x,t} \right) = \frac{{a^{2} }}{{2gh_{0} }}B\omega \left( {1 - \cos \omega t} \right)$$
(64)

and

$$\eta \left( {x,t} \right) = - \frac{1}{g}B\omega \cos \omega t\left( {x + u\left( {x,t} \right)} \right) - \frac{{a^{2} B^{2} }}{{8g^{2} h_{0} }}\omega^{2} \cos 2\omega t - \frac{{B^{2} }}{4g},\;\;\;\;\omega = \frac{{\sqrt {2gh_{0} } }}{a},$$
(65)

respectively, in which the involved parameters are selected as \(B = 5\;{{\text{m}} \mathord{\left/ {\vphantom {{\text{m}} {\text{s}}}} \right. \kern-0pt} {\text{s}}}\), \(g = 10\;{{\text{m}} \mathord{\left/ {\vphantom {{\text{m}} {{\text{s}}^{ 2} }}} \right. \kern-0pt} {{\text{s}}^{ 2} }}\).

Numerical simulation is performed with a time step \(\Delta t = 1\;{\text{s}}\) and a uniform grid with \(N_{\text{e}} = 300\) elements. The simulation lasts for 6000 s. Figure 4 shows the predicted water surface elevation at different times. Figure 5 shows the predicted locations of the left and right shorelines. Excellent agreement is observed between the numerical prediction and analytical solutions from Figs. 4 to 5, which validates that the proposed method is able to address the shallow water with complex bed topographies and wet-dry interfaces.

Fig. 4
figure 4

Water surface elevation at different times: a \(t = 1000\;{\text{s}}\); b \(t = 2000\;{\text{s}}\); c \(t = 3000\;{\text{s}}\); d \(t = 4000\;{\text{s}}\); e \(t = 5000\;{\text{s}}\); f \(t = 6000\;{\text{s}}\)

Fig. 5
figure 5

Locations of shorelines: a Left shoreline; b Right shoreline

The considered problem here is a conservative system, where the total energy of the system, denoted by \(H\left( t \right)\), will keep constant with time. The total energy is the summation of the kinetic energy and the potential energy, i.e., \(H\left( t \right) = T + U\). Figure 6 shows the relative error of the total energy, defined by \({{\left[ {H\left( t \right) - H_{0} } \right]} \mathord{\left/ {\vphantom {{\left[ {H\left( t \right) - H_{0} } \right]} {H_{0} }}} \right. \kern-0pt} {H_{0} }}\), where \(H_{0} = H\left( 0 \right)\). This figure shows that the proposed method conserves precisely the discrete energy of the considered shallow water system over long times. The relative energy error is on the order of \(10^{ - 10}\).

Fig. 6
figure 6

Energy relative error, \({{\left[ {H\left( t \right) - H_{0} } \right]} \mathord{\left/ {\vphantom {{\left[ {H\left( t \right) - H_{0} } \right]} {H_{0} }}} \right. \kern-0pt} {H_{0} }}\), for 6000 s

Simulating the shallow water problem with wet-dry interfaces and a sloping bottom, the numerical solutions often cannot conserve the total mass of the system exactly. In [17], a zero mass error method was proposed by Brufau et al. Here the ability of the proposed method to conserve the mass is also tested. Figure 7 shows the relative error of the total mass of the system, denoted by \({{\left[ {m\left( t \right) - m_{0} } \right]} \mathord{\left/ {\vphantom {{\left[ {m\left( t \right) - m_{0} } \right]} {m_{0} }}} \right. \kern-0pt} {m_{0} }}\), in which

$$m\left( t \right) = \rho \sum\limits_{n = 1}^{{N_{x} }} {d_{n} \left( {\Delta x_{n} + u_{n + 1} - u_{n} } \right)}$$
(66)

is the total mass of the shallow water system, and \(m_{0} = m\left( 0 \right)\).

Fig. 7
figure 7

Mass relative error, \({{\left[ {m\left( t \right) - m_{0} } \right]} \mathord{\left/ {\vphantom {{\left[ {m\left( t \right) - m_{0} } \right]} {m_{0} }}} \right. \kern-0pt} {m_{0} }}\), for 6000 s

It can be observed from Fig. 7 that the relative mass error is on the order of \(10^{ - 16}\), which means that the proposed method can provide numerical results with zero mass errors.

4.2 Spreading of a drop of shallow water

As the second example, the spreading of a parabola-shaped two-dimensional drop of shallow water on a horizontal plane is considered. The drop is initially confined to \(\left| x \right| < 1\) according to

$$z = \eta _{0} \left( x \right) = \left\{ \begin{gathered} 1 - x^{2} \quad {\text{for}}\;\left| x \right| < 1 \hfill \\ 0\quad {\text{for}}\;\left| x \right| \ge 1, \hfill \\ \end{gathered} \right.$$
(67)

and then is at rest. Upon releasing the drop, it spreads under the effect of gravity. The gravitational acceleration is \(g = 1\;{{\text{m}} \mathord{\left/ {\vphantom {{\text{m}} {{\text{s}}^{2} }}} \right. \kern-0pt} {{\text{s}}^{2} }}\). The temporal evolution of this system has been analytically investigated by Frei [43]. He noted that the parabolic shape is always retained and that the velocity across the drop is a linear function, i.e.,

$$\eta \left( {x,t} \right) = \lambda^{ - 1} \left[ {1 - \left( {\frac{\xi }{\lambda }} \right)^{2} } \right],\;\;\dot{u}\left( x \right) = \xi \left( {\frac{{\lambda_{t} }}{\lambda }} \right)$$
(68)

in which, \(\xi\) is defined by Eq. (1), \(\lambda\) describes the half-width of the drop, and \(\lambda_{t} = {{\partial \lambda } \mathord{\left/ {\vphantom {{\partial \lambda } {\partial t}}} \right. \kern-0pt} {\partial t}}\) is the velocity of the leading edge. Following Refs. [43, 44], \(\lambda \left( t \right)\) is obtained numerically as the root of the following equation

$$t = \frac{1}{2}\left[ {\sqrt {\lambda \left( {\lambda - 1} \right)} + \ln \left( {\sqrt {\lambda - 1} + \sqrt \lambda } \right)} \right].$$
(69)

The proposed SWE-DP is used to simulate this problem, and the numerical simulation is performed with \(N_{\text{e}} = 100\) elements. The time step is selected as \(\Delta t = 0.01\;{\text{s}}\), and the numerical simulation lasts for \(2\;{\text{s}}\). It is worth noting that the analytical solution (68) provided by Frei was derived based on the SVE, in which the effect of the vertical velocity is ignored. Hence in the numerical simulation, the matrices \({\mathbf{M}}_{d}\) and \({\mathbf{M}}_{du}\) in Eq. (62) are replaced with \(0 \cdot {\mathbf{M}}_{d}\) and \(0 \cdot {\mathbf{M}}_{du}\), respectively.

The analytical solutions and the numerical results computed using the proposed method are compared in Fig. 8. The first panel in Fig. 8 shows the comparison of the water free surfaces at 1 and 2 s, and the second panel in Fig. 8 shows the comparison of the velocities at 1 and 2 s. It can be observed that the numerical results computed using the proposed method are in excellent agreement with the analytical solution. The example used here was also discussed in Ref. [45], where the SVE was used to model the drop and a second order high resolution algorithm was applied to solve the SVE. The numerical velocities given in Ref. [45] are also displayed in the second panel of Fig. 8. It can be seen that these numerical velocities given in Ref. [45] are different from the analytical solutions at the left and right moving wet-dry interfaces, while the proposed method performs well at the wet-dry interfaces. Indeed, other researchers discussed this example by solving the SVE by means of different types of numerical schemes, e.g., Refs. [44, 46]. However, the accuracy of the numerical velocities at the left and right moving wet-dry interfaces in these reports was unsatisfactory. The numerical results demonstrate that the proposed model can correctly handle the problem of wet-dry interfaces.

Fig. 8
figure 8

Comparison between different solutions. First panel water free surfaces at 1 and 2 s; Second panel, velocities at 1 and 2 s

In Fig. 9 the relative error of the total energy of the drop versus time is displayed. From Fig. 9 it may be observed that the relative energy error is on the order of \(10^{ - 6}\), which means that the proposed method conserves precisely the discrete energy of the considered shallow water system. The max relative error of the total mass for 2 s is on the order of \(10^{ - 16}\), and hence the relative error of the total mass versus time is not exhibited here.

Fig. 9
figure 9

Energy relative error, \({{\left[ {H\left( t \right) - H_{0} } \right]} \mathord{\left/ {\vphantom {{\left[ {H\left( t \right) - H_{0} } \right]} {H_{0} }}} \right. \kern-0pt} {H_{0} }}\)

4.3 Dam break on dry bed

Consider a reservoir with length 150 m and water depth 10 m; see Fig. 10. Suddenly, the right dam is broken and the water pours out of the reservoir. The right side of the dam is the dry bed. Initially, the water surface is defined as

$$z = \eta_{0} \left( x \right) = \left\{ \begin{aligned} h_{0} ,\quad {\text{if}}\;\;x \le x_{0} \hfill \\ 0,\quad {\text{if}}\;\;x > x_{0}, \hfill \\ \end{aligned} \right.$$
(70)

where \(x_{0} = 150\;{\text{m}}\) and \(h_{0} = 10\;{\text{m}}\). The initial velocity is \(\dot{u}\left( {x,0} \right) = 0\;{{\text{m}} \mathord{\left/ {\vphantom {{\text{m}} {\text{s}}}} \right. \kern-0pt} {\text{s}}}\), and the gravitational acceleration is \(g = 9.81\;{{\text{m}} \mathord{\left/ {\vphantom {{\text{m}} {\text{s}}}} \right. \kern-0pt} {\text{s}}}\).

Fig. 10
figure 10

The dam

According to Ref. [42], the analytical solution can be given as

$$\eta \left( {x,t} \right) = \left\{ \begin{gathered} h_{0} ,\quad {\text{if}}\;\xi \le x_{0} - t\sqrt {gh_{0} } \hfill \\ \frac{1}{{9g}}\left( {2\sqrt {gh_{0} } - \frac{{\xi - x_{0} }}{t}} \right)^{2} ,\quad {\text{if}}\;x_{0} - t\sqrt {gh_{0} } < \xi \le x_{0} + 2t\sqrt {gh_{0} } \hfill \\ 0,\quad {\text{if}}\;\xi > x_{0} + 2t\sqrt {gh_{0} } \hfill \\ \end{gathered} \right.$$
(71)

and

$$\dot{u}\left( {x,t} \right) = \left\{ \begin{gathered} 0,\quad {\text{if}}\;\xi \le x_{0} - t\sqrt {gh_{0} } \hfill \\ \frac{2}{3}\left( {\sqrt {gh_{0} } + \frac{{\xi - x_{0} }}{t}} \right),\quad {\text{if}}\;x_{0} - t\sqrt {gh_{0} } < \xi \le x_{0} + 2t\sqrt {gh_{0} } \hfill \\ 0,\quad {\text{if}}\;\xi > x_{0} + 2t\sqrt {gh_{0} }, \hfill \\ \end{gathered} \right.$$
(72)

where \(\xi\) is defined by Eq. (1).

It should be noted that in the analytical solutions (71) and (72) were derived based on the SVE, in which the effect of the vertical velocity is ignored. Hence, to test the reliability of the proposed SWE-DP and the correctness of the proposed numerical scheme, the matrices \({\mathbf{M}}_{d}\) and \({\mathbf{M}}_{du}\) in Eq. (62) are replaced with \(0 \cdot {\mathbf{M}}_{d}\) and \(0 \cdot {\mathbf{M}}_{du}\), respectively in the numerical simulation. Another numerical simulation considering the effect of the vertical velocity is also performed. Both these numerical simulations are performed with \(N_{\text{e}} = 444\) elements and a time step of \(\Delta t = 0.01\;{\text{s}}\). The numerical simulation lasts for 6 s.

In Fig. 11, the water surface elevations and water discharges at \(t = 6\;{\text{s}}\) computed using different methods are compared in the first and second panels, respectively. The black solid line represents the analytical solution. The red dash line represents the numerical results computed using the proposed method in the case of \(\varepsilon = 0\), i.e., where the effect of the vertical velocity is ignored, and the blue dotted line represents the numerical results computed using the proposed method in the case of \(\varepsilon = 1\), i.e., where the effect of the vertical velocity is considered.

Fig. 11
figure 11

Comparison between different solutions. First panel water free surfaces at 6 s; Second panel, water discharge at 6 s

Excellent agreement is observed between the numerical results of \(\varepsilon = 0\) and the analytical solutions, from Fig. 11. No oscillations are detected in the computed results. This demonstrates the reliability of the proposed SWE-DP and the correction of the numerical scheme proposed in Sect. 4. It can also be observed from Fig. 11 that the vertical velocity makes the curves of the numerical results more smooth. Figure 12 shows the relative error of the total energy. It is clear that the proposed method conserves precisely the discrete energy. The relative energy error is on the order of \(10^{ - 6}\), and no numerical diffusion is detected in the computed results. The results depicted in these figures show that the proposed method is able to be employed to the shallow water problem with wet-dry interfaces.

Fig. 12
figure 12

Energy relative error for 6 s

Because the max relative error of the total mass for 6 s is on the order of \(10^{ - 16}\), the relative error of the total mass versus time is not exhibited here.

4.4 Order of accuracy of the proposed scheme

The error of the proposed method depends on two factors, i.e., the mesh size and the time step. To analyze the order of accuracy of the proposed scheme, the example 4.1 is used. The effect of the mesh size on the proposed method is discussed first by using different mesh sizes and the same time step. We select four quantities, i.e., \(u_{\text{A}}\), \(u_{\text{B}}\), \(d_{\text{C}}\) and \(\beta_{\text{D}}\), to determine the order of accuracy. Here, \(u_{\text{A}}\) and \(u_{\text{B}}\) represent the displacements at the points A and B, respectively. \(d_{\text{C}}\) is the water depth at the point C, and \(\beta_{\text{D}}\) the pressure at the point D. The points A, B, C, and D are shown in Fig. 3. The x coordinate values of the points A and B are \(- 4060.66\;{\text{m}}\) and \(1939.34\;{\text{m}}\). The x coordinate values of the points C and D are both \(- 1060.66\;{\text{m}}\). Points A and B are the initial left shoreline and right shoreline, respectively. Points C and D are located at the water surface and bottom, respectively. Let the numerical error be defined by

$$e\left( y \right) = \frac{{\sum\limits_{i = 1}^{{N_{\text{t}} }} {\left| {y\left( {t_{i} } \right) - y^{*} \left( {t_{i} } \right)} \right|} }}{{\sum\limits_{i = 1}^{{N_{\text{t}} }} {\left| {y^{*} \left( {t_{i} } \right)} \right|} }}$$
(73)

where \(y\left( {t_{i} } \right)\) are the solutions at time \(t_{i}\) computed using different mesh sizes, and \(y^{ *} \left( {t_{i} } \right)\) are the reference solutions at time \(t_{i}\). \(N_{\text{t}}\) is the number of time steps. The numerical error can be expressed as \(e = C\Delta x^{s}\), in which \(C\) is a constant independent of the mesh size \(\Delta x\), and \(s\) is the order of accuracy associated with the mesh size. Thus, the errors \(e_{1}\) and \(e_{2}\) for two different mesh sizes \(\Delta x_{1}\) and \(\Delta x_{2}\) can be given by

$$e_{1} = C\Delta x_{1}^{s} ,\;\;\;e_{2} = C\Delta x_{2}^{s} ,$$
(74)

and the order of accuracy can be shown by

$$s = \frac{{\log_{10} \left( {e_{1} } \right) - \log_{10} \left( {e_{2} } \right)}}{{\log_{10} \left( {\Delta x_{1} } \right) - \log_{10} \left( {\Delta x_{2} } \right)}}.$$
(75)

Three different mesh sizes \(\Delta x_{1} = 60\;{\text{m}}\), \(\Delta x_{2} = 30\;{\text{m}}\), \(\Delta x_{3} = 30\;{\text{m}}\) and \(\Delta x_{4} = 15\;{\text{m}}\) are selected to determine the order of accuracy in space. The solutions with mesh size \(\Delta x_{4}\) are seen as the reference solution. The time step is \(\Delta t = 1\;{\text{s}}\), and the interval of the time integration is set to be \(\left[ {0,6000} \right]\;{\text{s}}\). The numerical errors \(e_{i} \;\left( {i = 1\sim3} \right)\) of \(u_{\text{A}}\), \(u_{\text{B}}\), \(d_{\text{C}}\) and \(\beta_{\text{D}}\) are listed in Tables 1, in which \(e_{i}\) represents the numerical error calculated by using the mesh size \(\Delta x_{i}\). The orders of accuracy in space, calculated by the use of Eq. (75), are also listed in this table.

Table 1 The effect of the mesh size on the convergence rate

From Table 1, it can be seen that the numerical errors decrease as the mesh size gradually decreases, and the order of accuracy associated with the mesh size is approximately 2.

Next, we test the effect of the time step on the accuracy of the proposed method by using different time steps and the same mesh size. Let the numerical error be defined by

$$e\left( {{\mathbf{y}}\left( t \right)} \right) = \frac{{\left\| {{\mathbf{y}}\left( t \right) - {\mathbf{y}}^{*} \left( t \right)} \right\|_{1} }}{{\left\| {{\mathbf{y}}^{*} \left( t \right)} \right\|_{1} }}$$
(76)

where \({\mathbf{y}}\left( t \right)\) are the displacement and pressure vectors computed using different time steps, and \({\mathbf{y}}^{ *} \left( t \right)\) is the reference solutions. The numerical error can also be expressed as \(e = C\Delta t^{l}\), in which \(C\) is a constant independent of the time step \(\Delta t\) and \(l\) is the order of accuracy associated with the time step. For two different time steps \(\Delta t_{1}\) and \(\Delta t_{2}\), the errors are

$$e_{1} = C\Delta t_{1}^{l} ,\;\;\;e_{2} = C\Delta t_{2}^{l} ,$$
(77)

and the order of accuracy can be expressed as

$$l = \frac{{\log_{10} \left( {e_{1} } \right) - \log_{10} \left( {e_{2} } \right)}}{{\log_{10} \left( {\Delta t_{1} } \right) - \log_{10} \left( {\Delta t_{2} } \right)}} .$$
(78)

Four time steps \(\Delta t_{1} = 2\;{\text{s}}\), \(\Delta t_{2} = 1\;{\text{s}}\), \(\Delta t_{3} = 0.5\;{\text{s}}\), and \(\Delta t_{4} = 0.25\;{\text{s}}\) are selected and the solutions computed using the smallest time step are seen as the reference solutions. The mesh size is \(\Delta x = 20\;{\text{m}}\). The numerical errors \(e_{i} \;\left( {i = 1\sim3} \right)\) of \({\mathbf{u}}\left( t \right)\), \({\mathbf{d}}\left( t \right)\), and \({\varvec{\upbeta}}\left( t \right)\) at times \(t_{1} = 1000\;{\text{s}}\), \(t_{2} = 3000\;{\text{s}}\) and \(t_{3} = 5000\;{\text{s}}\) are listed in Tables 2, in which \(e_{i}\) represents the numerical error calculated by using the time step \(\Delta t_{i}\). The orders of accuracy in time, calculated by the use of Eq. (78), are also listed in Table 2.

Table 2 The effect of the time step on the convergence rate

From Table 2, it can be seen that the numerical errors decrease as the time step gradually decreases, and the order of accuracy associated with the time step is approximately 2. In terms of Tables 1 and 2, it is possible to conclude that the accuracy of the proposed method is second order.

5 Conclusion

The Lagrange method and the constrained Hamilton variational principle in classical mechanics are used for the shallow water wave problem with a sloping bottom and wet-dry interface. Based on the constrained Hamilton variational principle, a shallow water equation based on the displacement and pressure (SWE-DP) has been presented. A hybrid numerical method combining the finite element method for spatial discretization and the symplectic Zu-class method for time integration is constructed for the SWE-DP. Three numerical examples are used to test the reliability of the proposed SWE-DP and the effectiveness of the hybrid numerical method proposed for the SWE-DP. Numerical examples show that the proposed method performs well in the simulation of shallow water with a sloping bottom and wet-dry interface.

In this paper, we only consider one-dimensional shallow water. However, the basic ideas can be expanded to other hydrodynamics problems. Though the Eulerian coordinate system is the most popular approach in hydrodynamics, the Lagrangian coordinate system can be seen as an efficient supplementary approach based on its advantages of satisfying exactly nonlinear boundary conditions, such as the free surface orwetting/drying condition. We believe that the displacement method will play an important role in accurately and efficiently simulating hydrodynamics problems. In our next work, the proposed method will be expanded to shallow water with two dimensions.