1 Introduction

Advection–diffusion equations arise in the mathematical modelling of numerous areas of science and technology, such as atmospheric computation, oil reservoir simulation, groundwater modelling, financial modelling (see, for instance, [1,2,3, 15, 20]). Accurate numerical computation of the advection–diffusion problems is a challenging task, especially for the problems that advection is dominating over diffusion, and for the problems where advective stirring sharpens concentration gradients. The conventional numerical methods often encounter problems of non-physical oscillations and excessive numerical diffusions at steep fronts, while at the same time, these methods can not ensure mass conservation, which is required in various mathematical modelling applications. Ideally we would like to develop the efficient and high accuracy numerical approach that can solve advection and diffusion simultaneously and can preserve the mass conservation.

To overcome the difficulties in solving the advection–diffusion problems, elaborate numerical schemes based on the idea of characteristics have been proposed to achieve stable computation. The characteristic technique is natural from the physical point of view, as the solution procedure effectively solves the problem along the streamline of flow and gets accurate approximation, and it is attractive from the computational point of view, since it enables using large time steps and thus can significantly reduce computational costs. Many efforts have been devoted to the development of the characteristic methods. Douglas and Russell proposed a modified method of characteristics (MMOC) for solving one dimensional advection–diffusion problems in [9]. Further developments of the methods were carried out to solve high-dimensional advection–diffusion problems in [4, 8, 11], which are of first order accurate in time, and a second order in time scheme is proposed by Rui and Tabata [18]. Moreover, Liang et al. [14] developed a second order characteristic finite element scheme for nonlinear problems. However, all these schemes can not ensure conservation of mass in computation. For one-dimensional convection–diffusion problems, Celia et al. [6] proposed the Eulerian–Lagrangian localized adjoint method (ELLAM), which provides a consistent framework for conserving global mass. Further study of the ELLAM has been successfully taken for high-dimensional problems by Binning and Celia [5], Healy and Russell [12], and Liang et al. [13]. Rui [17, 19] proposed a conservative characteristic finite volume element method, and proposed a conservative characteristic finite element scheme. These conservative methods in [5, 6, 12, 13, 17, 19] preserve mass balance identity well, but are all first order accuracy in time. On another aspect of the problem, a number of mass conserving semi-Lagrangian schemes were developed for advection only problems by conservative remapping technique, which are mathematically based by using a piecewise parabolic method (PPM) [7] that applies a preserve parabola interpolation at previous time level to achieve local mass conservation. The methods were further discussed for high dimensional transport problems without diffusion [16, 21,22,23]. But there has been no work on such method dealing with combined advection–diffusion problems in high dimensions, where there will be difficulties in achieving approximation for diffusion terms that can satisfy mass conservation while maintaining a high accuracy in time.

In this work, we propose a time second-order mass conservation characteristic finite difference method (T2-MC-C-FDM) for two dimensional advection–diffusion problems. The proposed method combines the characteristic technique with mass-preserving interpolations, and provides the advantages of both techniques. It enables using large time step sizes to get high accurate solutions, while achieves the conservations of variables. The advection–diffusion governing equations are first transferred to a locally conservative formula by using the characteristic approach. In order to get mass-preserving results, we treat the advective integrals over the tracking cells at the previous time level by combining two 1D conservative interpolations on Eulerian–Lagrangian mesh. For getting high order accuracy in time, a second order scheme by averaging along the characteristics is proposed for the time discretization of the diffusion terms, which leads to high accurate characteristic solutions. And we propose to compute the diffusion fluxes by high order discrete schemes that provide continuity at the edges of irregular tracking cells at previous time level to maintain mass conservation. The developed method is mass preserving and has second order accuracy in time, whilst permitting the use of large time steps, and is therefore highly suitable for large scale problems. Numerical test of Gaussian hump moving in solid body rotation first demonstrates that the proposed method has second order accuracy both in time and space, and preserves the mass exactly. The experiments of a square wave moving test, a Gaussian hump moving test in vortex shear and a moving steep front test further validate the mass conservation advantage of our T2-MC-C-FDM over standard characteristic methods, and show the good stability of the new developed method.

The paper is structured as follows. Section 2 gives the description of the time second order mass conservation characteristic finite difference method (T2-MC-C-FDM) for 2D advection–diffusion problems. Numerical experiments are given in Sect. 3. Conclusions of this study are summarized in Sect. 4.

2 A Mass Preserving Time Second Order Characteristic Finite Difference Scheme

Let \(\varOmega \) be a bounded 2D domain with boundary \(\partial \varOmega = \varGamma _{in} + \varGamma _{out}\), where \(\varGamma _{in}\) and \(\varGamma _{out}\) are the inflow and outflow boundaries, respectively. T is a positive constant, and (0, T] is the time period. We now consider the following two dimensional advection–diffusion problem:

$$\begin{aligned}&\frac{\partial c}{\partial t} + \nabla \cdot (\mathbf {u} c) - \nabla \cdot (K \nabla c) = f(x,y,t), (x,y,t) \in \varOmega \times (0,T], \end{aligned}$$
(1)
$$\begin{aligned}&c(x,y,t) = g_{in} (x,y,t), (x,y,t) \in \varGamma _{in} \times (0, T], \end{aligned}$$
(2)
$$\begin{aligned}&K \frac{\partial c}{\partial \mathbf {\nu }} = 0, (x,y,t) \in \varGamma _{out} \times (0, T], \end{aligned}$$
(3)
$$\begin{aligned}&c(x,y,0) = c_0 (x,y), (x,y) \in \varOmega , \end{aligned}$$
(4)

where \({\mathbf {x}} = (x,y)\) is the location in space; \(\mathbf {u} = (u_x (x,y, t), u_y (x,y, t))\) is the velocity of the field; \(K=diag(K_x, K_y)\) is the diffusion tensor with \(K_x >0\) and \(K_y>0\); f(xyt) is the given source term; \(g_{in} (x,y,t)\) and \(c_0(x,y)\) are the given inflow boundary condition and initial distribution, respectively; and \(\mathbf {\nu }\) is the unit outer normal to the boundary \(\partial \varOmega \).

Divide the two dimensional domain \(\varOmega =[a_x, b_x] \times [a_y, b_y]\) into \(I \times J\) regular Eulerian cells \(\varOmega _{i,j}\), with the definition

$$\begin{aligned} \varOmega _{i,j} = \{(x,y), x\in [x_{i-1/2}, x_{i+1/2}], y\in [y_{j-1/2}, y_{j+1/2}] \}, \end{aligned}$$
(5)

where \(x_{i+1/2} = a_x + (i-1)h_x\), \(y_{j+1/2} = a_y + (j-1)h_y\), \(h_x=(b_x - a_x)/I \), and \(h_y=(b_y - a_y)/J\).

Let \({\varDelta {t}}\) denotes a time step and \(N_t = T/{\varDelta {t}} \) be the total time step number, and \(t^n = n {\varDelta {t}}\). During each time interval \(t \in (t^n, t^{n+1}]\), consider the problem (1)–(4) with \(c^{n}\) be the value at \(t^n\). Denote the characteristic direction by \(\tau \), and the characteristic line \(X(\tau ; {\mathbf {x}}, t^{n+1})\) of (1) along the velocity \(\mathbf {u}\) from any point \(({\mathbf {x}}, t^{n+1}) \) at time level \(t^{n+1}\) is defined by

$$\begin{aligned} \frac{ d X\left( \tau ; {\mathbf {x}}, t^{n+1}\right) }{d \tau }= & {} \mathbf {u} \left( X\left( \tau ; {\mathbf {x}}, t^{n+1}\right) , \tau \right) , \tau \in [t^n , t^{n+1}],\end{aligned}$$
(6)
$$\begin{aligned} X \left( t^{n+1}; {\mathbf {x}}, t^{n+1}\right)= & {} {\mathbf {x}}. \end{aligned}$$
(7)

Denote the intersection of the characteristic line with time level \(t=t^n\) by \(\bar{{\mathbf {x}}} ^n = X(t^n;{\mathbf {x}}, t^{n+1}) \).

For each \(\varOmega _{i,j}\), let \(\varOmega _{i,j} (t)\) be the corresponding characteristic cell

$$\begin{aligned} \varOmega _{i,j} (t) = \left\{ \bar{{\mathbf {x}}} \in \varOmega : \bar{{\mathbf {x}}} = X\left( t; {\mathbf {x}}, t^{n+1}\right) , {\mathbf {x}} \in \varOmega _{i,j}, t\in \left[ t^n, t^{n+1} \right] \right\} , \end{aligned}$$
(8)

and

$$\begin{aligned} {\bar{\varOmega }}_{i,j} \left( t^n\right) = \left\{ \bar{{\mathbf {x}}} \in \varOmega : \bar{{\mathbf {x}}} = X\left( t^n; {\mathbf {x}}, t^{n+1}\right) , {\mathbf {x}} \in \varOmega _{i,j} \right\} . \end{aligned}$$
(9)

Define a space-time volume \(R_{i,j}^{n+1}\) by

$$\begin{aligned} R_{i,j}^{n+1} = \left\{ \left( {\mathbf {x}}, t\right) ; {\mathbf {x}} \in \varOmega _{i,j}(t), t \in \left[ t^n, t^{n+1} \right] \right\} . \end{aligned}$$
(10)

Integrating the governing equation (1) over \(R_{i,j}^{n+1}\) leads to

$$\begin{aligned}&\int _{t^n}^{t^{n+1}} \int _{\varOmega _{i,j}(t)} \left( \frac{\partial c}{\partial t} +\nabla \cdot (\mathbf {u} c) \right) d {\mathbf {x}} d t - \int _{t^n}^{t^{n+1}} \int _{\varOmega _{i,j}(t)} \nabla \cdot (K \nabla c) d {\mathbf {x}} d t \nonumber \\&\quad = \int _{t^n}^{t^{n+1}} \int _{\varOmega _{i,j}(t)} f( {\mathbf {x}} , t) d {\mathbf {x}} d t. \end{aligned}$$
(11)

By applying the Leibniz rule for the differentiation of an integral in the plane [10], we have

$$\begin{aligned} \frac{d}{d t} \left( \int _{\varOmega _{i,j}(t)} c({\mathbf {x}} ,t) d {\mathbf {x}} \right) = \int _{\varOmega _{i,j}(t)} \left( \frac{\partial c}{\partial t} +\nabla \cdot (\mathbf {u} c) \right) d {\mathbf {x}} , \end{aligned}$$
(12)

substituting (12) into the first term of (11) yields

$$\begin{aligned}&\int _{\varOmega _{i,j}} c\left( {\mathbf {x}} ,t^{n+1}\right) d {\mathbf {x}} - \int _{{\bar{\varOmega }}_{i,j}\left( t^n\right) } c\left( {\mathbf {x}} ,t^{n}\right) d {\mathbf {x}} - \int _{t^n}^{t^{n+1}} \int _{\partial \varOmega _{i,j}(t)} K \nabla c \cdot {\vec {n}} d s d t \nonumber \\&\quad = \int _{t^n}^{t^{n+1}} \int _{\varOmega _{i,j}(t)} f( {\mathbf {x}} , t) d {\mathbf {x}} d t, \end{aligned}$$
(13)

which leads to the local conservation formula for the 2D advection–diffusion equation (1)

$$\begin{aligned} \begin{aligned}&\left( \int _{\varOmega _{i,j}} c\left( {\mathbf {x}} ,t^{n+1}\right) d {\mathbf {x}} - \int _{{\bar{\varOmega }}_{i,j}(t^n) } c\left( {\mathbf {x}} ,t^{n}\right) d {\mathbf {x}} \right) \\&\qquad - \int _{t^n}^{t^{n+1}} \left[ \int _{X\left( t; \mathbf {x_{i-\frac{1}{2},j-\frac{1}{2}}}, t^{n+1}\right) }^{X\left( t; \mathbf {x_{i+\frac{1}{2},j-\frac{1}{2}}}, t^{n+1}\right) } K \nabla c \cdot \mathbf {n} d s + \int _{X\left( t; \mathbf {x_{i+\frac{1}{2},j-\frac{1}{2}}}, t^{n+1}\right) }^{X\left( t; \mathbf {x_{i+\frac{1}{2},j+\frac{1}{2}}}, t^{n+1}\right) } K \nabla c \cdot \mathbf {n} d s \right. \\&\left. \qquad + \int _{X\left( t; \mathbf {x_{i+\frac{1}{2},j+\frac{1}{2}}}, t^{n+1}\right) }^{X\left( t; \mathbf {x_{i-\frac{1}{2},j+\frac{1}{2}}}, t^{n+1}\right) } K \nabla c \cdot \mathbf {n} d s + \int _{X\left( t; \mathbf {x_{i-\frac{1}{2},j+\frac{1}{2}}}, t^{n+1}\right) }^{X\left( t; \mathbf {x_{i-\frac{1}{2},j-\frac{1}{2}}}, t^{n+1}\right) } K \nabla c \cdot \mathbf {n} d s \right] d t \\&\quad = \int _{t^n}^{t^{n+1}} \int _{\varOmega _{i,j}(t)} f( {\mathbf {x}} , t) d {\mathbf {x}} d t, \end{aligned} \end{aligned}$$
(14)

where \(\vec n\) is the outward-pointing unit normal vector on the cell boundary of \(\varOmega _{i,j}(t)\).

Fig. 1
figure 1

Eulerian mesh-grids and the tracking Lagrangian mesh-grids in 2D. The continuous thin black lines indicate Eulerian cells; the dashed thin black lines are the centered Eulerian lines \(x_i\) and \(y_j\) ; the dashed thick black lines indicate the tracking Lagrangian cells; and the intersections of Lagrangian lines \({\mathcal {L}}x_i\) with centered Eulerian lines \(y_{j}\) are shown by open squares

To get the full discrete scheme, let \(C_{i,j} \) be the approximation to the average value of the solution c over cell \(\varOmega _{i,j}\) at time t,

$$\begin{aligned} C_{i,j} \approx \frac{1}{h_x h_y} \int _{\varOmega _{i,j}} c( {\mathbf {x}}, t ) d {\mathbf {x}}, \, \, \forall n \ge 0, i=1, \ldots , I, j=1, \ldots , J. \end{aligned}$$
(15)

Then we use the unknown \(C_{i,j}^{n + 1}\) at time \(t = t^{n + 1}\) level to approximate the first term in Eq. (14) as

$$\begin{aligned} \int _{\varOmega _{i,j}} c\left( {\mathbf {x}} ,t^{n+1}\right) d {\mathbf {x}} = h_x h_y C_{i,j}^{n + 1}. \end{aligned}$$
(16)

For the approximation of the second term of the integral of \(c(x, t^n)\) over Lagrangian cell \({\bar{\varOmega }}_{i,j} (t^n)\) at time level \(t^n\) in (14), i.e., the mass of c over \({\bar{\varOmega }}_{i,j} (t^n)\), standard interpolation methods like bi-linear interpolation or bi-parabolic interpolation can not ensure mass conservation. To preserve mass, we propose to utilize two 1D conservative interpolations.

Referring to Fig. 1, we denote the Lagrangian line \(\{\bar{{\mathbf {x}}}_{i+1/2, j+1/2};\) \(j = 0, 1, 2, \ldots , J \}\) by \({\mathcal {L}}x_{i+1/2} \), and define the Lagrangian line \(\{\bar{{\mathbf {x}}}_{i+1/2, j+1/2}; i=0, 1, 2, \ldots , I \}\) by \({\mathcal {L}}y_{j+1/2} \). Let the intersection point of \({\mathcal {L}}x_{i+1/2} \) with the line \(y_j\) be denoted by \(P_{i+1/2,j} (\tilde{x}_{i+1/2,j}, y_j) \), and the middle point of \(\bar{{\mathbf {x}}}_{i-1/2, j+1/2}\) and \( \bar{{\mathbf {x}}}_{i+1/2, j+1/2}\) be denoted by \(Q_{i, j+1/2} ({\tilde{x}}_{i, j+1/2} , {\tilde{y}}_{i,j+1/2} )\). Let \({{{\hat{\varOmega }}}}_{i,j}\) be the volume bounded in the x-direction by \(y_{j-1/2}\) and \(y_{j+1/2}\), and bounded within Lagrangian lines of \({\mathcal {L}}x_{i-1/2}\) and \({\mathcal {L}}x_{i+1/2}\) (\({ EFGH}\) in Fig. 1).

The advective integral over \({\bar{\varOmega }}_{i,j} (t^n)\) is then evaluated through the following two steps.

Step 1. We first consider a mass conservative computation along the Eulerian x-direction for a single \(y_j\) strip, \(\forall j=1, \ldots , J\), i.e., the domain between the lines \(y_{j-1/2}\) and \(y_{j+1/2}\). Define a second order preserving interpolation distribution \([{\mathcal {F}}^xC^n]_{p,j}\) as

$$\begin{aligned}{}[{\mathcal {F}}^xC^n]_{p,j}(x) = C^n _{p-\frac{1}{2},j} + \frac{x-x_{p-\frac{1}{2}}}{h_x} \left( \varDelta C^n_{p,j}+ C^n_{6,p,j} \frac{x_{p+\frac{1}{2}} - x }{h_x} \right) , \quad p=1, \ldots , I , \end{aligned}$$
(17)

which satisfies

$$\begin{aligned} \left\{ \begin{array}{ll} {}[{\mathcal {F}}^xC^n]_{p,j}\left( x_{p-\frac{1}{2}}\right) = {\langle {C}}^n {\rangle }_{p-\frac{1}{2},j}, \\ {}[{\mathcal {F}}^xC^n]_{p,j}\left( x_{p+\frac{1}{2}}\right) = {\langle {C}}^n {\rangle }_{p+\frac{1}{2},j}, \\ \int _{x_{p-\frac{1}{2}}}^{x_{p+\frac{1}{2}}} [{\mathcal {F}}^xC^n]_{p,j}(x) d x= h_x C^n_{p,j}, \end{array} \right. \end{aligned}$$
(18)

where, for fixed j, \(\varDelta C^n_{p,j}\), \(C^n_{6,p,j}\), \( \langle C^n \rangle _{p-\frac{1}{2},j}\) are computed as follows:

$$\begin{aligned}&{\langle {C}}^n{\rangle }_{p-\frac{1}{2},j} = \frac{1}{2} \left( C^n_{p-1,j} + C^n_{p,j}\right) , \ j=1, 2, \ldots , J, \end{aligned}$$
(19)
$$\begin{aligned}&{\varDelta {C}}^n_{p,j}= {\langle {C}}^n {\rangle }_{p+\frac{1}{2},j} - {\langle {C}}^n {\rangle }_{p-\frac{1}{2},j}, \end{aligned}$$
(20)
$$\begin{aligned}&C^n_{6,p,j} = 6 \left( C^n_{p,j}- \frac{1}{2}\left( {\langle {C}}^n {\rangle }_{p+\frac{1}{2},j} + {\langle {C}}^n {\rangle }_{p-\frac{1}{2},j}\right) \right) . \end{aligned}$$
(21)

\([{\mathcal {F}}^xC^n]_{p,j}\) gives a mass conserved concentration distribution over \(\varOmega _{p,j}\) along x-direction, and the mass over \({\hat{\varOmega }}_{i,j}\) can be approximated by computing an integral from the point \(P_{i-1/2,j}\) to \(P_{i+1/2,j}\), as

$$\begin{aligned} {\hat{M}}_{i,j}^n\approx & {} h_y \int _{{\tilde{x}}_{i-1/2,j}}^{{\tilde{x}}_{i+1/2,j}} [{\mathcal {F}}^xC^n](x,t^n) d x \nonumber \\= & {} \left\{ \begin{array}{ll} h_y \int _{{\tilde{x}}_{i-1/2,j}}^{x_{l+1/2}} [{\mathcal {F}}^xC^n]_{l,j}(x) d x + \sum \limits _{k=l+1}^{m-1} h_y h_x C_{k,j}^n &{} \\ \qquad + h_y \int ^{{\tilde{x}}_{i+1/2}}_{x_{m-1/2}} [{\mathcal {F}}^xC^n]_{m,j}(x) d x , &{} m\ge l+1, \\ h_y \int _{{\tilde{x}}_{i-1/2,j}}^{{\tilde{x}}_{i+1/2,j}} [{\mathcal {F}}^xC^n]_{l,j}(x) d x , &{} m=l\\ \end{array} \right. \nonumber \\\equiv & {} I_{h, {\hat{\varOmega }}_{i,j}} \left( C^n\right) , \end{aligned}$$
(22)

where m and \(l\,(m \ge l)\) are the x-indices of Eulerian cells that \({\tilde{x}}_{i-1/2,j}\) and \({\tilde{x}}_{i+1/2,j}\) lie in.

Step 2. We now consider a mass conservative computation for the single \({\mathcal {L}}x_i\) Lagrangian strip, i.e., the domain between the Lagrangian lines \({\mathcal {L}}x_{i-\frac{1}{2}}\) and \({\mathcal {L}}x_{i+\frac{1}{2}}\). Let \(\hat{C}^n_{i,q} = \hat{M}^n_{i,q} / h_y\), then for a fixed i, we define a second order mass preserving interpolation function \([{\mathcal {F}}^y{\hat{C}}^n]_{i,q}\) as

$$\begin{aligned}{}[{\mathcal {F}}^y{\hat{C}}^n]_{i,q}(y) = \hat{C}^n _{i,q-\frac{1}{2}} + \frac{y-y_{q-\frac{1}{2}}}{h_y} \left( \varDelta \hat{C}^n_{i,q}+ \hat{C}^n_{6,i,q} \frac{y_{q+\frac{1}{2}} - y }{h_y} \right) ,\quad q=1, \ldots , J,\nonumber \\ \end{aligned}$$
(23)

which satisfies

$$\begin{aligned} \left\{ \begin{array}{ll} {}[{\mathcal {F}}^y{\hat{C}}^n]_{i,q}\left( y_{q-\frac{1}{2}}\right) = \langle \hat{C}^n \rangle _{i,q-\frac{1}{2}}, \\ {}[{\mathcal {F}}^y{\hat{C}}^n]_{i,q}\left( y_{q+\frac{1}{2}}\right) = \langle \hat{C}^n \rangle _{i,q+\frac{1}{2}}, \\ \int _{y_{q-\frac{1}{2}}}^{y_{q+\frac{1}{2}}} [{\mathcal {F}}^y{\hat{C}}^n]_{i,q}(y) d y= h_y \hat{C}^n_{i,q}, \end{array} \right. \end{aligned}$$
(24)

where \(\varDelta \hat{C}^n_{i,q}\), \(\hat{C}^n_{6,i,q}\), \( \langle \hat{C}^n \rangle _{i,q-\frac{1}{2}}\) are computed similarly as (20), (21) and (19), respectively. \([{\mathcal {F}}^y{\hat{C}}^n]_{i,q}\) provides a mass conserved concentration distribution over cell \({\hat{\varOmega }}_{i,q}\) along y-direction, and the mass over \({\bar{\varOmega }}_{i,j} \) can then be approximated by computing an integral from the point \(Q_{i,j-\frac{1}{2}}\) to \(Q_{i,j+\frac{1}{2}}\), as

$$\begin{aligned}&\int _{{\tilde{y}}_{i, j-1/2}}^{{\tilde{y}}_{i, j+1/2}} [{\mathcal {F}}^y{\hat{C}}^n](y,t^n) d y \nonumber \\&\quad = \left\{ \begin{array}{ll} \int _{{\tilde{y}}_{i, j-1/2}}^{y_{l_y+1/2}} [{\mathcal {F}}^y{\hat{C}}^n]_{i, l_y} (y) d y + \sum \limits _{k=l_y+1}^{m_y-1} h_y \hat{C}_{i,k}^n &{} \\ \qquad + \int ^{{\tilde{y}}_{i, j+1/2}}_{y_{m_y-1/2}} [{\mathcal {F}}^y{\hat{C}}^n]_{i, m_y} (y) d y , &{} m_y \ge l_y +1, \\ \int _{{\tilde{y}}_{i, j-1/2}}^{{\tilde{y}}_{i, j+1/2}} [{\mathcal {F}}^y{\hat{C}}^n]_{i, l_y} (y) d y , &{} m_y = l_y\\ \end{array} \right. \nonumber \\&\quad \equiv I_{h, {\bar{\varOmega }}_{i,j} } \left( {C}^n\right) , \end{aligned}$$
(25)

where \(l_y\) and \(m_y\), \((m_y \ge l_y) \) are the y-indices of \({\hat{\varOmega }}_{i,q}\) that \({\tilde{y}}_{i, j-1/2}\) and \({\tilde{y}}_{i, j+1/2}\) lie in.

For getting second order in time accuracy, we propose to treat the diffusion terms in (14) by taking average along the characteristics

$$\begin{aligned}&\int _{t^n}^{t^{n+1}} \left[ \int _{X\left( t; \mathbf {x_{i-\frac{1}{2},j-\frac{1}{2}}}, t^{n+1}\right) }^{X\left( t; \mathbf {x_{i+\frac{1}{2},j-\frac{1}{2}}}, t^{n+1}\right) } K \nabla c \cdot \vec n d s + \int _{X\left( t; \mathbf {x_{i+\frac{1}{2},j-\frac{1}{2}}}, t^{n+1}\right) }^{X\left( t; \mathbf {x_{i+\frac{1}{2},j+\frac{1}{2}}}, t^{n+1}\right) } K \nabla c \cdot \vec n d s \right. \nonumber \\&\left. \qquad +\, \int _{X\left( t; \mathbf {x_{i+\frac{1}{2},j+\frac{1}{2}}}, t^{n+1}\right) }^{X\left( t; \mathbf {x_{i-\frac{1}{2},j+\frac{1}{2}}}, t^{n+1}\right) } K \nabla c \cdot \vec n d s + \int _{X\left( t; \mathbf {x_{i-\frac{1}{2},j+\frac{1}{2}}}, t^{n+1}\right) }^{X\left( t; \mathbf {x_{i-\frac{1}{2},j-\frac{1}{2}}}, t^{n+1}\right) } K \nabla c \cdot \vec n d s \right] d t \nonumber \\&\qquad \approx \frac{\varDelta t}{2} \left( \int _{\mathbf {x_{i-\frac{1}{2},j-\frac{1}{2}}}}^{\mathbf {x_{i+\frac{1}{2},j-\frac{1}{2}}}} K \frac{\partial c^{n+1}}{\partial \vec n} d s + \int _{\bar{{\mathbf {x}}}_{i-\frac{1}{2},j-\frac{1}{2}}}^{\bar{{\mathbf {x}}}_{i+\frac{1}{2},j-\frac{1}{2}}} K \frac{\partial c^{n}}{\partial \vec n} d s \right. \nonumber \\&\left. \qquad + \int _{\mathbf {x_{i+\frac{1}{2},j-\frac{1}{2}}}}^{\mathbf {x_{i+\frac{1}{2},j+\frac{1}{2}}}} K \frac{\partial c^{n+1}}{\partial \vec n} d s + \int _{\bar{{\mathbf {x}}}_{i+\frac{1}{2},j-\frac{1}{2}}}^{\bar{{\mathbf {x}}}_{i+\frac{1}{2},j+\frac{1}{2}}} K \frac{\partial c^{n}}{\partial \vec n} d s \right. \nonumber \\&\left. \qquad + \int _{\mathbf {x_{i+\frac{1}{2},j+\frac{1}{2}}}}^{\mathbf {x_{i-\frac{1}{2},j+\frac{1}{2}}}} K \frac{\partial c^{n+1}}{\partial \vec n} d s + \int _{\bar{{\mathbf {x}}}_{i+\frac{1}{2},j+\frac{1}{2}}}^{\bar{{\mathbf {x}}}_{i-\frac{1}{2},j+\frac{1}{2}}} K \frac{\partial c^{n}}{\partial \vec n} d s \right. \nonumber \\&\left. \qquad + \int _{\mathbf {x_{i-\frac{1}{2},j+\frac{1}{2}}}}^{\mathbf {x_{i-\frac{1}{2},j-\frac{1}{2}}}} K \frac{\partial c^{n+1}}{\partial \vec n} d s + \int _{\bar{{\mathbf {x}}}_{i-\frac{1}{2},j+\frac{1}{2}}}^{\bar{{\mathbf {x}}}_{i-\frac{1}{2},j-\frac{1}{2}}} K \frac{\partial c^{n}}{\partial \vec n} d s \right) . \end{aligned}$$
(26)

Referring to Fig. 1, the right side of (26) is more clear using the symbols in the figure and be written as

$$\begin{aligned}&\frac{\varDelta t}{2} \left( \int _{AB} K \frac{\partial c^{n+1}}{\partial \vec n} d s + \int _{\bar{A}\bar{B}} K \frac{\partial c^{n}}{\partial \vec n} d s \right. \nonumber \\&\left. \quad + \int _{BC} K \frac{\partial c^{n+1}}{\partial \vec n} d s + \int _{\bar{B}\bar{C}} K \frac{\partial c^{n}}{\partial \vec n} d s \right. \nonumber \\&\left. \quad + \int _{CD} K \frac{\partial c^{n+1}}{\partial \vec n} d s + \int _{\bar{C}\bar{D}} K \frac{\partial c^{n}}{\partial \vec n} d s \right. \nonumber \\&\left. \quad + \int _{DA} K \frac{\partial c^{n+1}}{\partial \vec n} d s + \int _{\bar{D}\bar{A}} K \frac{\partial c^{n}}{\partial \vec n} d s \right) . \end{aligned}$$
(27)

For the diffusion related terms at time level \(t^{n+1}\), we approximate \(\frac{\partial c}{\partial x}\) by \(\delta _x c\) and \(\frac{\partial c}{\partial y}\) by \(\delta _y c\), which leads to the following second order approximation (Refer to Fig. 1)

$$\begin{aligned}&\int _{AB} K \frac{\partial c^{n+1}}{\partial \vec n} d \text {s}\approx - \left( K h_x \frac{\partial c }{ \partial y}\right) _{i,j-\frac{1}{2}}^{n+1} \approx - K_{i,j-\frac{1}{2}} h_x \delta _y C^{n+1}_{i,j-\frac{1}{2}}, \end{aligned}$$
(28)
$$\begin{aligned}&\int _{CD} K \frac{\partial c^{n+1}}{\partial \vec n} d \text {s}\approx \left( K h_x \frac{\partial c }{ \partial y}\right) _{i,j+\frac{1}{2}}^{n+1} \approx K_{i,j+\frac{1}{2}} h_x \delta _y C^{n+1}_{i,j+\frac{1}{2}}, \end{aligned}$$
(29)
$$\begin{aligned}&\int _{BC} K \frac{\partial c^{n+1}}{\partial \vec n} d \text {s}\approx \left( K h_y \frac{\partial c }{ \partial x}\right) _{i+\frac{1}{2},j}^{n+1} \approx K_{i+\frac{1}{2},j} h_y \delta _x C^{n+1}_{i+\frac{1}{2},j}, \end{aligned}$$
(30)
$$\begin{aligned}&\int _{DA} K \frac{\partial c^{n+1}}{\partial \vec n} d \text {s}\approx - \left( K h_y \frac{\partial c }{ \partial x}\right) _{i-\frac{1}{2},j}^{n+1} \approx - K_{i-\frac{1}{2},j} h_y \delta _x C^{n+1}_{i-\frac{1}{2},j}. \end{aligned}$$
(31)

The computation of diffusion related terms at time level \(t^n\) is a difficult task since the cell boundaries are not align with the regular Eulerian mesh. In order to get the accurate approximation and preserve mass, we require that the discrete flux to \(\frac{\partial c^{n}}{\partial \vec n}\) keeps continuous at cell boundaries and has high order accuracy. Thus we propose to approximate the scalar field of \(c^n\) by the piecewise biparabolic function, from which we get the diffusion flux that is continuous at the tracking cell boundaries at time level \(t^n\). Based on the average values \(C_{i,j}\) (15), we define the piecewise biparabolic function on \(\varOmega _{i,j}\) as

$$\begin{aligned}&[{\mathcal {B}}C^n]_{i,j}(x,y) = \sum \limits _{k=1}^{9} N_k C_{i,j,k}, \nonumber \\&\qquad \forall n \ge 0, i=1, \ldots , I, j=1, \ldots , J, k=1, \ldots , 9, \end{aligned}$$
(32)

where

$$\begin{aligned}&C_{i,j,1}=C_{i-1,j-1}, \ C_{i,j,2}=C_{i+1,j-1}, \ C_{i,j,3}=C_{i+1,j+1}, \nonumber \\&C_{i,j,4}=C_{i-1,j+1}, \ C_{i,j,5}=C_{i-1,j}, \ C_{i,j,6}=C_{i,j-1}, \nonumber \\&C_{i,j,7}=C_{i+1,j}, \ C_{i,j,8}=C_{i,j+1}, \ C_{i,j,9}=C_{i,j}, \end{aligned}$$
(33)

and the elements of the piecewise function here are the local 2D second order polynomials with

$$\begin{aligned}&N_1 = \frac{1}{4} \xi \eta (\xi -1) (\eta -1), \ N_2= \frac{1}{4} \xi \eta (\xi +1) (\eta -1), \nonumber \\&N_3 = \frac{1}{4} \xi \eta (\xi +1) (\eta +1), \ N_4= \frac{1}{4} \xi \eta (\xi -1) (\eta +1), \nonumber \\&N_5 = \frac{1}{2}\xi (\xi - 1)(1-\eta ^2), \ N_6=\frac{1}{2}\eta (\eta -1) (1-\xi ^2), \nonumber \\&N_7 = \frac{1}{2}\xi (\xi + 1)(1-\eta ^2), \ N_8=\frac{1}{2}\eta (\eta +1) (1-\xi ^2), \nonumber \\&N_9 = (1-\xi ^2) ( 1- \eta ^2), \end{aligned}$$
(34)

where

$$\begin{aligned} \xi = \frac{x-x_i}{h_x}, \ \eta = \frac{y-y_j}{h_y}. \end{aligned}$$
(35)

We take \(\int _{\bar{A}\bar{B}} K \frac{\partial c^n}{\partial \vec n} d s\) for example. Assume that \(\bar{A}\bar{B}\) is divided into several small parts, which are defined by intersections of \(\bar{A}\bar{B}\) with the Eulerian grid lines. The integral over \(\bar{A}\bar{B}\), i.e., the integral of the piecewise function, can be understood as a sum of the elementary integrals over these small parts in different grid cells,

$$\begin{aligned} \int _{\bar{A}\bar{B}} K \frac{\partial c^n}{\partial \vec n} d s = \sum \limits _{v} I_v. \end{aligned}$$
(36)

Here \(I_v\) is an elementary integral over the small parts v. Since we already have the piecewise function \([{\mathcal {B}}C^n]\) on each \(\varOmega _{i,j}\), the integral can be obtained by

$$\begin{aligned} \int _{\bar{A}\bar{B}} K \frac{\partial c^n}{\partial \vec n} d s = \sum \limits _{v} \int _{v} K \frac{\partial [{\mathcal {B}}C^n]}{\partial \vec n} d s \equiv I_{h, \partial \bar{\varOmega }_{i,j,B}} \left( C^n\right) . \end{aligned}$$
(37)

More specifically, as shown in Fig. 1, \(\bar{A}\bar{B}\) is divided into two parts by the grid lines, which are denoted as \( {v_1}\) and \( {v_2}\), respectively. Based on (32), we have the piecewise biparabolic function on \(\varOmega _{i-2, j-2}\) and \(\varOmega _{i-1, j-2}\), therefore, the approximation of the integrals \(I_{v_1}\) and \(I_{v_2}\) can be evaluated, and the summation of \(I_{v_1}\) and \(I_{v_2}\) gives \(\int _{\bar{A}\bar{B}}\), which is denoted by \(I_{h, \partial \bar{\varOmega }_{i,j,B}} (C^n)\). Approximation of integrals \(\int _{\bar{B}\bar{C}}\), \(\int _{\bar{C}\bar{D}}\) and \(\int _{\bar{D}\bar{A}}\) can be similarly obtained, and we denote them as \(I_{h, \partial \bar{\varOmega }_{i,j,R}} (C^n)\), \(I_{h, \partial \bar{\varOmega }_{i,j,T}} (C^n)\) and \(I_{h, \partial \bar{\varOmega }_{i,j,L}} (C^n)\), where the letters BRTL represent the “Bottom”, “Right”, “Top” and “Left” boundaries of \(\partial {\hat{\varOmega }}_{i,j}\), respectively.

Fig. 2
figure 2

Velocity field of \(\mathbf {u} = (u_x, u_y) = (-4y, 4x)\). (Test 1)

Table 1 Errors and ratios in time for the 2D advection–diffusion problem by using our T2-MC-C-FDM and a characteristic finite difference method based on bi-linear interpolation (C-FDM-LI) and bi-quadratic interpolation (C-FDM-QI), with \(K=0\), \(\varDelta x=\frac{1}{100}\), and different \(N_t=10, 20, 30, 40\) and 50
Table 2 Errors and ratios in time for the 2D advection–diffusion problem by using our T2-MC-C-FDM and a characteristic finite difference method based on bi-linear interpolation (C-FDM-LI) and bi-quadratic interpolation (C-FDM-QI), with \(K=10^{-5}\), \(\varDelta x=\frac{1}{100}\), and different \(N_t=10, 20, 30, 40\) and 50
Table 3 Errors and ratios in time for the 2D advection–diffusion problem by using our T2-MC-C-FDM and a characteristic finite difference method based on bi-linear interpolation (C-FDM-LI) and bi-quadratic interpolation (C-FDM-QI), with \(K=10^{-3}\), \(\varDelta x=\frac{1}{100}\), and different \(N_t=10, 20, 30, 40\) and 50

From (14) to (37), the time second order mass conservative characteristic finite difference method (T2-MC-C-FDM) for solving the 2D advection–diffusion problem (1) is proposed as

$$\begin{aligned}&\left( h_x h_y C_{i,j}^{n+1} - I_{h, {\bar{\varOmega }}_{i,j}} \left( C^n\right) \right) \nonumber \\&\qquad - \frac{\varDelta t}{2} \left( h_x h_y \left[ \frac{1}{h_x} \left( K_{x_{i+\frac{1}{2},j}} \delta _x C^{n+1}_{i+\frac{1}{2},j} -K_{x_{i-\frac{1}{2},j}} \delta _x C^{n+1}_{i-\frac{1}{2},j} \right) \right. \right. \nonumber \\&\qquad \left. + \frac{1}{h_y} \left( K_{y_{i,j+\frac{1}{2}}} \delta _y C^{n+1}_{i,j+\frac{1}{2}} -K_{x_{i,j-\frac{1}{2}}} \delta _y C^{n+1}_{i,j-\frac{1}{2}} \right) \right] \nonumber \\&\qquad + I_{h, \partial \bar{\varOmega }_{i,j,B}} \left( C^n\right) + I_{h, \partial \bar{\varOmega }_{i,j,R}} \left( C^n\right) + I_{h, \partial \bar{\varOmega }_{i,j,T}} \left( C^n\right) + I_{h, \partial \bar{\varOmega }_{i,j,L}} \left( C^n\right) \bigg ) \nonumber \\&\quad = \int _{t^n}^{t^{n+1}} \int _{\varOmega _{i,j}(t)} f({\mathbf {x}},t) d {\mathbf {x}} d t, \end{aligned}$$
(38)

with the initial condition

$$\begin{aligned} C^0 (x_i, y_j) = c^0_{i,j}, \end{aligned}$$
(39)

and boundary conditions

$$\begin{aligned}&C^{n+1}(x,y)= f_{in} \left( x,y,t^{n+1}\right) , (x,y) \in \varGamma _{in}, \nonumber \\&\delta _x C_{\frac{1}{2},j}^{n+1} = 0, \left( x_{\frac{1}{2},j}, y\right) \in \varGamma _{out}, \nonumber \\&\delta _x C_{I +\frac{1}{2},j}^{n+1} = 0, \left( x_{I +\frac{1}{2},j}, y\right) \in \varGamma _{out}, \nonumber \\&\delta _y C_{i,\frac{1}{2}}^{n+1} = 0, \left( x, y_{i,\frac{1}{2}},\right) \in \varGamma _{out}, \nonumber \\&\delta _y C_{i, J+\frac{1}{2}}^{n+1} = 0, \left( x, y_{i, J+\frac{1}{2}}\right) \in \varGamma _{out}, \nonumber \\&\qquad \qquad \qquad \forall i=1, 2, \ldots , I , j=1, 2, \ldots , J, \ \forall n=1, 2, \ldots , N_t. \end{aligned}$$
(40)

Mass preserving property

We assume that the velocity field \(\mathbf {u}\) satisfies the following condition.

Hypothesis 1

The velocity \(\mathbf {u}\) satisfies

$$\begin{aligned} \left\{ \begin{array}{l} \mathbf {u}=C^0 \left( W^{1,\infty } (\varOmega )\right) , \\ \mathbf {u} \cdot \mathbf {\nu }=0, \ \mathrm {on \ } \partial \varOmega . \\ \end{array} \right. \end{aligned}$$
(41)

We now examine the mass preserving property of the time and space second order mass preserving characteristic finite difference method (T2-MC-C-FDM) (38).

Theorem 2

Under hypothesis 1, and consider the problem (1) with the following boundary condition,

$$\begin{aligned} \left. \frac{\partial c}{\partial x} \right| _{a_x} = \left. \frac{\partial c}{\partial x} \right| _{b_x} = 0, \quad \left. \frac{\partial c}{\partial y} \right| _{a_y} = \left. \frac{\partial c}{\partial x} \right| _{b_y} = 0, \end{aligned}$$
(42)

the numerical scheme (38) is globally mass conserved.

Proof

Summing the Eq. (38) from \(i=1\) to I, and \(j=1\) to J, leads to

$$\begin{aligned}&\sum \limits _{i=1}^{I } \sum \limits _{j=1}^{J} h_x h_y C_{i,j}^{n+1} - \sum \limits _{i=1}^{I } \sum \limits _{j=1}^{J} I_{h, {\bar{\varOmega }}_{i,j}} (C^n) \nonumber \\&\qquad - \, \frac{\varDelta t}{2} \sum \limits _{i=1}^{I } \sum \limits _{j=1}^{J} \left( h_x h_y \left[ \frac{1}{h_x } \left( K_{x_{i+\frac{1}{2},j}} \delta _x C^{n+1}_{i+\frac{1}{2},j} -K_{x_{i-\frac{1}{2},j}} \delta _x C^{n+1}_{i-\frac{1}{2},j} \right) \right. \right. \nonumber \\&\qquad \left. + \, \frac{1}{h_y } \left( K_{y_{i,j+\frac{1}{2}}} \delta _y C^{n+1}_{i,j+\frac{1}{2}} -K_{x_{i,j-\frac{1}{2}}} \delta _y C^{n+1}_{i,j-\frac{1}{2}} \right) \right] \nonumber \\&\qquad +\, I_{h, \partial \bar{\varOmega }_{i,j,B}} (C^n) + I_{h, \partial \bar{\varOmega }_{i,j,R}} (C^n)+ I_{h, \partial \bar{\varOmega }_{i,j,T}} (C^n) + I_{h, \partial \bar{\varOmega }_{i,j,L}} (C^n) \bigg ) \nonumber \\&\quad = \int _{t^n}^{t^{n+1}} \int _{\varOmega } f({\mathbf {x}},t) d {\mathbf {x}} d t. \end{aligned}$$
(43)

Under the Hypothesis 2, for any \(j=0, 1, \ldots , J\), we have \({\bar{x}}_{\frac{1}{2}, j} = x_{\frac{1}{2}, j} = a_x \), \({\bar{x}}_{I +\frac{1}{2}, j} = x_{I +\frac{1}{2}, j} = b_x \), and for any \(i=0, 1, \ldots , I \), we have \({\bar{y}}_{i, \frac{1}{2}} = y_{j, \frac{1}{2}} = a_y \), \({\bar{y}}_{i, J+\frac{1}{2}} = y_{i, J+\frac{1}{2}} = b_y \), combining (22), it leads to

$$\begin{aligned} \sum \limits _{i=1}^{I } \hat{M}^n_{i,j} = \sum \limits _{i=1}^{I } I_{h, {\hat{\varOmega }}_{i,j}}\left( C^n\right) = \sum \limits _{i=1}^{I } h_y h_x C_{i,j}^n. \end{aligned}$$
(44)

combining (25), it gives

$$\begin{aligned} \sum \limits _{j=1}^{J} I_{h, {\bar{\varOmega }}_{i,j}}\left( {C}^n\right) = \sum \limits _{j=1}^{J} I_{h, {\hat{\varOmega }}_{i,j}} \left( {C}^n\right) = \sum \limits _{j=1}^{J} {\hat{M}}^n_{i,j}, \end{aligned}$$
(45)

which yields

$$\begin{aligned} \sum \limits _{i=1}^{I } \sum \limits _{j=1}^{J} I_{h, {\bar{\varOmega }}_{i,j}} \left( {C}^n\right) =\sum \limits _{j=1}^{J} \sum \limits _{i=1}^{I } h_x h_y C_{i,j}^n. \end{aligned}$$
(46)
Table 4 Errors and ratios in space for the 2D advection–diffusion problem by using our T2-MC-C-FDM and a characteristic finite difference method based on bi-linear interpolation (C-FDM-LI) and bi-quadratic interpolation (C-FDM-QI), with \(K=0\), \(\varDelta t=1/900\) and different \(\varDelta x=\frac{1}{50}, \frac{1}{60}, \frac{1}{70}, \frac{1}{80}\) and \( \frac{1}{90}\)
Table 5 Errors and ratios in space for the 2D advection–diffusion problem by using our T2-MC-C-FDM and a characteristic finite difference method based on bi-linear interpolation (C-FDM-LI) and bi-quadratic interpolation (C-FDM-QI), with \(K=10^{-5}\), \(\varDelta t=1/900\) and different \(\varDelta x=\frac{1}{50}, \frac{1}{60}, \frac{1}{70}, \frac{1}{80}\) and \( \frac{1}{90}\)
Table 6 Errors and ratios in space for the 2D advection–diffusion problem by using our T2-MC-C-FDM and a characteristic finite difference method based on bi-linear interpolation (C-FDM-LI) and bi-quadratic interpolation (C-FDM-QI), with \(K=10^{-3}\), \(\varDelta t=1/900\) and different \(\varDelta x=\frac{1}{50}, \frac{1}{60}, \frac{1}{70}, \frac{1}{80}\) and \( \frac{1}{90} \)

Noting that for the adjacent two Lagrangian cells which shares one boundary, the flux that flow into one cell through that boundary is exactly equals the flux that flow out the other cell through that boundary,

$$\begin{aligned} I_{h, \partial \bar{\varOmega }_{i,j,B}} \left( C^n\right) + I_{h, \partial \bar{\varOmega }_{i,j-1,T}} \left( C^n\right) =0, \quad I_{h, \partial \bar{\varOmega }_{i,j,L}} \left( C^n\right) + I_{h, \partial \bar{\varOmega }_{i-1,j,R}} \left( C^n\right) =0, \end{aligned}$$
(47)

and considering the boundary condition (2), we have

$$\begin{aligned}&\sum \limits _{i=1}^{I } \sum \limits _{j=1}^{J} \left( h_x h_y \left[ \frac{1}{h_x } \left( K_{x_{i+\frac{1}{2},j}} \delta _x C^{n+1}_{i+\frac{1}{2},j} -K_{x_{i-\frac{1}{2},j}} \delta _x C^{n+1}_{i-\frac{1}{2},j} \right) \right. \right. \nonumber \\&\qquad \left. +\, \frac{1}{h_y } \left( K_{y_{i,j+\frac{1}{2}}} \delta _y C^{n+1}_{i,j+\frac{1}{2}} -K_{x_{i,j-\frac{1}{2}}} \delta _y C^{n+1}_{i,j-\frac{1}{2}} \right) \right] \nonumber \\&\qquad +\, I_{h, \partial \bar{\varOmega }_{i,j,B}} \left( C^n\right) + I_{h, \partial \bar{\varOmega }_{i,j,R}} \left( C^n\right) + I_{h, \partial \bar{\varOmega }_{i,j,T}} \left( C^n\right) + I_{h, \partial \bar{\varOmega }_{i,j,L}}\left( C^n\right) \bigg ) \nonumber \\&\quad = 0. \end{aligned}$$
(48)

Then from (43)–(48), it holds that

$$\begin{aligned} \sum \limits _{i=1}^{I } \sum \limits _{j=1}^{J} h_x h_y C_{i,j}^{n+1} - \sum \limits _{i=1}^{I } \sum \limits _{j=1}^{J} I_{h, {\bar{\varOmega }}_{i,j}} \left( C^n\right) = \int _{t^n}^{t^{n+1}} \int _{\varOmega } f({\mathbf {x}},t) d {\mathbf {x}} d t. \end{aligned}$$
(49)

\(\square \)

3 Numerical Simulation

3.1 Test 1: Gaussian Hump in Solid Body Rotation

In this first numerical test, we consider a advection–diffusion problem (1)–(4) of a Gaussian concentration hump moving in 2D spatial domain \(\varOmega = [-1 , 1] \times [-1, 1]\), the velocity \(\mathbf {u} = (u_x, u_y)=(-4y,4x)\) (Fig. 2). The initial concentration configuration of the Gaussian hump is given by

$$\begin{aligned} c(x,y,0) = \exp \left( - \frac{(x-x_0)^2 + (y-y_0)^2}{2 \sigma _0^2}\right) , \ (x,y) \in \varOmega , \end{aligned}$$
(50)

where \((x_0, y_0)= (-0.4, 0)\) is the initial center of the Gaussian hump, and \(\sigma _0 = 0.07\) is the standard deviation. The source term is set to be \(f(x,y,t)=0\). The inflow boundary condition \(g_{in}(x, y, t)\) is computed according to the analytical exact solution of the problem, which is given as

$$\begin{aligned} c(x,y,t)= \frac{2 \sigma ^2}{2 \sigma ^2 + 4Kt} \exp \left( -\frac{ ({\bar{x}} (t) - x_0)^2 + ({\bar{y}} (t) - y_0)^2}{2 \sigma ^2 + 4Kt} \right) , \end{aligned}$$
(51)

where \({\bar{x}} (t) = x \cos (4 t) + y \sin (4 t)\) and \({\bar{y}}(t) = -x \sin (4t) + y \cos (4t)\), and the outflow boundary condition is set according to the analytical solution as well.

Fig. 3
figure 3

Velocity field of \(\mathbf {u} = (u_x, u_y) = (0.1 \sin ( \pi x/5) \sin ( \pi y/5), 0)\) for square wave moving test. (Test 2)

Fig. 4
figure 4

Comparison of the surfaces plots of the moving square wave at \(\hbox {T}=50\) by different numerical methods with reference exact solution. a Reference solution, b T2-MC-C-FDM, c C-FDM-LI and d C-FDM-QI

Fig. 5
figure 5

Comparison of the contour plots of the moving square wave at \(\hbox {T}=50\) by different numerical methods with reference exact solution. a Reference solution, b T2-MC-C-FDM, c C-FDM-LI and d C-FDM-QI

Fig. 6
figure 6

We consider the evolution of density in a velocity field that is specified by \(\mathbf {u} = (0.1 \sin ( \pi x/5) \sin ( \pi y/5), 0)\). In such a velocity field, the standard characteristic finite different approach fails to capture the location of moving fronts and the shape of the solution. a \(t=20\) s, b \(t=30\) s, c \(t=50\) s and d \(t=60\) s

Fig. 7
figure 7

Shown is the time history of the discrete mass error \(\sum \varDelta x \varDelta y c_{i,j}(t) - \sum \varDelta x \varDelta y c_{i,j}(0)\) for a square wave that is evolved in a velocity field \(\mathbf {u} = (0.1 \sin ( \pi x/5) \sin ( \pi y/5), 0)\). Solutions are obtained by standard characteristic schemes C-FDM-LI, C-FDM-QI and our proposed conservative scheme T2-MC-C-FDM

Fig. 8
figure 8

Velocity field of \(\mathbf {u} = (u_x, u_y) = (\psi _y, -\psi _x)\), where \(\psi (x,y) = (1/\sqrt{2}) \sin (\pi x) \sin (\pi y)\). (Test 3)

Numerical experiments are carried out using different diffusion coefficients of \(K_x=K_y =K=0, 10^{-5}, 10^{-3}\), respectively. We first examine the convergence rates of numerical schemes in time by comparing the results at \(T=\frac{\pi }{4}\) by different methods. Tables 1, 2 and 3 exhibit the errors and ratios in time by using our T2-MC-C-FDM and a characteristic finite difference method based on bi-linear interpolation (C-FDM-LI) and bi-quadratic interpolation (C-FDM-QI) [9], and different \(N_t=10, 20, 30, 40\) and 50. We can see that the our scheme gets second order accuracy in time for both \(L_2\) and \(L_{\infty }\) errors, while the C-FDM-LI and C-FDM-QI get first order accuracy in time. For example, the ratios in \(L_2\) norm at \(N_t=60\) when the diffusion coefficients are \(10^{-5}\) and \(10^{-3}\) are 2.0046 and 1.9599 for our T2-MC-C-FDM, while C-FDM-LI gets 0.8284 and 0.8366, and C-FDM-QI gets 0.8884 and 0.8899, respectively. Meanwhile, T2-MC-C-FDM gets much smaller errors than C-FDM-LI and C-FDM-QI. For example, for \(K=10^{-3}\), the \(L_\infty \) error at \(N_t=40\) of T2-MC-C-FDM is \(8.0925\times 10^{-3}\), while it is \(3.2839\times 10^{-1}\) for C-FDM-LI, and \(3.2524\times 10^{-1}\) for C-FDM-QI, respectively. The mass errors are also shown in the tables, which indicate that T2-MC-C-FDM preserves mass perfectly, while the mass error for C-FDM-LI and C-FDM-QI are over \(5\times 10^{-3}\).

Fig. 9
figure 9

Time series of the mass error of the results computed by T2-MC-C-FDM, C-FDM-LI and C-FDM-QI when using time step size of \(\varDelta t = \frac{1}{40}\) and spatial step size of \(h_x = h_y = \frac{1}{200}\)

Fig. 10
figure 10

Comparison of the contour plots of the moving Gaussian hump in vortex shear at different times by different numerical methods with reference exact solution. a Reference solution, b T2-MC-C-FDM, c C-FDM-LI and d C-FDM-QI

Fig. 11
figure 11

The surfaces and contour plots of the moving sharp front by different numerical methods. a Reference Solution, b T2-MC-C-FDM, c C-FDM-LI and d C-FDM-QI

Then we test the convergence rates of numerical schemes in space. Table 4, 5 and 6 show the errors and ratios in space by using our T2-MC-C-FDM, C-FDM-LI and C-FDM-QI with \(\varDelta t=1/900\) and different \(\varDelta x=\frac{1}{50}, \frac{1}{60}, \frac{1}{70}, \frac{1}{80}\) and \( \frac{1}{90}\) for three different diffusion coefficients of \(K=0\), \(K=10^{-5}\) and \(K=10^{-3}\). We can see that the convergence rate of C-FDM-LI in space is less than one, and C-FDM-QI and T2-MC-C-FDM get second order accuracy in space for both the \(L_{\infty }\) and \(L_2\) errors, while T2-MC-C-FDM has better performances. For example, when \(K=10^{-5}\), \(\varDelta x = \frac{1}{70}\), the \(L_{\infty }\) and \(L_2\) errors of C-FDM-LI are \(6.1278\times 10^{-1}\) and \(6.5607\times 10^{-1}\), the errors of C-FDM-QI are \(1.3504\times 10^{-1}\) and \(1.4617\times 10^{-2}\), while T2-MC-C-FDM gets smaller errors of \(9.3274\times 10^{-2}\) and \(1.1453\times 10^{-2}\).

3.2 Test 2: Square Wave Moving Test

In this test, we consider the advection–diffusion problem for a advected square wave over the velocity field of \(\mathbf {u} = (u_x, u_y) = (0.1 \sin ( \pi x/5) \sin ( \pi y/5), 0)\) (Fig. 3) over a 2D spatial domain \(\varOmega = [0 , 5] \times [0, 5]\).

The initial value c(x, y,0) is given as

$$\begin{aligned} c (x,y,0) = \left\{ \begin{array}{l} 1, \quad 0.4 \le x \le 0.7, \quad 1.5 \le y \le 3.5, \\ 0, \quad \text {otherwise.} \\ \end{array} \right. \end{aligned}$$
(52)

The source term \(f(x,y,t)=0\) and the boundary condition is given as (2), such that the total mass of the advected square shall keep a constant value according to Theorem 2.

Figures 4 and 5 show the surface and contour plots of the advected wave at time \(t=50\) by using different numerical methods of our T2-MC-C-FDM and standard characteristic method with linear and quadratic interpolations, a large time step is taken as \(\varDelta t = 5\), and \(h = \frac{1}{40}\). Numerical solutions obtained by using fine mesh of \(h=\frac{1}{40}\) and \(\varDelta t = \frac{1}{40}\) are used as reference solution. Figure 6 shows results at \(y=2.5\) at different times of \(t=20\), \(t=30\), \(t=50\) and \(t=60\). We can note the marked difference between our T2-MC-C-FDM and standard characteristic FD method. It clearly shows that, even by using large time step size, our method could still capture the shape and front of the moving square very well, while the solutions of other two methods have much higher prediction of the hight of the moving square and show a clear deviation of the fronts from the reference exact solution. Figure 7 shows the loss of conservation of the standard characteristic method as compared to the T2-MC-C-FDM which maintains exact value up to round off error.

3.3 Test 3: Gaussian Hump in Vortex Shear

We now consider the transport of a Gaussian hump in a divergence free velocity field \(\mathbf {u} = (u_x, u_y) = (\psi _y, -\psi _x)\), where \(\psi (x,y) = \frac{1}{\sqrt{2}} \sin (\pi x) \sin (\pi y)\) (Fig. 8) over domain \(\varOmega = [0,1]\times [0,1]\).

The initial distribution of the Gaussian hump is given as

$$\begin{aligned} c(x,y,0) = \exp \left( - \frac{(x-x_0)^2 + (y-y_0)^2}{2 \sigma _0^2}\right) , \ (x,y) \in \varOmega , \end{aligned}$$
(53)

where the center of the initial Gaussian hump is specified as \(x_0 = 0.25\) and \(y_0 = 0.5\). The source term is zero.

Take the spatial step sizes \(h_x = h_y = 1/200\) and the time step size \(\varDelta t = \frac{1}{40}\), a group of contour plots at different times from \(t = 0.75\) to \(t=2\) are obtained by using our T2-MC-C-FDM, C-FDM-LI and C-FDM-QI, and are presented in Fig. 10. The distribution solved by using fine mesh of \(h=\frac{1}{200}\) and \(\varDelta t = \frac{1}{200}\) is used as reference exact solution. We can see clearly that our method get perfect match comparing to the exact solution, while C-FDM-LI and C-FDM-QI performs much worse, which smear the hump badly and lost large area of the hump. Figure 9 displays the mass errors of the results computed by T2-MC-C-FDM, C-FDM-LI and C-FDM-QI as time increases. Comparing to the initial total mass of 0.101, it can be seen that at the time \(T=2\), the C-FDM-LI and C-FDM-QI lost a majority percentage of the Gaussian hump mass, which is over 80% while our T2-C-CFDM conserves the mass perfectly.

Fig. 12
figure 12

The comparison of solution curves of different numerical methods on a sectional plane

3.4 Test 4: Steep Front Moving

In this subsection, we compute the moving steep front problem with our T2-MC-C-FDM. Consider the advection–diffusion problem on the spatial domain \(\varOmega = [0, 1] \times [0, 1]\) with the following initial and boundary conditions:

$$\begin{aligned}&c (x,y,0) = \left\{ \begin{array}{l} 1, \quad 0\le x \le 0.1 \quad \text {or} \quad 0.9 \le y \le 1, \\ 0, \quad \text {otherwise,} \\ \end{array} \right. \end{aligned}$$
(54)
$$\begin{aligned}&c(0,y,t)=1, y\in [0,1], c(x,1,t)=1, x \in [0,1], t\in (0,T], \end{aligned}$$
(55)
$$\begin{aligned}&\frac{\partial c (1,y,t)}{\partial x} = 0, y\in [0,1], \frac{\partial c (x,0,t)}{\partial y} = 0, x\in [0,1], \end{aligned}$$
(56)

the diffusion is taken as \(K = 0.001\) and the velocity is \(\mathbf {u} = (1,-1)\).

The contour plots of the approximate solutions at time \(t = 0.2\) computed by the T2-MC-C-FDM, the C-FDM-LI, the C-FDM-QI are presented in Fig. 11. The spatial step sizes are taken as \({\varDelta {x}} = {\varDelta {y}} = 1/100\). The approximation of our T2-MC-C-FDM (Fig. 11b) is obtained with a time step size \({\varDelta {t}} = 1/50\) while the solutions of the C-FDM-LI and the C-FDM-QI (Fig. 11c, d) are both obtained with a very small time step size \({\varDelta {t}} = 1/500\). We use a fine mesh of spatial step sizes \({\varDelta {x}} = {\varDelta {y}} = 1/200\) and time step size of \({\varDelta {t}} = 1/100\) to get a reference analytical solution. We can see that our T2-MC-CFDM simulates the steep front very well and get almost same results as the reference solution, even if the time step size taken is very large, while the standard C-FDM-LI fails to capture the rarefaction of the steep front, and C-FDM-QI shows non-physical oscillation near the front even by using a much smaller time step size (Fig. 12).

4 Conclusion

We have developped in this paper a time second order mass conservative accurate method for solving the advection–diffusion equations. The method takes advantage of characteristic method and is therefore capable of using large time step size, whilist by using high order conservative interpolation technique, it gets high accurate solutions and preserves the mass exactly, which makes it appropriate for large scale scientific simulations and areas where conservation is an important concern. The convergence order in time and space are verified through numerical tests by comparing with analytical solutions. Numerical experiments of moving square wave, Gaussian hump moving in vortex shear and steep front moving show that our T2-MC-C-FDM can get high accurate non-oscillation solutions even when large time step sizes are used.