1 Introduction

Space-time adaptive algorithms are efficient tools to approximate solutions of partial differential equations with accuracy and low computational cost. Whenever possible, the adaptive criteria is based on theoretical error estimates, this is mostly the case for elliptic and parabolic problems, fewer results are available for hyperbolic problems[11, 14, 18, 31, 37], nonlinear systems [3, 13, 30, 39, 41] or PDEs with variable coefficients [9, 24].

The classical theory of a posteriori error analysis for finite element methods was first developed on isotropic meshes [6, 16, 40], the involved constants were depending on the mesh aspect ratio. However, anisotropic finite elements, that is to say elements with possibly large aspect ratio, have been widely used to approximate phenomena involving boundary or internal layers. The isotropic theory for a posteriori error estimates was therefore updated, see for instance [4, 19, 22, 23, 25], and the involved constants were proved to be aspect ratio independent whenever the mesh was aligned with the solution.

The Crank-Nicolson method is a popular second order scheme for time dependent problems. However, most of the a posteriori error estimates are proved for first order methods only, for instance the Backward Euler scheme [8, 10, 32, 38]. Moreover, standard a posteriori proofs lead to suboptimal estimates for second order methods, as reported in [2]. To circumvent this problem, piecewise quadratic reconstructions have been introduced for parabolic problems [1, 2, 7, 28], in [21] for the transport equations and in [27] for the wave equation.

In this paper, the a posteriori error analysis of [21] for the transport equation is extended to the case where the velocity varies in space and time. As in [21], the a posteriori error analysis is valid for anisotropic meshes and a second order time discretization. In [21], the a posteriori error estimate was restricted to the case of a steady velocity while the new estimate is valid for velocity fields that may exhibit strong variations in time. The techniques used should be useful when coupling the transport equation to Navier-Stokes equations, which is the case for instance when considering free surface flows [20].

The outline of this paper is the following. In Sect. 2, the transport equation and the numerical method are presented. An a posteriori error estimate is proposed in Sect. 3, numerical experiments confirm the sharpness of the estimate in Sect. 4. Finally, an adaptive algorithm is presented in Sect. 5 and numerical results are discussed.

2 Statement of the problem and numerical scheme

Given a polygon \(\Omega\), a divergence free velocity field \({\mathbf {u}} \in C^1\left( \overline{\Omega } \times [0,T] \right)\), and an initial data \(\varphi _0 \in C^0\left( \overline{\Omega }\right)\), we are looking for \(\varphi :\Omega \times (0,T] \rightarrow {\mathbb {R}}\) the solution of the transport problem

$$\begin{aligned} \left\{ {\begin{array}{ll} \frac{\partial \varphi }{\partial t}+ {\mathbf {u}}\cdot \nabla \varphi =0, &\quad {\text {in }} \Omega \times (0,T], \\ {}&{}{}\\ \varphi =0, &\quad {\text {on } } \Gamma ^{-}\times (0,T], \\ {}&{}{}\\ \varphi (\cdot ,0) = \varphi _0,&{} \end{array}} \right. \end{aligned}$$
(1)

where the inflow boundary is defined by

$$\begin{aligned} \Gamma ^{-} = \left\{ {\mathbf {x}}\in \partial \Omega : {\mathbf {u}}({\mathbf {x}},t) \cdot {\mathbf {n}}({\mathbf {x}}) <0\right\} , \end{aligned}$$

with \({\mathbf {n}}\) standing for the unit outer normal of \(\partial \Omega\). It is assumed that the velocity field is such that the inflow boundary does not depend on time and that the data \({\mathbf {u}},\Omega ,\varphi _0\) are smooth enough to justify the forthcoming computations.

To approximate in space (1) a finite element stabilization scheme is needed. This scheme corresponds to the stabilized scheme studied in [12], in which the stabilization term is updated to the anisotropic setting, following [11, 21, 29].

The fully discrete method reads as follows. For every \(h>0\), let \({\mathcal {T}}_h\) be a conformal triangulation of \(\overline{\Omega }\) into triangles K of diameter \(h_K \le h\). Let \(V_h\) be the set of continuous, piecewise linear functions on each triangle \(K\in {\mathcal {T}}_h\), zero valued on \(\Gamma ^{-}\). Let N be a non-negative integer and a partition \(0=t^0< t^1< t^2< \cdots < t^N=T\). We denote \(\tau ^{n+1}=t^{n+1}-t^n\) the time step, \(t^{n+{\nicefrac{1}{2}}}= (t^{n+1}+t^n)/2\), \(n=0,1,2,\ldots ,N-1\). Starting from \(\varphi _h^0 = r_h (\varphi _0)\), where \(r_h\) stands for the Lagrange interpolant defined on \({\mathcal {T}}_h\), for \(n=0,1,2,\ldots ,N-1\), we are looking for \(\varphi _h^{n+1}\in V_h\) such that

$$\begin{aligned}&\int _\Omega \left( \frac{\varphi _h^{n+1}-\varphi _h^n}{\tau ^{n+1}}+ {\mathbf {u}}(t^{n+{\nicefrac{1}{2}}})\cdot \nabla \left( \frac{ \varphi _h^{n+1}+\varphi _h^n}{2}\right) \right) \nonumber \\&\qquad (v_h +\delta _h(t^{n+{\nicefrac{1}{2}}}) {\mathbf {u}}(t^{n+{\nicefrac{1}{2}}})\cdot \nabla v_h)dx =0,\qquad \forall v_h \in V_h. \end{aligned}$$
(2)

Here \(\delta _h>0\) stands for an O(h) stabilization parameter that will be specified in the sequel.

A priori error estimates for (2) have been proposed in [12] for isotropic meshes, constant time steps and a transport velocity independent of time. In [21], the analysis is extended to anisotropic meshes and variable time steps, and both a priori and a posteriori error estimates are derived. An a posteriori error analysis involving a time dependent transport velocity is proposed here, so as an adaptive algorithm. The corresponding a priori error estimates can be found in [20], so as additional numerical experiments.

In this paper, anisotropic finite elements will be used, that is to say meshes with possibly large aspect ratio. We will use the notations and results of [22, 23, 29], see also [25] for similar results. Let \(K\in {\mathcal {T}}_{h}\) and \(T_{K}:\hat{K}\longrightarrow K\) be the affine transformation mapping the reference triangle ,  into K defined by

$$\begin{aligned} {\mathbf {x}}=T_{K}(\hat{\mathbf {x}})=M_{K}\hat{\mathbf {x}}+{\mathbf {t}}_{K}\qquad \forall \hat{\mathbf {x}}\in \hat{K}, \end{aligned}$$

with \(M_{K}\in {\mathbb {R}}^{2\times 2},{\mathbf {t}}_{K}\in {\mathbb {R}}^{2}.\) Observe that since \(M_{K}\) is invertible it admits a singular value decomposition \(M_{k}=R_{K}^{T}\Lambda _{K}P_{K},\) where \(R_{K}\) and \(P_{K}\) are orthogonal matrices and

$$\begin{aligned} \Lambda _{K}= \left( {\begin{array}{ll} \lambda _{1,K} &{} 0\\ 0 &{} \lambda _{2,K} \end{array}} \right) ,\qquad \lambda _{1,K}\ge \lambda _{2,K}>0. \end{aligned}$$

We note

$$\begin{aligned} R_{K}= \left( {\begin{array}{l} r_{1,K}^{T}\\ r_{2,K}^{T} \end{array}} \right) , \end{aligned}$$

where \(r_{1,K},r_{2,K}\) are the unit vectors corresponding to directions of maximum and minimum stretching respectively, so that \(\lambda _{1,K},\lambda _{2,K}\) correspond to the value of maximum and minimum stretching.

A posteriori error analysis can be obtained using Clément’s interpolant [17]. Since anisotropic meshes are considered, the usual regularity assumption is omitted but two additional assumptions are needed. First, we assume that each vertex has a number of neighbours bounded from above, uniformly with respect to h. Second, we assume that for each K, the diameter of \(T_{K}^{-1}(\Delta K)\) (here \(\Delta K\) is the union of triangles sharing a vertex with K) is uniformly bounded with respect to h. For more details, we refer again to [22, 23, 29]. In this framework, the following estimation holds

$$\begin{aligned}&\parallel v-R_{h}(v)\parallel _{L^{2}(K)}^{2}+\lambda _{2,K}^{2}\parallel \nabla (v-R_{h}(v))\parallel _{L^{2}(K)}^{2}\nonumber \\&\qquad \qquad \le \hat{C}\omega _{K}^{2}(v)\quad \forall v\in H^{1}(\Omega ), \end{aligned}$$
(3)

where \(R_{h}\) is the Clément’s interpolant, \(\hat{C}>0\) is a constant depending only on the reference triangle \(\hat{K},\) and

$$\begin{aligned} \omega _{K}^{2}(v)=\lambda _{1,K}^{2}(r_{1,K}^{T}G_{K}(v)r_{1,K})+\lambda _{2,K}^{2}(r_{2,K}^{T}G_{K}(v)r_{2,K}), \end{aligned}$$
(4)

with \(G_K\) standing for the gradient matrix given by

$$\begin{aligned} G_{K}(v)= \left( {\begin{array}{ll} \displaystyle \int _{\Delta K}\left( \frac{{\displaystyle \partial v}}{{\displaystyle \partial x_{1}}}\right) ^{2}d{\mathbf {x}}&{} {\displaystyle \int _{\Delta K}}{\displaystyle \frac{\partial v}{\partial x_{1}}\frac{\partial v}{\partial x_{2}}}d{\mathbf {x}}\\ {}&{}{}\\ {\displaystyle \int _{\Delta K}}{\displaystyle \frac{\partial v}{\partial x_{1}}\frac{\partial v}{\partial x_{2}}}d{\mathbf {x}}&{} {\displaystyle \int _{\Delta K}}\left( {\displaystyle \frac{\partial v}{\partial x_{2}}}\right) ^{2}d{\mathbf {x}}\end{array}} \right) . \end{aligned}$$

3 A posteriori error estimates

To recover an error estimate of order two in time, we follow the idea introduced in [28] for the Crank-Nicolson approximation of the heat equation, and define a piecewise quadratic reconstruction of the numerical solution \(\varphi _h^n\) of (2). We introduce the following notations. For any quantity \(w^n\) and for \(n=0,\ldots ,N-1\) we note

$$\begin{aligned} w^{n+{\nicefrac{1}{2}}} = \frac{w^{n+1} +w^n}{2},\quad \partial w^{n+1} = \frac{w^{n+1}-w^n}{\tau ^{n+1}}, \end{aligned}$$

and for \(n=1,\ldots ,N-1\)

$$\begin{aligned} \bar{\partial }w^{n+1}= & {} \frac{w^{n+1}-w^{n-1}}{\tau ^{n+1}+\tau ^n},\quad \partial w^{n+{\nicefrac{1}{2}}} = \frac{w^{n+{\nicefrac{1}{2}}} -w^{n-{\nicefrac{1}{2}}}}{\dfrac{\tau ^{n+1}+\tau ^{n}}{2}},\\ \partial ^{2}w^{n+1}= & {} \dfrac{\dfrac{w^{n+1}-w^{n}}{\tau ^{n+1}}-\dfrac{w^{n}-w^{n-1}}{\tau ^{n}}}{\dfrac{\tau ^{n+1}+\tau ^{n}}{2}}. \end{aligned}$$

Setting \(\tau =\max (\tau ^1,\ldots ,\tau ^N)\), we define the piecewise numerical reconstruction \(\varphi _{h\tau }\) by

$$\begin{aligned}&\varphi _{h\tau }({\mathbf {x}},t)= \varphi _h^{n+{\nicefrac{1}{2}}}({\mathbf {x}})+(t-t^{n+{\nicefrac{1}{2}}})\partial \varphi _{h}^{n+1}({\mathbf {x}})\nonumber \\&\qquad \qquad \qquad +\dfrac{1}{2}(t-t^{n})(t-t^{n+1})\partial ^{2}\varphi _{h}^{n+1}({\mathbf {x}}), \end{aligned}$$
(5)

for \(({\mathbf {x}},t) \in \overline{\Omega }\times \left[ t^{n},t^{n+1}\right] , n \ge 1,\) and by

$$\begin{aligned} \varphi _{h\tau }({\mathbf {x}},t)=\varphi _h^{\nicefrac{1}{2}}({\mathbf {x}})+(t-t^{\nicefrac{1}{2}})\partial \varphi _{h}^{1}({\mathbf {x}}), \end{aligned}$$
(6)

for \(({\mathbf {x}},t) \in \overline{\Omega }\times \left[ t^{0},t^{1}\right] .\)

Note that (5) is the unique quadratic polynomial interpolating exactly \(\varphi _h^{n+1},\varphi _h^n,\varphi _h^{n-1}\) at time \(t=t^{n+1},t^n,t^{n-1}\). This quadratic reconstruction was first introduced in [28] to recover an a posteriori error estimate for the Crank-Nicolson method applied to the heat equation which was of order two in time. It is modification of another quadratic reconstruction proposed in [2], where it was indeed observed that linear reconstructions would yield to suboptimal error estimates. Here, for the transport equation (1), the motivation is the following. A priori error estimates for a simplified differential problem indicate that the error is order two, the constant depending on \(\partial _{ttt}\varphi\) [20], which is formally equal to \(-\partial _{tt}({\mathbf {u}}\cdot \nabla \varphi )\). Therefore, some information about the second derivative in time of \(\varphi\) must be available in the error indicator, which is precisely the role of the quadratic term in (5).

Our error indicator for the time discretization is obtained by inserting the numerical reconstruction (5) (6) into the transport equation.

Proposition 1

Let \((\varphi _h^n)_{n=0}^N\) be the solution of (2). Let \(\varphi _{h\tau }\) be the numerical reconstruction (5) (6). For all \(0\le n \le N-1\), for all \(v_h\in V_h\) and for all \(t\in (t^n,t^{n+1})\), we have

$$\begin{aligned}&\int _\Omega \left( \frac{\partial \varphi _{h\tau }}{\partial t} + {\mathbf {u}}(t)\cdot \nabla \varphi _{h\tau } \right) (v_h + \delta _h(t){\mathbf {u}}(t) \cdot \nabla v_h) d{\mathbf {x}}\\&\qquad \qquad \qquad = \int _\Omega \theta _n (v_h + \delta _h(t) {\mathbf {u}}(t)\cdot \nabla v_h) d{\mathbf {x}}+ \int _\Omega \varvec{\zeta }_n \cdot \nabla v_h d{\mathbf {x}}, \end{aligned}$$

where \(\theta _n\) is given for \(n\ge 1\) by

$$\begin{aligned}&\theta _n = \left( \frac{\tau ^n}{2}(t- t^{n+{\nicefrac{1}{2}}}) + \frac{1}{2}(t-t^n)(t-t^{n+1}) \right) {\mathbf {u}}(t) \cdot \nabla \partial ^2 \varphi _h^{n+1} \nonumber \\&\qquad \qquad \qquad + (t-t^{n+{\nicefrac{1}{2}}}) ( {\mathbf {u}}(t) - {\mathbf {u}}(t^{n-{\nicefrac{1}{2}}}))\cdot \nabla \bar{\partial }\varphi _h^{n+1}\nonumber \\&\qquad \qquad + \left( {\mathbf {u}}(t) - {\mathbf {u}}(t^{n+{\nicefrac{1}{2}}}) - (t-t^{n+{\nicefrac{1}{2}}}) \partial ){\mathbf {u}}(t^{n+{\nicefrac{1}{2}}})\right) \cdot \nabla \varphi _h^{n+{\nicefrac{1}{2}}}, \end{aligned}$$
(7)

and for \(n=0\) by

$$\begin{aligned} \theta _0 = (t-t^{\nicefrac{1}{2}}) {\mathbf {u}}(t) \cdot \nabla \partial \varphi _h^1 + ( {\mathbf {u}}(t) - {\mathbf {u}}(t^{\nicefrac{1}{2}})) \cdot \nabla \varphi _h^{\nicefrac{1}{2}}, \end{aligned}$$
(8)

and \(\varvec{\zeta }_n\) is given for \(n \ge 1\) by

$$\begin{aligned}&\varvec{\zeta }_n = \left( \partial \varphi _h^{n+1} + {\mathbf {u}}(t^{n+{\nicefrac{1}{2}}})\cdot \nabla \varphi _h^{n+{\nicefrac{1}{2}}}\right) \nonumber \\&\qquad \qquad \left( \delta _h(t){\mathbf {u}}(t) - \delta _h(t^{n+{\nicefrac{1}{2}}}) {\mathbf {u}}(t^{n+{\nicefrac{1}{2}}})- (t-t^{n+{\nicefrac{1}{2}}}) \partial [\delta _h(t^{n+{\nicefrac{1}{2}}}){\mathbf {u}}(t^{n+{\nicefrac{1}{2}}})]\right) \nonumber \\&\qquad \qquad \qquad + (t-t^{n+{\nicefrac{1}{2}}})\left( \partial ^2 \varphi _h^{n+1} + \partial [{\mathbf {u}}(t^{n+{\nicefrac{1}{2}}})\cdot \nabla \varphi _h^{n+{\nicefrac{1}{2}}}]\right) \nonumber \\&\qquad \qquad \qquad \qquad ( \delta _h(t){\mathbf {u}}(t)-\delta _h(t^{n-{\nicefrac{1}{2}}}){\mathbf {u}}(t^{n-{\nicefrac{1}{2}}})), \end{aligned}$$
(9)

and for \(n=0\) by

$$\begin{aligned} \varvec{\zeta }_0=\left( \partial \varphi _h^1 + {\mathbf {u}}(t^{\nicefrac{1}{2}}) \cdot \nabla \varphi _h^{\nicefrac{1}{2}}\right) (\delta _h(t){\mathbf {u}}(t)-\delta _h(t^{\nicefrac{1}{2}}){\mathbf {u}}(t^{\nicefrac{1}{2}})). \end{aligned}$$
(10)

Remark 1

(Optimality of the local time error indicator)

  1. (i)

    Assuming that \({\mathbf {u}}=(u_1,u_2)\) is twice continuously differentiable in time, a Taylor expansion yields, for \(i=1,2\):

    $$\begin{aligned} u_i(t)-u_i(t^{n-{\nicefrac{1}{2}}}) = (t-t^{n-{\nicefrac{1}{2}}}) \frac{\partial u_i(\bar{t})}{\partial t} \end{aligned}$$

    for some \(\bar{t}\) in (0, T) and

    $$\begin{aligned} {\mathbf {u}}(t) - {\mathbf {u}}(t^{n+{\nicefrac{1}{2}}}) - (t-t^{n+{\nicefrac{1}{2}}}) \frac{\mathbf {u}(t^{n+{\nicefrac{1}{2}}}) - {\mathbf {u}}(t^{n-{\nicefrac{1}{2}}})}{\dfrac{\tau ^{n+1}+\tau ^n}{2}} = (t-t^{n+{\nicefrac{1}{2}}})^2 \frac{\partial ^2 {\mathbf {u}}(\tilde{t})}{\partial t^2} \end{aligned}$$

    for some \(\tilde{t}\) in (0, T). Therefore, \(\theta _n\) (for \(n\ge 1\)) is an approximation of

    $$\begin{aligned} \tau ^2 {\mathbf {u}}\cdot \nabla \partial _{tt} \varphi _{h\tau } + \tau ^2 \partial _t {\mathbf {u}}\cdot \nabla \partial _t \varphi _{h\tau } + \tau ^2 \partial _{tt} {\mathbf {u}}\cdot \nabla \varphi _{h\tau }=\tau ^2\partial _{tt} ({\mathbf {u}}\cdot \nabla \varphi _{h\tau }), \end{aligned}$$

    and is thus of optimal order \(O(\tau ^2)\). We can also approximate \(\varvec{\zeta }_n\) (for \(n \ge 1)\) by

    $$\begin{aligned} \tau ^2 (\partial _t \varphi _{h\tau } + {\mathbf {u}}\cdot \nabla \varphi _{h\tau }) \partial _{tt} (\delta _h {\mathbf {u}}) + \tau ^2 \partial _t (\partial _{t} \varphi _{h\tau } + {\mathbf {u}}\cdot \nabla \varphi _{h\tau }) \partial _t (\delta _h {\mathbf {u}}), \end{aligned}$$

    thus, since \(\delta _h =O(h)\), \(\varvec{\zeta }_n\) is of higher order \(O(h\tau ^2)\).

  2. (ii)

    Note that if \({\mathbf {u}}\) and \(\delta _h\) are independent of time, then \(\varvec{\zeta }_n=0\), \(n=0,1,\ldots ,N-1,\) and \(\theta _n\) reduces to the time error indicator given in [21], Lemma 1.

Proof

Let \(n\ge 1\) and \(t\in (t^n,t^{n+1})\), we have:

$$\begin{aligned} \int _\Omega \left( \frac{\partial \varphi _{h\tau }}{\partial t} + {\mathbf {u}}(t)\cdot \nabla \varphi _{h\tau } \right) (v_h + \delta _h(t){\mathbf {u}}(t) \cdot \nabla v_h) d{\mathbf {x}}= I_1 + I_2 + I_3, \end{aligned}$$

where

$$\begin{aligned} I_1= & {} \int _\Omega (\partial \varphi _h^{n+1} + {\mathbf {u}}(t) \cdot \nabla \varphi _h^{n+{\nicefrac{1}{2}}})(v_h + \delta _h(t) {\mathbf {u}}(t)\cdot \nabla v_h) d{\mathbf {x}},\\ I_2= & {} (t-t^{n+{\nicefrac{1}{2}}}) \int _\Omega (\partial ^2 \varphi _h^{n+1} + {\mathbf {u}}(t) \cdot \nabla \partial \varphi _h^{n+1})(v_h + \delta _h(t) {\mathbf {u}}(t)\cdot \nabla v_h) d{\mathbf {x}},\\ I_3= & {} \frac{1}{2}(t-t^n)(t-t^{n+1})\int _\Omega {\mathbf {u}}(t) \cdot \nabla \partial ^2 \varphi _h^{n+1} (v_h + \delta _h(t) {\mathbf {u}}(t) \cdot \nabla v_h) d{\mathbf {x}}. \end{aligned}$$

Observe that \(I_3\) is already part of (7) and order two in time, so it remains to transform \(I_1\) and \(I_2\) into quantity of second order.

A straightforward computation for \(I_1\) yields that

$$\begin{aligned}I_1 &= \int _\Omega (\partial \varphi _h^{n+1} + {\mathbf {u}}(t^{n+{\nicefrac{1}{2}}}) \cdot \nabla \varphi _h^{n+{\nicefrac{1}{2}}})(v_h + \delta _h(t^{n+{\nicefrac{1}{2}}}) {\mathbf {u}}(t^{n+{\nicefrac{1}{2}}}) \cdot \nabla v_h) d{\mathbf {x}}\\& \quad + \int _\Omega ({\mathbf {u}}(t)-{\mathbf {u}}(t^{n+{\nicefrac{1}{2}}})) \cdot \nabla \varphi _h^{n+{\nicefrac{1}{2}}}(v_h + \delta _h(t) {\mathbf {u}}(t)\cdot \nabla v_h) d{\mathbf {x}}\\&\quad + \int _\Omega (\partial \varphi _h^{n+1} + {\mathbf {u}}(t^{n+{\nicefrac{1}{2}}}) \cdot \nabla \varphi _h^{n+{\nicefrac{1}{2}}}) ( \delta _h(t){\mathbf {u}}(t) - \delta _h(t^{n+{\nicefrac{1}{2}}}){\mathbf {u}}(t^{n+{\nicefrac{1}{2}}}))\cdot \nabla v_h d{\mathbf {x}}. \end{aligned}$$

Using the numerical scheme (2), the first term is in fact zero, remaining the following expression for \(I_1\):

$$\begin{aligned}I_1 &= \int _\Omega ({\mathbf {u}}(t)-{\mathbf {u}}(t^{n+{\nicefrac{1}{2}}})) \cdot \nabla \varphi _h^{n+{\nicefrac{1}{2}}}(v_h + \delta _h(t) {\mathbf {u}}(t)\cdot \nabla v_h) d{\mathbf {x}}\\&\quad +\int _\Omega (\partial \varphi _h^{n+1} + {\mathbf {u}}(t^{n+{\nicefrac{1}{2}}}) \cdot \nabla \varphi _h^{n+{\nicefrac{1}{2}}}) ( \delta _h(t){\mathbf {u}}(t) - \delta _h(t^{n+{\nicefrac{1}{2}}}){\mathbf {u}}(t^{n+{\nicefrac{1}{2}}}))\cdot \nabla v_h d{\mathbf {x}}. \end{aligned}$$

To simplify \(I_2\), we note that it looks like the discrete derivative of (2). Thus we first compute the difference between (2) taken at two successive steps, that is to say

$$\begin{aligned}&\int _\Omega \left( \partial \varphi _h^{n+1} + {\mathbf {u}}(t^{n+{\nicefrac{1}{2}}})\cdot \nabla \varphi _h^{n+{\nicefrac{1}{2}}}\right) (v_h +\delta _h(t^{n+{\nicefrac{1}{2}}}) {\mathbf {u}}(t^{n+{\nicefrac{1}{2}}})\cdot \nabla v_h)d{\mathbf {x}}\\&- \int _\Omega \left( \partial \varphi _h^{n} + {\mathbf {u}}(t^{n-{\nicefrac{1}{2}}}) \cdot \nabla \varphi _h^{n-{\nicefrac{1}{2}}}\right) (v_h +\delta _h(t^{n-{\nicefrac{1}{2}}}) {\mathbf {u}}(t^{n-{\nicefrac{1}{2}}}) \cdot \nabla v_h)d{\mathbf {x}}= 0. \end{aligned}$$

and we divide by \((\tau ^{n+1} + \tau ^n)/2\). We obtain that

$$\begin{aligned}&\int _\Omega \left( \partial ^2 \varphi _h^{n+1} + {\mathbf {u}}(t) \cdot \nabla \bar{\partial }\varphi _h^{n+1}\right) (v_h + \delta _h(t) {\mathbf {u}}(t)\cdot \nabla v_h) d{\mathbf {x}}\nonumber \\&= \frac{1}{\dfrac{\tau ^{n+1} + \tau ^n}{2}} \int _\Omega \left( ( {\mathbf {u}}(t) - {\mathbf {u}}(t^{n+{\nicefrac{1}{2}}}))\cdot \nabla \varphi _h^{n+{\nicefrac{1}{2}}}-( {\mathbf {u}}(t) - {\mathbf {u}}(t^{n-{\nicefrac{1}{2}}}))\cdot \nabla \varphi _h^{n-{\nicefrac{1}{2}}}\right) \nonumber \\&\qquad \qquad \qquad \qquad (v_h + \delta _h(t) {\mathbf {u}}(t)\cdot \nabla v_h) d{\mathbf {x}}\nonumber \\&\qquad \qquad + \frac{1}{\dfrac{\tau ^{n+1} + \tau ^n}{2}} \int _\Omega \left( \partial \varphi _h^{n+1} + {\mathbf {u}}(t^{n+{\nicefrac{1}{2}}})\cdot \nabla \varphi _h^{n+{\nicefrac{1}{2}}}\right) \nonumber \\&\qquad \qquad \qquad ( \delta _h(t){\mathbf {u}}(t) - \delta _h(t^{n+{\nicefrac{1}{2}}}){\mathbf {u}}(t^{n+{\nicefrac{1}{2}}}) )\cdot \nabla v_h d{\mathbf {x}}\nonumber \\&\qquad \qquad + \frac{1}{\dfrac{\tau ^{n+1} + \tau ^n}{2}} \int _\Omega \left( \partial \varphi _h^n + {\mathbf {u}}(t^{n-{\nicefrac{1}{2}}})\cdot \nabla \varphi _h^{n-{\nicefrac{1}{2}}}\right) \nonumber \\&\qquad \qquad \qquad \qquad ( \delta _h(t){\mathbf {u}}(t) - \delta _h(t^{n-{\nicefrac{1}{2}}}){\mathbf {u}}(t^{n-{\nicefrac{1}{2}}}) )\cdot \nabla v_h d{\mathbf {x}}, \end{aligned}$$
(11)

We now use the fact that we can transform the centered finite difference operator \(\bar{\partial }\) into the backward finite operator \(\partial\) through the relation

$$\begin{aligned} \bar{\partial } \varphi _h^{n+1} = \partial \varphi _h^{n+1} - \frac{\tau ^n}{2} \partial ^2 \varphi _h^{n+1}, \end{aligned}$$

Plugging this last relation into (11), we get

$$\begin{aligned}&\int _\Omega \left( \partial ^2 \varphi _h^{n+1} + {\mathbf {u}}(t) \cdot \nabla \partial \varphi _h^{n+1}\right) (v_h + \delta _h(t) {\mathbf {u}}(t)\cdot \nabla v_h) d{\mathbf {x}}\\&= \frac{\tau ^n}{2} \int _\Omega {\mathbf {u}}(t) \nabla \partial ^2 \varphi _h^{n+1} (v_h + \delta _h(t) {\mathbf {u}}(t)\cdot \nabla v_h)d{\mathbf {x}}\\&\frac{1}{\dfrac{\tau ^{n+1} + \tau ^n}{2}} \int _\Omega \left( ( {\mathbf {u}}(t) - {\mathbf {u}}(t^{n+{\nicefrac{1}{2}}}))\cdot \nabla \varphi _h^{n+{\nicefrac{1}{2}}}-( {\mathbf {u}}(t) - {\mathbf {u}}(t^{n-{\nicefrac{1}{2}}}))\cdot \nabla \varphi _h^{n-{\nicefrac{1}{2}}}\right) \\&\qquad \qquad \qquad \qquad (v_h + \delta _h(t) {\mathbf {u}}(t)\cdot \nabla v_h) d{\mathbf {x}}\\&\qquad \qquad + \frac{1}{\dfrac{\tau ^{n+1} + \tau ^n}{2}} \int _\Omega \left( \partial \varphi _h^{n+1} + {\mathbf {u}}(t^{n+{\nicefrac{1}{2}}})\cdot \nabla \varphi _h^{n+{\nicefrac{1}{2}}}\right) \\&\qquad \qquad \qquad ( \delta _h(t){\mathbf {u}}(t) - \delta _h(t^{n+{\nicefrac{1}{2}}}){\mathbf {u}}(t^{n+{\nicefrac{1}{2}}}) )\cdot \nabla v_h d{\mathbf {x}}\\&\qquad \qquad + \frac{1}{\dfrac{\tau ^{n+1} + \tau ^n}{2}} \int _\Omega \left( \partial \varphi _h^n + {\mathbf {u}}(t^{n-{\nicefrac{1}{2}}})\cdot \nabla \varphi _h^{n-{\nicefrac{1}{2}}}\right) \\&\qquad \qquad \qquad \qquad ( \delta _h(t){\mathbf {u}}(t) - \delta _h(t^{n-{\nicefrac{1}{2}}}){\mathbf {u}}(t^{n-{\nicefrac{1}{2}}}) )\cdot \nabla v_h d{\mathbf {x}}. \end{aligned}$$

By multiplying the last equality by \((t-t^{n+{\nicefrac{1}{2}}})\) it yields for \(I_2\) the following expression

$$\begin{aligned}&I_2= \frac{\tau ^n}{2}(t-t^{n+{\nicefrac{1}{2}}}) \int _\Omega {\mathbf {u}}(t) \nabla \partial ^2 \varphi _h^{n+1} (v_h + \delta _h(t) {\mathbf {u}}(t)\cdot \nabla v_h)d{\mathbf {x}}\\&2\frac{t-t^{n+{\nicefrac{1}{2}}}}{\tau ^{n+1} + \tau ^n} \int _\Omega \left( ( {\mathbf {u}}(t) - {\mathbf {u}}(t^{n+{\nicefrac{1}{2}}}))\cdot \nabla \varphi _h^{n+{\nicefrac{1}{2}}}-( {\mathbf {u}}(t) - {\mathbf {u}}(t^{n-{\nicefrac{1}{2}}}))\cdot \nabla \varphi _h^{n-{\nicefrac{1}{2}}}\right) \\&\qquad \qquad \qquad \qquad (v_h + \delta _h(t) {\mathbf {u}}(t)\cdot \nabla v_h) d{\mathbf {x}}\\&\qquad \qquad + 2\frac{t-t^{n+{\nicefrac{1}{2}}}}{\tau ^{n+1} + \tau ^n} \int _\Omega \left( \partial \varphi _h^{n+1} + {\mathbf {u}}(t^{n+{\nicefrac{1}{2}}})\cdot \nabla \varphi _h^{n+{\nicefrac{1}{2}}}\right) \\&\qquad \qquad \qquad ( \delta _h(t){\mathbf {u}}(t) - \delta _h(t^{n+{\nicefrac{1}{2}}}){\mathbf {u}}(t^{n+{\nicefrac{1}{2}}}) )\cdot \nabla v_h d{\mathbf {x}}\\&\qquad \qquad + 2\frac{t-t^{n+{\nicefrac{1}{2}}}}{\tau ^{n+1} + \tau ^n} \int _\Omega \left( \partial \varphi _h^n + {\mathbf {u}}(t^{n-{\nicefrac{1}{2}}})\cdot \nabla \varphi _h^{n-{\nicefrac{1}{2}}}\right) \\&\qquad \qquad \qquad \qquad ( \delta _h(t){\mathbf {u}}(t) - \delta _h(t^{n-{\nicefrac{1}{2}}}){\mathbf {u}}(t^{n-{\nicefrac{1}{2}}}) )\cdot \nabla v_h d{\mathbf {x}}. \end{aligned}$$

Finally, in order to have finite differences of the velocity, we add and substract the terms

$$\begin{aligned} 2\frac{t-t^{n+{\nicefrac{1}{2}}}}{\tau ^{n+1} + \tau ^n} \int _\Omega ( {\mathbf {u}}(t) - {\mathbf {u}}(t^{n-{\nicefrac{1}{2}}})) \cdot \nabla \varphi _h^{n+{\nicefrac{1}{2}}})(v_h + \delta _h(t) {\mathbf {u}}(t)\cdot \nabla v_h) d{\mathbf {x}}\end{aligned}$$

and

$$\begin{aligned}&2\frac{t-t^{n+{\nicefrac{1}{2}}}}{\tau ^{n+1} + \tau ^n} \int _\Omega \left( \partial \varphi _h^{n+1} + {\mathbf {u}}(t^{n+{\nicefrac{1}{2}}})\cdot \nabla \varphi _h^{n+{\nicefrac{1}{2}}}\right) \\&\qquad \qquad \qquad \qquad ( \delta _h(t){\mathbf {u}}(t) - \delta _h(t^{n-{\nicefrac{1}{2}}}){\mathbf {u}}(t^{n-{\nicefrac{1}{2}}}) )\cdot \nabla v_h d{\mathbf {x}}. \end{aligned}$$

We therefore obtain as final expression for \(I_2\)

$$\begin{aligned}&I_2= \frac{\tau ^n}{2}(t-t^{n+{\nicefrac{1}{2}}}) \int _\Omega {\mathbf {u}}(t) \nabla \partial ^2 \varphi _h^{n+1} (v_h + \delta _h(t) {\mathbf {u}}(t)\cdot \nabla v_h)d{\mathbf {x}}\\&\qquad + (t-t^{n+{\nicefrac{1}{2}}}) \int _\Omega ( {\mathbf {u}}(t)-{\mathbf {u}}(t^{n-{\nicefrac{1}{2}}})) \cdot \nabla \bar{\partial }\varphi _h^{n+1}(v_h + \delta _h(t) {\mathbf {u}}(t)\cdot \nabla v_h)d{\mathbf {x}}\\&\qquad \qquad \qquad - (t-t^{n+{\nicefrac{1}{2}}}) \int _\Omega \partial {\mathbf {u}}(t^{n+{\nicefrac{1}{2}}}) \cdot \nabla \varphi _h^{n+{\nicefrac{1}{2}}}(v_h + \delta _h(t) {\mathbf {u}}(t)\cdot \nabla v_h)d{\mathbf {x}}\\&\qquad \qquad + (t-t^{n+{\nicefrac{1}{2}}}) \int _\Omega \partial ^2 \varphi _h^{n+1}(\delta _h(t) {\mathbf {u}}(t) - \delta _h(t^{n-{\nicefrac{1}{2}}}){\mathbf {u}}(t^{n-{\nicefrac{1}{2}}}))\cdot \nabla v_h d{\mathbf {x}}\\&\qquad+ (t-t^{n+{\nicefrac{1}{2}}}) \int _\Omega \partial [{\mathbf {u}}(t^{n+{\nicefrac{1}{2}}})\cdot \nabla \varphi _h^{n+{\nicefrac{1}{2}}}](\delta _h(t) {\mathbf {u}}(t) - \delta _h(t^{n-{\nicefrac{1}{2}}}){\mathbf {u}}(t^{n-{\nicefrac{1}{2}}}))\cdot \nabla v_h d{\mathbf {x}}\\&\qquad- (t-t^{n+{\nicefrac{1}{2}}}) \int _\Omega \left( \partial \varphi _h^{n+1} + {\mathbf {u}}(t^{n+{\nicefrac{1}{2}}})\cdot \nabla \varphi _h^{n+{\nicefrac{1}{2}}}\right) \partial [\delta _h(t^{n+{\nicefrac{1}{2}}}){\mathbf {u}}(t^{n+{\nicefrac{1}{2}}})]\cdot \nabla v_h d{\mathbf {x}}. \end{aligned}$$

Now, by adding the first term of \(I_2\) with \(I_3\) and the third and the last terms with \(I_1\) yields the result for \(n\ge 1\).

Finally, for \(n=0\), reproducing the steps using to compute \(I_1\) here above yields that

$$\begin{aligned}&\int _\Omega \left( \frac{\partial \varphi _{h\tau }}{\partial t} + {\mathbf {u}}(t)\cdot \nabla \varphi _{h\tau } \right) (v_h + \delta _h(t){\mathbf {u}}(t) \cdot \nabla v_h) d{\mathbf {x}}\\&\qquad \qquad \qquad = (t-t^{{\nicefrac{1}{2}}}) \int _\Omega {\mathbf {u}}(t)\cdot \nabla \partial \varphi _h^1 ( v_h + \delta _h(t) {\mathbf {u}}(t) \cdot \nabla v_h) d{\mathbf {x}}\\&\qquad \qquad \qquad + \int _\Omega ({\mathbf {u}}(t)-{\mathbf {u}}(t^{{\nicefrac{1}{2}}}))\cdot \nabla \varphi _h^{{\nicefrac{1}{2}}} ( v_h + \delta _h(t) {\mathbf {u}}(t) \cdot \nabla v_h) d{\mathbf {x}}\\&\qquad \qquad + \int _\Omega \left( \partial \varphi _h^1 + {\mathbf {u}}(t^{{\nicefrac{1}{2}}})\cdot \nabla \varphi _h^{{\nicefrac{1}{2}}} \right) (\delta _h(t) {\mathbf {u}}(t) - \delta _h(t^{{\nicefrac{1}{2}}}){\mathbf {u}}(t^{{\nicefrac{1}{2}}}))\cdot \nabla v_h d{\mathbf {x}}. \end{aligned}$$

\(\square\)

In order to prove an a posteriori error estimate for the numerical method (2) we now need to define the stabilization parameter \(\delta _h\) in (2). Following [11, 29], \(\delta _h\) is defined for all \(t\in [0,T]\) and for \(K\in {\mathcal {T}}_h\) by

$$\begin{aligned} \delta _{h}(t)_{\vert K}=\frac{\lambda _{2,K}}{2\left\| {\mathbf {u}}(t)\right\| _{L^{\infty }(K)}}, \end{aligned}$$
(12)

if \({\mathbf {u}}(t)\) is not identically zero on K and by \(\delta _{h}(t)_{\vert K}=0\) otherwise.

Theorem 1

Assume that \(\varphi \in L^2(0,T;H^1(\Omega )) \cap H^1(0,T;L^2(\Omega ))\) where \(\varphi\) is the solution of (1). Let \((\varphi _h^n)_{n=0}^N\) be the solution of (2) with \(\delta _h\) defined by (12) and consider \(\varphi _{h\tau }\) the numerical reconstruction given by (5) (6). Setting \(e=\varphi -\varphi _{h\tau }\), there exists \(\hat{C}>0\) depending only on the reference triangle, in particular independent of \(T,\Omega , {\mathbf {u}}, \varphi\), the mesh size, aspect ratio and time step such that

$$\begin{aligned}&\left\| e(T)\right\| _{L^{2}(\Omega )}^{2}\le \hat{C}\Biggl (\left\| e(0)\right\| _{L^{2}(\Omega )}^{2}\nonumber \\&+\sum _{n=0}^{N-1}\sum _{K\in {\mathcal {T}}_{h}}\int _{t^{n}}^{t^{n+1}}\biggl (\left\| \frac{\partial \varphi _{h\tau }}{\partial t}+{\mathbf {u}}(t)\cdot \nabla \varphi _{h\tau }\right\| _{L^{2}(K)}\omega _{K}(e) +c_n\left\| \theta _n\right\| _{L^{2}(K)}^{2}dt\biggr )\nonumber \\&\qquad \qquad \qquad +\sum _{n=0}^{N-1}\sum _{K\in {\mathcal {T}}_{h}}\int _{t^{n}}^{t^{n+1}}\left( \left\| \theta _n\right\| _{L^{2}(K)}+ \frac{\left\| \varvec{\zeta _n}\right\| _{L^{2}(K)}}{\lambda _{2,K}}\right) \omega _K(e) dt\Biggr ), \end{aligned}$$
(13)

where \(\omega _K\) is defined in (4) , \(\theta _n, \varvec{\zeta }_n\) are defined in Proposition 1 and \(c_0=\tau ^1\), \(c_n=T-\tau ^1\), for \(n\ge 1\).

Remark 2

  1. (i)

    The a posteriori error estimate (13) is not standard since the exact solution \(\varphi\) is contained in \(\omega _K(e)\). To obtain a computable upper bound, post-processing techniques were advocated in [11], for instance Zienkiewicz−Zhu (ZZ) post-processing [42,43,44]. More precisely, to compute \(G_K(\varphi -\varphi _{h\tau })\), we replace the first order partial derivatives with respect to \(x_i\)

    $$\begin{aligned} \frac{\partial (\varphi -\varphi _{h\tau })}{\partial x_i} \; {\text {by}} \; \Pi _h^{ZZ} \frac{\partial \varphi _{h\tau }}{\partial x_i}-\frac{\partial \varphi _{h\tau }}{\partial x_i},\quad \quad i=1,2, \end{aligned}$$

    where, for any \(v_h\in V_h\) and for any vertex P of the mesh

    $$\begin{aligned} \Pi _h^{ZZ} \frac{\partial v_h}{\partial x_i} (P) = \dfrac{\displaystyle \sum _{\begin{array}{c} K\in {\mathcal {T}}_h\\ P \in K \end{array}}\vert K \vert \; \frac{\partial v_h}{\partial x_i}_{\vert K}}{\displaystyle \sum _{\begin{array}{c} K\in {\mathcal {T}}_h\\ P \in K \end{array}} \vert K \vert }, \end{aligned}$$

    in other words, \(\Pi _h^{ZZ} \partial v_h/\partial x_i\) is an approximate \(L^2(\Omega )\) projection of \(\partial v_h/\partial x_i\) onto \(V_h\). It corresponds to the weighted mean value of the gradient \(\nabla v_h\) over the support of the hat functions centered at vertex P. Superconvergence of the ZZ recovery has been proved for elliptic problems and structured meshes [44] and more recently for unstructured anisotropic meshes [15]. Numerical experiments have shown that the efficiency of ZZ post-processing is better than theoretical predictions, see for instance [11, 28, 33,34,35,36].

  2. (ii)

    Observe that if \({\mathbf {u}}\) is independent of time, then due to definitions of \(\theta _n\) and \(\varvec{\zeta }_n\), the a posteriori error estimate (13) reduces to the one proven in [21], Theorem 2.

  3. (iii)

    Based on the a priori error estimates in [12, 20], it is expected that \(\Vert e(T) \Vert _{L^2(\Omega )}^2 = O(h^3 + \tau ^4)\) (written in the isotropic setting for simplicity). Numerical experiments will confirm that

    $$\begin{aligned} \sum _{n=0}^{N-1}\sum _{K\in {\mathcal {T}}_{h}}\int _{t^{n}}^{t^{n+1}} \biggl ( \left\| \frac{\partial \varphi _{h\tau }}{\partial t}+{\mathbf {u}}(t)\cdot \nabla \varphi _{h\tau }\right\| _{L^{2}(K)}\omega _{K}(e)dt=O(h^3) \end{aligned}$$

    and

    $$\begin{aligned} \sum _{n=0}^{N-1}\sum _{K\in {\mathcal {T}}_{h}}\int _{t^{n}}^{t^{n+1}} c_n\left\| \theta _n\right\| _{L^{2}(K)}^{2}dt =O(\tau ^4). \end{aligned}$$

    The term

    $$\begin{aligned} \sum _{n=0}^{N-1}\sum _{K\in {\mathcal {T}}_{h}}\int _{t^{n}}^{t^{n+1}}\left( \left\| \theta _n\right\| _{L^{2}(K)}+ \frac{\left\| \varvec{\zeta _n}\right\| _{L^{2}(K)}}{\lambda _{2,K}}\right) \omega _K(e) dt \end{aligned}$$

    is a mixed quantity involving both space and time discretizations. It can be shown (see point (iv) below) to be of higher order when \(\tau ^2 = \Theta (h^{\nicefrac{3}{2}})\), that is exactly the goal of the adaptive algorithm proposed further. Since the initial error \(\Vert \varphi (0)-\varphi _{h\tau }(0) \Vert _{L^2(\Omega )}^2 = \Vert \varphi _0-r_h(\varphi _0) \Vert _{L^2(\Omega )}^2\) is \(O(h^4)\), the leading terms of the estimate (13) reduces to

    $$\begin{aligned} \sum _{n=0}^{N-1}\sum _{K\in {\mathcal {T}}_{h}}\int _{t^{n}}^{t^{n+1}}\biggl ( \left\| \frac{\partial \varphi _{h\tau }}{\partial t}+{\mathbf {u}}(t)\cdot \nabla \varphi _{h\tau }\right\| _{L^{2}(K)}\omega _{K}(e) +c_n\left\| \theta _n\right\| _{L^{2}(K)}^{2}\biggr )dt \end{aligned}$$

    that can be used as an a posteriori estimator for the error \(\Vert e(T) \Vert _{L^2(\Omega )}^2\).

  4. (iv)

    Assuming that the solution is smooth enough [20], it is expected that

    $$\begin{aligned} \omega _K(e)\lesssim h \Vert \nabla e \Vert _{L^2(\Omega )} = h O(h+\tau ^2) = O(h^2 + h\tau ^2). \end{aligned}$$

    Since \(\theta _n=O(\tau ^2)\) and \(\varvec{\zeta _n}=O(h\tau ^2)\) (see Remark 1), we finally have

    $$\begin{aligned} \sum _{n=0}^{N-1}\sum _{K\in {\mathcal {T}}_{h}}\int _{t^{n}}^{t^{n+1}}\left( \left\| \theta _n\right\| _{L^{2}(K)}+ \frac{\left\| \varvec{\zeta _n}\right\| _{L^{2}(K)}}{\lambda _{2,K}}\right) \omega _K(e) dt = O(h^2 \tau ^2 + h \tau ^4). \end{aligned}$$

    Since the goal of our adaptive algorithm is to equidistribute the error due to space and time, then \(\tau ^2 \simeq h^{\nicefrac{3}{2}}\) and the above term is \(O(h^{3.5} + \tau ^{5+1/3})\), that is to say of higher order compared the error at final time \(\Vert e(T) \Vert _{L^2(\Omega )}^2=O(h^3+\tau ^4)\).

Proof

In the following, we denote by \(\hat{C}\) any positive constant, which may depend only on the reference triangle and may change from line to line. In particular, \(\hat{C}\) is independent of T, \(\Omega\),\({\mathbf {u}}\), \(\varphi\), the mesh size, aspect ratio and the time step. Let \(t\in \left( t^{n},t^{n+1}\right)\), \(n\ge 1\). First observe that for all \(v \in H^1(\Omega )\) that is zero on \(\Gamma ^{-}\), we have

$$\begin{aligned} \int _\Omega ({\mathbf {u}}\cdot \nabla v)v d{\mathbf {x}}= \frac{1}{2}\int _\Omega \div \left( {\mathbf {u}} v^2\right) d{\mathbf {x}}= \frac{1}{2}\int _{\partial \Omega \setminus \Gamma ^{-}} ({\mathbf {u}}\cdot {\mathbf {n}}) v^2 d{\mathbf {x}}\ge 0. \end{aligned}$$
(14)

Therefore, applying (14) with \(v=e\) and using the fact that \(\varphi\) is the solution to (1) we have

$$\begin{aligned}&\frac{1}{2}\frac{d}{dt}\int _{\Omega }e^{2}dx\le \int _{\Omega }\left( \frac{\partial e}{\partial t}e+({\mathbf {u}}(t)\cdot \nabla e)e\right) d{\mathbf {x}}\\&\qquad \qquad \qquad = - \int _{\Omega }\left( \frac{\partial \varphi _{h\tau }}{\partial t}+{\mathbf {u}}(t)\cdot \nabla \varphi _{h\tau }\right) ed{\mathbf {x}}. \end{aligned}$$

Subtracting any \(v_h + \delta _h(t) {\mathbf {u}}(t)\cdot \nabla v_h\) and using Proposition 1, we obtain

$$\begin{aligned}&\frac{1}{2}\frac{d}{dt}\int _{\Omega }e^{2}dx\le - \int _{\Omega }\left( \frac{\partial \varphi _{h\tau }}{\partial t}+{\mathbf {u}}(t)\cdot \nabla \varphi _{h\tau }\right) (e- v_h - \delta _h(t) {\mathbf {u}}(t)\cdot \nabla v_h) d{\mathbf {x}}\\&\qquad \qquad \qquad \qquad - \int _\Omega \theta _n (v_h + \delta _h(t) {\mathbf {u}}(t)\cdot \nabla v_h) d{\mathbf {x}}- \int _\Omega \varvec{\zeta }_n \cdot \nabla v_h d\mathbf {x}\\&\qquad \qquad = - \int _{\Omega }\left( \frac{\partial \varphi _{h\tau }}{\partial t}+\mathbf {u}(t)\cdot \nabla \varphi _{h\tau } + \theta _n\right) (e- v_h - \delta _h(t) {\mathbf {u}}(t)\cdot \nabla v_h) d{\mathbf {x}}\\&\qquad \qquad \qquad \qquad \qquad - \int _\Omega \theta _n e d{\mathbf {x}}- \int _\Omega \varvec{\zeta }_n \cdot \nabla v_h d{\mathbf {x}}. \end{aligned}$$

Splitting the last inequality into a sum over the triangles, and using the triangle and Cauchy-Schwarz inequalities yields

$$\begin{aligned}&\frac{1}{2}\frac{d}{dt}\int _{\Omega }e^{2}dx\le \sum _{K\in {\mathcal {T}}_h}\left( \left\| \frac{\partial \varphi _{h\tau }}{\partial t}+{\mathbf {u}}(t)\cdot \nabla \varphi _{h\tau } \right\| _{L^2(K)} + \Vert \theta _n\Vert _{L^2(K)}\right) \\&\qquad \qquad \qquad \left( \Vert e - v_h \Vert _{L^2(K)} + \Vert \delta _{h|K}(t) {\mathbf {u}}(t)\cdot \nabla v_h \Vert _{L^2(K)}\right) \\&\qquad \qquad \qquad + \sum _{K\in {\mathcal {T}}_h}\Vert \theta _n\Vert _{L^2(K)} \Vert e \Vert _{L^2(K)} + \sum _{K\in {\mathcal {T}}_h}\Vert \varvec{\zeta }_n\Vert _{L^2(K)} \Vert \nabla v_h \Vert _{L^2(K)}. \end{aligned}$$

We now choose \(v_h = R_h e\) where we recall that \(R_h\) stands for the Clément’s interpolant. Using the anisotropic interpolation error estimate (3), we can prove that

$$\begin{aligned} \Vert \nabla R_h e \Vert _{L^2(K)} \le \hat{C} \frac{\omega _K(e)}{\lambda _{2,K}} \end{aligned}$$
(15)

Indeed, using that \(\nabla e = (\nabla e \cdot {\mathbf {r}}_{1,K}) {\mathbf {r}}_{1,K}+ (\nabla e \cdot {\mathbf {r}}_{2,K}) {\mathbf {r}}_{2,K})\) and

$$\begin{aligned} \Vert \nabla e \cdot {\mathbf {r}}_{i,K} \Vert _{L^2(\Delta K)}^2 = {\mathbf {r}}^T_{i,K} G_K(e) {\mathbf {r}}_{i,K}, \quad i=1,2, \end{aligned}$$

implies that

$$\begin{aligned} \lambda _{2,K}\Vert \nabla e \Vert _{L^2(\Delta K)} \le \omega _K(e). \end{aligned}$$

Thus, since

$$\begin{aligned}&\Vert \nabla R_h e \Vert _{L^2(K)} \le \Vert \nabla e \Vert _{L^2(K)} + \Vert \nabla (e-R_h e) \Vert _{L^2(K)}\\&\qquad \qquad \qquad \qquad \le \Vert \nabla e \Vert _{L^2(\Delta K)} + \Vert \nabla (e-R_h e) \Vert _{L^2(K)}, \end{aligned}$$

we obtain (15) by applying the interpolation error estimate (3). Moreover using (15) and the definition of \(\delta _{h|K}(t)\), we can finally prove that

$$\begin{aligned} \Vert e - R_he \Vert _{L^2(K)} + \Vert \delta _{h|K}(t) {\mathbf {u}}(t)\cdot \nabla R_h e \Vert _{L^2(K)} \le \hat{C} \omega _K(e). \end{aligned}$$

So we obtain that

$$\begin{aligned} \frac{1}{2}\frac{d}{dt}\int _{\Omega }e^{2}dx\le \hat{C} \sum _{K\in {\mathcal {T}}_h}(\alpha _K + \theta _K + \zeta _K) \omega _K(e) + \sum _{K\in {\mathcal {T}}_h}\theta _K \Vert e \Vert _{L^2(K)}, \end{aligned}$$

where we have set

$$\begin{aligned} \alpha _K = \left\| \frac{\partial \varphi _{h\tau }}{\partial t}+{\mathbf {u}}(t)\cdot \nabla \varphi _{h\tau } \right\| _{L^2(K)}, \end{aligned}$$

\(\theta _K = \Vert \theta _n\Vert _{L^2(K)}\) and \(\displaystyle \zeta _K = \frac{\Vert \varvec{\zeta }_n\Vert _{L^2(K)}}{\lambda _{2,K}}\). The discrete Cauchy-Schwarz implies then that

$$\begin{aligned} \frac{1}{2}\frac{d}{dt}\int _{\Omega }e^{2}dx\le \hat{C} \sum _{K\in {\mathcal {T}}_h}(\alpha _K + \theta _K + \zeta _K) \omega _K(e) + \left( \sum _{K\in {\mathcal {T}}_h}\theta _K^2\right) ^{{\nicefrac{1}{2}}} \Vert e \Vert _{L^2(\Omega )}. \end{aligned}$$

Finally, the Young’s inequality yields

$$\begin{aligned}&\frac{1}{2}\frac{d}{dt}\int _{\Omega }e^{2}dx\le \hat{C} \sum _{K\in {\mathcal {T}}_h}(\alpha _K + \theta _K + \zeta _K) \omega _K(e) \\&\qquad \qquad \qquad +\frac{T-t^1}{2} \sum _{K\in {\mathcal {T}}_h}\theta _K^2+ \frac{1}{2(T-t^1)}\Vert e \Vert _{L^2(\Omega )}^2, \end{aligned}$$

We conclude by using a Gronwall’s type inequality. Multiplying by \(\exp (-t / (T-t^1))\) on both sides and integrating between \(t^1\) and T yields

$$\begin{aligned}&\Vert e(T) \Vert ^2_{L^2(\Omega )} \le \hat{C} \left( \Vert e(t^1) \Vert ^2_{L^2(\Omega )} \right. \\&\qquad \qquad \left. + \sum _{n=1}^{N-1} \sum _{K\in {\mathcal {T}}_h}\int _{t^n}^{t^{n+1}} \left( \alpha _K + \theta _K + \zeta _K) \omega _K(e) + (T-t^1) \theta _K^2\right) dt \right) . \end{aligned}$$

Note that the choice to use \(\exp (-t / (T-t^1))\) is made in order to eliminate the exponential growth with respect to T in the estimate. Proceeding in the same manner we can obtain an estimate for \(\Vert e(t^1) \Vert ^2_{L^2(\Omega )}\)

$$\begin{aligned}&\Vert e(t^1) \Vert ^2_{L^2(\Omega )} \\&\qquad \qquad \le \hat{C} \left( \Vert e(0) \Vert ^2_{L^2(\Omega )} + \sum _{K\in {\mathcal {T}}_h}\int _{0}^{t^1} \left( \alpha _K + \theta _K + \zeta _K) \omega _K(e) + \tau ^1\theta _K^2\right) dt \right) . \end{aligned}$$

Combining both estimates yields finally

$$\begin{aligned}&\left\| e(T)\right\| _{L^{2}(\Omega )}^{2}\le \hat{C}\Biggl (\left\| e(0)\right\| _{L^{2}(\Omega )}^{2}\\&\qquad \qquad +\sum _{n=0}^{N-1}\sum _{K\in {\mathcal {T}}_{h}}\int _{t^{n}}^{t^{n+1}}\Biggl (\left\| \frac{\partial \varphi _{h\tau }}{\partial t}+{\mathbf {u}}\cdot \nabla \varphi _{h\tau }\right\| _{L^{2}(K)}\omega _{K}(e)+c_n\left\| \theta _n\right\| _{L^{2}(K)}^{2}dt\Biggl ) \\&\qquad \qquad \qquad +\sum _{n=0}^{N-1}\sum _{K\in {\mathcal {T}}_{h}}\int _{t^{n}}^{t^{n+1}}\left( \left\| \theta _n \right\| _{L^{2}(K)}+\frac{\Vert \varvec{\zeta }_n\Vert _{L^2(K)}}{\lambda _{2,K}}\right) \omega _{K}(e)dt\Biggl ). \end{aligned}$$

\(\square\)

4 Numerical experiments with non-adapted meshes and constant time steps

We denote \(e(T)_{L^2}\) the \(L^2\) numerical error at final time

$$\begin{aligned} e(T)_{L^2} = \Vert \varphi (T) - \varphi _{h\tau }(T) \Vert _{L^2(\Omega )}. \end{aligned}$$

Based on the a posteriori error estimate of Theorem 1, we define the error indicator \(\eta\) by

$$\begin{aligned} \eta = \left( (\eta ^A)^2 + (\eta ^T)^2 \right) ^{{\nicefrac{1}{2}}}, \end{aligned}$$
(16)

where the anisotropic space error indicator \(\eta ^A\) is defined by

$$\begin{aligned} \eta ^A = \left( \sum _{n=0}^{N-1}\sum _{K\in {\mathcal {T}}_h}(\eta _{K,n}^A)^2\right) ^{{\nicefrac{1}{2}}}, \end{aligned}$$
(17)

with the local space error indicator given by

$$\begin{aligned} (\eta _{K,n}^A)^2 = \int _{t^n}^{t^{n+1}} \left\| \frac{\partial \varphi _{h\tau }}{\partial t}+{\mathbf {u}}(t)\cdot \nabla \varphi _{h\tau }\right\| _{L^{2}(K)}\omega _{K}( \varphi -\varphi _{h\tau }) dt, \end{aligned}$$
(18)

and the time error indicator \(\eta ^T\) is defined by

$$\begin{aligned} \eta ^T = \left( \sum _{n=0}^{N-1}\sum _{K\in {\mathcal {T}}_h}(\eta _{K,n}^T)^2\right) ^{{\nicefrac{1}{2}}}, \end{aligned}$$
(19)

with the local time error indicator given by

$$\begin{aligned} (\eta _{K,n}^T)^2 = c_n \int _{t^n}^{t^{n+1}} \Vert \theta _n \Vert _{L^2(K)}^2 dt, \end{aligned}$$
(20)

where we recall that \(c_0 = \tau ^1\), \(c_n = T - \tau ^1\), \(n \ge 1\), and \(\theta _n\) is defined as in Proposition 1. As already anticipated in the Remark 2, the space error indicator (17) is made computable by replacing all the derivatives of \(\varphi\) by their ZZ post-processing. The sharpness of the error indicator \(\eta\) will be investigated by computing the effectivity index ei given by

$$\begin{aligned} ei = \frac{\eta }{e(T)_{L^2}}. \end{aligned}$$

Since we use the ZZ post-processing to make the space error indicator computable, we also check the efficiency of this procedure by computing the true \(H^1\) error

$$\begin{aligned} e_{L^2(H^1)} = \left( \int _0^T \Vert \nabla (\varphi - \varphi _{h\tau }) \Vert _{L^2(\Omega )}^2 dt \right) ^{{\nicefrac{1}{2}}}, \end{aligned}$$

and the approximated \(H^1\) error

$$\begin{aligned} \eta ^{ZZ} = \left( \int _0^T \Vert (\Pi _h^{ZZ} \nabla \varphi - \nabla \varphi _{h\tau } \Vert _{L^2(\Omega )}^2 dt \right) ^{{\nicefrac{1}{2}}}, \end{aligned}$$

and the ZZ effectivity index is denoted by

$$\begin{aligned} ei^{ZZ} = \frac{\eta ^{ZZ}}{e_{L^2(H^1)}}. \end{aligned}$$

To test the convergence of the numerical method presented above and check the sharpness of our error indicators, we start with numerical experiments for non-adapted meshes and constant time steps. The numerical experiments should possibly demonstrate the following properties:

  1. (i)

    To validate the equivalence between the error indicator and the true error, the effectivity index ei should remain close to a constant, in particular, the effectivity index ei should not depend on the solution, the time step and the mesh size and aspect ratio.

  2. (ii)

    To ensure that the ZZ post-processing is asymptotically exact and justify its use, the effectivity index \(ei^{ZZ}\) should be close to one.

We consider a ”1D” problem where the initial condition is given by

$$\begin{aligned} \varphi _0(x_1,x_2) = \tanh (-C((x_1-0.25)^2 - 0.01)), \end{aligned}$$

with \(C>0\) and we solve the transport equation

$$\begin{aligned} \frac{\partial \varphi }{\partial t}+ {\mathbf {u}}(t)\cdot \nabla \varphi =0 \end{aligned}$$

with

$$\begin{aligned} {\mathbf {u}}(x_1,x_2,t) = (10+10t^2,0). \end{aligned}$$

Finally, we impose Dirichlet boundary conditions on the left side of \(\Omega\) that is chosen as \((0,1)^2\) and we set \(T=0.05\). The exact solution is then given by

$$\begin{aligned} \varphi (x_1,x_2,t) = \varphi _0 ( x_1 - 10t-10/3 t^3, x_2). \end{aligned}$$

Observe that the solution is smooth, with small variations, except in a thin layer of width controlled by C.

The numerical results are reported in Table 1 where we choose \(\tau = O(h^2)\). When the error is mainly due to the space discretization, it is observed that ei stays close to a value of 20, as it was already concluded for non-depending on time velocity [21]. \(ei^{ZZ}\) is close to one, thus the ZZ post-processing is asymptotically exact, as predicted by the theory. The numerical errors are respectively \(\simeq O(h^{1.8})\) for the \(L^2\) error at final time and \(\simeq O(h)\) for the \(L^2(0,T; H^1(\Omega ))\) error. When we choose \(h=O(\tau ^2)\), the numerical error is mainly due to the time discretizazion and the effectivity index is close to 2. This value is already observed in [21] and we note that both numerical errors are \(O(\tau ^2)\), see Table 2. In all cases, ei is independent of the solution (the same effectivity indices are obtained with \(C=60\) and \(C=240\)), the mesh size and aspect ratio, and the time step as expected.

In order to have effectivity indices that are close to one, we finally perform numerical experiments with the normalized error indicator defined by

$$\begin{aligned} \eta =\sqrt{\left( \frac{\eta ^{A}}{20}\right) ^2+\left( \frac{\eta ^{T}}{2}\right) ^2}. \end{aligned}$$
(21)

Numerical experiments will show that indeed, the effectivity indices corresponding to the normalized error indicator will be close to one and independent of the solution, the mesh size and aspect ratio, and the time step. This normalized indicator will be then used as a criterion towards mesh and time step adaptivity. In Table 3, the effectivity indices are reported when using (21) as error indicator and when setting \(h^{\nicefrac{3}{2}} = O(\tau ^2)\).

Table 1 Convergence results when \(\tau =O(h^{2})\) with \(C=60\) (rows 1–6) and \(C=240\) (rows 7–12)
Table 2 Convergence results when \(h=O(\tau ^{2})\) with \(C=60\) (rows 1–7) and \(C=240\) (rows 8–15)
Table 3 Convergence results with the normalized error indicator when \(h^{\nicefrac{3}{2}}=O(\tau ^{2})\) with \(C=60\) (rows 1–7) and \(C=240\) (rows 8–14)

5 An adaptive algorithm

We now present an adaptive algorithm. The a priori error analysis contained in [12, 20] show that the final error increases as the square root of the final time T. Therefore, our goal is to ensure that the relative error over the time \(\frac{e(T)_{L^2}}{T^{{\nicefrac{1}{2}}}}=TOL\), where TOL is a preset tolerance chosen by the user. Since the normalized error indicator (21) is shown to be close to the true error, the goal of the adaptive algorithm is to build a sequence of meshes and time steps such that \(\frac{\eta }{T^{{\nicefrac{1}{2}}}}\) stays close to TOL. Therefore, we would like that at the end of the simulation, \(\eta\) verifies

$$\begin{aligned} 0.75 TOL \le \frac{\eta }{T^{{\nicefrac{1}{2}}}}\le 1.25 TOL. \end{aligned}$$
(22)

A sufficient condition so that (22) holds is to equidistribute the error between the space and time approximations. Therefore, we build a sequence of meshes such that

$$\begin{aligned} \frac{0.75^2 TOL^2}{2} \le \frac{(\eta ^A)^2}{T}\le \frac{1.25^2 TOL^2}{2}, \end{aligned}$$
(23)

and a sequence of time steps such that

$$\begin{aligned} \frac{0.75^2 TOL^2}{2} \le \frac{(\eta ^T)^2}{T}\le \frac{1.25^2 TOL^2}{2}. \end{aligned}$$
(24)

Finally, sufficient conditions at every steps \(n=0,1,..,N-1\) to satisfy the above criteria are

$$\begin{aligned} \frac{0.75^2 TOL^2}{2}\tau ^{n+1} \le \sum _{K\in {\mathcal {T}}_h}(\eta _{K,n}^A)^2 \le \frac{1.25^2 TOL^2}{2}\tau ^{n+1}, \end{aligned}$$
(25)

and

$$\begin{aligned} \frac{0.75^2 TOL^2}{2}\tau ^{n+1} \le \sum _{K\in {\mathcal {T}}_h}(\eta _{K,n}^T)^2 \le \frac{1.25^2 TOL^2}{2}\tau ^{n+1}. \end{aligned}$$
(26)

If the conditions (26) are not satisfied, we refine or coarsen the time step. If (25) are not satisfied, the mesh is changed and a new anisotropic mesh is generated with the BL2D software [26]. In practice, the new mesh is built by equidistributed \(\eta _{K,n}^A\) between the direction \({\mathbf {r}}_{1,K}\) and \({\mathbf {r}}_{2,K}\), and by aligning each triangle K with the eigenvectors of the gradient matrix \(G_K(\varphi -\varphi _{h\tau })\) (that is post-processed with ZZ post-processing). For more details on this procedure, we refer to [20].

Everytime a new mesh has to be built, the old values of the solutions have to be interpolated on the meshes. A detailed discussion and several interpolation operator are presented in [11] and [21]. In both studies, the conservative interpolation [5] demonstrates the best result. Therefore we decide to use it also for the numerical experiments presented below. The main steps of the adaptive algorithm are summarized in Table 4.

Table 4 Main steps of the time space adaptive algorithm

Example 1

(An anisotropic example) We apply the adaptive algorithm to the following example. The domain is still chosen as \((0,1)^2\) and we set the final time to \(T=0.3\). Dirichlet boundary conditions are still imposed on the left side of \(\Omega\) and we choose the initial condition as before as

$$\begin{aligned} \varphi _0(x_1,x_2) = \tanh (-C((x_1-0.25)^2 - 0.01)), \end{aligned}$$

with \(C=60\) or \(C=240\).

We now choose \({\mathbf {u}}(x_1,x_2,t) = (u_{\bar{t}}(t),0)\) with \(u_{\bar{t}}\) given by

$$\begin{aligned} u_{\bar{t}}(t) = \left\{ {\begin{array}{ll} 1,&{} t \le \bar{t} - 0.03, \\ {}&{}{}\\ \displaystyle 1+9\frac{x-\bar{t} -0.03}{ 0.06} + \frac{9}{2 \pi }\sin \left( \frac{\pi (x-\bar{t})}{0.03}\right) , &{} \bar{t}-0.03 \le t \le \bar{t}+0.03, \\ {}&{}{}\\ 10, &{} t \ge \bar{t}+0.03. \end{array}} \right. \end{aligned}$$
(27)

\(u_{\bar{t}}\) is a smooth function that is mainly 1 or 10, except in a small boundary layer of width 0.03 around \(t=\bar{t}\). Since the velocity quickly accelerates after \(t=\bar{t}\), it is expected that smaller time steps are chosen by the algorithm. For this particular example,we choose \(\bar{t}=0.25\).

We run the adaptive algorithm for various values of the prescribed tolerance TOL. We investigate the number of vertices, aspect ratio, number of time steps and remeshings. We summarize the notations we used for the analysis in Table 5. We make the following observations:

  • The number of vertices is multiplied by 1.6 as the tolerance is divided by two, expressing the fact that the method is \(O(h^{\nicefrac{3}{2}})\).

  • The number of time steps is multiplied by \(\sqrt{2}\) as the tolerance is divided by two, expressing the second order accuracy in time of the method.

  • The \(L^2\) error at final time is O(TOL).

  • ei stays around 1 and the ZZ post-processing is asymptotically exact.

  • The number of remeshings is independent of the tolerance and depends on the solutions.

In Tables 6, we present the converge results for several values of TOL. In Fig. 1, we check the evolution of the time step. We observe that the time step follows the evolution of \({\mathbf {u}}\), up to some oscillations occurring when the adaptive algorithm refuses the current time step. In particular, when \({\mathbf {u}}\) is 10 times larger, the adaptive algorithm selects a time step that is approximatively 10 times smaller. In Fig. 2, we represent the generated meshes and the solutions for \(C=240\) and \(TOL=0.00125\).

This example demonstrates the efficiency of anisotropic adaptive finite elements to approximate the behaviour of solutions with boundary layers. When \(TOL=0.00125\), the mesh size in the \(x_1\) direction is 0.0013 for \(C=60\) and 0.0003 for \(C=240\). An isotropic adaptive algorithm would need the same mesh size in both \(x_1\) and \(x_2\) directions, thus resulting in million vertices! Morover, numerical experiments show that the effectivity index corresponding to the normalized error indicator (21) remains close to one (say between 0.9 and 1.6).

Table 5 Additional notations for the analysis of the adaptive algorithm
Table 6 Example 1. Convergence results for the adaptive algorithm. \(C=60\) (lines 1–3) and \(C=240\) (lines 4–6).
Fig. 1
figure 1

Example 1. Evolution of the current time step for several values of TOL. \(C=60\) (left) and \(C=240\) (right)

Fig. 2
figure 2

Example 1. Meshes and solutions for \(C=240\), \(TOL=0.00125\) and \(t=0,0.25,0.28,0.3\) (from top to bottom)

Example 2

(An isotropic example) We present an isotropic example in order to show that the effectivity index indeed does not depend on the solution. The initial condition is given by

$$\begin{aligned} \varphi _0(x_1,x_2) = \exp ^{-100 ((x_1-0.3)^2 + (x_2-0.3)^2)} \end{aligned}$$

and the velocity field by

$$\begin{aligned} u(x_1,x_2,t)=(u_{\bar{t}}(t),u_{\bar{t}}(t)) \end{aligned}$$

where \(u_{\bar{t}}(t)\) is as in (27) and we choose \(\bar{t}=0.125\). The final time is set to 0.15. Numerical results are reported in Table 7 when runing the adaptive algorithm. In Fig. 3, we represent the generated meshes and the solutions at time t = 0, 0.125, 0.15. The same observations can be made, namely that the effectivity index is close to one (it ranges between 1 and 1.7) and the ZZ post-processing is asymptotically exact.

Table 7 Example 2. Convergence results for the adaptive algorithm.
Fig. 3
figure 3

Example 2. Meshes and solutions at time \(t=0,0.125,0.15\)

Example 3

(Stretching of a circle in a vortex flow) The last test case is the stretching of a circle in a vortex flow. We set \(\Omega = ]0,1[^{2},T=4\). The initial condition is given by

$$\begin{aligned} \varphi _0(x_1,x_2)=\tanh \left( -C(\sqrt{(x_1-0.5)^{2}+(x_2-0.75)^{2}}-0.15)\right) , \end{aligned}$$

where \(C=60\) or \(C=240\). No boundary conditions along \(\partial \Omega\) are prescribed. The velocity field is defined by

$$\begin{aligned} {\mathbf {u}}(x_1,x_2,t) = \left( {\begin{array}{l} -2\sin (\pi x_2)\cos (\pi x_2)\sin ^{2}(\pi x_1)\cos (0.25\pi t) \\ 2\sin (\pi x_1)\cos (\pi x_1)\sin ^{2}(\pi x_2)\cos (0.25\pi t) \end{array}} \right) . \end{aligned}$$

Since the flow is reversed at \(t=2\), we must have \(\varphi (x_1,x_2,4)=\varphi _0(x_1,x_2)\).

We start the adaptive algorithm with an initial grid of mesh size \(h=0.1\) and an initial time step \(\tau ^1 = 0.001\). Several meshes and numerical solutions are presented in Figs. 4 and 5 when \(TOL=0.00125\). In Figs. 6 and 7, convergence of the computed solution at final time is checked for several values of TOL.

Fig. 4
figure 4

Example 3. Mesh and solution at time \(t=0,1,2,3,4,\) with \(C=240\) and \(TOL=0.00125\)

Fig. 5
figure 5

Example 3. Zoom on the mesh at time \(t=2\) with \(C=240\) and \(TOL=0.00125\)

Fig. 6
figure 6

Example 3. Exact and numerical solutions at time \(T=4\) with \(C=60\) along \(x_1\) at \(x_2=0.75\). Right: zoom

Fig. 7
figure 7

Example 3. Exact and numerical solutions at time \(T=4\) with \(C=240\) along \(x_1\) at \(x_2=0.75\). Right: zoom

6 Conclusion

We prove an a posteriori error estimate for the space-time approximation of the transport equation in the case where the transport velocity depends on space and time. Anisotropic finite elements are considered and the Crank-Nicolson method is used to advance in time. The corresponding a posteriori error estimate is shown to be of optimal order. Error indicators for space and time are proposed, numerical experiments confirm their sharpness. An adaptive algorithm is then introduced in order to capture with accuracy and low computational cost solutions that have strong variations in space and time. The efficiency of the method is shown for three 2D examples. A few 3D computations are reported in [20].