The upwind finite difference scheme
Firstly, for each time level \(t_{n}=n\Delta t\), we construct an arbitrary nonuniform spatial mesh \(\overline{\varOmega }_{x}^{n}\) as follows:
$$\begin{aligned} \overline{\varOmega }_{x}^{n}=\bigl\{ 0=x_{0}^{n}< x_{1}^{n}< \cdots < x_{N}^{n}=1 \bigr\} , \end{aligned}$$
where n and \(h_{i}^{n}=x_{i}^{n}-x_{i-1}^{n}\) (\(i=1,\ldots ,N\)) denote the time level and the spatial step size, respectively. Then, for a given mesh function \(v(x_{i},t_{n})=v_{i}^{n}\), we define the forward, backward, and center difference operators \(D_{x}^{+}\), \(D_{x}^{-}\), and \(D_{x}\) as follows:
$$\begin{aligned} D_{x}^{+}v_{i}^{n}=\frac{v_{i+1}^{n}-v_{i}^{n}}{h_{i+1}^{n}}, \qquad D_{x} ^{-} v_{i}^{n}= \frac{v_{i}^{n}-v_{i-1}^{n}}{h_{i}^{n}}, \qquad D_{x}v_{i} ^{n}= \frac{D_{x}^{+}v_{i}^{n}-D_{x}^{-}v_{i}^{n}}{\hbar _{i}^{n}}, \end{aligned}$$
where \(\hbar _{i}^{n}=\frac{h_{i}^{n}+h_{i+1}^{n}}{2}\).
Finally, on \(\overline{\varOmega }_{x}^{n}\), the upwind finite difference spatial discretization of (4) takes the form
$$ \textstyle\begin{cases} \mathbf{U}_{i}^{n+1}+\Delta t \mathcal{L}_{x,\varepsilon }^{N} \mathbf{U}_{i}^{n+1}=\mathbf{U}_{i}^{n}+\Delta t \mathbf{f}(x_{i}^{n+1},t _{n+1}),\quad i=1,\ldots ,N-1,\\ \mathbf{U}_{0}^{n+1}=\mathbf{U}_{N} ^{n+1}=\mathbf{0}, \end{cases} $$
(11)
where
$$\begin{aligned} \mathcal{L}_{x,\varepsilon }^{N} \mathbf{U}_{i}^{n+1}=-E D_{x} \mathbf{U}_{i}^{n+1}+A_{i}^{n+1} D_{x}^{-} \mathbf{U}_{i}^{n+1}+B_{i} ^{n+1} \mathbf{U}_{i}^{n+1} \end{aligned}$$
is the discretization of the differential operator \(\mathcal{L}_{x, \varepsilon }\). Here, \(\mathbf{U}_{i}^{n}=(U_{1,i}^{n},U_{2,i}^{n})^{T}\) is the numerical solution of exact solution \(\mathbf{u}(x_{i},t_{n})\), \(E=\operatorname{diag}(\varepsilon _{1},\varepsilon _{2})\), \(A_{i}^{n+1}=A(x _{i}^{n+1})\), and \(B_{i}^{n+1}=B(x_{i}^{n+1})\).
Let I be a unit matrix of order two, then scheme (11) can be expanded in the form
$$ \textstyle\begin{cases} r_{i,n+1}^{-} \mathbf{U}_{i-1}^{n+1}+r_{i,n+1}^{c} \mathbf{U}_{i} ^{n+1}+r_{i,n+1}^{+} \mathbf{U}_{i+1}^{n+1}=\eta _{i}^{n}, \quad i=1, \ldots ,N-1,\\ \mathbf{U}_{0}^{n+1}=\mathbf{U}_{N}^{n+1}=\mathbf{0}, \end{cases} $$
(12)
where
$$\begin{aligned}& r_{i,n+1}^{-}=-\frac{E}{h_{i}^{n+1}\hbar _{i}^{n+1}}-\frac{a_{i}^{n+1} \Delta t}{h_{i}^{n+1}}I,\qquad r_{i,n+1}^{+}=-E\frac{ \Delta t}{h_{i+1} ^{n+1}\hbar _{i}^{n+1}}, \\& r_{i,n+1}^{c}=I+\Delta t b_{i}^{n+1}I-r_{i,n+1}^{-}-r_{i,n+1}^{+}, \qquad \eta _{i}^{n}=\widetilde{\mathbf{U}} \bigl(x_{i}^{n+1},t_{n}\bigr)+\Delta t \mathbf{f} \bigl(x_{i}^{n+1},t_{n+1}\bigr), \end{aligned}$$
\(\widetilde{\mathbf{U}}(x,t_{n})=(\widetilde{U}_{1}(x,t_{n}), \widetilde{U}_{2}(x,t_{n}))^{T}\) and \(\widetilde{U}_{j}(x,t_{n})\) is the linear interpolant function through points \((x_{i}^{n},U_{j,i}^{n})\), \(j=1,2\), \(i=0,1,\ldots ,N\).
Adaptive spatial grid algorithm
It is well known that a common approach to construct an adaptive grid is the use of a positive monitor function \(M(x)\) and the mesh equidistribution principle. That is to say, a grid \(\{x_{i} \} _{i=0}^{N}\) is chosen to satisfy the following equations:
$$\begin{aligned} \int _{x_{i-1}}^{x_{i}}M(s)\,ds=\frac{1}{N} \int _{0}^{1} M(s)\,ds, \quad i=1, \ldots ,N. \end{aligned}$$
(13)
In the literature, for a single singularly perturbed differential equation, a simple monitor function is the arc-length function \(M(x)=\sqrt{1+ [u'(x) ]^{2}}\) or its discrete analogue [21,22,23,24,25,26], where \(u(x)\) is the exact solution of the singularly perturbed problem. Recently, Liu and Chen [18] presented an adaptive grid method to solve a weakly coupled system of two singularly perturbed convection-diffusion equations, in which they developed a monitor function as follows:
$$\begin{aligned} \widetilde{M}(x)=\sqrt{1+\max_{x\in [0,1]} \bigl\{ \bigl[ \widetilde{U} _{1}'(x) \bigr]^{2}, \bigl[ \widetilde{U}_{2}'(x) \bigr]^{2} \bigr\} }, \end{aligned}$$
(14)
where \(\widetilde{U}_{j}(x)\) is the piecewise linear interpolant function passing through knots \((x_{i},U_{j,i})\), \(j=1,2\), \(i=0,1,\ldots ,N\). Here, in this paper, similar to (14), we choose the following monitor function:
$$\begin{aligned} M(x)=\sqrt{1+\max_{x\in [0,1]} \biggl\{ \biggl[\frac{\partial u _{1}(x,t_{n})}{\partial x} \biggr]^{2}, \biggl[\frac{\partial u_{2}(x,t _{n})}{\partial x} \biggr]^{2} \biggr\} }. \end{aligned}$$
(15)
In practical computation, the above monitor function (15) may be changed into the following discrete form:
$$\begin{aligned} \widetilde{M}(x)=\sqrt{1+\max_{x\in [0,1]} \bigl\{ \bigl[ \bigl(\widetilde{U} _{1}^{n}(x) \bigr)' \bigr]^{2}, \bigl[ \bigl(\widetilde{U}_{2}^{n}(x) \bigr)' \bigr] ^{2} \bigr\} }, \end{aligned}$$
(16)
where \(\widetilde{U}_{j}^{n}(x)\in C[0,1]\) (\(j=1,2\)) is the piecewise linear interpolant function through the knots \((x_{i}^{n},U_{j,i}^{n})\) (\(i=0,1, \ldots ,N\), \(n=1,\ldots ,M\)).
Therefore, to obtain an adaptive equidistribution grid and the corresponding numerical solution, we construct the following iteration algorithm:
Step 1. Let \(n=1\).
Step 2. For \(k=0\), let \(\{x_{i}^{n,(k)}=i/N,i=0,1,\ldots ,N \}\) be the initial uniform spatial mesh for \(n=1\), otherwise, choose \(\{x_{i}^{n-1}\}\) for the initial mesh.
Step 3. Compute the discrete solution \(\{\mathbf{U}_{i} ^{n,(k)} \}\) satisfying (12) on \(\{x_{i}^{n,(k)} \}\). Let \(h_{i}^{n,(k)}=x_{i}^{n,(k)}-x _{i-1}^{n,(k)}\) for each i. Let
$$\begin{aligned} \begin{aligned}[b] l_{i}^{n,(k)} &=h_{i}^{n,(k)} \sqrt{1+\max \bigl[ \bigl(D_{x}^{-} U _{1,i}^{n,(k)} \bigr)^{2}, \bigl(D_{x}^{-} U_{2,i}^{n,(k)} \bigr)^{2} \bigr]} \\ &=\sqrt{ \bigl(h_{i}^{n,(k)} \bigr)^{2}+\max \bigl[ \bigl(U_{1,i}^{n,(k)}-U _{1,i-1}^{n,(k)} \bigr)^{2}, \bigl(U_{2,i}^{n,(k)}-U_{2,i-1}^{n,(k)} \bigr) ^{2} \bigr]} \end{aligned} \end{aligned}$$
be the max arc-length between the points \((x_{i-1}^{n,(k)}, U _{j,i-1}^{n,(k)} )\) and \((x_{i}^{n,(k)}, U_{j,i}^{n,(k)} )\) in the piecewise linear computed solutions \(\widetilde{U}_{j}^{n,(k)}(x)\), where \(j=1,2\). Then the total max arc-length of the solution curve \(\widetilde{U}_{j}^{n,(k)}(x)\) is
$$\begin{aligned} L^{n,(k)}=\sum_{i=1}^{N} l_{i}^{n,(k)}=\sum_{i=1}^{N} \sqrt{ \bigl(h_{i}^{n,(k)} \bigr)^{2}+\max \bigl[ \bigl(U_{1,i}^{n,(k)}-U_{1,i-1} ^{n,(k)} \bigr)^{2}, \bigl(U_{2,i}^{n,(k)}-U_{2,i-1}^{n,(k)} \bigr) ^{2} \bigr]}. \end{aligned}$$
Step 4. Test mesh: Let \(C_{0}>1\) be a given constant. If the stopping criterion
$$\begin{aligned} \frac{\max\limits_{1\leq i\leq N}l_{i}^{n,(k)}}{L^{n,(k)}}\leq \frac{C _{0}}{N} \end{aligned}$$
(17)
holds true, then go to Step 7. Otherwise, continue to Step 5.
Step 5. Generate a new mesh by equidistributing monitor function (16): Choose points \(\{0=x_{0}^{n,(k+1)}< x_{1}^{n,(k+1)}< \cdots <x_{N}^{n,(k+1)}=1 \}\) such that
$$\begin{aligned} \int _{x_{i-1}^{n,(k+1)}}^{x_{i}^{n,(k+1)}}\sqrt{1+\max _{x\in [0,1]} \bigl\{ \bigl[ \bigl(\widetilde{U}_{1}^{n,k}(x) \bigr)' \bigr] ^{2}, \bigl[ \bigl(\widetilde{U}_{2}^{n,k}(x) \bigr)' \bigr]^{2} \bigr\} }\,dx=\frac{L ^{n,(k)}}{N}, \end{aligned}$$
where \(i=1,\ldots ,N\).
Step 6. Let \(k=k+1\) and go to Step 3.
Step 7. Choose \(\{x_{i}^{n,k-1} \}\) as the final mesh \(\{x_{i}^{n} \}\) and let \(U_{j,i}^{n,k-1}=U_{j,i}^{n}\).
Step 8. Let \(n=n+1\), return to Step 2.
Step 9. If \(n=M\), go to Step 10.
Step 10. Stop. \(U_{j,i}^{n}\) is the numerical solution, grid for each time level given by \(\{x_{i}^{n}\}\).