1 Introduction

Two- and three-dimensional elliptic partial differential equations (PDEs) play a pivotal role in different fields of science and technology. High-order compact schemes (HOC) are used for the solution of the Helmholtz equation and other elliptic PDEs [2, 3]. Consider the two-dimensional (2D) Helmholtz equation

$$ u_{xx}+u_{yy}+{k^{2}u}=f(x,y),\quad (x,y)\in\Omega, $$
(1)

where Ω is a rectangular domain and k is a wave number. The forcing function \(f(x,y)\) and the solution \(u(x,y)\) have the required continuous differentiability up to a specific order. The equation has many real-world applications like elasticity, electromagnetic waves, acoustic wave scattering, weather and climate prediction, water wave propagation, noise reduction in silencers, and radar scattering. In this paper, we use a finite-difference approximation on nonuniform grids in discrete domain to obtain a scheme up to fourth-order accuracy. We also considered the Helmholtz equation with constant value of k.

Equation (1) has been solved by different techniques such as finite-difference method (FDM) [4], fast-Fourier-transform-based (FFT) methods [5], finite-element method (FEM) [6], the spectral-element method [7], compact finite-difference method [8], and multigrid methods [9]. The multigrid method based on HOC schemes is among the most efficient iterative techniques for solving PDEs [10, 11].

In FDM the number of mesh points will be enlarged to increase the accuracy; however, it will also increase the computational time. The Helmholtz equation is solved by FEM and spectral-element method, but the limitations of these methods are of high computational cost [7]. Many iterative techniques for the Helmholtz equation suffer due to their slow convergence. The investigation on fast iterative methods to efficiently solve the large algebraic systems arising from high-order difference schemes for PDEs is more attractive. Multigrid methods together with the HOC schemes on uniform mesh sizes are developed in [1114]. In most cases where sudden changes occur in a flow, the step sizes have to be rectified over the entire domain. Under these situations, where points are concentrated in the regions of sharp variation, local mesh refinement procedures [1, 2, 9, 1517] are necessary, thus dramatically reducing the computational time and computer storage. Ge and Cao [1, 18] developed a multigrid method with HOC scheme on nonuniform grids for solving 2D convection diffusion equation and 3D Poisson equation. This paper is based on approach that an interpolation operator and a projection operator that are suited for a HOC scheme using nonuniform mesh are represented by a transformation-free HOC scheme on nonuniform grids. The main focus in this paper is to develop a multigrid method based on a HOC scheme on nonuniform grids for solving of the 2D Helmholtz equation. To the best of our knowledge, the 2D Helmholtz equation is not solved by a multigrid method based on a HOC scheme on nonuniform grids.

2 HOC scheme on nonuniform grids

Consider a square domain \((x,y)\in[a_{1},a_{2}]\times[b_{1},b_{2}]\). Discretization is performed on two-dimensional nonuniform gird points. The interval \([a_{1},a_{2}]\) is divided into subintervals

$$ a_{1}=x_{0},x_{1},x_{2}, \ldots,x_{N_{x}}=a_{2},\qquad b_{1}=y_{0},y_{1},y_{2}, \ldots,y_{N_{y}}=b_{2}. $$

In the x-direction, consider \(h_{x}= \frac{a_{2}-a_{1}}{N_{x}}\), and the forward and backward step sizes are given by

$$ h_{fx}=x_{i+1}-x_{i}= \theta_{fx}h_{x} ,\qquad h_{bx}=x_{i}-x_{i-1}= \theta_{bx}h_{x} , \quad 1\leq i< N_{x}-1. $$

Similarly in the y-direction, \(h_{y}= \frac{b_{2}-b_{1}}{N_{y}}\),

$$ h_{fy}=y_{j+1}-y_{j}= \theta_{fy}h_{y}, \qquad h_{by}=y_{j}-y_{j-1}= \theta_{by}h_{y}, \quad 1\leq j< N_{y}-1. $$

Furthermore, \(\alpha_{x}=\theta_{fx}\theta_{bx}\), \(\beta_{x}=\theta_{fx}+\theta_{bx}\), and \(\gamma_{x}=\theta_{fx}-\theta_{bx}\). If \(\theta_{fx}=\theta_{bx}=1\) (\(h_{fx}=h_{bx}\), \(h_{fy}=h_{by}\)), then the grids turn to be uniform. The approximate values of a function \(u(x,y)\) at interior grid points \((x_{i},y_{j})\) are represented by \(u_{0}\), and the estimated values of other eight neighboring points are determined by \(u_{i}\), \(i=1,2,3,\ldots,8\), as in Figure 1.

Figure 1
figure 1

Nonuniform grids in xy -plane. (a) Nonuniform grids distribution in xy-plane. (b) Stencil of nonuniform 2D grids.

The Taylor series expansion is performed for appropriate description of a sufficiently smooth function \(u({x,y})\) in the given domain at points 1 and 3, which are

$$\begin{aligned}& \begin{aligned}[b] u_{1}={}&u_{0}+\theta_{fx}h_{x}\, \partial_{x} u_{0}+\frac{ \theta^{2}_{fx} h^{2}_{x}}{2}\, \partial^{2}_{x} u_{0}+\frac{ \theta^{3}_{fx} h^{3}_{x}}{6}\, \partial^{3}_{x} u_{0} \\ &{}+\frac{\theta^{4}_{fx}h^{4}_{x}}{24}\, \partial^{4}_{x} u_{0}+\frac{ \theta^{5}_{fx}h^{5}_{x}}{120}\, \partial^{5}_{x} u_{0}+O\bigl(\theta^{6}_{fx}h^{6}_{x} \bigr), \end{aligned} \end{aligned}$$
(2)
$$\begin{aligned}& \begin{aligned}[b] u_{3}={}&u_{0}-\theta_{bx}h_{x}\, \partial_{x} u_{0}+\frac{\theta^{2}_{bx}h^{2}_{x}}{2}\, \partial^{2}_{x} u_{0}-\frac{\theta^{3}_{bx} h^{3}_{x}}{6}\, \partial^{3}_{x} u_{0} \\ &{}+\frac{\theta^{4}_{bx}h^{4}_{x}}{24}\, \partial^{4}_{x} u_{0}-\frac{\theta^{5}_{bx}h^{5}_{x}}{120}\, \partial^{5}_{x} u_{0}+O\bigl(\theta^{6}_{bx}h^{6}_{x} \bigr). \end{aligned} \end{aligned}$$
(3)

Multiplying equation (2) by \(\theta_{bx}\) and (3) by \(\theta_{fx}\), then adding and solving for the second-order derivative, which gives

$$\begin{aligned} \partial^{2}_{x} u_{0} =& \frac{2}{\alpha_{x} \beta_{x} h^{2}_{x}}(\theta _{bx}u_{1}-\beta_{x} u_{0}+\theta_{fx} u_{3}) -\frac{h_{x}}{3} \gamma _{x}\, \partial^{3}_{x} u_{0}- \frac{h^{2}_{x}}{12}\bigl(\beta^{2}_{x}-3\alpha_{x} \bigr)\, \partial^{4}_{x} u_{0} \\ &{}-\frac {h^{3}_{x}}{60} \bigl(\beta^{2}_{x}-2\alpha_{x}\bigr) \gamma_{x} \, \partial^{5}_{x} u_{0}+O \bigl(\eta_{x} h^{4}_{x}\bigr), \end{aligned}$$
(4)

where \(\eta_{x}=\beta^{4}_{x}-5\alpha_{x}(\beta^{2}_{x}-\alpha_{x})\), and the second-order central difference operator along the x-direction is defined as

$$ \delta^{2}_{x} u_{0}= \frac{2}{\alpha_{x} \beta_{x} h^{2}_{x}}(\theta _{bx}u_{1}-\beta_{x} u_{0}+\theta_{fx} u_{3}); $$
(5)

if \(\theta_{fx}=\theta_{bx}=1\), then equation (5) reduces to uniform grids of the central difference operator. Hence, the second-order derivative for the x-direction is

$$\begin{aligned} \partial^{2}_{x} u_{0} =& \delta^{2}_{x} u_{0} -\frac{h_{x}}{3} \gamma_{x}\, \partial^{3}_{x} u_{0}- \frac{h^{2}_{x}}{12}\bigl(\beta^{2}_{x}-3\alpha_{x} \bigr)\, \partial^{4}_{x} u_{0} \\ &{}-\frac {h^{3}_{x}}{60} \bigl(\beta^{2}_{x}-2\alpha_{x}\bigr) \gamma_{x} \, \partial^{5}_{x} u_{0}+O \bigl(\eta_{x} h^{4}_{x}\bigr), \end{aligned}$$
(6)

and the approximation of the second-order derivative for the variable y can be find accordingly. Therefore, the central difference (CD) scheme for the Helmholtz equation can be discretized as

$$ \delta^{2}_{x} u_{0}+ \delta^{2}_{y}u_{0}+k^{2}(u_{0})=f_{0}+ \tau_{0}, $$
(7)

where \(\tau_{0}\) is the truncation error and is defined as

$$\begin{aligned} \tau_{0} =&H_{1} \frac{\partial^{3} u_{0}}{\partial x^{3}}+L_{1} \frac{\partial^{3} u_{0}}{\partial y^{3}}+ H_{2} \frac{\partial^{4} u_{0}}{\partial x^{4}}+L_{2} \frac{\partial^{4} u_{0}}{\partial y^{4}} \\ &{}+H_{3} \frac{\partial^{5} u_{0}}{\partial x^{5}}+L_{3} \frac{\partial^{5} u_{0}}{\partial y^{5}} +O\bigl(\eta_{x} h^{4}_{x} \bigr)+O\bigl(\eta_{y} h^{4}_{y}\bigr). \end{aligned}$$
(8)

The equations \(H_{1}\), \(H_{2}\), \(H_{3}\) and \(L_{1}\), \(L_{2}\), \(L_{3}\) are defined as

$$\begin{aligned}& H_{1}=\frac{1}{3} h_{x} \gamma_{x}, \qquad L_{1}=\frac{1}{3}h_{y} \gamma_{y}, \qquad H_{2}=\frac{1}{12}h^{2}_{x} \bigl( \beta^{2}_{x}-3\alpha_{x}\bigr),\qquad L_{2}=\frac{1}{12}h^{2}_{y}\bigl( \beta^{2}_{y}-3\alpha_{y}\bigr), \\& H_{3}=\frac{1}{60}h^{3}_{x} \bigl( \beta^{2}_{x}-2\alpha_{x}\bigr) \gamma_{x},\qquad L_{3}=\frac{1}{60}h^{3}_{y} \bigl(\beta^{2}_{y}-2\alpha_{y}\bigr) \gamma_{y},\qquad \eta_{y}=\beta^{4}_{y}-5 \alpha_{y}\bigl(\beta^{2}_{y}- \alpha_{y}\bigr). \end{aligned}$$

If \(\tau_{0}\) is dropped off from equation (7), then the CD scheme for nonuniform grids becomes

$$ \delta^{2}_{x} u_{0}+ \delta^{2}_{y}u_{0}+k^{2}(u_{0})=f_{0}. $$
(9)

According to the definition of \(\delta^{2}_{x}\), \(\delta^{2}_{y}\), the CD scheme can be written as

$$ \biggl(k^{2}-2 \biggl(\frac{1}{\alpha_{x} h^{2}_{x}}+ \frac{1}{\alpha_{y} h^{2}_{y}}\biggr) \biggr)u_{0}+\frac{2\theta_{bx}}{\alpha_{x} \beta_{x} h^{2}_{x}}u_{1}+ \frac{2\theta_{by}}{\alpha_{y} \beta_{y} h^{2}_{y}}u_{2}+\frac{2\theta_{fx}}{\alpha_{x} \beta_{x} h^{2}_{x}}u_{3}+ \frac{2\theta_{fy}}{\alpha_{y} \beta_{y} h^{2}_{y}}u_{4}=f_{0}. $$
(10)

In equation (10), only five grid points are involved. From the definition of \(\tau_{0}\) we can see that when \(h_{fx}=h_{bx}\) and \(h_{fy}=h_{by}\), then equation (10) is of second-order accuracy. In order to improve the accuracy, we consider

$$\begin{aligned}& H_{1} \frac{\partial^{3} u_{0}}{\partial x^{3}}+L_{1} \frac{\partial^{3} u_{0}}{\partial y^{3}} \\& \quad = \biggl(H_{1} \frac{\partial}{\partial x}+L_{1} \frac{\partial}{\partial y} \biggr) \biggl(\frac{\partial^{2} u_{0}}{\partial x^{2}}+\frac{\partial^{2} u_{0}}{\partial y^{2}} \biggr)- \biggl(H_{1} \frac{\partial^{3} u_{0} }{\partial x\, \partial y^{2}}+L_{1}\frac{\partial^{3} u_{0}}{\partial y\, \partial x^{2}} \biggr) \\& \quad = H_{1} \frac{\partial f_{0}}{\partial x}+L_{1}\frac{\partial f_{0}}{\partial y}-k^{2} \biggl(H_{1} \frac{\partial u_{0}}{\partial x}+L_{1}\frac{\partial u_{0}}{\partial y} \biggr) \\& \qquad {}-H_{1} \biggl[\frac{2}{\alpha_{y} \beta_{y} h^{2}_{y}} \biggl(\theta_{by} \frac{\partial u_{2}}{\partial x}-\beta_{y} \frac{\partial u_{0}}{\partial x}+\theta_{fy} \frac{\partial u_{4}}{\partial x} \biggr)+O\bigl(h^{2}_{y}\bigr) \biggr] \\& \qquad {}-L_{1} \biggl[\frac{2}{\alpha_{x} \beta_{x} h^{2}_{x}} \biggl(\theta_{bx} \frac{\partial u_{1}}{\partial y}-\beta_{x} \frac{\partial u_{0}}{\partial y}+\theta_{fx} \frac{\partial u_{3}}{\partial y} \biggr)+O\bigl(h^{2}_{x}\bigr) \biggr] \end{aligned}$$
(11)

and

$$\begin{aligned}& H_{2} \frac{\partial^{4} u_{0}}{\partial x^{4}}+L_{2} \frac{\partial^{4} u_{0}}{\partial y^{4}} \\& \quad = \biggl(H_{2} \frac{\partial^{2} }{\partial x^{2}}+L_{2} \frac{\partial^{2}}{\partial y^{2}} \biggr) \biggl(\frac{\partial^{2} u_{0}}{\partial x^{2}}+\frac{\partial^{2} u_{0}}{\partial y^{2}} \biggr)- \biggl((H_{2}+L_{2}) \frac{\partial^{4} u_{0} }{\partial x^{2}\, \partial y^{2}} \biggr) \\& \quad = H_{2} \frac{\partial^{2} f_{0}}{\partial x^{2}}+L_{2}\frac{\partial^{2} f_{0}}{\partial y^{2}}-k^{2} \biggl(H_{2} \frac{\partial^{2} u_{0}}{\partial x^{2}}+L_{2}\frac{\partial^{2} u_{0}}{\partial y^{2}} \biggr) \\& \qquad {}-(H_{2}+L_{2}) \biggl[\frac{2}{\alpha_{y} \beta_{y} h^{2}_{y}} \biggl( \theta_{by}\frac{\partial^{2} u_{2}}{\partial x^{2}}-\beta_{y} \frac{\partial^{2} u_{0}}{\partial x^{2}}+ \theta_{fy}\frac{\partial^{2} u_{4}}{\partial x^{2}} \biggr)+O\bigl(h^{2}_{y} \bigr) \biggr]. \end{aligned}$$
(12)

Applying the central difference scheme to equation (11), we have

$$\begin{aligned}& H_{1} \frac{\partial^{3} u_{0}}{\partial x^{3}}+L_{1} \frac{\partial^{3} u_{0}}{\partial y^{3}} \\& \quad = H_{1} \frac{\partial f_{0}}{\partial x}+L_{1} \frac{\partial f_{0}}{\partial y}-k^{2} \biggl(H_{1} \biggl( \frac{ u_{1}-u_{3}}{\beta x h_{x}}\biggr)+L_{1}\biggl(\frac{ u_{2}-u_{4}}{\beta y h_{y}}\biggr) \biggr) \\& \qquad {}-H_{1} \biggl[\frac{2}{\alpha_{y} \beta_{y} h^{2}_{y}} \biggl(\theta_{by} \biggl(\frac{u_{5}-u_{6}}{\beta x h_{x}}\biggr)-\beta_{y} \biggl(\frac{ u_{1}-u_{3}}{\beta x h_{x}} \biggr)+\theta_{fy}\biggl(\frac{ u_{8}-u_{7}}{\beta x h_{x}}\biggr) \biggr) \biggr] \\& \qquad {}-L_{1} \biggl[\frac{2}{\alpha_{x} \beta_{x} h^{2}_{x}} \biggl(\theta_{bx} \biggl(\frac{ u_{5}-u_{8}}{\beta y h_{y}}\biggr)-\beta_{x} \biggl(\frac{u_{2}-u_{4}}{\beta y h_{y}} \biggr)+\theta_{fx}\biggl(\frac{u_{6}-u_{7}}{\beta y h_{y} }\biggr) \biggr) \biggr]. \end{aligned}$$
(13)

Similarly, equation (12) will be

$$\begin{aligned}& H_{2} \frac{\partial^{4} u_{0}}{\partial x^{4}}+L_{2} \frac{\partial^{4} u_{0}}{\partial y^{4}} \\& \quad = H_{2} \frac{\partial^{2} f_{0}}{\partial x^{2}}+L_{2} \frac{\partial^{2} f_{0}}{\partial y^{2}}-2k^{2} H_{2} \biggl(\frac{\theta_{bx} u_{1}-\beta_{x} u_{0}+\theta_{fx} u_{3}}{\alpha_{x} \beta_{x} h_{x}^{2}} \biggr) \\& \qquad {}-2k^{2} L_{2} \biggl(\frac{\theta_{by} u_{2}-\beta_{y} u_{0}+\theta_{fy} u_{4}}{\alpha_{y} \beta_{y} h_{y}^{2}} \biggr)- \frac{4(H_{2}+L_{2})}{\alpha_{x} \alpha_{y} \beta_{x} \beta_{y} h^{2}_{x} h^{2}_{y}} \bigl[ (\theta_{by}\theta_{bx} u_{5}-\theta_{by} \beta_{y} u_{2}+ \theta_{by}\theta_{fx} u_{6} ) \\& \qquad {}+ (\beta_{y} \theta_{bx} u_{1}+ \beta_{y} \beta_{x} u_{0}-\beta_{y} \theta_{fx} u_{6} )+ (\theta_{fy} \theta_{bx} u_{8}-\theta_{fy} \beta_{x} u_{4}+\theta_{fy}\theta_{fx} u_{7} ) \bigr]. \end{aligned}$$
(14)

Through central difference schemes, the first- and second-order derivatives in equations (12), (13) can be approximated. Now combining equations (7) and (8) with equations (12) and (13), the nine-point HOC scheme on nonuniform mesh points for two-dimensional Helmholtz equation (1) can be written as

$$ \sum^{8}_{i=0}A_{i} u_{i}=f_{0}+H_{1} \frac{\partial f_{0}}{\partial x}+ L_{1}\frac{\partial f_{0}}{\partial y}+H_{2}\frac{\partial^{2} f_{0}}{\partial x^{2}}+L_{2} \frac{\partial^{2} f_{0}}{\partial x^{2}}. $$
(15)

The coefficients of the LHS in equation (15) are given as

$$\begin{aligned}& A_{0} = -2 \biggl(\frac{1}{\alpha_{x} h^{2}_{x}}+\frac{1}{\alpha_{y} h^{2}_{y}} \biggr)- \frac{2 k^{2} H_{2}}{\alpha_{x} h_{x} ^{2}}-\frac{2 k^{2} L_{2}}{\alpha_{y} h_{y} ^{2}}+ \frac{4 (H_{2}+ L_{2})}{\alpha_{x} \alpha_{y} h_{x} ^{2} h_{y}^{2}}, \\& A_{1} = \frac{2 \theta_{bx}}{\alpha_{x} \beta_{x} h^{2}_{x}}-\frac{2H_{1}}{ \alpha_{y} \beta_{x} h_{x} h^{2}_{y}}+ \frac{2 k^{2} H_{2} \theta_{bx}}{\alpha_{x} \beta_{x} h_{x} ^{2}}+ \frac{k^{2} H_{1}}{\beta_{x} h_{x}}-\frac{4 (H_{2}+ L_{2})\beta_{y} \theta_{bx}}{\alpha_{x} \alpha_{y} \beta_{x} \beta_{y} h_{x} ^{2} h^{2}_{y} }, \\& A_{2} = \frac{2 \theta_{by}}{\alpha_{y} \beta_{y} h^{2}_{y}}+\frac{2k^{2} L_{2} \theta_{by}}{ \alpha_{y} \beta_{y} h^{2}_{y}}+ \frac{k^{2} L_{1}}{\beta_{y} h_{y}}- \frac{2L_{1}}{\alpha_{x} \beta_{y} h_{x}^{2} h_{y}}-\frac{4 (H_{2}+ L_{2})\beta_{x} \theta_{by}}{\alpha_{x} \alpha_{y} \beta_{x} \beta_{y} h_{x} ^{2} h^{2}_{y} }, \\& A_{3} = \frac{2 \theta_{fx}}{\alpha_{x} \beta_{x} h^{2}_{x}}+\frac{2k^{2} H_{2} \theta_{fx}}{ \alpha_{x} \beta_{x} h^{2}_{x}}- \frac{k^{2} H_{1}}{\beta_{x} h_{x}}+ \frac{2H_{1} }{\alpha_{y} \beta_{x} h_{x} h^{2}_{y}}-\frac{4 (H_{2}+ L_{2})\beta_{y} \theta_{fx}}{\alpha_{x} \alpha_{y} \beta_{x} \beta_{y} h_{x} ^{2} h^{2}_{y} }, \\& A_{4} = \frac{2 \theta_{fy}}{\alpha_{y} \beta_{y} h^{2}_{y}}+\frac{2k^{2} L_{2} \theta_{fy}}{ \alpha_{y} \beta_{y} h^{2}_{y}}-\frac{k^{2} L_{1}}{\beta_{y} h_{y}}+ \frac{2L_{1} }{\alpha_{x} \beta_{y} h^{2}_{x} h_{y}}-\frac{4 (H_{2}+ L_{2})\beta_{x} \theta_{fy}}{\alpha_{x} \alpha_{y} \beta_{x} \beta_{y} h_{x} ^{2} h^{2}_{y} }, \\& A_{5} = \frac{2 H_{1}\theta_{by}}{\alpha_{y} \beta_{y} \beta_{x} h_{x} h^{2}_{y}}+\frac{2L_{1} \theta_{bx}}{ \alpha_{x} \beta_{x} \beta_{y} h^{2}_{x} h_{y}}+\frac{4 (H_{2}+ L_{2})\theta_{bx} \theta_{by}}{\alpha_{x} \alpha_{y} \beta_{x} \beta_{y} h_{x} ^{2} h^{2}_{y} }, \\& A_{6} = \frac{2 L_{1}\theta_{fx}}{\alpha_{x} \beta_{x} \beta_{y} h^{2}_{x} h_{y}}-\frac{2H_{1} \theta_{by}}{ \alpha_{y} \beta_{x} \beta_{y} h_{x} h^{2}_{y}}+\frac{4 (H_{2}+ L_{2})\theta_{by} \theta_{fx}}{\alpha_{x} \alpha_{y} \beta_{x} \beta_{y} h_{x} ^{2} h^{2}_{y} }, \\& A_{7} = \frac{-2 L_{1}\theta_{bx}}{\alpha_{x} \beta_{x} \beta_{y} h^{2}_{x} h_{y}}+\frac{2H_{1} \theta_{fy}}{ \alpha_{y} \beta_{x} \beta_{y} h_{x} h^{2}_{y}}+\frac{4 (H_{2}+ L_{2})\theta_{fy} \theta_{bx}}{\alpha_{x} \alpha_{y} \beta_{x} \beta_{y} h_{x} ^{2} h^{2}_{y} }, \\& A_{8} = \frac{- 2 H_{1}\theta_{fy}}{\alpha_{y} \beta_{x} \beta_{y} h_{x} h^{2}_{y}}-\frac{2L_{1} \theta_{fx}}{ \alpha_{x} \beta_{x} \beta_{y} h^{2}_{x} h_{y}}+\frac{4 (H_{2}+ L_{2})\theta_{fx} \theta_{fy}}{\alpha_{x} \alpha_{y} \beta_{x} \beta_{y} h_{x} ^{2} h^{2}_{y} }. \end{aligned}$$

It is easier to know that this scheme has third to fourth order of accuracy from expansion of \(\tau_{0}\).

3 Multigrid method

The multigrid method is one of the most efficient and fastest methods for solving PDEs. In the multigrid method, the rate of convergence is independent of the mesh size. This method is more effective for solving large-scale sparse linear systems obtained from the discretization of elliptic PDEs [9, 10, 1922]. The main principle of the multigrid method is to smoothen the error on coarse grid level using basic iterative methods such as Jacobi or Gauss-Seidel method, etc. The multigrid method consists of three important components that are relaxation, restriction, and interpolation operators. These are applied as ‘a single iteration of a multigrid cycle comprised of manipulating the error by the application of relaxation method, fixing the residuals on the coarse grid level, solving the error equation on the coarse grid and adjusting the correction of coarse grid up to the fine grid level’.

Some specific methods have been applied for the solution of the 2D and 3D Helmholtz equations with HOC schemes on uniform grids [24, 6, 8, 12, 13]. A full weighting restriction operator and the standard bilinear interpolation operator are used as the inter-grid transfer operators. But in the case of nonuniform grids, these restriction and interpolation operators cannot be used; so new restriction and interpolation operators for nonuniform grids are proposed by Ge and Cao [1] by using the area law developed by Liu [23]. In the following section, we give out the derivation of the two operators for the completeness.

3.1 Restriction operator

The principle of developing restriction operator is based on the evaluation of the residuals on the coarse grid level with the use of residuals on the fine grid level. In the multigrid method, Liu developed a law for the restriction of the residual [23], known as the area law.

For every point on the coarse grid level, there are corresponding eight fine grid points surrounding it. On the coarse grid, there is a contribution of different degree between the reference grid points and the corresponding surrounding grid points on the fine grids, and a full weighting restriction operator for nonuniform grids is constructed on the base of area law. These points are shown for convenience in Figure 1. The basic idea for getting the full weighting restriction operator of each grid point is to analyze the weighting coefficients of the residuals. On the coarse grids, the reference point \((i,j)\) of the fine grids have the major contribution to it, so the corresponding weighting coefficient is evaluated by \(a_{0}/a \). At that instant, we noticed that the grid points near the reference point \((i,j)\) have much more contributions than those far away from it. For instance, the weighting coefficient of the point \((i+1,j)\) is given by \(a_{3}/a \), that of the point \((i-1,j)\) by \(a_{1}/a \), and so on. Now suppose that \(r_{ij}\) is the residual at the fine grid point \((i,j)\) and that \(\bar{r}_{\bar{i} , \bar{j}}\) is the corresponding residual at the coarse grid point \((\bar{i},\bar{j})\). It is very simple to see that \(i=2 \bar{i}\) and \(j=2\bar{j}\); thus, the full weighting restriction operator on nonuniform grids can be written as in [1]:

$$\begin{aligned} \bar{r}_{\bar{i} , \bar{j}} =&\frac{1}{a} [a_{0} r_{i,j}+a_{1} r_{i-1,j} + a_{2} r_{i,j-1}+a_{3} r_{i+1,j}+a_{4} r_{i,j+1} \\ &{}+ a_{5} r_{i-1,j-1}+a_{6} r_{i+1,j-1}+a_{7} r_{i+1,j+1}+a_{8} r_{i-1,j+1} ], \end{aligned}$$
(16)

in which

$$\begin{aligned}& a= (h_{fx}+h_{bx})\times(h_{fy}+h_{by}), \qquad a_{0}= \frac{1}{4}(h_{fx}+h_{bx}) \times(h_{fy}+h_{by}), \\& a_{1}= \frac{1}{4}\bigl(h_{fx}\times(h_{fy}+h_{by}) \bigr),\qquad a_{2}= \frac{1}{4}\bigl(h_{fy}\times(h_{fx}+h_{bx}) \bigr), \\& a_{3}= \frac {1}{4}\bigl(h_{bx} \times(h_{fy}+h_{by})\bigr),\qquad a_{4}= \frac{1}{4}\bigl(h_{by}\times(h_{fx}+h_{bx}) \bigr), \\& a_{5}= \frac{1}{4}(h_{fx}\times h_{fy}), \qquad a_{6}= \frac{1}{4}(h_{bx}\times h_{fy}), \\& a_{7}= \frac{1}{4}(h_{fx} \times h_{by}),\qquad a_{8}= \frac{1}{4}(h_{bx} \times h_{by}). \end{aligned}$$

If the step size reduces to equal size, then the total area is divided into sixteen equal small parts by the grid lines and half-grid lines. Denoting the area of each part by a, we obtain that \(a_{0}=4 \bar{a}\), \(a_{1}=a_{2}=a_{3}=a_{4}=2\bar{a}\), and \(a_{5}=a_{6}=a_{7}=a_{8}=\bar{a}\). Due to this situation, the restriction operator will reduced to the full weighting operator on equal mesh sizes [24]:

$$ \bar{r}_{\bar{i},\bar{j}}=\frac{1}{16}\bigl[4 r_{i,j}+2(r_{i-1,j}+r_{i+1,j}+r_{i,j+1}+r_{i,j-1})+(r_{i+1,j+1}+r_{i-1,j+1}+r_{i+1,j-1}+r_{i-1,j-1}) \bigr]. $$

3.2 Interpolation operator

For the construction of an interpolation operator, we use a similar strategy. We observed that when grid points are shifted from coarse level to the fine level, at that instant, the grids points on the coarse level are the grid points on fine level. These grid points are shifted directly from the coarse grid level to the fine grid level. The interpolation operator is expressed as \(r_{i,j}=\bar{r}_{\bar{i},\bar{j}}\). Thus, the points on the fine grid are interpolated with their own neighboring points on the coarse level. The formula for error correction along the x- and y-directions are interpolated as [1]

$$\begin{aligned}& r_{i-1,j}=\frac{1}{h_{fx}+h_{bx}}(h_{fx}\bar{r}_{\bar {i}-1,\bar{j}}+h_{bx} \bar{r}_{\bar{i},\bar{j}}), \\& r_{i,j-1}=\frac{1}{h_{fy}+h_{by}}(h_{fy}\bar{r}_{\bar {i},\bar{j}-1}+h_{by} \bar{r}_{\bar{i},\bar{j}}). \end{aligned}$$

In case of central grid points, we use four grid points around them on the coarse grid level to interpolate as follows [1]:

$$ r_{i-1,j-1}=\frac{1}{S_{xy}}(S_{1xy}\bar{r}_{\bar {i}-1,\bar{j}-1}+S_{2xy} \bar{r}_{\bar{i},\bar{j}-1} +S_{3xy}\bar{r}_{\bar{i},\bar{j}}+S_{4xy} \bar {r}_{\bar{i}-1,\bar{j}}), $$

where

$$\begin{aligned} \begin{aligned} &S_{xy}=({h_{fx}+h_{bx}})\times(h_{fy}+h_{by}), \qquad S_{1xy}=h_{fx}\times h_{fy}, \\ &S_{2xy}=h_{bx}\times h_{fy},\qquad S_{3xy}=h_{bx}\times h_{by},\qquad S_{4xy}=h_{fx}\times h_{by}. \end{aligned} \end{aligned}$$

When the grid sizes become equal, then the interpolation operator reduces to the bilinear interpolation on equal step sizes [24]:

$$\begin{aligned}& r_{i,j}=\bar{r}_{\bar{i},\bar{j}-1},\qquad r_{i-1,j}= \frac{1}{2}(\bar{r}_{\bar{i}-1,\bar {j}}+\bar{r}_{\bar{i},\bar{j}}), \\& r_{i,j-1}=\frac{1}{2}(\bar{r}_{\bar{i},\bar {j}-1}+ \bar{r}_{\bar{i},\bar{j}}),\qquad r_{i-1,j-1}=\frac{1}{4}( \bar{r}_{\bar{i}-1,\bar {j}-1}+\bar{r}_{\bar{i},\bar{j}-1} +\bar{r}_{\bar{i},\bar{j}}+ \bar{r}_{\bar {i}-1,\bar{j}}). \end{aligned}$$

3.3 Relaxation operator (smoother)

In the multigrid method, the relaxation operator is an important operator. Its work is not to remove the errors, but to damp the high-frequency components of the errors on the present grid level. A simple smoother (Gauss-Seidel relaxation) method can efficiently remove the errors in all directions for simple isotropic problems [7, 20], but in case of anisotropic and boundary layer problems, the line Gauss-Seidel [19, 21] and alternating line Gauss-Seidel methods [1, 2527] are shown to be more robust smoothers. In this paper, we use three relaxations to smooth the residuals on each coarse grid such as the line Gauss-Seidel relaxation, natural Gauss-Seidel relaxation, and Red-black Gauss-Seidel relaxation.

4 Numerical experiments

In order to check the effectiveness of the present method, some problems are chosen. The V-cycle multigrid method is used with zero initial guess, and the process is stopped when the Euclidean norm of the residual vector is reduced by 10−10 on the finest grid level. The effectiveness of the multigrid method with HOC scheme and CD scheme (10) is presented. The reported errors are the \(l_{2}\)-norms of the errors between the computed solution and the exact solution on finest grid. The order of accuracy for a difference scheme is defined as

$$\mathrm{Order}= \log_{2}\frac{\operatorname{Error}(N_{1})}{\operatorname{Error}(N_{2})}, $$

where \(\operatorname{Error}(N_{1})\) and \(\operatorname{Error}(N_{2})\) are the maximum absolute errors approximated for two different grids with \(N_{1} +1\) and \(N_{2} +1\) points in both direction, whereas \(N_{1}\) is half of \(N_{2}\). We use the \(l_{2}\)-norm for comparison of the numerical solution and the exact solution, which is defined as

$$ \|e\|_{2}=\frac{1}{N}\sqrt{ {\sum _{i,j=0}^{N} e_{i,j}^{2}}}, $$

where \(e_{i,j}\) is the error vector defined as, \(e_{i,j}=u_{i,j}-v_{i,j}\), and \(v_{i,j}\) is the discrete approximation of \(u_{i,j}\) which implies that \(u_{i,j} =v_{i,j} + {O}(h)^{4}\). First, we use different grid sizes from 82 to 1282 to compute the accuracy order.

The \(l_{2}\)-norms of the error and accuracy order for the same value of λ and different values of \(N, k\) are presented in Tables 1 and 2. We consider the case where \(N=16\) and \(N=32\) for the accuracy order of the scheme. We also examined the behavior of the scheme for different values of k. The scheme is sensitive for \(4\leq k\leq5\). If we increase the value of \(k=1\text{,}000\), then the error does not decrease further. The scheme behaves robustly with respect to the wave number k. However, for any value of N and k, overall, the error does not increase. One of the important advantages of this scheme is the execution time. The computed results show that the line Gauss-Seidel method takes less CPU time than the other smoothers.

Table 1 The number of multigrid V-cycles with two schemes and different values of \(\pmb{k=10,50, 100,500,1\text{,}000}\) and \(\pmb{\lambda=-0.9}\) for Example 1 , where \(\pmb{e^{-5}=10^{-5}}\)
Table 2 The number of multigrid V-cycles with two schemes and different values of \(\pmb{k=10,50, 100,500,1\text{,}000}\) and \(\pmb{\lambda=0.9}\) for Example 2 , where \(\pmb{e^{-5}=10^{-5}}\)

Example 1

Consider the following elliptic PDE with the source term:

$$\begin{aligned}& u_{xx}+u_{yy}+k^{2} u=f(x,y),\quad 0< x < 1, 0< y < 1, \end{aligned}$$
(17)
$$\begin{aligned}& f(x,y)=\bigl(k^{2}-10^{4} e^{-100x}\bigr) \bigl[x-y(1-y)\bigr]+198 e^{-100x}; \end{aligned}$$
(18)

the boundary conditions are given by the analytic solution, that is,

$$ u(x,y)=e^{-100x}\bigl[y(1-y)-x\bigr]. $$

This problem has a steep boundary layer along \(x=0\); therefore, we are using nonuniform grids along the x-axis, which are accumulating near \(x=0\), and uniform grids along the y-axis with the following stretching function [28]:

$$ x_{i}=\frac{i}{N_{x}} + \frac{\lambda}{\pi}\sin\biggl( \frac{\pi i}{N_{x}}\biggr),\qquad y_{j}= \frac{j}{N_{y}}, $$

where λ is a stretching parameter and controls the tightness of the grid points in the x-direction. When \(\lambda< 0\), more grid points are accumulated to the boundary \(x=0\) and to the boundary \(x=1\) for \(\lambda> 0\). If \(\lambda=0\), then the grids reduced to be uniform. When \(\lambda=-0.8\) and the grid numbers are 322, the grid distribution in the xy-plane is shown in Figure 1. The estimated accuracy and maximum absolute error with different stretching parameter λ are presented in Table 3. We see that when \(\lambda= 0\), the results are very poor. A more accurate solution and order of convergence are obtained from HOC and CD schemes with decreasing stretching parameter λ on nonuniform grids. We observe that when \(\lambda =-0.8\), the solution obtained with HOC scheme is more accurate, but when λ further decreases to −0.9, the accuracy decreases. This situation is not wondering because putting more grids in the boundary layer area will necessarily cause lack of mesh points in the other regions of the domain. Figure 2 indicates the configuration of solution in the xy-plane. Table 4 shows the \(l_{2}\)-norm of the error, CPU timing, and the order of accuracy for different stretching parameters λ in problem 1. It is also obvious from the results that the line Gauss-Seidel relaxation is the most efficient smoother with the least multigrid V-cycle numbers for such type of problems. (a) shows the exact solution, (b) the solution obtained from HOC scheme on uniform grids, (c) the computed solution obtained from a HOC scheme on nonuniform grids, and (d) the computed solution of CD scheme on nonuniform grids.

Figure 2
figure 2

Computed solutions through HOC and CDS schemes for problem 1. (a) Exact solution. (b) Computed solution from HOC scheme with uniform grids. (c) HOC scheme on nonuniform grids. (d) CDS scheme on nonuniform grids. The error vector \(e_{ij}=u_{ij}-v_{ij}\), and \(N=32\) is the number of nodes, and \(k=10\) and \(\lambda= -0.8\) for Example 1.

Table 3 The error norms and order of accuracy of the two schemes for Example 1 , where \(\pmb{e^{-5}=10^{-5}}\) , \(\pmb{\|e\|_{2}}\) , \(\pmb{k = 10}\) , \(\pmb{N = 16,32,64,128}\)
Table 4 The number of multigrid V-cycles and CPU time with two schemes and different relaxation methods with \(\pmb{32^{2}}\) for Example 1

Example 2

Consider the PDE with a source term \(f(x,y)\),

$$ u_{xx}+u_{yy}+k^{2} u=f(x,y) ,\quad 0< x,y < 1. $$
(19)

Its analytic solution is

$$ u(x,y)=\frac{(1-e^{100(x-1)})(1-e^{100(y-1)})}{(1-e^{-100})^{2}}. $$

The source function is determined by the analytic solution with the boundary layers along \(x=1\) and \(y=1\). Hence, nonuniform grids along the coordinate directions with accumulation near \(x=1\), \(y=1\) is used by the following stretching formula:

$$\begin{aligned}& x_{i}=\frac{i}{N_{x}} + \frac{\lambda}{\pi}\sin\biggl( \frac{\pi i}{N_{x}}\biggr), \\& y_{j}= \frac{j}{N_{y}}+ \frac{\lambda}{\pi}\sin\biggl(\frac{\pi j}{N_{y}}\biggr). \end{aligned}$$

When λ gets closer to 1, more grids are accumulated near \(x=1\), \(y=1\). When \(\lambda=0.8\) and the grids size is 322, the grids distribution is given in Figure 3. Table 5 indicates the error norms and order of accuracy for different stretching parameters λ for problem 2. The value of λ changes from 0.0 to 0.9. We observe that in nonuniform grids with increasing the stretching parameter λ, more and more grids accumulate into the boundary layers; consequently, more accurate results are obtained from HOC and CD schemes. The rate of convergence continuously increases with the increase of λ. We observe that when \(\lambda=0.8\), a considerably most accurate solution is obtained with the HOC scheme, but when λ increases to 0.9, it leads to decrease in accuracy. Figure 4 shows the contours of the exact solution in the xy-plane. Table 6 and Table 7 list the number of multigrid V-cycles and the corresponding CPU time in seconds for solving problem 2 on the 162, 322, 642, and 1282 grids. (a) represents the exact solution, (b) the solution obtained by the HOC scheme on uniform grids, (c) the computed solution by the CD scheme on uniform grids, and (d) the solution obtained by the HOC scheme on nonuniform grids with \(\lambda=0.8\).

Figure 3
figure 3

Nonuniform grids distribution in the xy -plane, \(\pmb{32^{2}}\) , \(\pmb{\lambda=0.8}\) .

Figure 4
figure 4

Computed solution obtained from HOC and CDS schemes for problem 2. (a) Exact solution. (b) Computed solution by HOC scheme on uniform grids. (c) CDS scheme on uniform grids. (d) HOC scheme on nonuniform grids, 322, \(\lambda=0.8\).

Table 5 The error norms and order of accuracy of the two schemes for Example 2 , where \(\pmb{e^{-5}=10^{-5}}\) , \(\pmb{\|e\|_{2}}\) , \(\pmb{k = 10}\) , \(\pmb{N = 16,32,64,128 }\)
Table 6 The number of multigrid V-cycles and CPU time with two schemes and different relaxation methods with \(\pmb{32^{2}}\) for Example 2
Table 7 The number of multigrid V-cycles and CPU time with two schemes and different relaxation methods with \(\pmb{32^{2}}\) for Example 2

Example 3

Consider the Helmholtz equation with a source function \(f(x,y)\),

$$ \begin{aligned} &u_{xx}+u_{yy}+k^{2} u=f(x,y) , \quad 0< x,y < 2, \\ &f(x,y)=\biggl(\frac{2k^{2}-\pi^{2}}{2}\biggr) \sin\biggl(\frac{\pi x}{2}\biggr) \sin\biggl(\frac{\pi y}{2}\biggr), \end{aligned} $$
(20)

with the Dirichlet boundary condition. Its analytic solution is

$$ u(x,y)= \sin\biggl(\frac{\pi x}{2}\biggr)\sin\biggl(\frac{\pi y}{2} \biggr). $$

We observe that the exact solution does not show high variations; therefore, nonuniform grids are not necessary. Uniform grids are used for this problem to check the effectiveness of the multigrid method. The results obtained from the HOC and CD schemes are presented. The reported error is the error norm over the discretized grid points on the finest grid level. Table 8 lists the number of multigrid V-cycles and the corresponding CPU time in seconds for solving problem 3 on the 162, 322, 642, and 1282 grids. We can see that, for this problem, the multigrid method is very efficient and all the smoothers work well.

Table 8 The error norms and CPU (seconds) for a multigrid method with different discretized schemes for Example 3 , \(\pmb{\|e\|_{2}}\) , \(\pmb{k = 10}\)

5 Conclusion

In this paper, we have proposed a transformation-free high-order compact finite-difference scheme on nonuniform grids for solution of the 2D Helmholtz equation to get up to fourth-order accuracy. Furthermore, we have applied the multigrid method based on the HOC scheme on nonuniform grids, which solved the resulting system efficiently. In the case of boundary layer problems with suitable grid stretching ratios, the accuracy is up to fourth order for the HOC scheme and second order for the CD scheme. Numerical results show that the multigrid method with HOC scheme has the required accuracy and is faster than the CD scheme.