betaFeedback

WorksPhysics and Astronomy

Solving the Discretised Shallow Water Equations on Distorted Structured Grids with Neural Physics

Abstract

This paper presents a method for solving the shallow water equations on highly distorted structured grids using convolution-based operators following the Neural Physics approach. By mapping distorted physical grids to a uniform computational domain with Jacobian transformations, the governing advection and diffusion operators are reformulated in a structured convolutional form. This enables the use of efficient stencil-based operations and, following the Neural Physics concept, we do this through convolutional layers whose weights are determined by the chosen numerical methods rather than by training. The method introduces consistent mass-lumped formulations, conservative and non-conservative advection forms, and a diffusion operator, all expressed as convolutions. A nonlinear Petrov-Galerkin stabilisation is incorporated to control numerical oscillations on distorted meshes. Two approximations for the Laplacian operator are also proposed to accelerate pressure and diffusion solves. The framework is validated using the Carlisle 2005 flood event, demonstrating accurate predictions of water depth and velocity on distorted meshes for both linear and quadratic discretisations. The results show that distorted structured grids can retain conservation, stability and accuracy, whilst adapting the mesh statically. The convolutional formulation makes the method well suited to Neural Physics implementations and GPU acceleration, offering a scalable approach for flood modelling and large-scale geophysical simulations.

Introduction

The shallow water equations (SWEs) are one of the most widely used mathematical models for describing depth-averaged free-surface flows in rivers, floodplains, estuaries and coastal environments. Derived from the incompressible Navier-Stokes equations under hydrostatic assumptions, the SWEs capture the dominant balance between gravity, inertia and bed friction in shallow flows [1, 2]. As a result, they form the basis of many hydrodynamic models used in flood prediction, coastal engineering and environmental management [3, 4]. Such models are essential for flood risk assessment, disaster mitigation and infrastructure planning in increasingly urbanised environments [5, 6].

Numerical solution of the shallow water equations presents several challenges due to nonlinear advection, moving wet–dry interfaces and discontinuities, such as hydraulic jumps and complex bathymetry. A wide range of numerical discretisation methods have therefore been developed for SWE simulations. These include finite difference schemes [7, 8], finite volume methods [9], finite element methods [10] and discontinuous Galerkin formulations [11, 12]. Finite volume methods are particularly attractive due to their conservative properties and their ability to capture discontinuities using Riemann solvers [2, 13, 14]. High-order discontinuous Galerkin methods combine conservation with geometric flexibility and have been successfully applied to coastal and flood modelling problems [15, 16].

A major difficulty in environmental flow modelling lies in the efficient representation of complex geometries and large spatial domains. Flood modelling applications often require high resolution near river channels, hydraulic structures or urban infrastructure, while large surrounding regions may require only coarse resolution [3]. Uniform structured grids are computationally efficient and well suited to high-performance computing architectures, including GPUs [17, 18, 19]. However, they can lead to inefficient use of computational resources when fine resolution is needed only in localised regions.

To address this issue, numerous adaptive mesh strategies have been proposed. Adaptive mesh refinement techniques dynamically increase spatial resolution in regions with strong gradients while maintaining coarse resolution elsewhere [20]. Unstructured mesh approaches allow flexible resolution near complex boundaries and have been widely used in CFD and geophysical modelling [21, 22]. Dynamic mesh movement and rr-adaptation methods redistribute nodes in response to evolving solution features [23, 24, 25]. Recent work has also explored multi-resolution approaches such as wavelet-based adaptive flood models [26].

An alternative approach can be found by distorting structured grids, so the connectivity of a Cartesian mesh is retained whilst the nodes are located where required [27, 28]. As the grid remains structured, differential operators can be evaluated using compact stencil operations with the deformation of the nodes being handled through coordinate transformations. Such techniques are widely used in atmospheric and ocean modelling through terrain-following coordinate systems that represent complex topography while preserving structured solvers [29, 30]. Similar strategies have been applied in hydrodynamic models to concentrate resolution in regions with strong gradients or complex geometry.

Several recent studies have demonstrated that classical numerical methods can be reformulated within machine learning frameworks. The so-called Neural Physics approach has been applied to a range of computational physics problems including neutron transport [31], incompressible flow [32], multiphase CFD simulations [33] and the shallow water equations [34, 35]. This approach exploits the correspondence between the numerical stencils used to discretise equations and the convolutional operations commonly used in deep learning architectures. The resulting implementations can leverage high-performance hardware whilst maintaining the mathematical accuracy of the traditional discretisations. As well as platform agnosticism of the code, the Neural Physics approach enables close coupling of physics-based models with trained surrogate models and is naturally suited to solving optimisation tasks as the code is differentiable [36, 37].

In this work we develop a Neural Physics framework for solving the shallow water equations on distorted structured grids. By mapping the distorted physical grid to a uniform computational domain, the governing equations can be reformulated in terms of discretised operators that retain a structured convolutional representation, enabling efficient GPU implementation.

The contributions of this paper are twofold. First, we extend the existing ConvFEM-based Neural Physics framework to distorted structured grids, enabling the governing equations to be discretised directly on geometry-adapted meshes through Jacobian-based coordinate transformations. Second, nonlinear Petrov-Galerkin stabilisation is incorporated to control oscillations arising from advection-dominated flows on distorted meshes. The resulting framework enables static mesh adaptation through diffusion-based grid distortion, allowing resolution to be concentrated in regions of high interpolation error whilst retaining the underlying structured computational topology. This provides a practical compromise between the flexibility of adaptive meshes and the computational efficiency of structured solvers.

The remainder of the paper is organised as follows. § 2 introduces implementation of Neural Physics and the mapping from physical (distorted) coordinate system to the structured coordinate system. § 3 introduces the discretisation of the SWEs. § 4 describes the optimisation procedure for generating distorted grids. Numerical examples and validation cases are presented in § 5. Finally, § 6 discusses the computational characteristics and broader implications of the method for large-scale environmental flow modelling within the Neural Physics framework.

Methodology

This section describes the numerical framework used to solve the governing equations on statically distorted structured grids. It introduces the Jacobian transformation and the convolutional kernels used within Neural Physics framework.

Discretisation using Convolutional Filters

The idea behind the Neural Physics approach is that the matrix-vector multiplications associated with numerical discretisations can be written as discrete convolutions. Such operations are commonly used in the convolutional layers of neural networks and can be expressed using functions within machine learning libraries.

Notation

The action of a discretisation stencil on a tensor Cn\mathbf{C}^{n} can be written as

f(Cn;w)∣i,j=∑ii=−ℓℓ∑jj=−ℓℓwii,jjCi+ii,j+jjn,(1)f(\mathbf{C}^{n};\mathbf{w})\big|_{i,j} = \sum_{ii=-\ell}^{\ell} \sum_{jj=-\ell}^{\ell} \mathbf{w}_{ii,jj}\mathbf{C}^{n}_{i+ii,j+jj}, \tag*{(1)}

where w\mathbf{w} is a (2ℓ+1)×(2ℓ+1)(2\ell+1) \times(2\ell+1) array containing the coefficients of the numerical stencil. This operation is equivalent to the application of a convolutional filter, where w\mathbf{w} represents the kernel weights. Throughout this work, the tensor f(Cn;w)f(\mathbf{C}^{n};\mathbf{w}) is used to denote the application of a filter w\mathbf{w} to the tensor Cn\mathbf{C}^{n}.

To evaluate the stencil near domain boundaries, a halo region (padding) of width ℓ\ell is included in the computational domain, giving a solution array of size (Nx+2ℓ)×(Ny+2ℓ)(N_x+2\ell) \times(N_y+2\ell). The resulting output field is defined on the physical domain and therefore has dimensions Nx×NyN_x \times N_y. The stencil radius ℓ\ell depends on the discretisation scheme used (see § 3.1.5).

Non-uniform distorted grid for advection term

The variables ξ\xi and η\eta represent coordinates on the uniform structured grid, which, without loss of generality, can be assumed to have a grid spacing of 1. In this case, the lumped mass matrix on this grid has a coefficient of mξL=1m_{\xi L}=1 in the convolutional notation. The Jacobian associated with the transformation from the distorted grid to the uniform structured grid is,

J=(∂x∂ξ∂y∂ξ∂x∂η∂y∂η),J−1=1det⁡(J)(∂y∂η−∂y∂ξ−∂x∂η∂x∂ξ)=((J−1)xx(J−1)xy(J−1)yx(J−1)yy),(2)J = \begin{pmatrix} \frac{\partial x}{\partial\xi} & \frac{\partial y}{\partial\xi} \\ \frac{\partial x}{\partial\eta} & \frac{\partial y}{\partial\eta} \end{pmatrix}, \quad J^{-1} = \frac{1}{\det(J)}\begin{pmatrix} \frac{\partial y}{\partial\eta} & -\frac{\partial y}{\partial\xi} \\ -\frac{\partial x}{\partial\eta} & \frac{\partial x}{\partial\xi} \end{pmatrix} = \begin{pmatrix} (J^{-1})_{xx} & (J^{-1})_{xy} \\ (J^{-1})_{yx} & (J^{-1})_{yy} \end{pmatrix}, \tag*{(2)}

where det⁡(J)=∂x∂ξ∂y∂η−∂x∂η∂y∂ξ\det(J)=\frac{\partial x}{\partial\xi}\frac{\partial y}{\partial\eta}-\frac{\partial x}{\partial\eta}\frac{\partial y}{\partial\xi}. Based on the following relationship between coordinate systems

\begin{pmatrix} \frac{\partial C}{\partial\xi} \\ \frac{\partial C}{\partial\eta} \end{pmatrix} = J \begin{pmatrix} \frac{\partial C}{\partial x} \\ \frac{\partial C}{\partial y} \end{pmatrix}, \tag*{(3)}\end{pmatrix}

the advection terms on the distorted grid can be written as

\begin{pmatrix} \frac{\partial C}{\partial x}\\ \frac{\partial C}{\partial y} \end{pmatrix} =J^{-1} \begin{pmatrix} \frac{\partial C}{\partial\xi}\\ \frac{\partial C}{\partial\eta} \end{pmatrix}. \tag*{(4)}\end{pmatrix}

Moreover, the coordinates x,yx,y with nodal coordinate arrays x,y\mathbf{x},\mathbf{y} on the distorted grid can be differentiated,

∂x∂ξ=1mξLf(x,wξ),∂y∂ξ=1mξLf(y;wξ),∂x∂η=1mξLf(x,wη),∂y∂η=1mξLf(y;wη),(5)\frac{\partial x}{\partial\xi}=\frac{1}{m_{\xi L}}f(x,w_{\xi}),\qquad \frac{\partial y}{\partial\xi}=\frac{1}{m_{\xi L}}f(y;w_{\xi}),\qquad \frac{\partial x}{\partial\eta}=\frac{1}{m_{\xi L}}f(x,w_{\eta}),\qquad \frac{\partial y}{\partial\eta}=\frac{1}{m_{\xi L}}f(y;w_{\eta}), \tag*{(5)}

where wξw_{\xi} and wηw_{\eta} are the weights of the convolutional filters that represent derivatives in ξ\xi and η\eta directions on the uniform structured grid. The derivation of the system in Equation (5) can be seen from the FEM discretisation:

∫VξNi,j∂x∂ξ dξdη=∫VξNi,j∑ii,jj∂(Nii,jjxii,jj)∂ξ dξdη,(6)\int_{V_{\xi}}N_{i,j}\frac{\partial x}{\partial\xi}\,\mathrm{d}\xi\mathrm{d}\eta = \int_{V_{\xi}}N_{i,j}\sum_{ii,jj}\frac{\partial\left(N_{ii,jj}x_{ii,jj}\right)}{\partial\xi}\,\mathrm{d}\xi\mathrm{d}\eta, \tag*{(6)}

with the FEM expansion of x=∑ii,jjNii,jjxii,jjx=\sum_{ii,jj}N_{ii,jj}x_{ii,jj} and then substituting the lumped mass for the consistent mass approximation to form the equation on the left-hand-side of Equations (5). For anything but linear elements we follow the procedure outlined in [38] to form the ConvFEM discretisation. For the advection equation on the distorted grid,

det⁡(J)⊙∂C∂t+u~⊙∂C∂ξ+v~⊙∂C∂η=det⁡(J)⊙s(7)\det(\mathbf{J})\odot\frac{\partial C}{\partial t} +\tilde{\mathbf{u}}\odot\frac{\partial C}{\partial\xi} +\tilde{\mathbf{v}}\odot\frac{\partial C}{\partial\eta} =\det(\mathbf{J})\odot s \tag*{(7)}

where

u~=1mξLdet⁡(J)⊙(u⊙Jxx−1+v⊙Jyx−1),v~=1mξLdet⁡(J)⊙(u⊙Jxy−1+v⊙Jyy−1),(8)\tilde{\mathbf{u}}=\frac{1}{m_{\xi L}}\det(\mathbf{J})\odot\left(\mathbf{u}\odot J_{xx}^{-1}+\mathbf{v}\odot J_{yx}^{-1}\right),\qquad \tilde{\mathbf{v}}=\frac{1}{m_{\xi L}}\det(\mathbf{J})\odot\left(\mathbf{u}\odot J_{xy}^{-1}+\mathbf{v}\odot J_{yy}^{-1}\right), \tag*{(8)}

which, using mass lumping of the mass terms and one point quadrature at the nodes for the other terms, becomes:

det⁡(J)⊙∂C∂t+u~⊙∂C∂ξ+v~⊙∂C∂η=det⁡(J)⊙s,(9)\det(\mathbf{J})\odot\frac{\partial C}{\partial t} +\tilde{\mathbf{u}}\odot\frac{\partial C}{\partial\xi} +\tilde{\mathbf{v}}\odot\frac{\partial C}{\partial\eta} =\det(\mathbf{J})\odot s, \tag*{(9)}

in which

u~=1mξLdet⁡(J)⊙(u⊙Jxx−1+v⊙Jyx−1),(10)\tilde{\mathbf{u}}=\frac{1}{m_{\xi L}}\det(\mathbf{J})\odot\left(\mathbf{u}\odot J_{xx}^{-1}+\mathbf{v}\odot J_{yx}^{-1}\right), \tag*{(10)}
v~=1mξLdet⁡(J)⊙(u⊙Jxy−1+v⊙Jyy−1).(11)\tilde{\mathbf{v}}=\frac{1}{m_{\xi L}}\det(\mathbf{J})\odot\left(\mathbf{u}\odot J_{xy}^{-1}+\mathbf{v}\odot J_{yy}^{-1}\right). \tag*{(11)}

Thus the non-conservative form can be written as follows,

ML⊙∂C∂t+1mξLdet⁡(J‾)⊙(u⊙Jxx−1+v⊙Jyx−1)⊙f(C;wξ)+1mξLdet⁡(J‾)⊙(u⊙Jxy−1+v⊙Jyy−1)⊙f(C;wη)=ML⊙s,(12)M_L \odot\frac{\partial C}{\partial t} + \frac{1}{m_{\xi L}}\det(\underline{J}) \odot(u \odot J_{xx}^{-1} + v \odot J_{yx}^{-1}) \odot f(C;w_{\xi}) + \frac{1}{m_{\xi L}}\det(\underline{J}) \odot(u \odot J_{xy}^{-1} + v \odot J_{yy}^{-1}) \odot f(C;w_{\eta}) = M_L \odot s, \tag*{(12)}

or

ML⊙∂C∂t+u~⊙f(C;wξ)+v~⊙f(C;wη)+γcC⊙(f(u~;wξ)+f(v~;wη))=ML⊙s,(13)M_L \odot\frac{\partial C}{\partial t} + \tilde{u} \odot f(C;w_{\xi}) + \tilde{v} \odot f(C;w_{\eta}) + \gamma_c C \odot\left(f(\tilde{u};w_{\xi}) + f(\tilde{v};w_{\eta})\right) = M_L \odot s, \tag*{(13)}

in which γc=1\gamma_c = 1 corresponds to conservative from and γc=0\gamma_c = 0 non-conservative form and the lumped mass matrix is:

ML=det⁡(J‾).(14)M_L = \det(\underline{J}). \tag*{(14)}

When γc=1\gamma_c = 1, the term C⊙(f(u~;wξ)+f(v~;wη))C \odot\left(f(\tilde{u};w_{\xi}) + f(\tilde{v};w_{\eta})\right) can be smoothed out using mass tensor mξm_{\xi}, which is on the uniform structured grid and can be expressed as a convolutional filter as below for linear and quadratic with Δξ=Δη=1\Delta\xi= \Delta\eta= 1. In addition, to ensure mass conservation, the conservative form can also be expressed as

ML⊙∂C∂t+(f(u~⊙C;wξ)+f(v~⊙C;wη))=ML⊙s.(15)M_L \odot\frac{\partial C}{\partial t} + \left(f(\tilde{u} \odot C;w_{\xi}) + f(\tilde{v} \odot C;w_{\eta})\right) = M_L \odot s. \tag*{(15)}

Non-linear Petrov-Galerkin Diffusion on Distorted Grids

The diffusion based discrete residual RiR_i can be written as below using the mixed mass approximation to the residual,

Rc=αrf(u~⊙f(C;wξ)+v~⊙f(C;wη);1mξLmξ−I),(16)R_c = \alpha_r f\left(\tilde{u} \odot f(C;w_{\xi}) + \tilde{v} \odot f(C;w_{\eta});\frac{1}{m_{\xi L}}m_{\xi} - I\right), \tag*{(16)}

where mξL=ΔξΔηm_{\xi L} = \Delta\xi\Delta\eta is the lumped mass term, mξm_{\xi} is the mass filter associated with the finite element matrices and αr\alpha_r is set to 2 as default. Thus, the resulting diffusion term is ∇ξ⋅(kξ∇ξC)\nabla_{\xi} \cdot(k_{\xi}\nabla_{\xi}C) (that is, in the uniform structured grid) with the diffusion coefficient kξk_{\xi} calculated as,

kξη=αk∣Rc∣⊙(ϵk+f(C;wξ)2+f(C;wη)2),(17)k_{\xi\eta} = \alpha_k |R_c| \odot\left(\epsilon_k + \sqrt{f(C;w_{\xi})^2 + f(C;w_{\eta})^2}\right), \tag*{(17)}

in which the operator ⊘\oslash is defined a⊘b=((a1/b1,a2/b2,…))Ta \oslash b = ((a_1/b_1,a_2/b_2,\ldots))^{T}, a=(a1,a2,…)T\sqrt{a} = (\sqrt{a_1},\sqrt{a_2},\ldots)^{T}, a2=((a1)2,(a2)2,…)Ta^2 = ((a_1)^2,(a_2)^2,\ldots)^{T}. The final Petrov–Galerkin diffusion coefficient is given by:

kξ=det⁡(J‾)⊙min⁡{kξηmax⁡,kξη}.(18)k_{\xi} = \det(\underline{J}) \odot\min\{k_{\xi\eta\max}, k_{\xi\eta}\}. \tag*{(18)}

in which min⁡{a,b}=(min⁡{a1,b1},min⁡{a2,b2},…)T\min\{\mathbf{a},\mathbf{b}\}=(\min\{a_1,b_1\},\min\{a_2,b_2\},\ldots)^{T} and with kξηmax⁡=(0.25/Δt,0.25/Δt,0.25/Δt,…)T\mathbf{k}_{\xi\eta\max}=(0.25/\Delta t,0.25/\Delta t,0.25/\Delta t,\ldots)^{T} is introduced for numerical stability of the explicit predictor-corrector time stepping.

The final diffusion term can be calculated as follows:

∇ξ⋅(kξ∇ξC)∼12(kξ⊙f(C;w∇ξ2)+f(kξ⊙C;w∇ξ2)−C⊙f(kξ;w∇ξ2)),(19)\nabla_{\xi}\cdot(k_{\xi}\nabla_{\xi}C)\sim\frac{1}{2}\left(k_{\xi}\odot f(C;\mathbf{w}_{\nabla_{\xi}^{2}})+f(k_{\xi}\odot C;\mathbf{w}_{\nabla_{\xi}^{2}})-C\odot f(k_{\xi};\mathbf{w}_{\nabla_{\xi}^{2}})\right), \tag*{(19)}

where w∇ξ2\mathbf{w}_{\nabla_{\xi}^{2}} is the Laplacian operation on the uniform regular grid, see [32].

Discretisation and Solution of the Shallow Water Equations

Discretisation in Time

Discretisation of the Continuity Equation in Time

The continuity equation, part of the Shallow Water Equations, which governs the water depth, η\eta, is discretised in time using a central difference approximation about tn+12t^{n+\frac{1}{2}}.

hn+1−hnΔt+∂(un+12ηn+12)∂x+∂(vn+12ηn+12)∂y=shn+1,(20)\frac{h^{n+1}-h^{n}}{\Delta t}+\frac{\partial\left(u^{n+\frac{1}{2}}\eta^{n+\frac{1}{2}}\right)}{\partial x}+\frac{\partial\left(v^{n+\frac{1}{2}}\eta^{n+\frac{1}{2}}\right)}{\partial y}=s_{h}^{n+1}, \tag*{(20)}

in which hnh^{n} is the free surface height at time level nn, Δt\Delta t is the time step and the source, shs_h, is treated implicitly.

Discretisation of the Momentum Equations in Time

The momentum equations part of the Shallow Water Equations (written in non-conservative form and divided through by the water depth η\eta) are also discretised in time using a central difference approximation about tn+12t^{n+\frac{1}{2}} resulting in:

ρg(qn+1−qnΔt+un+12∂qn+12∂x+vn+12∂qn+12∂y)+σqn+1qn+1=−∇hn+12,(21)\rho_g\left(\frac{\mathbf{q}^{n+1}-\mathbf{q}^{n}}{\Delta t}+u^{n+\frac{1}{2}}\frac{\partial\mathbf{q}^{n+\frac{1}{2}}}{\partial x}+v^{n+\frac{1}{2}}\frac{\partial\mathbf{q}^{n+\frac{1}{2}}}{\partial y}\right)+\sigma_q^{n+1}q^{n+1}=-\nabla h^{n+\frac{1}{2}}, \tag*{(21)}

where ρg=1g\rho_g=\frac{1}{g}, qn=(un vn)T\mathbf{q}^{n}=(u^{n}\ v^{n})^{T} denotes the velocity and the bed friction term is expressed as follows:

σqn+1=σ^qn+1gηn+1=gnM2(ηn+1)−1/3(un+1)2+(vn+1)2gηn+1≈nM2(un+1)2+(vn+1)2(max⁡{ϵη,ηn+1})4/3,(22)\sigma_q^{n+1}=\frac{\widehat{\sigma}_q^{n+1}}{g\eta^{n+1}}=\frac{g n_M^2(\eta^{n+1})^{-1/3}\sqrt{(u^{n+1})^2+(v^{n+1})^2}}{g\eta^{n+1}}\approx\frac{n_M^2\sqrt{(u^{n+1})^2+(v^{n+1})^2}}{\left(\max\{\epsilon_{\eta},\eta^{n+1}\}\right)^{4/3}}, \tag*{(22)}

in which a limit on how small η\eta can be in the denominator is applied to avoid dividing by a number close to zero and here ϵη=10−4\epsilon_{\eta}=10^{-4}. The source term from the continuity equation, shs_h, would appear in the non-conservative form of the momentum equations, Equation (21). However, if the momentum equations, themselves, had a source, which had the same velocity as the fluid, the sources would cancel. This is assumed to be the case here.

Discretisation of the Continuity Equation in Space

After applying the product rule to the first order derivatives in the continuity equation, (20), the FE spatial discretisation (written as convolutional filters that are derived in Section 2.1) is applied. This produces a conservative (in ηn\eta^n) discretised system of equations. For stabilisation, a diffusion operator (analytically ∇⋅(k∇η)\nabla\cdot(k\nabla\eta)) is added to the right-hand side of (20) (see 2.3 for details of its discretisation). The resulting equation can be written as follows:

rhn+12=ML⊙(hn+1−hnΔt)−ML⊙shn+1+u~n+12⊙f(ηn+12;wξ)+v~n+12⊙f(ηn+12;wη)+ηn+12⊙(f(u~n+12;wξ)+f(v~n+12;wη))+f∇2(ηn+12,kηn+12;w∇ξ2PG),(23)\begin{aligned} r_h^{n+\frac{1}{2}} ={}& \mathbf{M}_L \odot\left(\frac{h^{n+1}-h^n}{\Delta t}\right)-\mathbf{M}_L\odot s_h^{n+1}\\ &+\tilde{u}^{n+\frac{1}{2}}\odot f\left(\eta^{n+\frac{1}{2}}; \mathbf{w}_{\xi}\right)+\tilde{v}^{n+\frac{1}{2}}\odot f\left(\eta^{n+\frac{1}{2}}; \mathbf{w}_{\eta}\right)\\ &+\eta^{n+\frac{1}{2}}\odot\left(f\left(\tilde{u}^{n+\frac{1}{2}};\mathbf{w}_{\xi}\right)+f\left(\tilde{v}^{n+\frac{1}{2}};\mathbf{w}_{\eta}\right)\right)\\ &+f^{\nabla^2}\left(\eta^{n+\frac{1}{2}},k_{\eta}^{n+\frac{1}{2}};\mathbf{w}_{\nabla_{\xi}^{2}}^{\mathrm{PG}}\right), \tag*{(23)} \end{aligned}

where rhr_h is the residual associated with the free surface height, hnh^n, ηn\eta^n, u~n\tilde{u}^n, v~n\tilde{v}^n and shns_h^n are tensors containing the nodal values at time level nn of the free surface height, water depth, ξ\xi and η\eta components of velocity and source respectively. The entry-wise multiplication of tensors is represented by the Hadamard product, which is denoted by ⊙\odot. The function f(⋅ ;⋅)f(\cdot\,;\cdot) represents a convolution of the first argument with the kernel or filter given in the second argument, see Section 2.1. The terms wξ\mathbf{w}_{\xi} and wη\mathbf{w}_{\eta} represent the filters (whose entries make up the weights) of the neural network that correspond to the discretisations of the first derivative with respect to ξ\xi and η\eta. Similarly, the term w∇ξ2PG\mathbf{w}_{\nabla_{\xi}^{2}}^{\mathrm{PG}} represent filters corresponding to coefficients associated with the Petrov-Galerkin diffusion applied to stabilise the free surface height. See Section 2.1 for derivations of the convolutional filters. Petrov-Galerkin stabilisation [10] is used here to control oscillations in the free surface height that often occur with central-difference or FEM-based discretisations of the advection term. The stabilisation introduces a diffusion term (with diffusion coefficients kηn+12k_{\eta}^{n+\frac{1}{2}}) and provides robustness for demanding problems, such as those which include wetting and drying. It can be convenient to use a linear FEM filter for w∇ξ2PG\mathbf{w}_{\nabla_{\xi}^{2}}^{\mathrm{PG}} rather than a higher order ConvFEM filter, as the latter has a greater tendency to introduce oscillations due to its use of high order FEM polynomials. For idealised problems, the stabilisation term w∇ξ2PG\mathbf{w}_{\nabla_{\xi}^{2}}^{\mathrm{PG}} was discretised with the same order of ConvFEM filters as the other spatial derivatives (that is w∇ξ2PG=w∇ξ2\mathbf{w}_{\nabla_{\xi}^{2}}^{\mathrm{PG}}=\mathbf{w}_{\nabla_{\xi}^{2}}), as the form of this term was found to have little influence on the results. However, for the more demanding test cases, the stabilisation term was discretised with linear elements irrespective of the order of discretisation used for the other terms.

Discretisation of the Momentum Equations in Space

The momentum equations include a term which depends on the bed friction, Equation (25). To discretise this term, we first need to distribute the value of ηn+1\boldsymbol{\eta}^{n+1} over the nodes using

η^n+1=f(ηn+1;wmℓξ−1wmξ),(24)\hat{\boldsymbol{\eta}}^{n+1}=f\left(\boldsymbol{\eta}^{n+1};\mathbf{w}_{m\ell\xi}^{-1}\mathbf{w}_{m\xi}\right), \tag*{(24)}

where the filter wmℓξ−1wmξ\mathbf{w}_{m\ell\xi}^{-1}\mathbf{w}_{m\xi} represents the product of two filters associated with the inverse lumped mass matrix (e.g. wmℓξ−1=I\mathbf{w}_{m\ell\xi}^{-1}=\mathbf{I}) and the consistent mass matrix in the non-distorted domain, respectively. Distributing the values of water depth over the nodes in this way enables the water to move from the wet to dry areas without being inhibited by excessive bottom drag. On discretising Equation (25) using the expression in Equation (24), we obtain

σqn+1=(nM)2⊙cn+1⊘(max⁡{1ϵη,(1−αη)ηn+1+αηη^n+1})4/3,(25)\boldsymbol{\sigma}_{q}^{n+1}=(n_M)^2\odot\mathbf{c}^{n+1}\oslash\left(\max\left\{1\epsilon_{\eta},(1-\alpha_{\eta})\boldsymbol{\eta}^{n+1}+\alpha_{\eta}\hat{\boldsymbol{\eta}}^{n+1}\right\}\right)^{4/3}, \tag*{(25)}

in which the fluid speed tensor cn+1\mathbf{c}^{n+1} is such that ci,jn+1=(ui,jn+1)2+(vi,jn+1)2c_{i,j}^{n+1}=\sqrt{\left(u_{i,j}^{n+1}\right)^2+\left(v_{i,j}^{n+1}\right)^2}. The tensor of nodal values of the Manning coefficient, nM\mathbf{n}_M, is assumed to be constant and αη=0.1\alpha_{\eta}=0.1 is a heuristically obtained parameter.

When discretising the momentum equations (Equation (21)), we adopt a Petrov-Galerkin stabilisation similar to that used for the free surface height. However, for the momentum equations, the stabilisation terms have the same order elements as the other terms in the equations, hence the weights are denoted by w∇ξ2\mathbf{w}_{\nabla_{\xi}^{2}} and not w∇ξPG\mathbf{w}_{\nabla_{\xi}^{\mathrm{PG}}}. Mass lumping is used for the advection, time and absorption terms. Applying the FE spatial discretisations through convolutional filters leads to:

run+12=ML⊙ρg(un+1−unΔt)+ML⊙(σqn+1⊙un+1)+ρg(u~n+12⊙f(un+12;wξ)+v~n+12⊙f(un+12;wη))+f∇2(un+12,kun+12;w∇ξ2)+Jxx−1⊙f(hn+12;wξ)+Jxy−1⊙f(hn+12;wη),(26)\begin{aligned} \mathbf{r}_{u}^{n+\frac{1}{2}}={}&\mathbf{M}_{L}\odot\rho_g\left(\frac{\mathbf{u}^{n+1}-\mathbf{u}^{n}}{\Delta t}\right)+\mathbf{M}_{L}\odot\left(\boldsymbol{\sigma}_{q}^{n+1}\odot\mathbf{u}^{n+1}\right)\\ &+\rho_g\left(\tilde{\mathbf{u}}^{n+\frac{1}{2}}\odot f(\mathbf{u}^{n+\frac{1}{2}};\mathbf{w}_{\xi})+\tilde{\mathbf{v}}^{n+\frac{1}{2}}\odot f(\mathbf{u}^{n+\frac{1}{2}};\mathbf{w}_{\eta})\right)\\ &+f^{\nabla^{2}}\left(\mathbf{u}^{n+\frac{1}{2}},k_{u}^{n+\frac{1}{2}};\mathbf{w}_{\nabla_{\xi}^{2}}\right)+\mathbf{J}_{xx}^{-1}\odot f(\mathbf{h}^{n+\frac{1}{2}};\mathbf{w}_{\xi})+\mathbf{J}_{xy}^{-1}\odot f(\mathbf{h}^{n+\frac{1}{2}};\mathbf{w}_{\eta}), \tag*{(26)} \end{aligned}
rvn+12=ML⊙ρg(vn+1−vnΔt)+ML⊙(σqn+1⊙vn+1)+ρg(u~n+12⊙f(vn+12;wx)+v~n+12⊙f(vn+12;wy))+f∇2(vn+12,kvn+12;w∇ξ2)+Jyx−1⊙f(hn+12;wξ)+Jyy−1⊙f(hn+12;wη),(27)\begin{aligned} \mathbf{r}_{v}^{n+\frac{1}{2}}={}&\mathbf{M}_{L}\odot\rho_g\left(\frac{\mathbf{v}^{n+1}-\mathbf{v}^{n}}{\Delta t}\right)+\mathbf{M}_{L}\odot\left(\boldsymbol{\sigma}_{q}^{n+1}\odot\mathbf{v}^{n+1}\right)\\ &+\rho_g\left(\tilde{\mathbf{u}}^{n+\frac{1}{2}}\odot f(\mathbf{v}^{n+\frac{1}{2}};\mathbf{w}_{x})+\tilde{\mathbf{v}}^{n+\frac{1}{2}}\odot f(\mathbf{v}^{n+\frac{1}{2}};\mathbf{w}_{y})\right)\\ &+f^{\nabla^{2}}\left(\mathbf{v}^{n+\frac{1}{2}},k_{v}^{n+\frac{1}{2}};\mathbf{w}_{\nabla_{\xi}^{2}}\right)+\mathbf{J}_{yx}^{-1}\odot f(\mathbf{h}^{n+\frac{1}{2}};\mathbf{w}_{\xi})+\mathbf{J}_{yy}^{-1}\odot f(\mathbf{h}^{n+\frac{1}{2}};\mathbf{w}_{\eta}), \tag*{(27)} \end{aligned}

where kuk_u and kvk_v are diffusion coefficients in xx and yy directions, respectively.

In this work, the momentum equations are solved in non-conservative form. This choice is motivated by several considerations. First, it avoids the need to divide by the fluid depth η\eta after solving for the conservative variables (ηu)n(\eta u)^n and (ηv)n(\eta v)^n in order to recover the velocities unu^n and vnv^n. Second, when bed friction is included, momentum is no longer strictly conserved and the advantages of a conservative formulation are reduced, particularly in flows where frictional effects dominate. Third, solving directly for the velocity fields allows numerical diffusion arising from the Petrov-Galerkin stabilisation to be applied naturally to the velocity variables in the discretised momentum equations (Equation (21)). Fourth, non-conservative formulations facilitate the construction of schemes that preserve motionless steady states. This desirable property, commonly referred to as the C-property, ensures that a stationary solution remains stationary under the numerical discretisation [39].

Finally, the non-conservative formulation leads to a simpler numerical implementation, which can improve computational efficiency in large-scale simulations.

Application of Boundary Conditions

Boundary conditions are imposed using halo nodes (also referred to as ghost or virtual cells) located around the perimeter of the computational domain. These halo nodes are implemented through padding, as illustrated in Figure 1. Using halo nodes allows the same discretisation stencil to be applied at interior and boundary nodes, simplifying the numerical implementation.

Schematic diagram showing how the boundary conditions work for symmetry boundaries and specified velocity and free surface height boundaries

Figure 1. Schematic diagram showing how the boundary conditions work for symmetry boundaries and specified velocity and free surface height boundaries. The boundary conditions are enforced between the cells/nodes in the diagram by specifying suitable values of the halo values (in grey).

The width of the halo region depends on the order of the numerical discretisation. For example, a halo width of one node is sufficient for linear elements, two nodes for quadratic ConvFEM elements, three nodes for cubic ConvFEM elements and so forth.

Dirichlet boundary conditions are imposed by assigning the prescribed value directly to the halo nodes. When a specified normal derivative is required, the halo values are obtained by extrapolating from the nearest interior node using the prescribed gradient. A common special case is the zero-gradient condition, which corresponds to symmetry or slip boundary conditions (see Figure 1). In this case, the halo node values are simply set equal to the value at the nearest interior node.

Stage 1: Velocity Solution

To solve for velocity, we wish to reduce the residuals written in Equations (26) and (27) to zero. As the future velocity and the bed friction are the dominant terms in the residuals, we treat these terms implicitly by forming the equations below:

un+1←−ML−1⊙run+12⊘(ρgΔt1+σqn+1)+un+1,(28)\mathbf{u}^{n+1} \leftarrow-\mathbf{M}_{L}^{-1} \odot\mathbf{r}_{u}^{n+\frac{1}{2}} \oslash\left(\frac{\rho_g}{\Delta t}\mathbf{1}+\boldsymbol{\sigma}_{q}^{n+1}\right)+\mathbf{u}^{n+1}, \tag*{(28)}
vn+1←−ML−1⊙rvn+12⊘(ρgΔt1+σqn+1)+vn+1,(29)\mathbf{v}^{n+1} \leftarrow-\mathbf{M}_{L}^{-1} \odot\mathbf{r}_{v}^{n+\frac{1}{2}} \oslash\left(\frac{\rho_g}{\Delta t}\mathbf{1}+\boldsymbol{\sigma}_{q}^{n+1}\right)+\mathbf{v}^{n+1}, \tag*{(29)}

where 1\mathbf{1} is a tensor, in which each entry is unity (that is 1i,j=1\mathbf{1}_{i,j}=1). Hadamard entrywise division of tensors of the same size is denoted by ⊘\oslash and defined as follows,

c^=a^⊘b^⟺c^i,j=a^i,jb^i,j.\hat{\mathbf{c}}=\hat{\mathbf{a}}\oslash\hat{\mathbf{b}}\quad\Longleftrightarrow\quad\hat{c}_{i,j}=\frac{\hat{a}_{i,j}}{\hat{b}_{i,j}}.

Having solved for un+1\mathbf{u}^{n+1} and vn+1\mathbf{v}^{n+1}, the velocities un+12\mathbf{u}^{n+\frac{1}{2}} and vn+12\mathbf{v}^{n+\frac{1}{2}} are updated. On the right-hand side of Equations (28) and (29), the variables un+1\mathbf{u}^{n+1} and vn+1\mathbf{v}^{n+1} refer to the most up-to-date approximation that is available — for the predictor step this will be un\mathbf{u}^{n} and vn\mathbf{v}^{n}. Writing Equations (28) and (29) in a residual form, enables one to use either the consistent mass matrix (defined by the convolutional filter wm\mathbf{w}_{m}) or the lumped mass matrix (wml\mathbf{w}_{\mathrm{ml}}) for the time term within the residual. As, if the iteration process converges, the residuals will have been forced to zero whichever mass matrix is used. Choosing a diagonal lumped mass matrix has the benefit of being easy to invert, making the iterative process efficient.

Stage 2: Free Surface Height Correction

The free surface correction equation is derived by subtracting out the velocity equation (Equation (21)) with the previous free surface height at time level nn and the new free surface height at time level n+1n+1 that leads to the satisfaction of the continuity equation (Equation (20)). The divergence of the resulting momentum equation is formed to produce the free surface height correction equation similar to [40]. In continuous form, the resulting iterative correction Δh\Delta h to the free surface height can be determined by solving:

(−∇2+βhρg(Δt)2ηn+12)Δh=βhρgΔtηn+12(hn+1−hnΔt+∇⋅(qn+12ηn+12)−shn+1)(30)\left(-\nabla^2 + \frac{\beta_h \rho g}{(\Delta t)^2 \eta^{n+\frac{1}{2}}}\right)\Delta h = \frac{\beta_h \rho g}{\Delta t \eta^{n+\frac{1}{2}}}\left(\frac{h^{n+1}-h^n}{\Delta t}+\nabla\cdot\left(q^{n+\frac{1}{2}}\eta^{n+\frac{1}{2}}\right)-s_h^{n+1}\right) \tag*{(30)}

in which all the variables on the right-hand side of this expression use the best estimate of the variables hn+1h^{n+1}, qn+1q^{n+1}. Here a parameter βh=4\beta_h = 4 has been included. If large time steps are being used and the non-linear convergence is struggling, βh\beta_h can be reduced. βh=1\beta_h = 1 corresponds to a more stable, but less accurate, backward Euler time discretisation rather than the predictor-corrector method used here. The discretised form of Equation (30) is

βcf(Δh;w∇2)+βhρg(Δt)2(1⊘max⁡{ϵη1,ηn+12})⊙ML⊙Δh=−βhρgΔtrhn+12⊘max⁡{ϵη1,ηn+12}(31)\beta_c f(\Delta h; w_{\nabla^2})+\frac{\beta_h\rho g}{(\Delta t)^2}\left(1\mathbin{\oslash}\max\{\epsilon_\eta1,\eta^{n+\frac{1}{2}}\}\right)\mathbin{\odot}M_L\mathbin{\odot}\Delta h=-\frac{\beta_h\rho g}{\Delta t}r_h^{n+\frac{1}{2}}\mathbin{\oslash}\max\{\epsilon_\eta1,\eta^{n+\frac{1}{2}}\} \tag*{(31)}

in which ηn+12\eta^{n+\frac{1}{2}} has been replaced by max⁡{ϵη1,ηn+12}\max\{\epsilon_\eta1,\eta^{n+\frac{1}{2}}\} in the above to aid stability for wetting and drying occurring at small water depths. Also to increase the speed of the algorithm the discretised Laplacian has been approximated by the discretised Laplacian in the uniform grid domain, that is the first term of Equation (31) and βc∈[0,1]\beta_c \in[0,1] is a relaxation coefficient βc=1\beta_c = 1 is used here. For idealised problems, ϵη=0\epsilon_\eta= 0, and for non-idealised problems, ϵη=0.0001\epsilon_\eta= 0.0001 m. Equation (31) is solved for Δh\Delta\mathbf{h} using a Jacobi iteration, which is sufficient for Courant numbers (based on the wave speed) of less than O(10)O(10), say. For larger Courant numbers, a multigrid method could also be used to calculate the free surface height correction tensor. See [31] for a description of how the multigrid method can be implemented through neural networks with the U-Net architecture [41]. Having solved for Δh\Delta\mathbf{h}, the free surface height is updated according to

hn+1←hn+1+Δh.h^{n+1}\leftarrow h^{n+1}+\Delta h.

Stage 3: Velocity Correction

The velocity correction Δq\Delta q is then calculated, which, in continuous form, is given by

Δq=−Δt2ρg∇Δh.(32)\Delta\mathbf{q} = -\frac{\Delta t}{2\rho_g}\nabla\Delta h. \tag*{(32)}

In discretised form, this becomes

Δu=−Δt2ρgML−1⊙(Jxx−1⊙f(Δh;wξ)+Jxy−1⊙f(Δh;wη)).(33)\Delta\mathbf{u} = -\frac{\Delta t}{2\rho_g}M_L^{-1}\odot\left(J_{xx}^{-1}\odot f(\Delta h;\mathbf{w}_{\xi})+J_{xy}^{-1}\odot f(\Delta h;\mathbf{w}_{\eta})\right). \tag*{(33)}
Δv=−Δt2ρgML−1⊙(Jyx−1⊙f(Δh;wξ)+Jyy−1⊙f(Δh;wη)).(34)\Delta\mathbf{v} = -\frac{\Delta t}{2\rho_g}M_L^{-1}\odot\left(J_{yx}^{-1}\odot f(\Delta h;\mathbf{w}_{\xi})+J_{yy}^{-1}\odot f(\Delta h;\mathbf{w}_{\eta})\right). \tag*{(34)}

Once Δu\Delta\mathbf{u} and Δv\Delta\mathbf{v} are obtained, the tensors representing the discrete velocity components can be updated:

un+1←un+1+Δu,vn+1←vn+1+Δv.(35)\mathbf{u}^{n+1}\leftarrow\mathbf{u}^{n+1}+\Delta\mathbf{u},\qquad\mathbf{v}^{n+1}\leftarrow\mathbf{v}^{n+1}+\Delta\mathbf{v}. \tag*{(35)}

Static grid optimisation

Static grid optimisation is achieved by first estimating a desired element size field from interpolation theory, where the local truncation error is related to solution curvature. To ensure robustness for time-dependent problems, the maximum interpolation error over all time levels is taken, producing a conservative measure of where resolution is required. This error is then converted into a target grid spacing or element size, and subsequently a diffusion coefficient, which is typically defined as the inverse of the target grid spacing. The diffusion coefficient is initially computed on the uniform computational grid and interpolated onto the physical mesh. A diffusion equation is solved to redistribute the mesh nodes, driving them toward regions requiring higher resolution while smoothing the overall distribution. This process results in a mesh that equilibrates according to the prescribed spacing field, concentrating nodes in high-error regions and coarsening elsewhere, while maintaining stability and mesh quality through the diffusive smoothing mechanism.

When adapting the resolution, we also take account of element quality, and attempt to limit the movement of nodes to avoid badly conditioned elements. We express the redistribution of nodes and the element quality as two terms in a functional, FF, which we will minimise:

F=∫Ωξ(12(∇ξx)Tk(∇ξx)+12((x−x0)Tσ(x−x0))) dVξ.(36)F=\int_{\Omega_{\xi}}\left(\frac{1}{2}(\nabla_{\xi}x)^{T}k(\nabla_{\xi}x)+\frac{1}{2}((x-x_{0})^{T}\sigma(x-x_{0}))\right)\,\mathrm{d}V_{\xi}. \tag*{(36)}

in which kk is a tensor containing diffusion coefficients, σ\sigma is a tensor of relaxation coefficients, x=(x,y)Tx=(x,y)^{T} are the coordinates and x0\mathbf{x}_0 contains the grid locations from a previous iteration that we relax towards. This expression balances relocating the nodes according to a diffusion mechanism whilst, at the same time, not moving the nodes too far from their previous locations. If time stepping is used to solve this equation, then one can use the second term to help find a solution by setting x0\mathbf{x}_0 to the previous time step value x0=x(n)\mathbf{x}_0=\mathbf{x}^{(n)} and σ=diag⁡(1Δt∗)\boldsymbol{\sigma}=\operatorname{diag}\left(\frac{1}{\Delta t^*}\right), in which nn is the time level and Δt∗\Delta t^* the pseudo time-step size. We integrate over the entire uniform grid represented by Ωξ\Omega_\xi. Differentiating (36), assuming k\mathbf{k} is independent of x\mathbf{x}, and setting this to zero results in:

∂F∂x=∫Ωξ(−(∇ξT(k∇ξx)+σ(x−x0))) dVξ=0,(37)\frac{\partial F}{\partial\mathbf{x}}=\int_{\Omega_\xi}\left(-\left(\nabla_\xi^T(\mathbf{k}\nabla_\xi\mathbf{x})+\boldsymbol{\sigma}(\mathbf{x}-\mathbf{x}_0)\right)\right)\,dV_\xi=0, \tag*{(37)}

which occurs at the extremum (the minimum) of the quadratic functional FF. The diffusion coefficient(s) can be set in a number of ways. A simple way to produce isotropic non-uniform resolution is to use a relative length scale LrefL_{ref} that varies non-uniformly across the grid. In this case the diffusion coefficient becomes:

k=1Lref.(38)k=\frac{1}{L_{ref}}. \tag*{(38)}

The tensor k\mathbf{k} can also generate anisotropic grid spacing by defining multiple components:

k=Lref−1.(39)\mathbf{k}=L_{ref}^{-1}. \tag*{(39)}

If, alongside element quality, we wish to include solution error when redistributing the nodes, we can use interpolation theory and adjust the above definitions of k\mathbf{k}. For a given direction across the undistorted system, we can estimate the solution error by ∣∇ξaTA∇ξψ∣\lvert\nabla_\xi\mathbf{a}^T\mathbf{A}\nabla_\xi\psi\rvert along a unit direction a\mathbf{a} in the undistorted grid. This term estimates the curvature of the solution field in the direction a\mathbf{a}. Assuming ϵ\epsilon is the desired interpolation error of the solution variables, then a way to introduce anisotropy is to represent the resulting diffusion coefficient as a tensor k\mathbf{k}, which can be thought of as a hyperellipse representing the strength of diffusion in different directions. Another way to represent this diffusion anisotropy is directly through the discretisation. Suppose we have a 3×3×33\times3\times3 stencil in 3D then a way to represent the anisotropy is to effectively have 13 directions across the stencil which are discretised separately with their own diffusion coefficient associated with them. Suppose the index for a node is i,ji,j then the diffusion coefficients across node i,ji,j is then

ki+li,j+lji,j,∀ li,lj∈{−1,0,1} other than li=lj=0.(40)k^{i,j}_{i+l_i,j+l_j},\quad\forall\ l_i,l_j\in\{-1,0,1\}\ \text{other than}\ l_i=l_j=0. \tag*{(40)}

As the diffusion tensor is symmetric, ki+l,j+li,j=ki−l,j−li,jk^{i,j}_{i+l,j+l}=k^{i,j}_{i-l,j-l}.

Interpolation theory suggests the absolute value of interpolation error is, in 1D:

ϵ0=γh2∣∂2ψ∂x2∣.(41)\epsilon_0=\gamma h^2\left|\frac{\partial^2\psi}{\partial x^2}\right|. \tag*{(41)}

in which ϵ0\epsilon_0 is the specified interpolation error; hh is the desired edge length (distance between neighbouring nodes); γ\gamma is an O(1)O(1) scalar (here γ=1\gamma=1 is used); and Δx\Delta x is the actual edge length. In a 1D non-distorted space represented by ξ\xi, this equation is modified and can be rearranged for hh:

ϵ0=γh2(Δx)2∣∂2ψ∂ξ2∣⟹h=(Δx)2ϵ0γ∣∂2ψ∂ξ2∣.(42)\epsilon_0=\gamma\frac{h^2}{(\Delta x)^2}\left|\frac{\partial^2\psi}{\partial\xi^2}\right|\quad\Longrightarrow\quad h=\sqrt{\frac{(\Delta x)^2\epsilon_0}{\gamma\left|\frac{\partial^2\psi}{\partial\xi^2}\right|}}. \tag*{(42)}

The diffusion coefficient is k=1/hk=1/h in which hh is the desired node spacing. This can be seen from the discretised in 1D diffusion equation of the xx coordinate: ki+12(xi+1−xi)/(Δξ)2−ki−12(xi−xi−1)/(Δξ)2=0k_{i+\frac{1}{2}}(x_{i+1}-x_i)/(\Delta\xi)^2-k_{i-\frac{1}{2}}(x_i-x_{i-1})/(\Delta\xi)^2=0 which re-arranging becomes ki−12/ki+12=Δxi+12/Δxi−12k_{i-\frac{1}{2}}/k_{i+\frac{1}{2}}=\Delta x_{i+\frac{1}{2}}/\Delta x_{i-\frac{1}{2}} which is realised with ki+12=1/hi+12k_{i+\frac{1}{2}}=1/h_{i+\frac{1}{2}} and in which Δξ\Delta\xi is the uniform grid spacing in the non-distorted domain. Now, since the diffusion coefficient is:

k=1h,(43)k=\frac{1}{h}, \tag*{(43)}

then

k=γ∣∂2ψ∂ξ2∣(Δx)2ϵ0.(44)k=\sqrt{\frac{\gamma\left|\frac{\partial^2\psi}{\partial\xi^2}\right|}{(\Delta x)^2\epsilon_0}}. \tag*{(44)}

For time dependent problem in order to produce a diffusion coefficient that reflects the length scales needed over all time we effectively use the infinity norm or:

k=γmax⁡n{∣∂2ψn∂ξ2∣}(Δx)2ϵ0.(45)k=\sqrt{\frac{\gamma\max_n\left\{\left|\frac{\partial^2\psi^n}{\partial\xi^2}\right|\right\}}{(\Delta x)^2\epsilon_0}}. \tag*{(45)}

Now, introducing the maximum and minimum edge lengths hmaxh_{max} and hminh_{min} one obtains:

k=min⁡{max⁡{γmax⁡n{∣∂2ψn∂ξ2∣}(Δx)2ϵ0,1hmax},1hmin}.(46)k=\min\left\{\max\left\{\sqrt{\frac{\gamma\max_n\left\{\left|\frac{\partial^2\psi^n}{\partial\xi^2}\right|\right\}}{(\Delta x)^2\epsilon_0}},\frac{1}{h_{max}}\right\},\frac{1}{h_{min}}\right\}. \tag*{(46)}

Now using the approximations in 1D:

∂2ψn∂ξ2≈2ψi,jn−ψi+1n−ψi−1n(Δξi+1i)2.(47)\frac{\partial^2\psi^n}{\partial\xi^2}\approx\frac{2\psi^n_{i,j}-\psi^n_{i+1}-\psi^n_{i-1}}{(\Delta\xi^i_{i+1})^2}. \tag*{(47)}

In 2D, for the shallow water equations, this becomes:

ki,jli,lj=γmax⁡n{∣∇ξ2ψn∣i,jli,lj}12((Δxi,jli,lj)2+(Δxi,j−li,−lj)2)ϵ0i,jli,lj≈γmax⁡n{∣2ψi,jn−ψi+li,j+ljn−ψi−li,j−ljn∣/(Δξi,jli,lj)2}12((Δxi,jli,lj)2+(Δxi,j−li,−lj)2)ϵ0i,jli,lj∀li,lj∈{−1,0,1},(48)\begin{aligned} k_{i,j}^{l_i,l_j} &= \sqrt{\frac{\gamma\max_n\left\{\left|\nabla_{\xi}^{2}\psi^{n}\right|_{i,j}^{l_i,l_j}\right\}}{\frac{1}{2}\left(\left(\Delta x_{i,j}^{l_i,l_j}\right)^2+\left(\Delta x_{i,j}^{-l_i,-l_j}\right)^2\right)\epsilon_{0i,j}^{l_i,l_j}}} \\ &\approx\sqrt{\frac{\gamma\max_n\left\{\left|2\psi_{i,j}^{n}-\psi_{i+l_i,j+l_j}^{n}-\psi_{i-l_i,j-l_j}^{n}\right|/\left(\Delta\xi_{i,j}^{l_i,l_j}\right)^2\right\}}{\frac{1}{2}\left(\left(\Delta x_{i,j}^{l_i,l_j}\right)^2+\left(\Delta x_{i,j}^{-l_i,-l_j}\right)^2\right)\epsilon_{0i,j}^{l_i,l_j}}} \qquad\forall l_i,l_j\in\{-1,0,1\}, \tag*{(48)} \end{aligned}

in which li,ljl_i,l_j represents the direction of diffusion in ki,jli,ljk_{i,j}^{l_i,l_j} and i,ji,j the node on which the diffusion coefficient is centred. Also,

(Δξli,lj)2=1,if ∣li∣+∣lj∣=1;(49)\left(\Delta\xi^{l_i,l_j}\right)^2=1,\qquad\text{if } |l_i|+|l_j|=1; \tag*{(49)}
(Δξli,lj)2=2,if ∣li∣+∣lj∣=2,(50)\left(\Delta\xi^{l_i,l_j}\right)^2=2,\qquad\text{if } |l_i|+|l_j|=2, \tag*{(50)}

and Δxi,jli,lj\Delta x_{i,j}^{l_i,l_j} and Δξli,lj\Delta\xi^{l_i,l_j} are the edge length scales (grid spacing) in the real (distorted) and local (uniform non-distorted) coordinated system in the direction associated with the stencil li,ljl_i,l_j. ϵ0i,jli,lj\epsilon_{0i,j}^{l_i,l_j} represents the desired interpolation error. In addition, the distance between neighbouring nodes is calculated as follows:

Δxi,jli,lj=∥xi,j−xi+li,j+lj∥p,(51)\Delta x_{i,j}^{l_i,l_j}=\left\|\mathbf{x}_{i,j}-\mathbf{x}_{i+l_i,j+l_j}\right\|_p, \tag*{(51)}

in which the distance or p=2p=2 is generally used; however, p=1p=1 or p=∞p=\infty are more computationally efficient. The pp-norms are calculated using:

∥xi,j−xi+li,j+lj∥1=∣xi,j−xi+li,j+lj∣+∣yi,j−yi+li,j+lj∣,(52)\left\|\mathbf{x}_{i,j}-\mathbf{x}_{i+l_i,j+l_j}\right\|_1 =|x_{i,j}-x_{i+l_i,j+l_j}|+|y_{i,j}-y_{i+l_i,j+l_j}|, \tag*{(52)}
∥xi,j−xi+li,j+lj∥2=(xi,j−xi+li,j+lj)2+(yi,j−yi+li,j+lj)2,(53)\left\|\mathbf{x}_{i,j}-\mathbf{x}_{i+l_i,j+l_j}\right\|_2 =\sqrt{(x_{i,j}-x_{i+l_i,j+l_j})^2+(y_{i,j}-y_{i+l_i,j+l_j})^2}, \tag*{(53)}
∥xi,j−xi+li,j+lj∥∞=max⁡{∣xi,j−xi+li,j+lj∣,∣yi,j−yi+li,j+lj∣}.(54)\left\|\mathbf{x}_{i,j}-\mathbf{x}_{i+l_i,j+l_j}\right\|_\infty =\max\{|x_{i,j}-x_{i+l_i,j+l_j}|,|y_{i,j}-y_{i+l_i,j+l_j}|\}. \tag*{(54)}

With the inclusion of a maximum and minimum length scale (hmax i,jli,ljh_{max\,i,j}^{l_i,l_j}, hmin i,jli,ljh_{min\,i,j}^{l_i,l_j} respectively), the approximation for ki,jli,ljk_{i,j}^{l_i,l_j} from (48) can be written as

min⁡{max⁡{γmax⁡n{∣2ψi,jn−ψi+li,j+ljn−ψi−li,j−ljn∣/(Δξi,jli,lj)2}max⁡{12((Δxi,jli,lj)2+(Δxi,j−li,−lj)2),(Δxmin)2}ϵ0i,jli,lj,1hmax i,jli,lj},1hmin i,jli,lj},(55)\min\left\{\max\left\{\sqrt{\frac{\gamma\max_n\left\{|2\psi_{i,j}^{n}-\psi_{i+l_i,j+l_j}^{n}-\psi_{i-l_i,j-l_j}^{n}|/(\Delta\xi_{i,j}^{l_i,l_j})^2\right\}}{\max\left\{\frac{1}{2}\left(\left(\Delta x_{i,j}^{l_i,l_j}\right)^2+\left(\Delta x_{i,j}^{-l_i,-l_j}\right)^2\right),(\Delta x_{min})^2\right\}\epsilon_{0i,j}^{l_i,l_j}}},\frac{1}{h_{max\,i,j}^{l_i,l_j}}\right\},\frac{1}{h_{min\,i,j}^{l_i,l_j}}\right\}, \tag*{(55)}

in which we have introduced Δxmin\Delta x_{min} as the minimum element length or node to the spacing of the neighbouring nodes that we want in the grid. This stops the method from producing increasingly fine grids. After calculating these values of ki,jli,ljk_{i,j}^{l_i,l_j} they are smoothed using the consistent mass matrix Sm=MξL−1MξS_m=M_{\xi L}^{-1}M_{\xi} (the row sum lumped and consistent mass matrices MξLM_{\xi L}, MξM_{\xi} are evaluated in the uniform domain Ωξ\Omega_{\xi} and thus these matrices do not depend on the position i,ji,j due to the grid being uniform), that is:

ki,jli,lj←∑jj=−11∑ii=−11Smii,jjki+ii,j+jjli,lj.(56)k_{i,j}^{li,lj} \leftarrow\sum_{jj=-1}^{1} \sum_{ii=-1}^{1} S_m^{ii,jj} k_{i+ii,j+jj}^{li,lj}. \tag*{(56)}

This represents a single iteration of the smoothing. We typically use two smoothing iterations. For multiple solution variables for which we want to adapt the mesh, we typically repeat the above operations to calculate the diffusion coefficient and simply take the maximum diffusion coefficient at each node i,ji,j and in each direction li,ljli,lj. This will then produce a distorted grid that is able to represent all the solution variables as best it can.

For simplicity, the desired interpolation error ϵ0i+li,j+lji,j\epsilon_{0i+li,j+lj}^{i,j} can be defined isotropically (the same in each direction) and uniform across the whole domain, for example (although many variants of this simplification exist) with:

ϵ0i,jli,lj=ϵ0,(57)\epsilon_{0i,j}^{li,lj} = \epsilon_0, \tag*{(57)}

in which ϵ0\epsilon_0 is a scalar. The same is true of the minimum and maximum edge length scale scalars hmaxh_{max} and hminh_{min} and thus:

hmin,i,jli,lj=hmin,(58)h_{min,i,j}^{li,lj} = h_{min}, \tag*{(58)}
hmax,i,jli,lj=hmax.(59)h_{max,i,j}^{li,lj} = h_{max}. \tag*{(59)}

In addition, the curvature of the coordinate xx can be approximated as (as used in (55)):

∇ξ2x∣i,jli,lj=−(2xi,j−xi+li,j+lj−xi−li,j−lj)/(Δξi,jli,lj)2,\nabla_{\xi}^{2}x\big|_{i,j}^{li,lj} = -(2x_{i,j}-x_{i+li,j+lj}-x_{i-li,j-lj})/(\Delta\xi_{i,j}^{li,lj})^{2},
∀∈{−1,0,1} other than li=lj=0.(60)\forall\in\{-1,0,1\}\ \text{other than } li=lj=0. \tag*{(60)}

In order to evaluate ∇ξk∇ξx∣i,jli,lj\nabla_{\xi}k\nabla_{\xi}x\big|_{i,j}^{li,lj} we use the identity:

(∇ξk∇ξx)∣i,jli,lj=12(ki,jli,lj∇ξ2x∣i,jli,lj+∇ξ2(kx)∣i,jli,lj−xi,j∇ξ2k∣i,jli,lj),(\nabla_{\xi}k\nabla_{\xi}x)\big|_{i,j}^{li,lj} = \frac{1}{2}\left(k_{i,j}^{li,lj}\nabla_{\xi}^{2}x\big|_{i,j}^{li,lj}+\nabla_{\xi}^{2}(kx)\big|_{i,j}^{li,lj}-x_{i,j}\nabla_{\xi}^{2}k\big|_{i,j}^{li,lj}\right),
∀∈{−1,0,1} other than li=lj=0.(61)\forall\in\{-1,0,1\}\ \text{other than } li=lj=0. \tag*{(61)}

The diffusion operator ∇ξk∇ξ\nabla_{\xi}k\nabla_{\xi} at node i,ji,j is then discretised using:

∇ξk∇ξx∣i,j≈∑li=−11∑lj=−11(∇ξk∇ξx)∣i,jli,lj.(62)\nabla_{\xi}k\nabla_{\xi}x\big|_{i,j} \approx\sum_{li=-1}^{1}\sum_{lj=-1}^{1}(\nabla_{\xi}k\nabla_{\xi}x)\big|_{i,j}^{li,lj}. \tag*{(62)}

An alternative, computationally efficient version of this operator can also be used:

∇ξk∇ξx∣i,j≈(∇ξk∇ξx∣i,j)li,lj1,0+(∇ξk∇ξx∣i,j)li,lj0,1.(63)\nabla_{\xi_k}\nabla_{\xi}x\big|_{i,j} \approx\left(\nabla_{\xi_k}\nabla_{\xi}x\big|_{i,j}\right)^{1,0}_{l_i,l_j}+\left(\nabla_{\xi_k}\nabla_{\xi}x\big|_{i,j}\right)^{0,1}_{l_i,l_j}. \tag*{(63)}

This has the disadvantage that the cross terms that are used for controlling the element quality then require additional computational overheads to introduce, so we generally use this efficient approach without the element quality terms.

The resulting pseudo time-stepping approach discretised using forward Euler in time then becomes for each of the nodal/cell coordinates:

xi,j←xi,j+Δt∗∑li=−11∑lj=−11(∇ξk∇ξx)i,jli,lj.(64)x_{i,j} \leftarrow x_{i,j}+\Delta t^*\sum_{l_i=-1}^{1}\sum_{l_j=-1}^{1}\left(\nabla_{\xi_k}\nabla_{\xi}x\right)^{l_i,l_j}_{i,j}. \tag*{(64)}
yi,j←yi,j+Δt∗∑li=−11∑lj=−11(∇ξk∇ξy)i,jli,lj.(65)y_{i,j} \leftarrow y_{i,j}+\Delta t^*\sum_{l_i=-1}^{1}\sum_{l_j=-1}^{1}\left(\nabla_{\xi_k}\nabla_{\xi}y\right)^{l_i,l_j}_{i,j}. \tag*{(65)}

which forms an iterative method within a time step that starts from xi,j=xi,jnx_{i,j}=x^n_{i,j}, yi,j=yi,jny_{i,j}=y^n_{i,j}. The Δt∗\Delta t^* controls the pseudo time step size or step length associated with grid movement. For stability we limit this pseudo time step such that:

kmax⁡-stable,i,jli,lj=γstab(Δxi,jli,lj)2Δt∗,(66)k^{l_i,l_j}_{\max\text{-stable},i,j}=\gamma_{\mathrm{stab}}\frac{\left(\Delta x^{l_i,l_j}_{i,j}\right)^2}{\Delta t^*}, \tag*{(66)}

in which the factor γstab=0.25\gamma_{\mathrm{stab}}=0.25 is typically used for safety rather than the strict value of 1 and kmax⁡-stable,i,jli,ljk^{l_i,l_j}_{\max\text{-stable},i,j} is the maximum stable diffusion value for a given pseudo time step Δt∗\Delta t^*. Thus for stability the maximum stable diffusion size is:

Δt∗≤γstab(Δxi,jli,lj)2ki,jli,lj,∀i∈{1,2,…,Nx}, ∀j∈{1,2,…,Ny}(67)\Delta t^* \leq\gamma_{\mathrm{stab}}\frac{\left(\Delta x^{l_i,l_j}_{i,j}\right)^2}{k^{l_i,l_j}_{i,j}},\quad\forall i\in\{1,2,\ldots,N_x\},\ \forall j\in\{1,2,\ldots,N_y\} \tag*{(67)}

and ∀li∈{−1,0,1}\forall l_i\in\{-1,0,1\}, ∀lj∈{−1,0,1}\forall l_j\in\{-1,0,1\}.

Δti,j∗li,lj=γstab(Δxi,jli,lj)2ki,jli,lj.(68)\Delta t^{*l_i,l_j}_{i,j}=\gamma_{\mathrm{stab}}\frac{\left(\Delta x^{l_i,l_j}_{i,j}\right)^2}{k^{l_i,l_j}_{i,j}}. \tag*{(68)}

It is convenient to have a square in (Δxi,jli,lj)2\left(\Delta x^{l_i,l_j}_{i,j}\right)^2 as it avoids an additional square route in the calculation of Δxi,jli,lj\Delta x^{l_i,l_j}_{i,j} is a 2-norm or distance norm is used in its calculation. If one wants to take small pseudo-time steps because it helps with the non-linearity or produce a small grid velocity then one can use a much smaller γstab\gamma_{\mathrm{stab}} (e.g. γstab=0.01\gamma_{\mathrm{stab}} = 0.01) and not have too many iterations per time step. In this case the nodal updates become:

xi,j←xi,j+∑li=−11∑lj=−11Δti,j∗li,lj(∇ξk∇ξx)∣i,jli,lj,(69)x_{i,j} \leftarrow x_{i,j}+\sum_{l_i=-1}^{1}\sum_{l_j=-1}^{1}\Delta t^{*l_i,l_j}_{i,j}\left.(\nabla_{\xi} k\nabla_{\xi} x)\right|^{l_i,l_j}_{i,j}, \tag*{(69)}
yi,j←yi,j+∑li=−11∑lj=−11(Δti,j∗li,lj)(∇ξk∇ξy)∣i,jli,lj,(70)y_{i,j} \leftarrow y_{i,j}+\sum_{l_i=-1}^{1}\sum_{l_j=-1}^{1}\left(\Delta t^{*l_i,l_j}_{i,j}\right)\left.(\nabla_{\xi} k\nabla_{\xi} y)\right|^{l_i,l_j}_{i,j}, \tag*{(70)}

in which this iteration starts from initial guesses for xi,j,yi,jx_{i,j},y_{i,j} from a uniform grid spacing, say. The main problem with the above approach is the calculation of Δti,j∗li,lj\Delta t^{*l_i,l_j}_{i,j} in (68) as it has a the diffusion coefficient on the denominator which can result in too large a time step size. The next section fixes this issue.

Choosing the time pseudo time step size using the analogy with Jacobi iteration method

Here it is computationally more efficient to use the discretisation of the diffusion operator based on a simple 1D finite difference scheme to obtain the nodal coordinate updates:

xi,j←xi,j−1Di,j∑li=−11∑lj=−11(12(ki,j+ki+li,j+lj)xi,j−xi+li,j+lj(Δξi,jli,lj)2+12(ki,j+ki−li,j−lj)xi,j−xi−li,j−lj(Δξi,j−li,−lj)2),(71)\begin{aligned} x_{i,j} \leftarrow x_{i,j} - \frac{1}{D_{i,j}}\sum_{l_i=-1}^{1}\sum_{l_j=-1}^{1}\Biggl(&\frac{1}{2}(k_{i,j}+k_{i+l_i,j+l_j})\frac{x_{i,j}-x_{i+l_i,j+l_j}}{(\Delta\xi^{l_i,l_j}_{i,j})^2}\\ &+\frac{1}{2}(k_{i,j}+k_{i-l_i,j-l_j})\frac{x_{i,j}-x_{i-l_i,j-l_j}}{(\Delta\xi^{-l_i,-l_j}_{i,j})^2}\Biggr), \tag*{(71)} \end{aligned}
yi,j←yi,j−1Di,j∑li=−11∑lj=−11(12(ki,j+ki+li,j+lj)yi,j−yi+li,j+lj(Δξi,jli,lj)2+12(ki,j+ki−li,j−lj)yi,j−yi−li,j−lj(Δξi,j−li,−lj)2),(72)\begin{aligned} y_{i,j} \leftarrow y_{i,j} - \frac{1}{D_{i,j}}\sum_{l_i=-1}^{1}\sum_{l_j=-1}^{1}\Biggl(&\frac{1}{2}(k_{i,j}+k_{i+l_i,j+l_j})\frac{y_{i,j}-y_{i+l_i,j+l_j}}{(\Delta\xi^{l_i,l_j}_{i,j})^2}\\ &+\frac{1}{2}(k_{i,j}+k_{i-l_i,j-l_j})\frac{y_{i,j}-y_{i-l_i,j-l_j}}{(\Delta\xi^{-l_i,-l_j}_{i,j})^2}\Biggr), \tag*{(72)} \end{aligned}

with

Di,j=wd∑li=−11∑lj=−11(12ki,j+ki+li,j+lj(Δξi,jli,lj)2+12ki,j+ki−li,j−lj(Δξi,j−li,−lj)2),(73)D_{i,j}=w_d\sum_{l_i=-1}^{1}\sum_{l_j=-1}^{1}\left(\frac{1}{2}\frac{k_{i,j}+k_{i+l_i,j+l_j}}{(\Delta\xi^{l_i,l_j}_{i,j})^2}+\frac{1}{2}\frac{k_{i,j}+k_{i-l_i,j-l_j}}{(\Delta\xi^{-l_i,-l_j}_{i,j})^2}\right), \tag*{(73)}

in which wd>1w_d>1 under relaxes the Jacobi iteration and wd=1w_d=1 is the Jacobi method. This corresponds to a pseudo time step of

(Δti,j∗)=1Di,j.(74)(\Delta t^*_{i,j})=\frac{1}{D_{i,j}}. \tag*{(74)}

The more computationally efficient version of the equations above using (63) as the basis are:

xi,jn+1←xi,jn+1−1Di,jn∑ll=−10(12(ki,jn+ki+d(ll+1),j+d(ll−0)n)xi,jn−xi+d(ll+1),j+d(ll−0)n(Δξi,jd(ll+1),d(ll−0))2+12(ki,jn+ki−d(ll+1),j−d(ll−0)n)xi,jn−xi−d(ll+1),j−d(ll−0)n(Δξi,j−d(ll+1),−d(ll−0))2)(75)x_{i,j}^{n+1} \leftarrow x_{i,j}^{n+1} - \frac{1}{D_{i,j}^{n}} \sum_{ll=-1}^{0} \left( \frac{1}{2}\left(k_{i,j}^{n}+k_{i+d(ll+1),j+d(ll-0)}^{n}\right)\frac{x_{i,j}^{n}-x_{i+d(ll+1),j+d(ll-0)}^{n}}{\left(\Delta\xi_{i,j}^{d(ll+1),d(ll-0)}\right)^{2}} + \frac{1}{2}\left(k_{i,j}^{n}+k_{i-d(ll+1),j-d(ll-0)}^{n}\right)\frac{x_{i,j}^{n}-x_{i-d(ll+1),j-d(ll-0)}^{n}}{\left(\Delta\xi_{i,j}^{-d(ll+1),-d(ll-0)}\right)^{2}} \right) \tag*{(75)}
yi,jn+1←yi,jn+1−1Di,jn∑ll=−10(12(ki,jn+ki+d(ll+1),j+d(ll−0)n)yi,jn−yi+d(ll+1),j+d(ll−0)n(Δξi,jd(ll+1),d(ll−0))2+12(ki,jn+ki−d(ll+1),j−d(ll−0)n)yi,jn−yi−d(ll+1),j−d(ll−0)n(Δξi,j−d(ll+1),−d(ll−0))2)(76)y_{i,j}^{n+1} \leftarrow y_{i,j}^{n+1} - \frac{1}{D_{i,j}^{n}} \sum_{ll=-1}^{0} \left( \frac{1}{2}\left(k_{i,j}^{n}+k_{i+d(ll+1),j+d(ll-0)}^{n}\right)\frac{y_{i,j}^{n}-y_{i+d(ll+1),j+d(ll-0)}^{n}}{\left(\Delta\xi_{i,j}^{d(ll+1),d(ll-0)}\right)^{2}} + \frac{1}{2}\left(k_{i,j}^{n}+k_{i-d(ll+1),j-d(ll-0)}^{n}\right)\frac{y_{i,j}^{n}-y_{i-d(ll+1),j-d(ll-0)}^{n}}{\left(\Delta\xi_{i,j}^{-d(ll+1),-d(ll-0)}\right)^{2}} \right) \tag*{(76)}

in which d(l)=1d(l)=1 if l=0l=0 else d(l)=0d(l)=0 and with

Di,jn=wd∑ll=−10(12(ki,jn+ki+d(ll+1),j+d(ll−0)n)(Δξi,jd(ll+1),d(ll−0))2+12(ki,jn+ki−d(ll+1),j−d(ll−0)n)(Δξi,j−d(ll+1),−d(ll−0))2).(77)D_{i,j}^{n}=w_d\sum_{ll=-1}^{0}\left(\frac{1}{2}\frac{\left(k_{i,j}^{n}+k_{i+d(ll+1),j+d(ll-0)}^{n}\right)}{\left(\Delta\xi_{i,j}^{d(ll+1),d(ll-0)}\right)^{2}}+\frac{1}{2}\frac{\left(k_{i,j}^{n}+k_{i-d(ll+1),j-d(ll-0)}^{n}\right)}{\left(\Delta\xi_{i,j}^{-d(ll+1),-d(ll-0)}\right)^{2}}\right). \tag*{(77)}

Controlling the element quality

The element quality is controlled through diagonal diffusion terms and in 2D there is one plane of two diagonal diffusion coefficients and thus 2 possible additional diffusion terms. The amendments of the diffusion coefficient are as follows (leaving out the superscript nn for clarity):

ki,j1,1←ki,j1,1+α1max⁡{ki,j1,0,ki,j0,1}min⁡{200,max⁡{di+1,j+12 i−1,j−1/di+1,j−12 i−1,j+1−4,0}}+α2max⁡{ki,j1,0,ki,j0,1}min⁡{200,max⁡{di+1,j+12 i−1,j−1/(2max⁡{di+1,j+02 i−1,j+0,di+0,j+12 i+0,j−1})−1,0}},(78)k_{i,j}^{1,1}\leftarrow k_{i,j}^{1,1} +\alpha_{1}\max\{k_{i,j}^{1,0},k_{i,j}^{0,1}\}\min\{200,\max\{d_{i+1,j+1}^{2\,i-1,j-1}/d_{i+1,j-1}^{2\,i-1,j+1}-4,0\}\} +\alpha_{2}\max\{k_{i,j}^{1,0},k_{i,j}^{0,1}\}\min\{200,\max\{d_{i+1,j+1}^{2\,i-1,j-1}/(2\max\{d_{i+1,j+0}^{2\,i-1,j+0},d_{i+0,j+1}^{2\,i+0,j-1}\})-1,0\}\}, \tag*{(78)}
ki,j1,−1←ki,j1,−1+α1max⁡{ki,j1,0,ki,j0,1}min⁡{200,max⁡{di+1,j−12 i−1,j+1/di+1,j+12 i−1,j−1−4,0}}+α2max⁡{ki,j1,0,ki,j0,1}min⁡{200,max⁡{di+1,j−12 i−1,j+1/(2max⁡{di+1,j+02 i−1,j+0,di+0,j+12 i+0,j+1})−1,0}},(79)k_{i,j}^{1,-1}\leftarrow k_{i,j}^{1,-1} +\alpha_{1}\max\{k_{i,j}^{1,0},k_{i,j}^{0,1}\}\min\{200,\max\{d_{i+1,j-1}^{2\,i-1,j+1}/d_{i+1,j+1}^{2\,i-1,j-1}-4,0\}\} +\alpha_{2}\max\{k_{i,j}^{1,0},k_{i,j}^{0,1}\}\min\{200,\max\{d_{i+1,j-1}^{2\,i-1,j+1}/(2\max\{d_{i+1,j+0}^{2\,i-1,j+0},d_{i+0,j+1}^{2\,i+0,j+1}\})-1,0\}\}, \tag*{(79)}

in which the distances squared across the grid stencil (say 3×33\times3 stencil) are defined:

di+li,j+lj2 i+lii,j+ljj=(xi+li,j+lj−xi+lii,j+ljj)2+(yi+li,j+lj−yi+lii,j+ljj)2.(80)d_{i+li,j+lj}^{2\,i+lii,j+ljj}=(x_{i+li,j+lj}-x_{i+lii,j+ljj})^{2}+(y_{i+li,j+lj}-y_{i+lii,j+ljj})^{2}. \tag*{(80)}

The default values are α1=α2=0.25\alpha_{1}=\alpha_{2}=0.25. The values −4-4 and −1-1 in the equations above are there to avoid the first term and the second term having too much influence when the aspect ratios are less than 2 and 1 respectively. The distances across a stencil are represented with different coloured terms within the equations above and are shown diagrammatically in Figure 2. In the absence of a suitable boundary values of the diffusion coefficients that controls the skewness of the mesh we set all the additions to the diffusion coefficient to zero on the boundary and one node into the domain.

Diagram showing how the grid or stencil lengths are used

Figure 2. Diagram showing how the grid or stencil lengths are used when combined with Equations (78) and (79) in order to determine the skewness of the grid or stencil. The equations are coloured to correspond to the lengths shown in the diagram.

Algorithm 1 Static mesh adaptation via diffusion and interpolation error

  1. Input: Initial grid x0\mathbf{x}^{0}, solution history {ψn}\{\psi^{n}\}, target error ϵ0\epsilon_{0}, bounds hmin⁡,hmax⁡h_{\min},h_{\max}

  2. Initialise: Set x←x0\mathbf{x}\leftarrow\mathbf{x}^{0}

  3. Step 1: Compute interpolation error Ei,jli,ljE_{i,j}^{l_i,l_j}

  4. for each node (i,j)(i,j) and stencil direction (li,lj)(l_i,l_j) do

  5. Compute second derivative for three variables ψ1=h+H\psi_{1}=h+H, ψ2=(h+H)u\psi_{2}=(h+H)u and ψ3=(h+H)v\psi_{3}=(h+H)v

∂2ψNn∂ξ2≈2ψN,i,jn−ψN,i+li,j+ljn−ψN,i−li,j−ljn(Δξli,lj)2∀N∈{1,2,3}∀li,lj∈{−1,0,1},\frac{\partial^{2}\psi_{N}^{n}}{\partial\xi^{2}}\approx\frac{2\psi_{N,i,j}^{n}-\psi_{N,i+l_i,j+l_j}^{n}-\psi_{N,i-l_i,j-l_j}^{n}}{(\Delta\xi^{l_i,l_j})^{2}}\quad\forall N\in\{1,2,3\}\quad\forall l_i,l_j\in\{-1,0,1\},
  1. Compute maximum over time

Ei,jli,lj=(max⁡n{max⁡N∣∂2ψNn∂ξ2∣})1R∀N∈{1,2,3}E_{i,j}^{l_i,l_j}=\left(\max_{n}\left\{\max_{N}\left|\frac{\partial^{2}\psi_{N}^{n}}{\partial\xi^{2}}\right|\right\}\right)^{\frac{1}{R}}\quad\forall N\in\{1,2,3\}
  1. Step 2: Compute desired mesh spacing hi,jli,ljh_{i,j}^{l_i,l_j}

  2. for each node (i,j)(i,j) and direction (li,lj)(l_i,l_j) do

hi,jli,lj=(Δxi,jli,lj)2ϵ0γEi,jli,lj∀li,lj∈{−1,0,1}hi,jli,lj←min⁡{max⁡{hi,jli,lj,hmin⁡},hmax⁡}h_{i,j}^{l_i,l_j}=\sqrt{\frac{(\Delta x_{i,j}^{l_i,l_j})^{2}\epsilon_{0}}{\gamma E_{i,j}^{l_i,l_j}}}\quad\forall l_i,l_j\in\{-1,0,1\}\qquad h_{i,j}^{l_i,l_j}\leftarrow\min\{\max\{h_{i,j}^{l_i,l_j},h_{\min}\},h_{\max}\}
  1. Step 3: Define diffusion coefficient

  2. for each node (i,j)(i,j) and direction (li,lj)(l_i,l_j) do

ki,jli,lj=1hi,jli,ljk_{i,j}^{l_i,l_j}=\frac{1}{h_{i,j}^{l_i,l_j}}
  1. Step 4: Smooth diffusion coefficient

  2. for each node (i,j)(i,j) do

ki,jli,lj←∑ii=−11∑jj=−11Smii,jjki+ii,j+jjli,ljSm←Mξk_{i,j}^{l_i,l_j}\leftarrow\sum_{ii=-1}^{1}\sum_{jj=-1}^{1}S_{m}^{ii,jj}k_{i+ii,j+jj}^{l_i,l_j}\qquad S_{m}\leftarrow M_{\xi}
  1. Step 5: Interpolate kk onto physical grid

  2. Interpolate diffusion coefficients from computational grid to current grid positions

  3. Step 6: Solve diffusion equation (pseudo-time)

  4. repeat

  5. for each node (i,j)(i,j) do

  6. Compute diffusion operator (∇ξk∇ξx)i,j(\nabla_{\xi}k\nabla_{\xi}\mathbf{x})_{i,j}

  7. Update node positions xi,j←xi,j+Δt∗(∇ξk∇ξx)i,j\mathbf{x}_{i,j}\leftarrow\mathbf{x}_{i,j}+\Delta t^{*}(\nabla_{\xi}k\nabla_{\xi}\mathbf{x})_{i,j}

  8. Update Δt∗\Delta t^{*} for stability if required

  9. Re-interpolate kk onto updated grid

  10. until convergence of x\mathbf{x}

  11. Output: Adapted mesh x\mathbf{x}

Remarks. This formulation ensures that regions with large solution curvature (e.g. near shocks, wetting–drying fronts, or strong velocity gradients) receive higher resolution, while smooth regions are coarsened. The resulting diffusion-driven mesh adaptation provides a physically consistent and computationally efficient mechanism for generating distorted structured grids.

Results

To validate the proposed distorted structured grid formulation within the Neural Physics framework, the Carlisle 2005 flooding event is simulated. The results are compared against observational data and numerical predictions obtained using Neural Physics on regular grids. Figure 3 presents an overview of the case setup. Figure 3a shows the flood extent corresponding to time when the Eden inlet discharge was at a maximum (1200 m3/s1200\ \mathrm{m^3/s}), which determines the value of our particular mass source tensor shn+1s_h^{n+1} in Equation (23), together with the locations of the sampling points (Sheepmount, Botcherby Bridge and Denton Holme). Figure 3b illustrates the inflow rates of the three rivers (Eden, Petteril and Caldew). Figure 3c and (d) display the two distorted structured grids generated using a diffusion equation to statically adapt the resolution of the structured grid. The distorted grid picks out the river channels and regions of strong hydraulic gradients, demonstrating the capability of the diffusion-based static mesh adaptation to concentrate resolution in important areas while preserving the bathymetry without loss of physical information. The details of the numerical setup and distorted mesh generation are summarised in Table 1 and Table 2. Six models (C—H) are tested on a range of distorted meshes, while two models (A and B) are evaluated on regular grids. All other numerical settings are kept identical to ensure a consistent comparison. In addition, simulations on a uniformly refined mesh are performed to provide reference (baseline) results. The grid distortion will not change the original bathymetry (Geometry conservation) thus preserving the bathymetry without loss of physical information and holding this bathymetry information on a uniform structured grid and when needed this information is interpolated onto the distorted grid.

Neural Physics (Model)ConvFEMGrid size (m)MeshAdaption ratio (hmax/hminh_{max}/h_{min})Order of root (RR)Grid points (nx×nyn_x \times n_y)Time step (s) MeshTime step (s) Fluid
BaselineLinear2.5Regular——1902×1222—0.125
ALinear5.0Regular——951×611—0.25
BQuadratic5.0Regular——951×611—0.25
CLinear5.0Distort5.03951×6110.050.25
DQuadratic5.0Distort5.03951×6110.050.25
ELinear5.0Distort5.02951×6110.050.25
FQuadratic5.0Distort5.02951×6110.050.25
GLinear5.0Distort5.01951×6110.050.25
HQuadratic5.0Distort5.01951×6110.050.25

Table 1. Six Neural Physics models used for the 2D Carlisle flooding simulation. The RR refers to the nn–th root as described in Algorithm 1 Ei,jli,lj=(max⁡n{max⁡N∣∂2ψNn∂σ2∣})1RE_{i,j}^{l_i,l_j} = \left(\max_n\left\{\max_N\left|\frac{\partial^2 \psi_N^n}{\partial\sigma^2}\right|\right\}\right)^{\frac{1}{R}}.

SurfaceVelocity (u,v)T(u,v)^TWater depth η=h+H\eta= h + H
Westu=0u = 0, ∂v/∂x=0\partial v/\partial x = 0η=0\eta= 0
Eastu=0u = 0, ∂v/∂x=0\partial v/\partial x = 0η=0\eta= 0
Northv=0v = 0, ∂u/∂y=0\partial u/\partial y = 0η=0\eta= 0
Southv=0v = 0, ∂u/∂y=0\partial u/\partial y = 0η=0\eta= 0

Table 2. Boundary conditions applied in the 2D Carlisle flooding simulation, specifying the velocity components and water depth constraints imposed on each domain boundary.

Flood extent and sampling points

(a)

River inflow curves

(b)

Distorted grid

(c)

Distorted grid

(d)

Figure 3. Carlisle 2005 flooding: (a) the flood extent when the Eden inlet was at its maximum flow rate (1200 m/s), with positions and names of the sampling points indicated; (b) the three rivers and topology of the area being modelled; (c) and (d) distorted grid (Models C-F described in Table 1) generated by the moving the nodes according to a diffusion equation in response to the interpolation error.

Figure 4 presents Models C-H (See Table 1) respectively for the Carlisle flooding simulation. Sub-figures (a)–(c) present the cumulative interpolation error obtained by integrating errors over the entire time of a structured grid simulation and taking different order of root (See Equation Ei,jli,lj=(max⁡n{max⁡N∣∂2ψNn∂ξ2∣})1RE_{i,j}^{l_i,l_j} = \left(\max_n\left\{\max_N\left|\frac{\partial^2\psi_N^n}{\partial\xi^2}\right|\right\}\right)^{\frac{1}{R}} in Algorithm 1). Areas of large error correspond to the location of rivers and their surrounding areas, which is where flooding will occur and the water velocities will be at their highest. There are mainly only two colours in Figure 4 (a) because using a cube root (Models C and D R=3R = 3) for the production of the error measure may lead to a more uniform error distribution in inundated regions. With this error field, we apply the method of distorting the grid as described in § 2. Sub-figures 4 (d)–(l) illustrate that as the diffusion algorithm progresses, the grid gradually deforms, concentrating resolution in regions of higher error while smoothing and coarsening in regions of lower error. This behaviour demonstrates that the proposed approach is able to identify areas requiring higher resolution in a physically consistent manner, suggesting that method is robust. The distorted grid shown in Sub-figures 4 (j)–(l) is used to run the simulation again. Details of the numerical set up: time step, the structured grid size, the min and max node spacing in the distorted grid, and the mass source, are shown in Table 1 and Table 2.

Panels: (a) Static interpolate error $R = 3$; (b) Static interpolate error $R = 2$; (c) Static interpolate error $R = 1$; (d) 25,000 iterations; (e) 25,000 iterations; (f) 25,000 iterations; (g) 50,000 iterations; (h) 50,000 iterations; (i) 50,000 iterations; (j) 150,000 iterations; (k) 150,000 iterations; (l) 150,000 iterations

Figure 4. Static mesh distortion driven by the cumulative error field (a) obtained over the full simulation. (b)-(f), evolution of the distorted mesh after different Jacobi iterations (25,000 to 150,000) of solving diffusion equation for initial regular uniform coordinates. The mesh is used in Models C–H depicted in Table 1.

Figure 5 compares the evolution of the grid size distributions for Models C/D (R=3R = 3), Models E/F (R=2R = 2) and Models G/H (R=1R = 1) as listed in Table 1 after 5,000, 25,000, 50,000 and 100,000 iterations for the 2D Carlisle flooding simulation. In each figure, the width of bar WbW_b is represented as Wb=hmax⁡−hmin⁡W_b = h_{\max} - h_{\min}.

At 5,000 iterations, both mesh configurations exhibit a narrow distribution concentrated around h=5h = 5 m, indicating that they remain close to the initial uniform grid. As the iterations increase, the distributions for both models progressively broaden, with an increasing proportion of both smaller and larger grid sizes.

From 25,000 to 50,000 iterations, this trend becomes more significant, where the right tail develops towards larger grid size and the left side extends towards smaller cells. This indicates that the proposed distorted mesh capability can effectively redistribute cell sizes through local stretching and produce a wider range of spatial resolution across the domain, enhancing the accuracy of the numerical solution in capturing fine-scale features. At 100,000 iterations, the overall shape of the distribution becomes more stable in both models, suggesting that the solution of distorting mesh is converged. Importantly, despite the significant change in the shape of the mesh size distribution, the mean grid size remains consistently close to 5 m at all stages. This demonstrates that the distortion is conservative with respect to the global mesh size, enabling mesh adaptation while maintaining the overall average resolution.

On the other hand, the differences among the three error formulations are present but not significant. All three cases show the same overall trend, a progressive broadening of the distribution away from the initial peak at h=5h = 5 m as the mesh distortion develops. Interestingly, at later iterations, Models G/H (R=1R = 1) exhibit a slightly wider spread towards both smaller and larger grid sizes, while Models E/F (R=2R = 2) show an intermediate behaviour and Models C/D (R=3R = 3) remain relatively more concentrated around the mean value. This suggests that reducing R could lead to a slightly stronger redistribution of mesh resolution, although the overall differences between the three formulations remain moderate. Overall, the results indicate that the choice of RR controls the final range of cell sizes and thus provides a practical means of adjusting the aggressiveness of the mesh adaptation procedure.

Histogram of grid size distribution at 5,000 iterations

(a) 5,000 iterations

Histogram of grid size distribution at 25,000 iterations

(b) 25,000 iterations

Histogram of grid size distribution at 50,000 iterations

(c) 50,000 iterations

Histogram of grid size distribution at 100,000 iterations

(d) 100,000 iterations

Figure 5. Histograms of grid size distribution during the mesh distortion process for the 2D Carlisle flooding simulation at (a) 5,000, (b) 25,000, (c) 50,000, and (d) 100,000 iterations. The results are obtained from Models C to H as depicted in Table 1.

Figure 6 compares simulated water depth in the Denton Holme region using six Neural Physics models (Models A-F summarised in Table 1) on regular and distorted grids. The results are shown at three different time levels which are after 20 hours (top row), 40 hours (middle row) and 60 hours (bottom row) of flooding. Regarding the regular uniform grid (Models A and B), both linear and quadratic discretisations capture the overall flooding pattern, however, small-scale features near river banks and urban structures are less sharply resolved. This observation has been reported in [34]. To see the small scale features we have zoomed in on them in Figure 8 and Figure 11. For the distorted grid solution (Models C to F), the water depth distribution exhibits improved spatial definition, particularly along narrow flow paths and wetting-drying interfaces. Moreover, the distorted grid leads to a more noticeable change in the predicted water depth near the river (particularly after 60 hours of flooding) when using the quadratic ConvFEM model (Models D and F) compared to the linear ConvFEM model (Models C and E).

Simulated water depth in one focusing area (Denton Holme) on regular and distorted grid using Linear and Quadratic ConvFEM models

Figure 6. Simulated water depth in one focusing area (Denton Holme) on regular and distorted grid using Linear and Quadratic ConvFEM models. The results are shown at three different time levels, top, 20 h; middle, 40 h; bottom, 60 h.

Absolute, relative, signed, and gradient differences for the Linear ConvFEM model

(a) Linear ConvFEM

Absolute, relative, signed, and gradient differences for the Quadratic ConvFEM model

(b) Quadratic ConvFEM

Figure 8. Spatial distribution of differences in water depth between regular and distorted grids using Linear and Quadratic ConvFEM models. Absolute, relative, signed, and gradient magnitude differences are shown for two representative regions, Denton Holme and Botcherby Bridge, after 60 hours of flooding.

Spatial distribution of differences in water speed between regular and distorted grids using Linear and Quadratic ConvFEM models

Figure 11. Spatial distribution of differences in water speed between regular and distorted grids using Linear and Quadratic ConvFEM models. Absolute, relative, signed, and gradient magnitude differences are shown for two representative regions, Denton Holme and Botcherby Bridge, after 60 hours of flooding.

A similar analysis is performed for another flooded area (Botcherby Bridge), as shown in Figure 7. The results present the water depth distributions obtained using the linear and quadratic ConvFEM on both regular and distorted grids. Three representative time levels (20 hours, 40 hours and 60 hours) are selected for comparison. The effect of the distorted grid on the predicted water depth near the river is more pronounced for the quadratic ConvFEM model (comparing Models D and F to Model B) than for the linear ConvFEM model (comparing Models C and E to Model A), particularly after 40 hours of flooding, resulting in relatively larger simulated water depths.

Simulated water depth in the area around Botcherby Bridge on regular and distorted grids using Linear and Quadratic ConvFEM models

Figure 7. Simulated water depth in the area around Botcherby Bridge on regular and distorted grids using Linear and Quadratic ConvFEM models. The results are shown at three different time levels: top, 20 h; middle, 40 h; bottom, 60 h.

Figure 8 presents a detailed comparison of the water depth fields obtained using regular and distorted grids, discussed through absolute, relative, signed, and gradient magnitude differences for both Linear (Model A vs Model C) and Quadratic (Model B vs Model D) ConvFEM models. Two representative regions, Denton Holme and Botcherby Bridge, are selected to highlight localised behaviours after 60 hours of flooding. The absolute differences ∣hdis−hreg∣|h_{dis} - h_{reg}| indicate that the overall discrepancies remain spatially localised, with the majority of the domain exhibiting minimal variation between the two grid configurations. Interestingly, larger differences are concentrated along river channels and flood fronts, suggesting that the distorted grid primarily influences dynamically active regions. The relative difference ∣hdis−hreg∣hreg\frac{|h_{dis}-h_{reg}|}{h_{reg}} further emphasises these localised effects, revealing that even where absolute differences are small, noticeable variations can arise in regions of shallow water depth. This highlights the sensitivity of low-depth areas to grid adaptation and suggests that the distorted grid enhances resolution in these regions. The signed difference hdis−hregh_{dis} - h_{reg} shows a clear pattern of local redistribution of water depth with alternating positive and negative regions. These variations are spatially localised and do not exhibit a consistent domain-wide offset, suggesting that the distorted grid primarily modifies the solution locally while preserving the overall flooding pattern. The gradient difference ∇hdis−∇hreg\nabla h_{dis} - \nabla h_{reg} provides additional insight into the underlying mechanism of these discrepancies. Differences are predominantly observed in regions with strong spatial gradients of water depth, such as flow boundaries and rapidly varying free-surface regions. This demonstrates that the distorted grid enhances the representation of sharp gradients and local flow features, which are otherwise smoothed on the regular grid. Comparing the Linear and Quadratic ConvFEM results, the Quadratic model exhibits more pronounced and structured differences, particularly in gradient-sensitive regions, indicating its increased sensitivity to mesh adaptation and its ability to capture finer-scale flow variations.

Following the analysis of water depth, we examine the impact of the static distorted grid on the flow velocity. Figure 9 and Figure 10 present the simulated water speed in two areas, Denton Holme and Botcherby Bridge. The same Neural Physics models and time levels are selected for comparison as in Figure 6 and Figure 7. Consistent with the results of the predicted water depth, the results obtained on the distorted grid indicate that using the distorted grid enables more detailed flow structures to be captured near in the areas near rivers.

Results for water speed in the Denton Holme area on regular and distorted grids using Linear and Quadratic ConvFEM models

Figure 9. Results for water speed in the Denton Holme area on regular and distorted grids using Linear and Quadratic ConvFEM models. The results are shown at three different time levels, top, 20 h; middle, 40 h; bottom, 60 h.

Water speed in the area surrounding Botcherby Bridge on regular and distorted grids using Linear and Quadratic ConvFEM models

Figure 10. Water speed in the area surrounding Botcherby Bridge on regular and distorted grids using Linear and Quadratic ConvFEM models. The results are shown at three different time levels, top, 20 h; middle, 40 h; bottom, 60 h.

Figure 11 presents the spatial distribution of differences in flow velocity between the regular and distorted grids, using the same set of metrics as for water depth, including absolute, relative, signed, and gradient magnitude differences. Two representative regions, Denton Holme and Botcherby Bridge, are analysed after 60 hours of flooding. Compared to the water depth results (Figure 8), the velocity differences exhibit more pronounced and coherent spatial structures. The absolute differences ∣Udis−Ureg∣|U_{dis} - U_{reg}| are primarily concentrated along the main flow pathways, particularly within river channels, junctions, and regions of flow acceleration and deceleration. Although the magnitude of absolute differences is not directly comparable between water depth and velocity, the velocity field exhibits more coherent and spatially structured variations, indicating a stronger sensitivity to mesh distortion in dynamically active regions. The relative difference ∣Udis−Ureg∣Ureg\frac{|U_{dis}-U_{reg}|}{U_{reg}} highlights significant variations in low-velocity areas, where small absolute changes can lead to amplified relative discrepancies. This effect is particularly evident near floodplain regions and shallow flow zones, reflecting the increased sensitivity of velocity to local mesh adaptation. The signed difference Udis−UregU_{dis} - U_{reg} reveals a pattern of local redistribution, with both positive and negative deviations distributed along flow structures. The results illustrate that the differences are primarily localised along flow structures, rather than forming a consistent domain-wide offset, suggesting that the distorted grid mainly introduces local redistribution of the velocity field. The gradient difference ∇Udis−∇Ureg\nabla U_{dis} - \nabla U_{reg} further highlights that discrepancies are concentrated in regions of strong velocity gradients, particularly along shear layers, channel edges, and zones of flow acceleration. These regions correspond to dynamically active areas where sharp spatial variations occur. The distorted grid produces more pronounced gradients in these locations, indicating an improved ability to resolve local flow features and sharp velocity transitions that appear more diffused on the regular grid. A comparison between the Linear and Quadratic ConvFEM models shows that the Quadratic formulation produces more structured and pronounced differences, particularly in gradient-sensitive regions. This suggests that higher-order discretisation benefits more from the adaptive characteristics of the distorted grid, leading to improved representation of fine-scale flow dynamics.

To quantify the improvement seen when using distorted grids, Figure 12 compares the time series of predicted water depth (68 hours in total) at the three sampling locations (Sheepmount, Botcherby Bridge and Denton Holme) with observations and a solution generated by the TRITON model [42]. Two Neural Physics (linear and quadratic ConvFEM) models are applied on regular and distorted grids, of which details are summarised in Table 1. At Sheepmount (top), all models capture the increase of the water level and the timing of the peak level accurately. The distorted grid simulations slightly reduce the overestimation of the peak seen in the regular grid and linear ConvFEM simulation. The quadratic ConvFEM models provide improved agreement with observations as the water level recedes. At Botcherby Bridge (middle), the differences between simulations become more significant during the peak flow period (from 35 hours to 45 hours). The distorted grid tends to moderate peak water-depth predictions and improves agreement with the observations. In addition, the quadratic discretisation reduces numerical oscillations and more accurately reproduces the shape of the observed water depth profile.

Numerical prediction of water depth versus time at three sampling points

Figure 12. Numerical prediction of water depth versus time at three sampling points (Sheepmount, Botcherby Bridge and Denton Holme) on regular and distorted grid using Linear and Quadratic ConvFEM models. The details of the models considered are summarised in Table 1.

At Denton Holme (bottom), where complex urban topography strongly influences the flow dynamics, the advantages of the distorted grid become more evident. The distorted mesh reduces discrepancies either side of the peak water level and the quadratic distorted grid shows the closest overall agreement with the observations. These improvements are consistent with the mesh analysis presented earlier: the distorted grids redistribute resolution towards dynamically important regions, enabling better representation of local flow features such as rapid water level changes and peak dynamics. In general, the distorted structured grid maintains numerical stability and produces results comparable to or better than the regular grid, particularly when combined with quadratic ConvFEM discretisation.

Computational Performance

The computational cost of NN4PDE simulations scales approximately with the number of finite-element nodes and the number of Jacobi iterations used for solving the free-surface height. The total simulation time can therefore be approximated as proportional to the number of nodes, the number of time steps, and the iterations performed within each time step. This leads to the empirical model

simulation duration=(1.3)p−1NITN(Ms+JFs),(81)\text{simulation duration} = (1.3)^{p-1} \mathcal{N}_{I} \mathcal{T} \mathcal{N} (M_s + J F_s), \tag*{(81)}

where pp is the polynomial order (p=1p = 1 linear, p=2p = 2 quadratic), NI\mathcal{N}_{I} is the number of nonlinear iterations per time step (typically NI=2\mathcal{N}_{I} = 2), T\mathcal{T} is the number of time steps, N=NxNy\mathcal{N} = N_xN_y is the number of FE nodes, and JJ is the number of Jacobi iterations used for the free-surface solve. The constants MsM_s and FsF_s represent the computational cost per node for the main solver and the Jacobi update respectively, and depend on the GPU architecture. These coefficients are approximately: NVIDIA A100 GPU (Ms=2.76×10−9 sM_s = 2.76 \times10^{-9}\,\mathrm{s}, Fs=9.2×10−11 sF_s = 9.2 \times10^{-11}\,\mathrm{s}); NVIDIA H100 GPU (Ms=1.20×10−9 sM_s = 1.20 \times10^{-9}\,\mathrm{s}, Fs=4.0×10−11 sF_s = 4.0 \times10^{-11}\,\mathrm{s}); NVIDIA H200 GPU (Ms=1.00×10−9 sM_s = 1.00 \times10^{-9}\,\mathrm{s}, Fs=3.5×10−11 sF_s = 3.5 \times10^{-11}\,\mathrm{s}). These coefficients were obtained by timing simulations of the Carlisle flooding benchmark using different numbers of Jacobi iterations and solving for the proportionality constants. For the Carlisle case considered here (T=306000\mathcal{T} = 306000, N=951×611=581061\mathcal{N} = 951 \times611 = 581061, quadratic elements, NI=2\mathcal{N}_{I} = 2, J=1J = 1), the model predicts a runtime of approximately 24 min on an A100 GPU, compared with the measured runtime of 21.3 min.

Discussion and Conclusions

This study presents a convolution-based Neural Physics framework for solving the shallow water equations on distorted structured grids. By formulating the governing equations in a uniform computational space and incorporating metric terms through the Jacobian transformation, the method preserves conservation while enabling efficient structured-grid computation.

The advection operator is derived in both conservative and non-conservative forms, allowing flexibility depending on stability requirements. A nonlinear Petrov-Galerkin dissipation term provides adaptive stabilisation, particularly important in advection-dominated and distorted-grid regimes. Two approximations for the Laplacian operator were introduced to accelerate pressure and diffusion solves while retaining acceptable accuracy. Validation against the Carlisle 2005 flooding benchmark demonstrates that distorted meshes can achieve accuracy comparable to regular grids while enabling resolution concentration in regions of interest.

The convolutional structure of the discretised operators makes the framework naturally compatible with GPU acceleration and Neural Physics implementations. Furthermore, the static mesh adaptation strategy based on diffusion principles provides a systematic approach to resolution control without sacrificing structured-grid efficiency.

Overall, this work demonstrates that distorted structured grids combined with convolutional operators provide a powerful and scalable methodology for geophysical flow simulation. The framework offers a promising foundation for future extensions to fully coupled atmospheric and oceanic systems, dynamic mesh adaptation, and hybrid physics-informed machine learning solvers.

Funding sources

The authors would like to acknowledge the following UKRI grants: GP4Streets, “Pioneering Climate Adaptation in Urban Environments” (APP44894 / UKRI 1281); AI4Urban-Health, “AI Solutions to Urban Health Using a Place-Based Approach” (APP55547 / UKRI 1241); and AI-Respire, “AI for personalised respiratory health and pollution (EP/Y018680/1). Support from Imperial-X’s Eric and Wendy Schmidt Centre for AI in Science (a Schmidt Futures program) is gratefully acknowledged.

References

  1. [1]J. J. Stoker, Water Waves: The Mathematical Theory with Applications, Interscience, 1957.
  2. [2]E. F. Toro, Shock-Capturing Methods for Free-Surface Shallow Flows, Wiley, 2001.
  3. [3]J. Teng, A. Jakeman, J. Vaze, B. F. W. Croke, D. Dutta, S. Kim, Flood inundation modelling: A review of methods, Environmental Modelling & Software 90 (2017) 201–216.
  4. [4]S. Zanardo, J. L. Salinas, An Introduction to Flood Modeling for Catastrophe Risk Management, WIREs Water 9 (2022) e1568. doi:10.1002/wat2.1568.DOI
  5. [5]R. Spiekermann, S. Kienberger, J. Norton, F. Briones, J. Weichselgartner, The Disaster-Knowledge Matrix – Reframing and Evaluating the Knowledge Challenges in Disaster Risk Reduction, International Journal of Disaster Risk Reduction 13 (2015) 96–108. doi:10.1016/j.ijdrr.2015.05.002.DOI
  6. [6]J. Henonin, B. Russo, O. Mark, P. Gourbesville, Real-Time Urban Flood Forecasting and Modelling: A State of the Art, Journal of Hydroinformatics 15 (2013) 717–736. doi:10.2166/hydro.2013.132.DOI
  7. [7]V. Casulli, Semi-implicit finite difference methods for the two-dimensional shallow water equations, Journal of Computational Physics 86 (1990) 56–74. doi:10.1016/0021-9991(90)90091-E.DOI
  8. [8]L. Lundgren, K. Mattsson, An efficient finite difference method for the shallow water equations, Journal of Computational Physics 422 (2020) 109784. doi:10.1016/j.jcp.2020.109784.DOI
  9. [9]R. LeVeque, Finite Volume Methods for Hyperbolic Problems, Cambridge University Press, 2002.DOI
  10. [10]J. Donea, A. Huerta, Finite Element Methods for Flow Problems, John Wiley & Sons, Chichester, 2003. doi:10.1002/0470013826.DOI
  11. [11]B. Cockburn, C.-W. Shu, The development of discontinuous Galerkin methods, SIAM Review 42 (2000) 463–487.DOI
  12. [12]H. Lee, Discontinuous Galerkin discretization of shallow water equations in implicit primal formulations for turbulent stresses, Journal of Mechanical Science and Technology 35 (2021) 2471–2479. doi:10.1007/s12206-021-0520-7.DOI
  13. [13]P. G. LeFloch, M. D. Thanh, A Godunov-type method for the shallow water equations with discontinuous topography in the resonant regime, Journal of Computational Physics 230 (2011) 7631–7660. doi:10.1016/j.jcp.2011.06.014.
  14. [14]R. Bernetti, V. A. Titarev, E. F. Toro, Exact solution of the Riemann problem for the shallow water equations with discontinuous bottom geometry, Journal of Computational Physics 227 (2008) 3212–3243. doi:10.1016/j.jcp.2007.10.012.
  15. [15]J. Shaw, G. Kesserwani, J. Neal, P. Bates, M. K. Sharifian, LISFLOOD-FP 8.0: the new discontinuous Galerkin shallow-water solver for multi-core CPUs and GPUs, Geoscientific Model Development 14 (2021) 3577–3602. doi:10.5194/gmd-14-3577-2021.
  16. [16]S. Bunya, E. J. Kubatko, J. J. Westerink, C. Dawson, A wetting and drying treatment for the Runge–Kutta discontinuous Galerkin solution to the shallow water equations, Computer Methods in Applied Mechanics and Engineering 198 (2009) 1548–1562. doi:10.1016/j.cma.2009.01.002.
  17. [17]X. Xia, Q. Liang, A GPU-accelerated Smoothed Particle Hydrodynamics (SPH) model for the shallow water equations, Environmental Modelling & Software 75 (2016) 28–43. doi:10.1016/j.envsoft.2015.10.010.
  18. [18]L. S. Smith, Q. Liang, Towards a generalised GPU/CPU shallow-flow modelling tool, Computers & Fluids 88 (2013) 334–343. doi:10.1016/j.compfluid.2013.09.018.DOI
  19. [19]A. Lacasta, M. Morales-Hernández, J. Murillo, P. García-Navarro, GPU implementation of the 2D shallow water equations for the simulation of rainfall/runoff events, Environmental Earth Sciences 74 (2015) 7295–7305. doi:10.1007/s12665-015-4705-7.DOI
  20. [20]M. Berger, P. Colella, Local adaptive mesh refinement for shock hydrodynamics, Journal of Computational Physics 82 (1989) 64–84.DOI
  21. [21]C. C. Pain, A. P. Umpleby, C. R. E. De Oliveira, A. J. H. Goddard, Adaptive unstructured mesh methods for CFD, International Journal for Numerical Methods in Fluids 34 (2001) 327–355.
  22. [22]K. Estrem, D. Moxey, S. J. Sherwin, J. Peir’o, Efficient anisotropic mesh adaptivity for fluid dynamics simulations, Computer Methods in Applied Mechanics and Engineering 361 (2020) 112761. doi:10.1016/j.cma.2019.112761.
  23. [23]W. Huang, R. D. Russell, Adaptive moving mesh methods, Applied Numerical Mathematics 61 (2011) 873–889.DOI
  24. [24]F. Alauzet, A. Loseille, Parallel anisotropic mesh adaptation, Computers & Fluids 39 (2010) 1760–1775.
  25. [25]A. Loseille, F. Alauzet, Anisotropic mesh adaptation for CFD computations, Journal of Computational Physics 230 (2011) 1621–1645.
  26. [26]G. Kesserwani, M. K. Sharifan, (Multi)wavelet-based Godunov-type simulators of flood inundation: Static versus dynamic adaptivity, Advances in Water Resources 171 (2023) 104357. doi:10.1016/j.advwatres.2022.104357.DOI
  27. [27]J. F. Thompson, Z. U. A. Warsi, C. Mastin, Numerical Grid Generation: Foundations and Applications, North-Holland, 1985.
  28. [28]J. F. Thompson, B. K. Soni, N. P. Weatherill, Handbook of Grid Generation, CRC Press, 1998.
  29. [29]A. Staniforth, J. Thuburn, Horizontal grids for global weather and climate prediction models, Quarterly Journal of the Royal Meteorological Society 138 (2012) 1–26.DOI
  30. [30]H. Miura, W. C. Skamarock, An upwind-biased transport scheme using a quadratic reconstruction on spherical icosahedral grids, Monthly Weather Review 141 (2013) 832–847. doi:10.1175/MWR-D-12-00048.1.
  31. [31]T. R. F. Phillips, C. E. Heaney, B. Chen, A. G. Buchan, C. C. Pain, Solving the discretised neutron diffusion equations using neural networks, International Journal for Numerical Methods in Engineering 124 (2023) 4659–4686. doi:10.1002/nme.7321.DOI
  32. [32]B. Chen, C. E. Heaney, C. C. Pain, Neural Physics: Using AI Libraries to Develop Physics-Based Solvers for Incompressible CFD, Computers & Fluids 308 (2026) 106981. doi:10.1016/j.compfluid.2026.106981.DOI
  33. [33]B. Chen, C. E. Heaney, J. L. M. A. Gomes, O. Matar, C. C. Pain, Solving the discretised multi-phase flow equations using machine learning libraries, Computer Methods in Applied Mechanics and Engineering 426 (2024) 116974. doi:10.1016/j.cma.2024.116974.
  34. [34]B. Chen, A. Nadimy, C. E. Heaney, M. K. Sharifian, L. V. Estrem, L. Nicotina, A. Hilberts, C. C. Pain, Solving the discretised shallow water equations using neural networks, Advances in Water Resources 197 (2025) 104903. doi:10.1016/j.advwatres.2025.104903.DOI
  35. [35]A. Nadimy, B. Chen, Z. Chen, C. E. Heaney, C. C. Pain, Solving the discretised shallow water equations using non-uniform grids and machine-learning libraries, Environmental Modelling & Software 196 (2026) 106752. doi:10.1016/j.envsoft.2025.106752.DOI
  36. [36]R. Huang, C. E. Heaney, M. van Reuwijk, Parameter estimation for land-surface models using Neural Physics, Geoscientific Model Development 19 (2026) 8801–8814. doi:10.5194/gmd-19-8801-2026.DOI
  37. [37]Y. Jiao, H. Zhang, T. Xue, B. Chen, J. Yang, T. Ba, S. See, C. W. Kang, C. E. Heaney, C. C. Pain, et al., NP4Buoyancy: An End-to-End Differentiable Neural-Physics Framework for Buoyancy-Driven Flows, Journal of Computational Physics (2026) 115179. doi:10.1016/j.jcp.2026.115179.DOI
  38. [38]T. R. F. Phillips, C. E. Heaney, B. Chen, A. G. Buchan, C. C. Pain, Solving the Discretised Boltzmann Transport Equations Using Neural Networks: Applications in Neutron Transport, arXiv preprint (2023) 2301.09991. doi:10.48550/arXiv.2301.09991.DOI
  39. [39]D. Vanzo, A. Siviglia, E. F. Toro, Pollutant Transport by Shallow Water Equations on Unstructured Meshes: Hyperbolization of the Model and Numerical Solution via a Novel Flux Splitting Scheme, Journal of Computational Physics 321 (2016) 1–20. doi:10.1016/j.jcp.2016.05.023.DOI
  40. [40]D. Pavlidis, J. L. M. A. Gomes, Z. Xie, J. R. Percival, C. C. Pain, O. K. Matar, Compressive advection and multi-component methods for interface-capturing, International Journal for Numerical Methods in Fluids 80 (2016) 256–282. doi:10.1002/fld.4078.DOI
  41. [41]O. Ronneberger, P. Fischer, T. Brox, U-Net: Convolutional Networks for Biomedical Image Segmentation, in: Medical Image Computing and Computer-Assisted Intervention (MICCAI), volume 9351 of LNCS, Springer, 2015, pp. 234–241. doi:10.48550/arXiv.1505.04597.DOI
  42. [42]TRITON: Two-dimensional Runoff Inundation Toolkit for Operational Needs, Oak Ridge National Lab., 2022. Accessed 01-December-2023.

Paper details

vlnc:W_2csgpyqk
Version
v1 · latest
Published
Fresh — added to the Hub within the last 30 days
Added
License
CC BY 4.0
Usage

views · 0

downloads · 0

A view counts once per browser per day, a download each time the PDF is requested.

  • Physics and Astronomy

Not recorded for this paper

View statement
Looking for related papers…
Contents