1 Introduction

A finite element method (FEM) that uses discontinuous piecewise polynomial spaces as trial and test spaces is commonly called a discontinuous Galerkin (DG) method. Already in 1973 a DG method was introduced for the neutron transport equation [26]. Later for nonlinear time dependent hyperbolic conservation laws DG discretizations in space were coupled to Runge–Kutta time discretizations and limiters see e.g. [5,6,7]. The approach was shown to work well, retaining high order accuracy, conservation and other important properties, and has become very popular. For more details on DG methods, we refer to [16, 28].

Most finite element methods require the mesh to be aligned to boundaries and material interfaces and to achieve the full potential accuracy the mesh quality needs to be high. This type of requirements can be problematic for problems posed on complicated geometries or with material interfaces, especially when the geometry is evolving. For time-dependent problems the time step may be severely restricted. To overcome these problems, approaches using fixed background meshes, unfitted to boundaries and interfaces, are of great interest. However, in a naive approach small cut elements will cause problems, including ill-conditioned linear systems and severe time-step restrictions. Various techniques have been introduced to handle such difficulties. One approach often used in unfitted methods based on DG is cell merging or agglomeration techniques where new elements of sufficient size are created by merging small cut elements with their neighbours [17, 18, 22, 23, 25]. A common technique in connection with Cut Finite Element Methods (CutFEM) is to add ghost penalty stabilization terms in the weak form [3, 4]. In CutFEM the physical domain is embedded into a computational domain equipped with a quasi-uniform mesh. Elements that have an intersection with the domain of interest define the active mesh and associated to that is a finite dimensional function space and a weak form that together define the numerical scheme [9, 14, 21, 31]. Interface and boundary conditions are typically imposed weakly. For hyperbolic problems, CutFEM based on discontinuous piecewise polynomial spaces and ghost penalty stabilization has been developed, e.g. see [12] where a time independent linear advection-reaction problem is considered and see [10] for time dependent nonlinear conservation laws. We also refer to the recent work [8] where a DG method for time dependent linear advection problems is developed with a stabilization of small elements that is designed to restore proper domains of dependence.

The focus of this paper is conservation at material interfaces. We consider time dependent linear hyperbolic conservation laws with discontinuous coefficients in the flux at a stationary or moving interface. We assume the problem has a structure such that requiring conservation yields sufficient conditions at the interface for well-posedness. Typically the interface condition requires the solution to be discontinuous at the interface. Such problems can model for example wave propagation in materials where the wave speed changes abruptly at a material interface.

The first main result is an extension of the family of high order CutFEM with ghost penalty stabilization in [10] to problems with stationary interfaces. In the new method the solution is built from separate solutions on the two sides of the interface, and coupled through the interface condition, which is imposed weakly through penalties in the weak form. We show how to choose these penalties such that both conservation and stability is ensured, independently of how the interface cuts the elements. Numerical results demonstrate that conservation can indeed be lost with other choices. We note that our proposed CutFEM scheme is locally conservative in elements away from the interface and in the patch of elements involving the interface. The stability result is based on a semi-discrete energy analysis, which generalises the stability result in [19], where a high order finite difference methodology with a grid aligned with the interface is analyzed. We apply our method to the scalar advection equation in one and two space dimensions, and to an acoustic system in one space dimension, but the proposed method can be applied to other hyperbolic systems with similar structure.

A second result is a space-time CutFEM for the case of a moving interface. We use a framework similar to that proposed in [9, 15, 32], but here we use discontinuous elements both in space and time. The interface condition is imposed weakly as above, with the same restriction on penalties imposed by conservation. Our analysis as well as our numerical results show that the choice of weak form is important for achieving conservation in the discrete setting. Since the space-time formulation corresponds to an implicit time discretization, the method is computationally more demanding than the proposed method for the case of a stationary interface. However, we also demonstrate a strategy where the space-time CutFEM is restricted to the interface region, and coupled to a standard DG method with explicit time discretization in other parts of the domain.

The paper is organized as follows. In Sect. 2, the model problem is given. In Sect. 3, we consider a stationary interface, propose a discontinuous cut finite element discretization in space and perform a stability analysis, and an a priori error estimate is given for the scalar problems. Numerical examples show that the proposed method has the expected convergence rate, is conservative, and allows for similar time steps as a corresponding standard DG method. In Sect. 4 we consider a moving interface and propose a space-time CutFEM. The stability of the semi-discrete scheme is analyzed and we present some examples to show that the method can simulate the moving interface problem with expected accuracy and with conservation. In Sect. 4.6, we formulate a locally implicit CutFEM. In Sect. 5, we extend our scheme to the advection equation in two space dimensions with a material interface. Finally, in Sect. 6 we conclude.

2 Model Problem

Let \(x_\Gamma (t)\) be an interface that separates the domain \(\Omega =[x_L, x_R]\) into two subdomains \(\Omega _1=[x_L,x_\Gamma (t)]\) and \(\Omega _2=[x_\Gamma (t),x_R]\). Consider the hyperbolic conservation law

$$\begin{aligned}&u_{t}+F(u)_{x}=0,&\quad {x \in \Omega _1\cup \Omega _2, t>0,} \end{aligned}$$
(2.1)
$$\begin{aligned}&{u(x,0)=f(x),}&\quad {x \in \Omega _1\cup \Omega _2,} \end{aligned}$$
(2.2)
$$\begin{aligned}&{[F(u)]_\Gamma -x_\Gamma '(t)[u]_\Gamma =0,}&\quad { t \ge 0,} \end{aligned}$$
(2.3)

with suitable boundary conditions at \(x_L\) and \(x_R\). Here the unknown conservative variable is

$$\begin{aligned} u=\left\{ \begin{array}{ll} u_1, &{} x \in \Omega _1(t), \\ u_2, &{} x\in \Omega _2(t), \end{array} \right. \end{aligned}$$
(2.4)

which may be discontinuous across the interface \(x_\Gamma (t)\) with jump

$$\begin{aligned}{}[u]_\Gamma =u_2(x_\Gamma ,t)-u_1(x_\Gamma ,t). \end{aligned}$$
(2.5)

We assume that \(u_i\), \(i=1,2\) are continuous functions with sufficiently many continuous derivatives, and that a discontinuity in u may exist only at the interface. The flux function is

$$\begin{aligned} F(u)=\left\{ \begin{array}{ll} F_1(u_1)\equiv A_1 u_1, &{} x \in \Omega _1(t), \\ F_2(u_2)\equiv A_2 u_2, &{} x\in \Omega _2(t), \end{array}\right. \end{aligned}$$
(2.6)

with \(A_1\) and \(A_2\) being either constant scalars or matrices. We will only consider problems where the interface condition (2.3) ensures that the problem is well-posed. For the scalar case this means that \(A_1-x_\Gamma '(t)\) and \(A_2-x_\Gamma '(t)\) have the same sign. For systems the number of positive and negative eigenvalues of \(A_i-x_\Gamma '(t)I\), \(i=1,2\) with I being the identity matrix, must be the same on both sides of the interface, and the eigenstructure of the matrices must be such that the interface condition determines entering characteristic variables in terms of exiting characteristic variables.

Also, note that

$$\begin{aligned} \frac{d}{dt} \int _{x_L}^{x_R} u dx&=\frac{d}{dt}\int _{x_L}^{x_\Gamma (t)} u_1 dx+\frac{d}{d t}\int _{x_\Gamma (t)}^{x_R} u_2 dx\nonumber \\&=\int _{x_L}^{x_\Gamma (t)}\partial _t u_1 d x+\int _{x_\Gamma (t)}^{x_R}\partial _{t} u_2 d x+u_{1}(x_\Gamma ,t) x_\Gamma ^{\prime }(t)-u_2(x_\Gamma ,t)x_\Gamma ^{\prime }(t)\nonumber \\&=-\int _{x_L}^{x_\Gamma (t)} (F_1(u_1))_x d x-\int ^{x_R}_{x_\Gamma (t)}(F_2(u_2))_xd x- x_\Gamma ^{\prime }(t)[u]_\Gamma \nonumber \\&=F_1(u_{1}(x_L,t))-F_1(u_1(x_\Gamma ,t))+F_2(u_2(x_\Gamma ,t))-F_2(u_2(x_R,t))-x_\Gamma ^{\prime }(t)[u]_\Gamma . \end{aligned}$$

When the interface condition (2.3) is satisfied, i.e.

$$\begin{aligned} F_2(u_2(x_\Gamma ,t))-F_1(u_1(x_\Gamma ,t))-x_\Gamma ^{\prime }(u_2(x_\Gamma ,t)-u_1(x_\Gamma ,t))=0, \end{aligned}$$

we have

$$\begin{aligned} \frac{d}{dt}\int _{x_L}^{x_R} u(x,t) dx=F_1(u_1(x_L,t))-F_2(u_2(x_R,t)). \end{aligned}$$
(2.7)

Thus, condition (2.3) ensures conservation of u. In this paper, we will consider both a stationary interface, \(x_\Gamma '=0\), and a moving interface.

Before we propose a DG scheme for the problem (2.1)–(2.3) we introduce some notations. For square integrable scalar real valued functions on a given domain K, the standard notation is used for the inner product and the \(L^2\)-norm, namely,

$$\begin{aligned} (v,w)_{K}:=\int _{K} vw \ dx, \quad \Vert v\Vert _K:=\sqrt{(v,v)_{K}}, \quad \forall v, w\in L^2(K), \end{aligned}$$
(2.8)

and for square integrable vector real valued functions vw with m components, each component in \(L^2\), we will use the same notation, but now vw means the standard dot product, i.e.

$$\begin{aligned} (v,w)_{K}:=\int _K v^Twdx, \quad \Vert v\Vert _K:=\sqrt{(v,v)_{K}}, \quad \forall v, w\in {[L^2(K)]}^{m}. \end{aligned}$$
(2.9)

Furthermore

$$\begin{aligned} (v,w)_{\Omega _1 \cup \Omega _2}:= \sum _{i=1}^2 (v,w)_{\Omega _i}. \end{aligned}$$
(2.10)

3 Stationary Interface

Consider (2.1)–(2.3) in the case of a stationary interface, that is with \(x_\Gamma '=0\) and interface condition \([F(u)]_\Gamma =0\). In the following we define the mesh, the space, and the weak formulation for a cut finite element method based on the DG framework.

3.1 Mesh and Spaces

Let \({\mathcal {T}}_h\) be a quasi-uniform partition of the domain \(\Omega \) generated independently of the position of the interface and let \({\mathcal {E}}_h\) denote the set containing the edges in this mesh. The mesh consists of intervals \(I_{j}=[x_{j-\frac{1}{2}},x_{j+\frac{1}{2}}], j=1,\ldots ,N\) with length \(\Delta x_j=x_{j+\frac{1}{2}}-x_{j-\frac{1}{2}}\), and \(x_{L}=x_{\frac{1}{2}}<x_{\frac{3}{2}}<\cdots<x_\Gamma<\cdots <x_{N+\frac{1}{2}}=x_{R}\). The mesh size is \(h=\max _{1\le j\le N} \Delta x_j\). See Fig. 1 for an illustration.

Fig. 1
figure 1

A uniform partition of \(\Omega \) with mesh size \(h=(x_R-x_L)/N\). In this case, the interface splits the cell \(I_{j}\) into two cells of length \(\alpha _1 h\) and \(\alpha _2h\)

Define the following active meshes

$$\begin{aligned} {\mathcal {T}}_{h,i}=\left\{ I_j \in {\mathcal {T}}_h: I_j \cap \Omega _{i} \ne \emptyset \right\} , \quad i=1,2, \end{aligned}$$
(3.1)

and the set of edges

$$\begin{aligned} {\mathcal {E}}_{h,i}=\{e\in {\mathcal {E}}_h: e\cap \Omega _i\ne \emptyset \}. \end{aligned}$$
(3.2)

Denote by \({\mathcal {F}}_{h,i}\) the interior edge in \({\mathcal {E}}_{h,i}\) that belongs to a cut element, i.e.,

$$\begin{aligned} {\mathcal {F}}_{h,i}=\{e=I_j\cap I_k: I_j,I_k \in {\mathcal {T}}_{h,i} \text { and } x_\Gamma \in I_j \text { or } I_k, \, j\ne k\}. \end{aligned}$$
(3.3)

Define the piecewise polynomial space

$$\begin{aligned} {\widetilde{{\mathcal {V}}_h^r}}=\{v : {v}|_{I_j} \in P^r(I_j), \,\forall I_j \in {\mathcal {T}}_h\}, \end{aligned}$$
(3.4)

where \(P^{r}(I_j)\) is the space of polynomials with degree at most r on \(I_j\). We note that if \(v\in {\widetilde{{\mathcal {V}}_h^r}}\) is a vector, it means each of its component belongs to \(P^r(I_j)\). Define the active finite element spaces

$$\begin{aligned} {\mathcal {V}}_{h,i}^r={{\widetilde{{\mathcal {V}}_h^r}}|_{{\mathcal {T}}_{h,i}}}, \, i=1,2, \end{aligned}$$
(3.5)

and let \({\mathcal {V}}_h^r={\mathcal {V}}_{h,1}^r \times {\mathcal {V}}_{h,2}^r\). Hence, with \(v\in {\mathcal {V}}_h^r\) we mean \(v=(v_1,v_2)\) with \(v_i \in {\mathcal {V}}_{h,i}^r\).

For any \(v(\cdot ,t) \in {\mathcal {V}}_{h,i}^r\) at a fixed time \(t\in [0,T]\), let \(v^+ \) and \(v^- \) denote the limit values of v at x from right and left, i.e.,

$$\begin{aligned} v^-(x,t)=\lim \limits _{\epsilon \rightarrow 0^+}v(x-\epsilon ,t), \quad v^+(x,t)=\lim \limits _{\epsilon \rightarrow 0^+}v(x+\epsilon ,t). \end{aligned}$$
(3.6)

Define the average and the jump of the function v at an edge \(e\in {\mathcal {E}}_{h,i}\) by

$$\begin{aligned} \{v\}_e=\frac{1}{2}(v^++v^-), \quad [v]_e=v^+-v^-. \end{aligned}$$
(3.7)

On the interface the average and jump of \(v(\cdot ,t)=(v_1(\cdot ,t),v_2(\cdot ,t))\in {\mathcal {V}}_h^r\) are defined by

$$\begin{aligned} \{v\}_\Gamma =\frac{1}{2}(v_1(x_\Gamma ,t)+v_2(x_\Gamma ,t)),\quad [v]_\Gamma =v_2(x_\Gamma ,t)-v_1(x_\Gamma ,t). \end{aligned}$$
(3.8)

3.2 Weak Formulation

We now state a semi-discrete weak formulation. For \(t\in [0,T]\), find \(u_h(\cdot ,t)\) \(\in {\mathcal {V}}_h^r\) such that

$$\begin{aligned}&\left( (u_h(\cdot ,t))_t,v_h \right) _{\Omega _1\cup \Omega _2}+\gamma _MJ_1((u_h(\cdot ,t))_t,v_h)+A_h(u_h(\cdot ,t),v_h)=0, \, t>0, \end{aligned}$$
(3.9)
$$\begin{aligned}&(u_h(\cdot ,0),v_h)_{\Omega _1\cup \Omega _2}+\gamma _MJ_1(u_h(\cdot ,0),v_h)=(f(x),v_h)_{\Omega _1\cup \Omega _2}, \end{aligned}$$
(3.10)

for all \(v_h\in {\mathcal {V}}_h^r\). Here

$$\begin{aligned} A_h(u_h,v_h)&=a_h(u_h,v_h)+\gamma _AJ_0(u_h,v_h), \end{aligned}$$
(3.11)

with

$$\begin{aligned} a_h(u_h,v_h)&=- (F(u_h),(v_h)_x)_{\Omega _1\cup \Omega _2} -\sum _{i=1}^{2}\sum _{e\in {\mathcal {E}}_{h,i}} {\widehat{F}}_e(u_h)[v_h]_e \nonumber \\&\quad -\left( [F(u_h)v_h]_\Gamma +[F(u_h)]_\Gamma [\lambda v_h]_\Gamma \right) , \end{aligned}$$
(3.12)

and

$$\begin{aligned} J_s(u_h, v_h)=\sum _{i=1}^2\sum _{e \in {\mathcal {F}}_{h,i}} \sum _{k=0}^{r} \omega _kh^{2 k+s}\left[ \partial ^ku_{h,i}\right] _e\left[ \partial ^{k} v_{h,i}\right] _{e}. \end{aligned}$$
(3.13)

The stabilization terms \(J_s(u,v),s=0,1\), are added in order to have a stable scheme independently of how the interface cuts the background mesh. Otherwise, the mass matrix may be nearly singular, which can cause very severe time step restriction or ill-conditioning. The parameters in front of the stabilization terms, \(\gamma _M,\gamma _A\) and \(\omega _k\) are positive constants. The choice is not unique and we choose \(\omega _k=\frac{1}{(k!)^2(2k+1)}\) as in [27]. The penalty parameters at the interface in (3.12) is

$$\begin{aligned} \lambda =\left\{ \begin{array}{ll} \lambda _1, &{} x \in \Omega _1(t), \\ \lambda _2, &{} x\in \Omega _2(t). \end{array} \right. \end{aligned}$$
(3.14)

The choice of values will be discussed below. We note that interfaces between elements and boundary edges are handled with the usual DG methodology, where we choose a single-valued function \({\widehat{F}}_e\) to approximate F(u) on edge e. In this paper, the flux \({\widehat{F}}_e\) is chosen as

$$\begin{aligned} {\widehat{F}}_e(u_h)=\{F(u_h)\}_e-\frac{\lambda _e}{2}[u_h]_e, \quad e\in {\mathcal {E}}_{h,i}. \end{aligned}$$
(3.15)

Here, \(\{F(u_h)\}_e=\frac{1}{2}\left( F(u_h^-)+F(u_h^+)\right) \), \([u_h]_e=u_h^+-u_h^-\), and \(\lambda _e\) is an estimate of the largest absolute eigenvalue of the Jacobian \(\frac{\partial F(u_h)}{\partial u_h}\) in the neighbourhood of edge e. This flux is known as the Lax-Friedrichs flux. In this paper we only consider the Lax-Friedrichs flux, but other monotone fluxes are also possible. At the boundaries of the domain, \(x_L\) and \(x_R\), we define the average and jump of a test functions \(v_h\) as

$$\begin{aligned} \{v_h\}_L=v_h^+, \, \{v_h\}_R=v_h^-, \quad [v_h]_L=v_h^+,\, [v_h]_R=-v_h^-. \end{aligned}$$
(3.16)

For scalar problems, we use the inflow boundary condition \(u(x,t)=g(t), x=x_L\) or \(x_R\). To specify the corresponding values \(u_h\) on \(x_L\) and \(x_R\), we set

$$\begin{aligned} u_h^-(x_L,\cdot )=\left\{ \begin{array}{ll} g_{h}(\cdot ), &{} \text { if } a_i>0, \\ u_h^+(x_L,\cdot ), &{} \text { if } a_i<0, \end{array} \right. \quad u_h^+(x_R,\cdot )=\left\{ \begin{array}{ll} g_{h}(\cdot ), &{} \text { if } a_i<0, \\ u_h^-(x_R,\cdot ), &{} \text { if } a_i>0. \end{array} \right. \end{aligned}$$
(3.17)

Here \(g_h\) is the approximation of the given boundary data g at the inflow boundary. For the approximation of boundary conditions in systems see [5].

To derive the weak formulation above we multiply Eq. (2.1) by a test function \(v\in {\mathcal {V}}_h^r\), integrate by parts, and enforce the interface condition (2.3). Since \(v \in {\mathcal {V}}_h^r\) is discontinuous across interior edges, integration by parts results in jump terms \([F(u)v]_e\) across interior edges. Since \([u]_e=0\) these terms can be rewritten as

$$\begin{aligned}{}[F(u)v]_e=\{F(u)\}_e[v]_e-\frac{\lambda _e}{2}[u]_e[v]_e={\widehat{F}}_e(u)[v]_e. \end{aligned}$$
(3.18)

Since the stabilization terms \(J_s(u,v)\) vanish when u is a sufficiently smooth exact solution, the proposed formulation is consistent.

Taking test function \(v_h=1\) in the scheme (3.9), we have

$$\begin{aligned} \int _\Omega (u_h)_tdt&={\widehat{F}}_L(u_h(x_L,t))-{\widehat{F}}_R(u_h(x_R,t)) +\left( \lambda _2-\lambda _1+1\right) [F(u_h)]_\Gamma . \end{aligned}$$
(3.19)

Clearly, the proposed scheme is conservative only if

$$\begin{aligned} \lambda _2-\lambda _1+1=0. \end{aligned}$$
(3.20)

If this condition is satisfied it follows that

$$\begin{aligned} \frac{d}{dt}\int _\Omega u_h dx={\widehat{F}}_L-{\widehat{F}}_R. \end{aligned}$$
(3.21)

We note that our scheme is locally conservative on the elements that along with their neighbors do not involve the interface, like \(\{I_j\}_{j=1}^{J-2}\) and \(\{I_{j}\}_{j=J+2}^{N}\) in Fig. 2. The method is also locally conservative in subintervals containing elements which need to be stabilized, like the subinterval \(K_1=(I_{J-1}\cup I_{J})\cap \Omega _1\) and \(K_2=(I_{J}\cup I_{J+1})\cap \Omega _2\) in Fig. 2. For the scheme to be stable the penalty parameters need to satisfy additional requirements. See Theorem 1 for the scalar problem and Theorem 3 for the acoustic system, for choices that yield a conservative and energy stable interface treatment.

Fig. 2
figure 2

Illustration of intervals where the proposed scheme is locally conservative

3.3 Stability Analysis

Here we will use the energy method to investigate how requiring stability of the proposed semi-discrete scheme will restrict the choice of the penalty parameters \(\lambda _1\) and \(\lambda _2\) beyond (3.20).

3.3.1 The Scalar Problem

We consider the linear scalar problem, i.e.

$$\begin{aligned} F(u)=au=\left\{ \begin{array}{ll} F_1(u)\equiv a_1u_1, &{} x \in \Omega _1, \\ F_2(u)\equiv a_2u_2, &{} x \in \Omega _2, \end{array}\right. \end{aligned}$$
(3.22)

where \(a_1,a_2\) are non-zero constants with the same sign. In the proposed scheme we use \(\lambda _e=|a_i|\) in Eq. (3.15).

Let \(v_h=(u_{h,1},0)\) and \(v_h=(0, u_{h,2})\) in (3.9), integrate \((a_iu_{h,i},(u_{h,i})_x)_{\Omega _i}\), and take into account discontinuities of \(u_{h,i}\) across the edges to get

$$\begin{aligned}&\frac{1}{2}\frac{d}{dt} \left( \int _{\Omega _1} |u_{h,1}|^2 dx + \gamma _M J_1(u_{h,1},u_{h,1}) \right) +\sum _{e\in {\mathcal {E}}_{h,1}}\left( \frac{a_1}{2} [u_{h,1}^2]_e -\widehat{F_{e}}(u_{h,1})[u_{h,1}]_e\right) \nonumber \\&\quad +(\frac{a_1}{2}-a_1\lambda _1)|u_{h,1}(x_\Gamma ,t)|^2+\lambda _1a_2u_{h,2}(x_\Gamma ,t)u_{h,1}(x_\Gamma ,t) + \gamma _A J_0(u_{h,1},u_{h,1})=0, \nonumber \\&\frac{1}{2}\frac{d}{dt} \left( \int _{\Omega _2} |u_{h,2}|^2 dx + \gamma _M J_1(u_{h,1},u_{h,1}) \right) +\sum _{e\in {\mathcal {E}}_{h,2}}\left( \frac{a_2}{2}[u_{h,2}^2]_e-\widehat{F_{e}}(u_{h,2}) [u_{h,2}]_e\right) \nonumber \\&\quad -(a_2\lambda _2+\frac{a_2}{2})|u_{h,2}(x_\Gamma ,t)|^2+ \lambda _2 a_1u_{h,2}(x_\Gamma ,t)u_{h,1}(x_\Gamma ,t)+ \gamma _A J_0(u_{h,2},u_{h,2})=0. \end{aligned}$$
(3.23)

By \(\frac{a}{2}[u_{h}^2]_e=a\{ u_h \}_e[u_{h}]_e\) and the definition of the flux, Eq. (3.15), we have

$$\begin{aligned} \frac{a_i}{2}[u_{h,i}^2]_e-\widehat{F_{e}}(u_{h,i})[u_{h,i}]_e=\frac{\lambda _e}{2} [u_{h,i}]^2_e,\quad i=1,2. \end{aligned}$$
(3.24)

Introducing a weighted energy \(E_\eta \), where \(\eta \) is a positive constant,

$$\begin{aligned} E_\eta (t)&= \frac{1}{2} \left( \int _{\Omega _1} |u_{h,1}|^2 dx + \gamma _M J_1(u_{h,1},u_{h,1}) \right) \nonumber \\&\quad + \frac{\eta }{2} \left( \int _{\Omega _2} |u_{h,2}|^2 dx + \gamma _M J_1(u_{h,2},u_{h,2}) \right) , \end{aligned}$$
(3.25)

we have from (3.23), (3.24) with \(\lambda _e=|a_i|\) for \(e\in {\mathcal {E}}_{h,i}\) that

$$\begin{aligned} \frac{d}{dt} E_\eta&=-{\mathbf {u}}_h^T S {\mathbf {u}}_h -\sum _{e\in {\mathcal {E}}_{h,1}}\frac{|a_1|}{2}[u_{h,1}]_e^2-\sum _{e\in {\mathcal {E}}_{h,2}}\frac{|a_2|\eta }{2}[u_{h,2}]_e^2 \nonumber \\&\quad - \gamma _A J_0(u_{h,1},u_{h,1})-\eta \gamma _A J_0(u_{h,2},u_{h,2}). \end{aligned}$$
(3.26)

Here

$$\begin{aligned} S=\left( \begin{array}{cc} (\frac{1}{2}-\lambda _1)a_1 &{} \frac{a_2\lambda _1+ a_1\eta \lambda _2}{2} \\ \frac{a_2\lambda _1+a_1\eta \lambda _2}{2} &{} -(\lambda _2+\frac{1}{2})\eta a_2 \end{array} \right) ,\quad {\mathbf {u}}_h= \left( \begin{array}{c}u_{h,1}(x_\Gamma ,t)\\ u_{h,2}(x_\Gamma ,t)\end{array}\right) . \end{aligned}$$
(3.27)

If S is positive semi-definite, then the energy is non-increasing with time. In “Appendix A”, Lemma 1 states conditions for S to be positive semi-definite. We summarize the results for scalar problems in the following theorem.

Theorem 1

Consider the discontinuous cut finite element method (3.9) for the scalar problem (2.1)–(2.3) with F(u) as in (3.22) with \(x_\Gamma '(t)=0\) and stabilization parameters \(\gamma _A\ge 0, \gamma _M\ge 0\). For penalty parameters \(\lambda _1\) and \(\lambda _2\), that satisfy (3.20) and

$$\begin{aligned} \left\{ \begin{array}{ll} {\lambda _1\le \frac{1}{2},\lambda _2\le -\frac{1}{2},}&{}{\text {if } a_1>0,a_2>0,}\\ {\lambda _1\ge \frac{1}{2},\lambda _2\ge -\frac{1}{2},}&{}{\text {if } a_1<0,a_2<0,}\\ \end{array}\right. \end{aligned}$$
(3.28)

the method is conservative and there exists a positive \(\eta \) such that the energy defined in (3.25) does not grow with time.

Remark 1

The stability results in Theorem 1 are derived assuming a conservative interface treatment with \(\lambda _1\) and \(\lambda _2\) satisfying (3.20). Without the conservation condition (3.20), less restrictive stability results are possible. See Lemma 2 in Appendix A. In the right panel of Figs. 4 and 16, we show that when the penalty parameters satisfy a stability condition but don’t satisfy the conservation condition (3.20), the scheme produces large conservation errors.

Based on the stability result we can derive an a priori estimate for the scalar problems, if it has a sufficiently smooth solution.

Theorem 2

Let \(u(x,t)=u_i(x,t)\) for \(x \in \Omega _i\), be the solution to problem (2.1)–(2.3) with F(u) as in (3.22) and \(x_\Gamma '(t)=0\). Assume \(u_i\) is sufficiently smooth: \(u_i, \,(u_i)_{t} \in L^{\infty }\left( [0,T] ; H^{r+1}({\Omega _i}) \right) \). Let \(u_h=(u_{h,1}, u_{h,2}) \) with \(u_{h,i}(\cdot ,t)\in {\mathcal {V}}_{h,i}^r\) be the solution to the discontinuous cut finite element scheme (3.9). Then the following a priori error estimate hold

$$\begin{aligned} ||u_1(\cdot ,t)-u_{h,1}(\cdot ,t)||^2_{\Omega _1}+||u_2(\cdot ,t)-u_{h,2}(\cdot ,t)||^2_{\Omega _2}\le C h^{2r},\,t\in [0,T], \end{aligned}$$

where C is a constant which is independent of the mesh parameter h and how the interface cuts the mesh.

The proof of this theorem is given in “Appendix B”.

3.3.2 The Acoustic System

We consider the acoustic system [24]

$$\begin{aligned}&\rho u_{t}+p_{x} =0,&\quad {x \in \Omega _1\cup \Omega _2, t>0,} \nonumber \\&p_{t}+\rho c^{2} u_{x}=0,&\quad {x \in \Omega _1\cup \Omega _2, t>0,} \\&[u]_\Gamma =0, \ [p]_\Gamma =0,&\quad {x=x_\Gamma (t), t\ge 0,} \nonumber \end{aligned}$$
(3.29)

with a stationary interface at \(x=x_\Gamma \), i.e., \(x'_\Gamma (t)=0\). Here, u(xt) is the velocity, p(xt) is the pressure, \(\rho (x)\) is the density, and c(x) is the sound speed. The density and the sound speed are piecewise constant

$$\begin{aligned} (\rho , c)=\left\{ \begin{array}{ll} \left( \rho _{1}, c_{1}\right) &{} \text{ if } x \in \Omega _1, \\ \left( \rho _2, c_2\right) &{} \text{ if } x \in \Omega _2. \end{array}\right. \end{aligned}$$

By introducing \(q=\frac{p}{\rho c^2}\) and \(m=\rho u\), denoting strain and momentum, we can write problem (3.29) in the conservative form as in Eqs. (2.1)–(2.3),

$$\begin{aligned}&U_{t}+F(U)_{x}=0,&\quad {x \in \Omega _1\cup \Omega _2, t>0,} \end{aligned}$$
(3.30)
$$\begin{aligned}&{U(x,0)=f(x),}&\quad {x \in \Omega _1\cup \Omega _2,} \end{aligned}$$
(3.31)
$$\begin{aligned}&[F(U)]_\Gamma =0,&\quad {x=x_\Gamma , t\ge 0,} \end{aligned}$$
(3.32)

with

$$\begin{aligned} F(U)=\left\{ \begin{array}{ll} A_1U_1, &{} x \in \Omega _1, \\ A_2U_2, &{} x \in \Omega _2, \end{array}\right. \end{aligned}$$
(3.33)

where

$$\begin{aligned} U_i=\left( \begin{array}{l} m_i \\ q_i \end{array}\right) \text { and } A_i=\left( \begin{array}{cc} 0 &{}\rho _i c_i^{2} \\ \frac{1}{\rho _i} &{} 0 \end{array}\right) , \ i=1,2. \end{aligned}$$
(3.34)

The components of U, m and q, are the conserved quantities, and are referred to as the conservative variables, while u and p are called the primitive variables.

We begin with showing an energy estimate in the continuous setting for the physically motivated energy

$$\begin{aligned} E(t)=\frac{1}{2}\int _{\Omega _1\cup \Omega _2} U^TBU dx,\quad B={\left\{ \begin{array}{ll}B_1, &{} x \in \Omega _1, \\ B_2, &{} x \in \Omega _2, \end{array}\right. },\quad B_i=\left( \begin{array}{cc} \frac{1}{\rho _i}&{}0 \\ 0&{}\rho _i c_i^2 \end{array}\right) ,\, i=1,2. \end{aligned}$$
(3.35)

Since B is symmetric

$$\begin{aligned} \frac{d}{dt}E=\int _{\Omega _1}U^T_1B_1\frac{dU_1}{dt}dx+\int _{\Omega _2}U^T_2B_2\frac{dU_2}{dt}dx. \end{aligned}$$
(3.36)

Introduce \(U_t=-(AU)_x\) and integrate by parts to get

$$\begin{aligned} \frac{d}{dt}E&=-\frac{1}{2}\int _{\Omega _1\cup \Omega _2} U^T (A^TB^T-BA)U_x dx +\frac{1}{2}\left( U_1^TA_1^TB_1^TU_1|_{x_L}^{x_\Gamma }+U_2^TA_2^TB_2^TU_2|_{x_\Gamma }^{x_R}\right) \nonumber \\&\equiv -ET+IT. \end{aligned}$$
(3.37)

Note that \(B_iA_i\) is symmetric and therefore the bulk terms vanish, and only terms at the physical boundary, collected in ET, and terms at the interface, collected in IT, remain. We can write the contributions at the interface as

$$\begin{aligned} IT=\frac{1}{2}\left( U_{1}^TA_1^TB_1^TU_{1}-U_{2}^TA_2^TB_2^TU_{2}\right) |_\Gamma =\frac{1}{2}\left( U_{1}^T\left( (A_2^TB_1)^T-A_1^TB_2\right) U_{2}\right) |_\Gamma . \end{aligned}$$

The last equality follows using again that \(B_iA_i\) is symmetric and the interface condition (3.32), i.e., \(U_{1}^TA_1^T=U_{2}^TA_2^T\). Note that

$$\begin{aligned} A_2^TB_1=\left( \begin{array}{cc} 0&{} \frac{\rho _1c_1^2}{\rho _2} \\ \frac{\rho _2 c_2^2}{\rho _1}&{}0 \end{array}\right) ,\quad A_1^TB_2=\left( \begin{array}{cc} 0&{} \frac{\rho _2c_2^2}{\rho _1} \\ \frac{\rho _1 c_1^2}{\rho _2}&{}0 \end{array}\right) . \end{aligned}$$

Thus,

$$\begin{aligned} (A_2^TB_1)^T=A_1^TB_2, \end{aligned}$$
(3.38)

and therefore the interface term vanishes, \(IT=0\). We conclude that the interface term gives no contribution to energy growth or decay.

Next we study the stability of the proposed discontinuous CutFEM (3.9) for the system (3.30)–(3.34). Guided by the energy result for the continuous system we define

$$\begin{aligned} E_h(t)=\frac{1}{2}\left( \int _{\Omega _1\cup \Omega _2} U_h^TBU_h dx + \gamma _MJ_1(U_{h},BU_h)\right) , \end{aligned}$$
(3.39)

and take \(v_h=BU_h\) in (3.9) and get

$$\begin{aligned} \frac{d}{dt}E_h&= ((U_{h})_t,BU_h)_{\Omega _1\cup \Omega _2} + \gamma _MJ_1((U_{h})_t,BU_h) \nonumber \\&=\int _{\Omega _1\cup \Omega _2}U_h^T B A (U_{h})_x \ dx +\sum _{i=1}^{2}\sum _{e\in {\mathcal {E}}_{h,i}} {\widehat{F}}_e(U_h)^T[BU_h]_e \nonumber \\&\quad +([F(U_h)^TBU_h]_\Gamma +[F(U_h)^T]_\Gamma [\lambda BU_h]_\Gamma ) -\gamma _AJ_0(U_h,BU_h). \end{aligned}$$
(3.40)

The bulk term can be integrated by parts and therefore only interface and edge terms remain in the right hand side of (3.40). Contribution from element edges when the Lax-Friedrichs flux is used are well-known, and therefore we only analyze the terms from the interface at \(x_\Gamma \),

$$\begin{aligned} IT&= -(F_1({\mathbf {U}}_{h,1})+\lambda _1[F({\mathbf {U}}_h)]_\Gamma )^TB_1{\mathbf {U}}_{h,1} +(F_2({\mathbf {U}}_{h,2})+\lambda _2[F({\mathbf {U}}_h)]_\Gamma )^TB_2{\mathbf {U}}_{h,2} \nonumber \\&\quad +\frac{1}{2}{\mathbf {U}}_{h,1}^TA_1^TB_1{\mathbf {U}}_{h,1}-\frac{1}{2} {\mathbf {U}}_{h,2}^TA_2^TB_2{\mathbf {U}}_{h,2} \nonumber \\&=-(\frac{1}{2}-\lambda _1){\mathbf {U}}_{h,1}^TA_1^TB_1{\mathbf {U}}_{h,1}+ (\frac{1}{2}+\lambda _2){\mathbf {U}}_{h,2}^TA_2^TB_2{\mathbf {U}}_{h,2} \nonumber \\&\quad -{\mathbf {U}}_{h,2}^T(\lambda _1A_2^TB_1+\lambda _2(A_1^TB_2)^T){\mathbf {U}}_{h,1}. \end{aligned}$$
(3.41)

Here \({\mathbf {U}}_{h,1},{\mathbf {U}}_{h,2}\) denote the numerical solution values at the interface \(x_\Gamma \). We can write

$$\begin{aligned} IT=- \left( \begin{array}{c} {\mathbf {U}}_{h,1} \\ {\mathbf {U}}_{h,2} \end{array}\right) ^T {\mathbf {S}}\left( \begin{array}{c} {\mathbf {U}}_{h,1}\\ {\mathbf {U}}_{h,2} \end{array}\right) , \text { with } {\mathbf {S}}=\left( \begin{array}{cc} (\frac{1}{2}-\lambda _1)A_1^TB_1&{}\frac{\lambda _1+\lambda _2}{2}A_1^TB_2\\ \frac{\lambda _1+\lambda _2}{2}A_2^TB_1&{}-(\frac{1}{2}+\lambda _2)A_2^TB_2 \end{array}\right) . \end{aligned}$$

Note that by (3.38) the matrix \({\mathbf {S}}\) is symmetric. To ensure that the interface terms do not cause energy growth, \({\mathbf {S}}\) needs to be positive semi-definite. The only possible choice for the penalty parameters that also satisfies the conservation condition (3.20) is

$$\begin{aligned} \lambda _1=\frac{1}{2},\quad \lambda _2=-\frac{1}{2}, \end{aligned}$$

which implies \({\mathbf {S}}=0\) and correspondingly \(IT=0\). This proves the following theorem.

Theorem 3

Consider the semi-discrete discontinuous cut finite element method (3.9) for the acoustic system (3.30) in conservative form, with penalty parameters

$$\begin{aligned} \lambda _1=\frac{1}{2},\quad \lambda _2=-\frac{1}{2}. \end{aligned}$$

The interface treatment is conservative, and does not contribute to temporal growth or decay of the energy (3.39).

3.4 Numerical Results

We use the proposed discontinuous CutFEM (3.9) to solve the scalar advection Eq. (3.22) and the acoustic system (3.30). The background mesh on the domain \(\Omega \) is uniform with mesh size \(h=|\Omega |/N\), where N is the number of elements. In the numerical simulations, we use \(\gamma _M=0.25\) and \(\gamma _A=0.75\).

To discretize in time we use the explicit third order TVD Runge–Kutta method [11] when the polynomial degree in space \(r\le 2\) (see (3.4)), i.e.,

$$\begin{aligned} u^{n,1}&=u^{n}+\Delta t L\left( u^{n},g_h^n,t^{n}\right) , \end{aligned}$$
(3.42)
$$\begin{aligned} u^{n,2}&=\frac{3}{4} u^{n}+\frac{1}{4} u^{n,1}+\frac{1}{4} \Delta t L\left( u^{n,1},g_h^{n,1},t^{n}+\Delta t \right) , \end{aligned}$$
(3.43)
$$\begin{aligned} u^{n+1}&=\frac{1}{3} u^{n}+\frac{2}{3} u^{n,2}+\frac{2}{3} \Delta t L\left( u^{n,2}, g_h^{n,2}, t^{n}+\frac{1}{2} \Delta t \right) . \end{aligned}$$
(3.44)

Here \(u_t=L(u,g,t)\) is the semi-discrete problem, \(\Delta t =t^{n+1}-t^n\) is the time step and \(g_h^n, g_h^{n,1},g_h^{n,2}\) denote the approximations of the boundary condition g(t) at different time stages. The inflow information g is imposed via Taylor expansion of g(t) to avoid order reduction with \(g_h^n=g(t^n)\), \(g_h^{n,1}=g(t^n)+\Delta t g'(t^n)\) and \(g_h^{n,2}=g(t^n)+\frac{\Delta t }{2} g'(t^n) +\frac{(\Delta t )^2}{4}g''(t^n)\), for details see [33]. For the approximation of boundary conditions in systems see [5]. When \(r=3\) we instead use the fourth order five stages Runge–Kutta method [11]. The time step is taken to be \(\Delta t =\frac{Ch}{\max _\Omega \{|F'(u_h)|\}}\) with given Courant number \(C=0.3,0.2,0.1\), for \(r=1,2,3\), respectively. Here, \(\max _\Omega \{|F'(u_h)|\}\) represents the largest absolute value of the eigenvalues of the Jacobian \( \frac{\partial F( u_h)}{\partial u_h}\) on the domain \(\Omega \). Next, we will demonstrate the accuracy and conservation of the proposed method by solving test problems. We will measure the error in the following norms

$$\begin{aligned} ||u-u_h||^p_{\Omega }&=\sum _{i=1}^2 ||u_i-u_{h,i}||^p_{\Omega _i}, \quad p=1,2,\\ ||u-u_h||_{L^\infty (\Omega _1\cup \Omega _2)}&= \max \{\max _{x\in \Omega _1}\{|u_1(x,t)-u_h(x,t)|\},\max _{x\in \Omega _2}\{|u_2(x,t)-u_h(x,t)|\}\}. \end{aligned}$$

Here \(||\cdot ||^p_{\Omega _i}=\int _{\Omega _i} |\cdot |^pdx\) denotes the usual \(L^p\)-norms in domain \(\Omega _i\). The error in the \(L^\infty \)-norm is measured as the maximum value of \(|u-u_h|\) on the quadrature points of each element, the end points of each elements and the interface point. We note that the quadrature points of the integration in the cut element in each domain \(\Omega _i\) are taken over the part of the background element, which is in the domain \(\Omega _i\).

3.4.1 Scalar Problem: Accuracy

We consider problem (3.22) with \(x_L=-1\), \(x_R=1\), a stationary interface at \(x_\Gamma =10^{-4}\), parameters \(a_1=2,a_2=1\), initial condition

$$\begin{aligned} f(x)=\left\{ \begin{array}{ll} {\sin (2\pi x),} &{} {x\in [-1,x_\Gamma ],} \\ {2\sin (4\pi (x-x_\Gamma /2)),} &{} {x\in [x_\Gamma ,1],} \end{array}\right. \end{aligned}$$
(3.45)

and inflow boundary condition \(u(x_L,t)=g(t)=\sin (2\pi (-1-2t))\). Note that \(u_2(x_\Gamma ,0)=2u_1(x_\Gamma ,0)\) so the initial condition satisfies the interface condition (2.3). The exact solution to this problem is

$$\begin{aligned} u(x,t)= \left\{ \begin{array}{ll} {\sin (2\pi (x-2t)),} &{} {x\in [-1,x_\Gamma ],} \\ {2\sin (4\pi (x-t-x_\Gamma /2)),} &{} {x\in [x_\Gamma ,1].} \end{array}\right. \end{aligned}$$
(3.46)

We solve up to time \(t=1\) with different mesh sizes and polynomial spaces \(r=1, 2, 3\) (i.e., \(P^1,P^2,P^3\)). We choose the penalty parameters to be \(\lambda _1=0.1\) and \(\lambda _2=\lambda _1-1\). Errors in the \(L^2\)- and \(L^\infty \)-norm and the corresponding convergence orders using the proposed method are shown in the left part of Table 1. For comparison, we also show results using the standard DG method in the right part of Table 1. For the standard DG method we use the same numerical fluxes but generate the mesh so that the interface \(x_\Gamma \) is located on an element edge. We do this by using uniform meshes with \(N=N_1+N_2\) elements and mesh size \(h_1=|\Omega _1|/N_1,h_2=|\Omega _2|/N_2\) for \(\Omega _1\) and \(\Omega _2\), respectively. Here \(N_1,N_2\) are chosen such that \(h_1,h_2\) are close to the mesh size \(h=|\Omega |/N\) we use in the CutFEM. From the numerical results in Table 1, we observe that the proposed method and the standard DG method have optimal order of accuracy and that the magnitude of the errors in both \(L^2\)- and \(L^\infty \)-norm are similar for the two methods. We have also tested other choices for the parameters \(a_1\) and \(a_2\) and observed similar results as shown here.

Table 1 Errors and orders of accuracy at \(t=1\) for the problem in Sect. 3.4.1 solved by the proposed method on a uniform background mesh and by a standard DG method on a quasi-uniform mesh fitted to the interface. Polynomial degrees 1, 2, 3 and N elements are used

3.4.2 Scalar Problem: Conservation

With this example we test how well quantities are conserved, and how errors and the condition number of the mass matrix depend on the cut size. This example is used in [19] and is similar to Example 1.1, but with less smooth initial data. The initial condition and inflow boundary conditions are \(f(x)=0\) and \(u(x_L,t)=g(t)=\sin (4 \pi (-1+3 t))\), respectively. The inflow condition is weakly imposed by the upwind flux information at the inflow boundary. The exact solution is

$$\begin{aligned} u(x,t)= \left\{ \begin{array}{ll} {g(t-(x-x_L)/2),} &{} { t\ge \frac{x-x_L}{2}, \ x\in [-1,x_\Gamma ],} \\ {2g(t-x+(x_\Gamma +x_L)/2),} &{} { t\ge x-\frac{x_\Gamma +x_L}{2},\ x\in [x_\Gamma ,1],}\\ {0,} &{} {else.} \\ \end{array}\right. \end{aligned}$$
(3.47)

We use the proposed method with \(r=2\), i.e. quadratic polynomials and a uniform background mesh. The interface is at \(x_\Gamma =10^{-4}\). In Fig. 3, we show the numerical solution on the background mesh consisting of 400 elements and the exact solution at time \(t=0.5\) and \(t=1\). Our results compare well with those in [19].

In Fig. 4, we show the conservation error

$$\begin{aligned} e(t)&=\sum _{n=0}^{N_t-1}\frac{\Delta t }{6}\Big (a_1g_h^{n}-a_2u_h^n(x_R)+4\left( a_1g_h^{n,2}-a_2u_h^{n,2}(x_R)\right) \nonumber \\&\quad \quad +a_1g_h^{n,1}-a_2u_h^{n,1}(x_R)\Big )-\int _{\Omega }(u_h^{N_t}(x)-u_h^0(x))dx. \end{aligned}$$
(3.48)

Here, \(N_t\) is the number of time steps from time 0 to t. \(u_h^n, u_h^{n,1}, u_h^{n,2}\) are the approximations of the solution at time \(t^n,t^{n}+\Delta t ,t^n+\Delta t /2\), respectively. The inflow information introduced in each time step is equal to \(\frac{\Delta t }{6}\left( g_h^{n}+4g_h^{n,2}+g_h^{n,1}\right) \), which is an approximation of the integral \(\int _{t^n}^{t^{n+1}}g(t)dt\). The error e(t) takes into account the approximation of the inflow boundary condition. If instead the exact integral at the inflow boundary is used there would be a contribution to the conserved quantity of the order \(\Delta t^4\) corresponding to the integration error. The conservation error e (Fig. 4, left panel) with \(\lambda _1,\lambda _2\) satisfying condition (3.20), is of the order of machine epsilon and remains on the same level also for other refinements and for other polynomial degrees than \(r=2\). This shows that the interface treatment of the proposed method is conservative. We also show the conservation error when the parameters \(\lambda _1=0.25\), \(\lambda _2=-0.25\), which do not satisfy the conservation condition (3.20), see the right panel of Fig. 4. We observe that the scheme in this case is not conservative and has a large error, which decrease with mesh refinement but still is large compared to machine error.

Fig. 3
figure 3

Solutions to the problem in Sect. 3.4.2 with zero initial data using discontinuous quadratic polynomials in space on a uniform mesh with 400 elements. Left: \(t=0.5\). Right: \(t=1\). Star: numerical solution. Solid line: exact solution. The dashed line indicates the interface’s position

Fig. 4
figure 4

Conservation errors for the example in Sect. 3.4.2. A uniform mesh with 40 elements and piecewise quadratic polynomials are used. Left: \(\lambda _1=0.1,\lambda _2=1-\lambda _1\). Right: \(\lambda _1=0.25,\lambda _2=-0.25\)

Next we investigate how the error depends on the position of the interface relative the background mesh. We use linear polynomials in space, \(h=1/200\) and \(x_\Gamma =\alpha h\), with \(\alpha \) varying between 0 and 1. Note that there is a mesh node at \(x=0 \) so that \(\alpha \) is the relative cut size. In Fig. 5, we plot the \(L^1\)-, \(L^2\)- and \(L^\infty \)-errors at t=1 as a function of \(\alpha \). We have scaled the \(L^\infty \)-error, by dividing the error with 10, to show all errors in one figure. We observe that the \(L^1-\) and \(L^2-\)errors are independent of how the interface cuts the background mesh and the \(L^\infty \)-error does not change much either.

Fig. 5
figure 5

Errors in the numerical solution of the problem in Sect. 3.4.2 at t=1 as a function of the relative cut size. A uniform mesh with 400 elements and piecewise linear polynomials are used. The interface is at \(x_\Gamma =\alpha h\), and we use 400 equally distributed \(\alpha \)’s in [0, 1]

We have also checked the conditioning of the mass matrix in the same setting as above, for several element types. The condition numbers as a function of the relative cut size for piecewise linear, quadratic and cubic polynomials are shown in Fig. 6. We see that the stabilization controls the condition number so that it stays bounded and on the same level, independently of how the interface cuts the background mesh.

Fig. 6
figure 6

The condition number of the mass matrix as a function of the relative cut size for the problem in Sect. 3.4.2 at \(t=1\). A uniform mesh with 400 elements and \(P^1,P^2,P^3\) polynomials are used. The interface is at \(x_\Gamma =\alpha h\), and we have considered 400 equally distributed \(\alpha \)’s in [0, 1]

3.4.3 The Acoustic System

We now use the proposed CutFEM method (3.9) with penalty parameters \(\lambda _1=0.5\) and \(\lambda _2=-0.5\) to solve the acoustic system in conservation form (3.30). We consider the same example as in [24]. The domain is \(\Omega =[0,300]\), a long fluid medium with an interface at \(x_\Gamma =96.3\), and with physical parameters

$$\begin{aligned} (\rho (x), c(x))=\left\{ \begin{array}{ll} \rho _{1}=1000\,\mathrm {kg}{/}\mathrm {m}^{3}, &{} c_{1}=1500\,\mathrm {m}{/}\mathrm {s}, \, \text{ if } x \le x_\Gamma , \\ \rho _{2}=1200\,\mathrm {kg}{/}\mathrm {m}^{3}, &{} c_{2}=2800\,\mathrm {m}{/}\mathrm {s}, \text{ if } x \ge x_\Gamma . \end{array}\right. \end{aligned}$$

The initial condition is

$$\begin{aligned} U(x,0)={\mathbf {f}}(x)=-f_{0}(\xi )\left( \begin{array}{c} \frac{1}{c_{0}} \\ \rho _{0} \end{array}\right) . \end{aligned}$$

Here, \(f_{0}(\xi )\) is a spatially bounded sinusoidal function

$$\begin{aligned} f_{0}(\xi )=\left\{ \begin{array}{ll} \sin \left( \omega _{c} \xi \right) -\frac{21}{32} \sin \left( 2 \omega _{c} \xi \right) +\frac{63}{768} \sin \left( 4 \omega _{c} \xi \right) -\frac{1}{512} \sin \left( 8 \omega _{c} \xi \right) , &{} \text{ if } 0<\xi <\frac{1}{f_{c}}, \\ 0 \text{ else, } \text{ with } \xi =t_{0}-\frac{x}{c}, \end{array}\right. \end{aligned}$$

where the central frequency \(f_{c}=50\,\mathrm {Hz}\), \(\omega _c=2\pi f_c\), and \(t_{0}=51\,\mathrm {ms}\). The initial values of the conservative variables m and q are shown to the left in Fig. 7. When the wave reaches the interface, the acoustic wave is transmitted and reflected.

Fig. 7
figure 7

Initial data and solution at \(t=39\) ms for the acoustic problem in Sect. 3.4.3. A uniform background mesh with 400 elements and piecewise quadratic polynomials are used. Solid line: exact solution. Symbols: numerical solution

We simulate this problem up to time \(t=39\,\mathrm {ms}\) using different mesh sizes and polynomial spaces. We note that the waves do not reach the boundaries up to time \(t=39\,\mathrm {ms}\) thus the zero boundary condition is used in our implementation. In the computation the conservative variables are used, but in Table 2, we give the \(L^2\)-and \(L^\infty \)-errors and the corresponding order of accuracy for the primitive variables. We observe that the proposed method has optimal order of accuracy also for the acoustic problem. In Fig. 7, we show the initial values and the numerical solution at time \(t=39\) ms. We see that our scheme can simulate this problem very well and capture the reflected wave and the transmitted wave. In Fig. 8, we plot the conservation errors of \(m_h\) and \(q_h\) with respect to time t. The conservation errors have small oscillations after the wave arrives at the interface. But all errors are of the order of machine epsilon which demonstrates that the proposed method is conservative also for the acoustic problem.

Table 2 Errors and orders of accuracy at \(t=39\) ms for the acoustic problem in Sect. 3.4.3. Uniform background meshes with N elements and piecewise polynomials of orders 1,2,3 (top, middle, bottom) are used
Fig. 8
figure 8

Conservation errors for the acoustic example in Sect. 3.4.3. A uniform background mesh with 400 elements and piecewise quadratic polynomials are used

4 Moving Interface

We now consider the scalar hyperbolic problem (2.1)–(2.3) for \(t\in [0,T]\), with flux

$$\begin{aligned} F(u)=au=\left\{ \begin{array}{ll} F_1(u_1)\equiv a_1 u_1, &{} x \in \Omega _1(t), \\ F_2(u_2)\equiv a_2 u_2, &{} x\in \Omega _2(t), \end{array}\right. \end{aligned}$$
(4.1)

and a moving interface with \(x_\Gamma '\ne 0\). We assume \(a_1-x_\Gamma '(t)\), \(a_2-x_\Gamma '(t)\) are non-zero, and have the same sign at any fixed time t. In the following we define a space-time CutFEM with discontinuous elements in both space and time following [9, 15, 32]. We emphasise that we do not explicitly construct a space-time domain in \(R^{d+1}\) as is done in for example [29]. Here d is the space dimension. The method we propose here is based on approximating the space-time integrals in the weak form by using first a quadrature rule in time. The implementation of the space-time unfitted finite element method we propose is straightforward and simple starting from an implementation of CutFEM for a stationary interface.

4.1 Mesh and Spaces

As before, let \({\mathcal {T}}_h\) be a quasi-uniform partition of the domain \(\Omega \) generated independently of the position of the interface and let \({\mathcal {E}}_h\) denote the set containing the edges in this mesh. On this time independent mesh, that we refer to as the background mesh, we define the polynomial space \(\widetilde{{\mathcal {V}}_h^{r_s}}\) as in (3.4). For time \(t\in [0, T]\) define \({\mathcal {T}}_{h,i}(t)\) as in (3.1) and \({\mathcal {E}}_{h,i}(t)\) as in (3.2). These sets are now time dependent since the interface is moving and \(\Omega _i\) changes with time. We also define the set

$$\begin{aligned} {\mathcal {T}}_{h,\Gamma }(t)=\left\{ I_j \in {\mathcal {T}}_h: I_j \cap \Gamma (t) \ne \emptyset \right\} . \end{aligned}$$
(4.2)

We discrete the interval [0, T] with \(0=t_0<t_1<t_2<\cdots <t_N=T\). During the time interval \(I^n=[t^{n-1},t^n]\), the active meshes \({\mathcal {T}}_{h,1}^n\) and \({\mathcal {T}}_{h,2}^n\), contain those elements in the background mesh that create the following subdomains \({\mathcal {N}}_{h,1}^n\) and \({\mathcal {N}}_{h,2}^n\), respectively

$$\begin{aligned} {\mathcal {N}}_{h,1}^n&=\bigcup _{t\in I^n}\bigcup _{I_j\in {\mathcal {T}}_{h,1}(t)}I_j, \ {\mathcal {N}}_{h,2}^n=\bigcup _{t\in I^n}\bigcup _{I_j\in {\mathcal {T}}_{h,2}(t)}I_j. \end{aligned}$$
(4.3)

We let \({\mathcal {E}}_{h,i}^n\) denote the set of interior edges in the active mesh \({\mathcal {T}}_{h,i}^n\), for \(i=1,2\). We also define the set of elements in the background mesh that are cut by the interface during the interval \(I^n\)

$$\begin{aligned} {\mathcal {T}}_{h,\Gamma }^n=\left\{ I_j \in {\mathcal {T}}_{h,\Gamma }(t): t\in I^n \right\} . \end{aligned}$$
(4.4)

Let \({\mathcal {F}}_{h,i}^n\) contain those edges in the mesh \({\mathcal {T}}_{h,\Gamma }^n\) that also belong to \({\mathcal {E}}_{h,i}^n\). Note that the set \({\mathcal {F}}_{h,i}^n\) does not change in the time interval \(I^n\). For an illustration see Fig.  9.

Fig. 9
figure 9

Illustration of the active meshes and a function \(u_h\in V_h^{n,1}\) at some time \(t\in I^n\)

In the proposed space-time method, we use piecewise polynomial spaces both in time and space. On the space-time slab \(I^n\times {\mathcal {N}}_{h,i}^n\), \(i=1,2\) we define the space

$$\begin{aligned} V_{h,i}^{n,r}={\text {P}}^{{\mathrm{r}}_{\mathrm{t}}}(I^n) \otimes \widetilde{{\mathcal {V}}_h^{r_s}} |_{{\mathcal {T}}_{h,i}^{n}}. \end{aligned}$$

Here \(r=(r_s, r_t)\), where \(r_s\) and \(r_t\) are the degree of the polynomials used in space and time, respectively. Define the function space \({\mathcal {V}}_{h}^{n,r}\) as

$$\begin{aligned} {\mathcal {V}}_{h}^{n,r}=\left\{ v_h=(v_{h,1},v_{h,2}): v_{h,i} \in V_{h,i}^{n,r}, i=1,2 \right\} . \end{aligned}$$
(4.5)

For example, for piecewise linear elements in time and space, \(r=(1,1)\), a function \(v_h\in {\mathcal {V}}_{h}^{n,r}\) can be expressed as \(v_h=(v_{h,1},v_{h,2})\) with

$$\begin{aligned} v_{h, i}=v_{i00}+v_{i01} \frac{x-x_{k}}{h / 2}+v_{i10} \frac{t-t^{n-1}}{\Delta t^n}+v_{i 11} \frac{x-x_{k}}{h / 2} \frac{t-t^{n-1}}{\Delta t^n}. \end{aligned}$$
(4.6)

Here, \(v_{ikj}\) are the coefficients of the basis functions: \(1, \frac{x-x_{k}}{h/ 2}, \frac{t-t^{n-1}}{\Delta t^n}, \frac{t-t^{n-1}}{\Delta t^n}\frac{x-x_{k}}{h/ 2}\) and \(\Delta t^n=t^{n}-t^{n-1}\) denotes the time step of interval \(I^n\). Functions in \({\mathcal {V}}_{h}^{n,r}\) are discontinuous both in space and time. We define the jump and average of a function v at x as in (3.6) and (3.7) and the jump at a time \(t^{n}\) as

$$\begin{aligned}&[v]^n=v^{n,+}-v^{n,-}, \text { with } v^{n,-}=\lim \limits _{\epsilon \rightarrow 0^+}v(x,t^{n}-\epsilon ), \ v^{n,+}=\lim \limits _{\epsilon \rightarrow 0^+}v(x,t^{n}+\epsilon ). \end{aligned}$$

When a function is single valued at \(t^n\) we will use the notation \(v^n(\cdot )=v(\cdot ,t^n)\).

4.2 Weak Formulation

We now present a weak formulation where space and time are treated similarly. For each time interval \(I^n\), given \(u_{h}^{n-1,-}\), find \(u_h \in {\mathcal {V}}_{h}^{n,r}\) such that for \(\forall v_h \in {\mathcal {V}}_{h}^{n,r}\)

$$\begin{aligned}&(u_h^{n,-},v_h^n)_{\Omega _1(t^{n})\cup \Omega _2(t^{n})} -(u_h^{n-1,-},v_h^{n-1})_{\Omega _1(t^{n-1})\cup \Omega _2(t^{n-1})} \nonumber \\&\quad -\int _{I^n} (u_h,(v_h)_t)_{\Omega _1(t)\cup \Omega _2(t)} \ dt+ \int _{I^n} a_h(u_h,v_h) \ dt + \gamma _A\int _{I^n} J_0(u_h,v_h) \ dt= 0. \end{aligned}$$
(4.7)

Here \(u_h^{n-1,-}\) is the solution from the previous space-time slab (with \(u_h^{0,-}\) given by the initial condition) and

$$\begin{aligned} a_h(u_h,v_h)&=-(F(u_h),(v_h)_x)_{\Omega _1(t)\cup \Omega _2(t)} - \sum _{i=1}^{2}\sum _{e\in {\mathcal {E}}_{h,i}(t)} {\widehat{F}}_e(u_h)[v_h]_e \nonumber \\&\quad -\left( [(F(u_h)-x_\Gamma 'u_h)v_h]_{\Gamma (t)}+[F(u_h)-x_\Gamma 'u_h]_\Gamma [\lambda v_h]_{\Gamma (t)} \right) . \end{aligned}$$
(4.8)

The flux \({\widehat{F}}_e(u_h)\) is defined as in (3.15) with \(\lambda _e=|a_i|\) for \(e\in {\mathcal {E}}_{h,i}\), and the penalty parameter \(\lambda \) is piecewise constant, see (3.14), and will be chosen such that the scheme is stable and conservative (see Theorem 4). The stabilization term \(J_0(u_h,v_h)\) is defined as in (3.13), but with the set \({\mathcal {F}}_{h,i}^n\) instead of \({\mathcal {F}}_{h,i}(t)\). Since the set \({\mathcal {F}}_{h,i}^n\) does not change in the time interval \(I^n\), and \(u_h\) and \(v_h\) are polynomials in time, the integral \(\int _{I^n} J_0(u_h,v_h) \ dt\), can be computed analytically. The stabilization term is introduced to control the condition number of the resulting system matrix independently of how the geometry cuts through the background mesh, and defines an extension of \(u_h\) to the entire active mesh which is needed when the space-time integrals in the weak form are approximated by quadratures rules, see Sect. 4.4.

To see that the weak formulation above is consistent, we multiply Eq. (2.1) by a test function \(v\in V_h^{n,r}\), integrate in both space and time and impose the interface condition (2.3) weakly. Integration by parts in space and using (3.18), together with integration by parts in time, yields

$$\begin{aligned}&\int _{I^n} \int _{\Omega _1(t)\cup \Omega _2(t)} (uv)_t \ dx dt = \int _{I^n} \frac{d}{dt} \int _{\Omega _1(t)\cup \Omega _2(t)} u v \ dx dt + \int _{I^n} [x_\Gamma '(t)u v]_\Gamma \ dt \nonumber \\&\quad = (u^n,v^n)_{\Omega _1(t^{n})\cup \Omega _2(t^{n})} -(u^{n-1},v^{n-1})_{\Omega _1(t^{n-1})\cup \Omega _2(t^{n-1})} + \int _{I^n} [x_\Gamma '(t)u v]_\Gamma \ dt. \end{aligned}$$
(4.9)

By adding \(([u]^{n-1},v^{n-1})_{\Omega _1(t^{n-1})\cup \Omega _2(t^{n-1})}\), using \([u]^{n}=0\) at all time \(t=t^{n}\), and using the identity \(u_tv=(uv)_t-uv_t\) we get the proposed weak formulation.

Choosing the test function \(v_h=1\) in (4.7) we have

$$\begin{aligned} \int _{\Omega (t^{n})}&u_h^{n,-} \ dx-\int _{\Omega (t^{n-1})} u_h^{n-1,-} \ dx\nonumber \\&\quad =\int _{I^n}\left( {\widehat{F}}(u_h(x_L,t))-{\widehat{F}}(u_h(x_R,t))\right) \ dt \nonumber \\&\qquad +\int _{I^n}([F(u_h)-x_\Gamma 'u_h]_\Gamma +(\lambda _2-\lambda _1)[F(u_h)-x_\Gamma 'u_h]_\Gamma ) \ dt. \end{aligned}$$
(4.10)

With \(\lambda _2-\lambda _1+1=0\), as in (3.20), the proposed space-time CutFEM is conservative.

Remark 2

Note that we can also consider the space-time formulation without integration by parts in time. Thus, given \(u_h^{n-1,-}\), find \(u_h \in {\mathcal {V}}_{h}^{n,r}\) such that

$$\begin{aligned}&\int _{I^n} ((u_h)_t, v_h )_{\Omega _1(t)\cup \Omega _2(t)} dt+([u_h]^{n-1},v^{n-1}_h)_{\Omega _1(t^{n-1})\cup \Omega _2(t^{n-1})} \nonumber \\&\quad -\int _{I^n} (F(u_h),(v_h)_x)_{\Omega _1(t)\cup \Omega _2(t)} \ dt - \int _{I^n} \sum _{i=1}^{2}\sum _{e\in {\mathcal {E}}_{h,i}} {\widehat{F}}_e(u_h)[v_h]_e\ dt \nonumber \\&\quad -\int _{I^n}\left( [F(u_h)v_h]_\Gamma +[F(u_h)-x_\Gamma 'u_h]_\Gamma [\lambda v_h]_\Gamma \right) \ dt +\gamma _A\int _{I^n} J_0(u_h,v_h)dt=0, \end{aligned}$$
(4.11)

for all \(v_h \in {\mathcal {V}}_{h}^{n,r}\). This weak formulation is also consistent. With \(v_h=1\) we get

$$\begin{aligned}&\int _{I^n}\int _{\Omega _1(t)\cup \Omega _2(t)}(u_h)_t \ dxdt- \int _{I^n}({\widehat{F}}(u(x_L,t))-{\widehat{F}}(u(x_R,t)) ) \ dt \nonumber \\ \quad&\quad -\int _{I^n}\left( [F(u_h)]_\Gamma +[F(u_h)-x_\Gamma 'u_h]_\Gamma (\lambda _2-\lambda _1)\right) \ dt +\int _{\Omega (t^{n-1})}[u_h]^{n-1} \ dx=0. \end{aligned}$$
(4.12)

If (4.9) (with \(v=1\)) holds for the discrete function \(u_h\), that is if

$$\begin{aligned}&\int _{I^n}\int _{\Omega _1(t)\cup \Omega _2(t)}(u_h)_t \ dxdt - \int _{I^n} [x_\Gamma 'u_h]_\Gamma \ dt + \int _{\Omega (t^{n-1})}[u_h]^{n-1} \ dx \nonumber \\&\quad = \int _{\Omega (t^{n})} u_h^{n,-} \ dx -\int _{\Omega (t^{n-1})} u_h^{n-1,-} \ dx, \end{aligned}$$
(4.13)

it follows that the scheme (4.11) is conservative when (3.20) holds, i.e. \(\lambda _2-\lambda _1=-1\). However, in the fully discrete scheme we use a quadrature rule to approximate the time integral. Since the domain is time-dependent, (4.13) can not hold exactly. Therefore a method based on the weak formulation (4.11) may not be exactly conservative with a conservation error depending on the accuracy of the quadrature rule. This is demonstrated in the numerical examples.

4.3 Stability Analysis of the Semi-discrete Scheme

We now consider the energy stability of the proposed semi-discrete space-time CutFEM (4.7). Similar to the scalar advection problem (3.22) with a stationary interface, we consider the weighted energy with \(\eta >0\), i.e.,

$$\begin{aligned} E_\eta (t,u_h)=\frac{1}{2}\int _{\Omega _1(t)} (u_{h,1}(x,t))^2 \ dx+\frac{\eta }{2}\int _{\Omega _2(t)} (u_{h,2}(x,t))^2 \ dx. \end{aligned}$$
(4.14)

For convenience, we will use the notation \(\Omega _1^n\), \(\Omega _2^n\) for \(\Omega _1(t^n)\), \(\Omega _2(t^n)\), respectively. Choosing \(v_h=(u_{h,1},\eta u_{h,2})\) in (4.7) we have

$$\begin{aligned}&\int _{\Omega _1^{n}} (u_{h,1}^{n,-})^2 \ dx-\int _{\Omega _1^{n-1}}u_{h,1}^{n-1,-}u_{h,1}^{n-1,+} \ dx-\int _{I_n}\int _{\Omega _1(t)}u_{h,1}(u_{h,1})_t \ dx dt \nonumber \\&\qquad +\eta \int _{\Omega _2^{n}} (u_{h,2}^{n,-})^2 \ dx -\eta \int _{\Omega _2^{n-1}}u_{h,2}^{n-1,-}u_{h,2}^{n-1,+}dx -\eta \int _{I_n}\int _{\Omega _2(t)}u_{h,2}(u_{h,2})_t \ dx dt \nonumber \\&\quad =-\int _{I_n} a_h(u_h,v_h) \ dt -\gamma _A\int _{I_n} J_0(u_h,v_h) \ dt. \end{aligned}$$
(4.15)

Integrating the last two terms in the left hand side of Eq. (4.15) we get

$$\begin{aligned} Lhs&=-\frac{1}{2}\left( \int _{\Omega _1^{n}} (u_{h,1}^{n,-})^2 dx-\int _{\Omega _1^{n-1}}(u_{h,1}^{n-1,+})^2dx-\int _{I_n}x_\Gamma '(u_{h,1}( x_\Gamma ,t)) ^2\ dt\right) \nonumber \\&\quad -\frac{\eta }{2}\left( \int _{\Omega _2^{n}} (u_{h,2}^{n,-})^2 dx-\int _{\Omega _2^{n-1}}(u_{h,2}^{n-1,+})^2dx+\int _{I_n}x_\Gamma '(u_{h,2}( x_\Gamma ,t)) ^2 \ dt\right) \nonumber \\&\quad +\int _{\Omega _1^{n}} (u_{h,1}^{n,-})^2 dx-\int _{\Omega _1^{n-1}}u_{h,1}^{n-1,+}u_{h,1}^{n-1,-}dx \nonumber \\&\quad +\eta \left( \int _{\Omega _2^{n}} (u_{h,2}^{n,-})^2 dx-\int _{\Omega _2^{n-1}}u_{h,2}^{n-1,+}u_{h,2}^{n-1,-}dx\right) \nonumber \\&=E_\eta (t^{n},u_h^{n,-})-E_\eta (t^{n-1},u_h^{n-1,-}) + \frac{1}{2} \left( \Vert [u_{h,1}]^{n-1} \Vert ^2_{\Omega _1^{n-1}} + \eta \Vert [u_{h,2}]^{n-1} \Vert ^2_{\Omega _2^{n-1}} \right) \nonumber \\&\quad -\frac{1}{2} \int _{I_n} \left( \eta x_\Gamma '(u_{h,2}( x_\Gamma ,t)) ^2-x_\Gamma '(u_{h,1}( x_\Gamma ,t)) ^2\right) \ dt. \end{aligned}$$
(4.16)

As in the analysis in Sect. 3.3, using the definition of \(a_h(\cdot ,\cdot )\), and integrating the term \((au_{h,i},(u_{h,i})_x)_{\Omega _i(t)}\), taking into account that \(u_{h,i}\) is discontinuous across the edges, using that \(\frac{a}{2}[u_{h}^2]_e=a\{ u_h \}_e[u_{h}]_e\), and the definition of \({\widehat{F}}_e\) (3.15), we have

$$\begin{aligned}&-\int _{I_n} a_h(u_h,v_h) \ dt -\gamma _A\int _{I_n} J_0(u_h,v_h) \ dt \nonumber \\&\quad +\frac{1}{2} \int _{I_n} x_\Gamma '\left( \eta (u_{h,2}( x_\Gamma ,t)) ^2-(u_{h,1}( x_\Gamma ,t)) ^2\right) \ dt = -ET-IT, \end{aligned}$$
(4.17)

where \(v_h=(u_{h,1},\eta u_{h,2})\) and

$$\begin{aligned} ET&=\int _{I_n}\left( \frac{a_1}{2}\sum _{e\in {\mathcal {E}}_{h,1}}([u_{h,1}]_e)^2+\eta \frac{a_2}{2}\sum _{e\in {\mathcal {E}}_{h,2}}([u_{h,2}]_e)^2 \right) \ dt, \nonumber \\&\quad +\int _{I_n}\gamma _A\left( \sum _{e\in {\mathcal {F}}_{h,1}^n} J_0(u_{h,1},u_{h,1})+\sum _{e\in {\mathcal {F}}^n_{h,2}} \eta J_0(u_{h,2},u_{h,2}) \right) \ dt, \end{aligned}$$
(4.18)
$$\begin{aligned} IT&= \int _{I_n} \left( \frac{1}{2}(a_1-x_\Gamma ')u_{h,1} +\lambda _1[(a-x_\Gamma ')u_h]_\Gamma \right) u_{h,1} \ dt \nonumber \\&\quad -\eta \int _{I_n} \left( \frac{1}{2}(a_2-x_\Gamma ')u_{h,2}+\lambda _2[(a-x_\Gamma ')u_{h}]_\Gamma \right) u_{h,2} \ dt. \end{aligned}$$
(4.19)

Collecting the results in (4.15)–(4.19) and letting \(\widetilde{a_1}=a_1-x_\Gamma '\) and \(\widetilde{a_2}=a_2-x_\Gamma '\) yields

$$\begin{aligned}&E_\eta (t^n,u_h^{n,-})-E_\eta (t^{n-1},u_h^{n-1,-})+ \frac{1}{2} \left( \Vert [u_{h,1}]^{n-1} \Vert ^2_{\Omega _1^{n-1}} + \eta \Vert [u_{h,2}]^{n-1} \Vert ^2_{\Omega _2^{n-1}} \right) \nonumber \\&\quad =-ET-\int _{I_n}{\mathbf {u}}_h^{\text{ T }}S{\mathbf {u}}_h\ dt, \end{aligned}$$
(4.20)

with

$$\begin{aligned} S=\begin{pmatrix} (\frac{1}{2}-\lambda _1)\widetilde{a_1} &{} \frac{1}{2}(\widetilde{a_2}\lambda _1+\widetilde{a_1} \eta \lambda _2) \\ \frac{1}{2}(\widetilde{a_2}\lambda _1+\widetilde{a_1} \eta \lambda _2) &{} -(\frac{1}{2}+\lambda _2) \eta \widetilde{a_2} \end{pmatrix}, \quad {\mathbf {u}}_h=\left( \begin{array}{c} u_{h,1}(x_\Gamma ,t) \\ u_{h,2}(x_\Gamma ,t) \end{array}\right) . \end{aligned}$$
(4.21)

In (4.18) \(ET\ge 0\) and will not contribute to energy growth. Hence, if the matrix S is positive semi-definite, we obtain energy stability. Note that the matrix S in (4.21) is of the same form as in the case of a stationary interface, see (3.27), but with \(\widetilde{a_i}\) instead of \(a_i\). Thus, by Lemma 1 we have the following theorem.

Theorem 4

Consider the problem (2.1)–(2.3) with the flux function (4.1), and a moving interface at \(x_\Gamma (t)\) such that \(a_1-x_\Gamma '(t)\) and \(a_2-x_\Gamma '(t)\) have equal, non-zero and constant sign for all time t. With penalty parameters \(\lambda _1\) and \(\lambda _2\) satisfying (3.20) and

$$\begin{aligned} \left\{ \begin{array}{ll} {\lambda _1\le \frac{1}{2},\lambda _2\le -\frac{1}{2},}&{}{\text {if } a_1-x_\Gamma '< 0,a_2-x_\Gamma '>0,}\\ {\lambda _1\ge \frac{1}{2},\lambda _2\ge -\frac{1}{2},}&{}{\text {if } a_1-x_\Gamma '<0,a_2-x_\Gamma '>0,}\\ \end{array}\right. \end{aligned}$$
(4.22)

the space-time CutFEM (4.7) is conservative and there exists a positive \(\eta \) such that the energy defined in (4.14) does not grow with time.

4.4 Quadrature in Time

As in [9, 15, 32], we approximate the space-time integrals in the variational formulation using quadrature rules, first in time and then in space. Note that using a quadrature rule in time we have

$$\begin{aligned} \int _{I^n}\int _{\Omega _i(t)} f(x,t) dxdt\approx \sum _{q=1}^{n_{q}} \omega _{q}^{n}\int _{\Omega _i(t_q^n)} f(x,t_q^n)dx. \end{aligned}$$
(4.23)

Here, \(\omega _{q}^{n}\) are the quadrature weights, \(t_{q}^{n}\), \(q=1, \ldots , n_{q}\) are quadrature points in the interval \(I^n\), and \(n_{q}\) is the number of quadrature points.

In the numerical examples, both the trapezoidal rule and Simpson’s rule are used. In the time interval \(I^n=[t^{n-1},t^{n}]\), the trapezoidal rule is given by two quadrature points, \(t_{1}^{n}=t^{n-1}\) and \(t_{2}^{n}=t^{n},\) and weights \(\omega _{1}^{n}=\omega _{2}^{n}=\frac{\Delta t^{n}}{2}\). In Simpson’s quadrature rule, the three quadrature points are \(t_{1}^{n}=t^{n-1},\) \(t_{2}^{n}=\frac{t^{n-1}+t^{n}}{2}\), and \(t_{3}^{n}=t^{n}\), and the weights are \(\omega _{1}^{n}=\omega _{3}^{n}=\frac{\Delta t^{n}}{6}\) and \(\omega _{2}^{n}=\frac{4 \Delta t^{n}}{6}\).

4.5 Numerical Examples with Moving Interfaces

We use the proposed space-time cut finite element method (4.7) to solve problem (2.1)–(2.3) with flux (4.1) and an moving interface \(x_\Gamma (t)\).

4.5.1 Scalar Problem with a Moving Interface: Accuracy

We use \(a_1=2\), \(a_2=1\), \(x_\Gamma (0)=10^{-4}\), \(x'_\Gamma =0.111\), and the initial value

$$\begin{aligned} u(x,0)=f(x)=\left\{ \begin{array}{ll} {\sin (2\pi x),} &{} {x\in [-1,x_\Gamma (0)]}, \\ {\beta \sin (2\pi \beta x+2\pi x_\Gamma (0) (1-\beta ))}, &{} {x\in [x_\Gamma (0),1].} \end{array}\right. \end{aligned}$$
(4.24)

Here \(\beta =\frac{a_1-x_\Gamma '}{a_2-x_\Gamma '}\). This initial condition satisfies the interface condition (2.3). The inflow boundary condition \(g(t)=u(x_L,t)=\sin (2\pi (x_L-2t))\) is used. The outflow boundary condition is used on the right boundary. The exact solution is

$$\begin{aligned} u(x,t)=\left\{ \begin{array}{ll} {\sin (2\pi (x-2t)),} &{} {x\in [-1,x_\Gamma (t)]}, \\ {\beta \sin (2\pi \beta (x-t)+2\pi x_\Gamma (0)(1-\beta ))}, &{} {x\in [x_\Gamma (t),1].} \end{array}\right. \end{aligned}$$
(4.25)

We use the space-time CutFEM (4.7) with discontinuous piecewise linear polynomials in time and discontinuous piecewise linear and quadratic polynomials in space. For the time integration we use Simpson’s rule. The time step is \(\Delta t=h/12\) when linear elements are used in space, that is \(r=(1,1)\), and \(\Delta t=0.005h\) when quadratic polynomials are used in space, that is \(r=(2,1)\). In the latter case the time step is small enough so that the error is not dominated by the error in the time discretization. We use \(\gamma _A=0.75\), \(\lambda _1=0\), and \(\lambda _2=\lambda _1-1\). We solve the problem up to time \(t=0.1\). In Table 3, we show the \(L^2\)-and \(L^\infty \)-errors for different mesh sizes \(h=2/N\) and we observe that the space-time CutFEM (4.7) has the optimal order of accuracy for this moving interface problem. Note that we use a uniform background mesh with mesh size h and the interface cuts the mesh arbitrarily as it evolves in time.

Table 3 Errors and orders of accuracy at \(t=0.1\) for the problem in Sect. 4.5.1 with a moving interface. The approximation uses space-time polynomials of orders (1,1) and (2,1), respectively, and a uniform background mesh with N elements in space

4.5.2 Scalar Problem with a Moving Interface: Conservation

We consider the same example as in [19] but with a moving interface

$$\begin{aligned} x_\Gamma (t)=x_\Gamma (0)+0.4\sin (t)(x_\Gamma (0)-x_L)(x_R-x_\Gamma (0)), \end{aligned}$$
(4.26)

where \(x_\Gamma (0)=-0.499\). Let \(a_1=2\), \(a_2=1\), \(f(x)=0\) on the domain \(\Omega =[-1,1]\). The inflow boundary condition \(g(t)=\sin (4 \pi (-1+3 t))\) is used on the left boundary. We solve the problem up to time \(t=1\) when the outflow information is still zero. The space-time CutFEM is used to solve the problem with parameters \(\lambda _1=0\) and \(\lambda _2=\lambda _1-1\), a uniform background mesh with 400 elements, and linear elements both in time and space, \(r=(1,1)\). Simpson’s rule is used for the time integration with Courant number \(C=1/6\). We measure the conservation error as in (3.48), but replacing \(u_h^n\) by \(u_h^{n,-}\) and noting that \(\Omega =\Omega _1(t)\cup \Omega _2(t)\).

In the left panel of Fig. 10, the numerical solution \(u_h\) is shown and we can observe that the proposed space-time CutFEM can simulate the problem with a moving interface well. We note that the solution has a weak discontinuity and it is not surprising that small oscillations appear. In the right side of Fig. 10, we show the conservation error e(t) for the numerical solution \(u_h\). We see that the proposed space-time method is conservative. In Fig. 11, we also show the numerical solution \(u_h\) and the conservation error e(t) using the variational formulation (4.11). We observe that this scheme also simulates this problem well, but the conservation error is significantly larger when the weak formulation (4.11) is used.

Fig. 10
figure 10

Results for the problem in Sect. 4.5.2, solved by the proposed space-time method (4.7) with r=(1,1) on a uniform background mesh with 400 elements in space. Left: \(u_h\) at \(t=1\), with initial and present interface positions indicated by dashed lines. Right: Conservation error e(t) (see Sect. 3.4.2)

Fig. 11
figure 11

Results for the problem in Sect. 4.5.2, solved by the space-time method (4.11) with r=(1,1) on a uniform background mesh with 400 elements in space. Left: \(u_h\) at \(t=1\), with initial and present interface positions indicated by dashed lines. Right: Conservation errors, (see Sect. 3.4.2)

4.6 A Locally Implicit Method

We now combine the proposed space-time CutFEM with an explicit CutFEM. The space-time method is active in a neighbourhood of the interface and the explicit CutFEM method is applied away from the interface. For simplicity, we only consider the case \(a_1-x_\Gamma '>0\), \(a_2-x_\Gamma '>0\), and piecewise linear polynomials both in space and time.

Recall the sets \({\mathcal {F}}_{h,i}^n\), \(i=1,2\) from Sect. 4.1. We now let \(\Omega _{l}\) be the subdomain containing the set of elements that have an edge in \(\cup _{i} {\mathcal {F}}_{h,i}^n\) and denote by \(\Omega _{i, E}\) the remaining part of \(\Omega _{i}\), i.e, the elements in \(\Omega _i\) that are not in \(\Omega _{l}\). Note that \(\Omega _{i,E} \subset \Omega _i(t)\) for all \(t\in I^n\) and that no elements in \(\Omega _{i,E}\) are cut by the interface during the time interval \(I^n\). In Fig. 12 we illustrate how the space-time domain \(I^n\times \Omega \) can be partitioned into the three parts, \(I^n \times \Omega _l\), \(I^n \times \Omega _{1,E}\), and \(I^n \times \Omega _{2,E}\).

Fig. 12
figure 12

The domains in the locally implicit scheme

In regions away from the interface we want to apply a standard explicit DG method. Recall the mesh \({\mathcal {T}}_{h}\) and the piecewise polynomial space \(\widetilde{{\mathcal {V}}_h^1}\) defined in Sect. 3.1. We define the following meshes and spaces restricted to \(\Omega _{i,E}\),

$$\begin{aligned} {\mathcal {T}}_{h,i}^E=\left\{ I_j \in {\mathcal {T}}_{h}: I_j \cap \Omega _{i,E} \ne \emptyset \right\} , \end{aligned}$$
(4.27)

and

$$\begin{aligned} {\mathcal {V}}_{h,i}=\widetilde{{\mathcal {V}}_h^1} |_{{\mathcal {T}}_{h,i}^E}, \quad i=1,2. \end{aligned}$$
(4.28)

We now formulate a standard DG method with a two stage second order Runge–Kutta method: given \({\hat{u}}_{h,i}^{n-1}\in {\mathcal {V}}_{h,i}\) find \({\hat{u}}_{h,i}^{(1)} \in {\mathcal {V}}_{h,i}\) and \({\hat{u}}_{h,i}^{n} \in {\mathcal {V}}_{h,i}\) such that

$$\begin{aligned}&\left( {\hat{u}}_{h,i}^{(1)}-{\hat{u}}_{h,i}^{n-1},{\hat{v}}_h \right) _{\Omega _{i,E}}+\Delta t^n A_h({\hat{u}}_{h,i}^{n-1},{\hat{v}}_{h})=0, \quad \forall {\hat{v}}_{h} \in {\mathcal {V}}_{h,i}, \end{aligned}$$
(4.29)
$$\begin{aligned}&\left( {\hat{u}}_{h}^{n}-\frac{1}{2}({\hat{u}}_{h}^{n-1}+{\hat{u}}_{h}^{(1)}), {\hat{v}}_{h} \right) _{\Omega _{i,E}}+\frac{\Delta t^n}{2} A_h({\hat{u}}_{h}^{(1)},{\hat{v}}_{h}) =0, \quad \forall {\hat{v}}_{h} \in {\mathcal {V}}_{h,i}, \end{aligned}$$
(4.30)

with

$$\begin{aligned} A_h({\hat{u}}_{h,i},{\hat{v}}_{h})&= - (F({\hat{u}}_{h,i}),({\hat{v}}_{h})_x)_{\Omega _{i,E}} -\sum _{i=1}^{2}\sum _{e\in {\mathcal {E}}_{h,i} \cap \Omega _{i,E}} {\widehat{F}}_e({\hat{u}}_{h,i})[{\hat{v}}_{h}]_e, \end{aligned}$$
(4.31)

and \({\widehat{F}}_e({\hat{u}}_{h,i})\) as in (3.15) at interior edges with \(\lambda _e=|a_i|\) for \(e\in {\mathcal {E}}_{h,i}\), \(i=1,2\).

In the space-time slab \(I^n \times \Omega _l\) we use the proposed space-time method. The active meshes and the spaces are defined exactly as in Sect. 4.1, but with \({\mathcal {T}}_{h,i}(t)\), \(i=1,2\) restricted to \(\Omega _l\). Thus, given \(u_h^{n-1,-}\), the solution from the previous space-time slab, find \(u_h \in {\mathcal {V}}_{h}^{n,r}\) such that

$$\begin{aligned}&\sum _1^2\left( ((u_h^{n,-},v_h^{n})_{\Omega _l\cap \Omega _i(t^{n})} -(u_h^{n-1,-},v_h^{n-1})_{\Omega _l\cap \Omega _i(t^{n-1})} -\int _{I^n} (u_h,(v_h)_t)_{\Omega _l\cap \Omega _i(t)} \ dt\right) \nonumber \\&\quad + \int _{I^n} a_h(u_h,v_h) \ dt + \gamma _A\int _{I^n} J_0(u_h,v_h) \ dt= 0, \quad \forall v_h \in {\mathcal {V}}_{h}^{n,r}, \end{aligned}$$
(4.32)

with

$$\begin{aligned} a_h(u_h,v_h)&=-\sum _{i=1}^2\left( (F(u_h),(v_h)_x)_{\Omega _l \cap \Omega _i(t)} + \sum _{e\in {\mathcal {E}}_{h,i}(t)\cap \Omega _l} {\widehat{F}}_e(u_h) [v_h]_e \right) \nonumber \\&\quad -\left( [(F(u_h)-x_\Gamma 'u_h)v_h]_{\Gamma }+[F(u_h)-x_\Gamma 'u_h]_\Gamma [\lambda v_h]_{\Gamma } \right) , \end{aligned}$$
(4.33)

and \(\lambda \) as in Theorem 4. We choose \(r=(1,1)\).

Taking the test functions to be one in both schemes, i.e., \({\hat{v}}_h=1\), and \(v_h=1\) and assuming for simplicity that the contributions at the physical boundary \(x=x_L\) and \(x=x_R\) vanish we have

$$\begin{aligned}&\sum _{i=1}^{2} \left( ({\hat{u}}_{h,i}^{n}, 1)_{\Omega _{i,E}}- ({\hat{u}}_{h,i}^{n-1}, 1)_{\Omega _{i,E}} -\frac{\Delta t^n}{2} \left( {\widehat{F}}_{e_i}({\hat{u}}_{h,i}^{n-1}) +{\widehat{F}}_{e_i}({\hat{u}}_{h,i}^{(1)}) \right) \right) =0, \end{aligned}$$
(4.34)
$$\begin{aligned}&\sum _{i=1}^{2} \left( (u_h^{n},1)_{\Omega _l\cap \Omega _i(t^{n})} -(u_h^{n-1,-},1)_{\Omega _l\cap \Omega _i(t^{n-1})} -\int _{I^n} {\widehat{F}}_{e_i} (u_h) \ dt \right) = 0, \end{aligned}$$
(4.35)

where (4.34) is obtained by multiplying (4.29) with 1/2 and adding to Eq. (4.30). Thus, for the locally implicit scheme to be conservative, we need the numerical fluxes at the edges \(e_i\), between \(\Omega _{i,E}\) and \(\Omega _l\) (see Fig. 12), to satisfy

$$\begin{aligned} \int _{I^n} {\widehat{F}}_{e_i}(u_h) dt&=\frac{\Delta t^n}{2}\left( {\widehat{F}}_{e_i}({\hat{u}}_{h,i}^{n-1})+{\widehat{F}}_{e_i}({\hat{u}}_{h,i}^{(1)})\right) , \quad i=1,2. \end{aligned}$$
(4.36)

Taking into account boundary conditions, the flux’s direction, as well as condition (4.36), we choose the fluxes at the boundaries and edges \(e_1,e_2\) as

$$\begin{aligned} {\widehat{F}}_L({\hat{u}}_{h,1}^{n-1})&= F(g(t^{n-1})),&{\widehat{F}}_L({\hat{u}}_{h,1}^{(1)})=F(g(t^{n-1}+\Delta t^n)), \\ {\widehat{F}}_R({\hat{u}}_{h,2}^{n-1})&= F({\hat{u}}_{h,i}^{n-1}(x_R,t^{n-1})),&{\widehat{F}}_R({\hat{u}}_{h,2}^{(1)})=F({\hat{u}}_{h,i}^{(1)}(x_R,t^{n-1})),\\ {\widehat{F}}_{e_1}({\hat{u}}_{h,1}^{n-1})&={F}({\hat{u}}_{h,1}^n(x_{e_1},t^{n-1})),&{\widehat{F}}_{e_1}({\hat{u}}_{h,1}^{(1)})={F}({\hat{u}}_{h,1}^{(1)}(x_{e_1},t^{n})), \\ {\widehat{F}}_{e_2}({\hat{u}}_{h,2}^{n-1})&= F_{e_2}(u_h^{n-1,+}),&{\widehat{F}}_{e_2}({\hat{u}}_{h,2}^{(1)})=F_{e_2}(u_h^{n,-}),\\ \int _{I^n} {\widehat{F}}_{e_1}(u_h) dt&= \frac{\Delta t^n}{2}\left( {\widehat{F}}_{e_1}({\hat{u}}_{h,1}^{n-1}) +{\widehat{F}}_{e_1}({\hat{u}}_{h,1}^{(1)})\right) ,\\ \int _{I^n} {\widehat{F}}_{e_2}(u_h) dt&= \frac{\Delta t^n}{2}\left( {F}_{e_2}(u_h^{n-1,+})+{F}_{e_2}(u_h^{n,-}) \right) . \end{aligned}$$

The method can straightforwardly be used in a computation by time-stepping first in \(\Omega _{1,E}\), then in \(\Omega _l\), and finally in \(\Omega _{2,E}\). The first and last steps are explicit, while the middle step is implicit.

4.6.1 Numerical Examples

We now test the accuracy and conservation of the locally implicit method. Consider first the same example as in Sect. 4.5.1 with a time step size \(\Delta t^n=\Delta t=h/12\). Table 4 shows the expected second order accuracy in the \(L^2\)-norm. In \(L^\infty \)-norm convergence is slower. We have also solved this problem on finer meshes, \(N=1280,2560,5120\), and we observe that the convergence is slower than the optimal second order convergence. When a smaller time step is used the degradation of convergence rate occurs at a finer grid, indicating that the problem is related to the discretization of time. Since both the fully implicit and the standard method work well, we conclude that the problem comes from the coupling.

Table 4 Errors and orders of accuracy at \(t=0.1\) for the problem in Sect. 4.5.1 with a moving interface when using the locally implicit method. The uniform background mesh has N elements in space

Next we solve the example in Sect. 4.5.2 and simulate this problem up to time \(t=1\) with \(N=400\) uniform elements in the background mesh, and time step \(\Delta t^n=h/12\). We show the numerical solution in the left of Fig. 13. We see that the locally implicit scheme can simulate this problem well and captures the discontinuity at the interface. We measure the conservation error by e(t) using the inflow information based on the numerical integration used in the scheme. We show the conservation error in the right of Fig.  13. The conservation error is of the order of machine epsilon.

Fig. 13
figure 13

Results for the problem with a moving interface in Sect. 4.5.2, discretized by the locally implicit method on a uniform background mesh with 400 elements in space. Left: solution \(u_h\) at \(t=1\). right: conservation error e(t)

5 Extension to Two Space Dimensions

Let \(\Omega \) be a bounded convex domain in \({\mathbb {R}}^2\), with polygonal boundary \(\partial \Omega \) and let \(\Gamma \) be a smooth internal boundary that separates the domain \(\Omega \) into two subdomains \(\Omega _1\) and \(\Omega _2\) such that \({\bar{\Omega }} = {\bar{\Omega }}_1 \cup {\bar{\Omega }}_2\). Consider the hyperbolic conservation law

$$\begin{aligned}&u_{t}(x,y,t)+\nabla \cdot {\mathbf {F}}(u(x,y,t))=0,&\quad {(x,y) \in \Omega _1\cup \Omega _2, \quad t \in (0,T]} \end{aligned}$$
(5.1)
$$\begin{aligned}&{u(x,y,0)=f(x,y),}&\quad {(x,y) \in \Omega _1\cup \Omega _2,} \end{aligned}$$
(5.2)
$$\begin{aligned}&[{\mathbf {F}}(u(x,y,t))\cdot {\mathbf {n}}]_\Gamma =0,&\quad {(x,y) \in \Gamma }, \end{aligned}$$
(5.3)

together with suitable boundary conditions. Here \({\mathbf {n}}\) is the unit normal vector of \(\Gamma \), \({\mathbf {F}}(u)={\mathbf {a}} u\), \({\mathbf {a}}={\mathbf {a}}_1\) in \(\Omega _1\) and \({\mathbf {a}}={\mathbf {a}}_2\) in \(\Omega _2\). Only a stationary interface is considered.

5.1 The Finite Element Method

Let \({\mathcal {T}}_h\) be a quasi-uniform simplicial mesh of the domain \(\Omega \) generated independently of the position of the interface \(\Gamma \) and let \({\widetilde{{\mathcal {V}}_h^r}}\) be the finite element space on \({\mathcal {T}}_h\) consisting of piecewise polynomials of degree at most r. We define the active meshes \({\mathcal {T}}_{h,i}\), the set of edges in each active mesh \({\mathcal {E}}_{h,i}\), and the set \({\mathcal {F}}_{h,i}\) where the stabilization is applied, \(i=1,2\), as in Sect. 3.1 but now \(I_j\) denotes a triangle in \({\mathcal {T}}_h\). The active finite element spaces are

$$\begin{aligned} {\mathcal {V}}_{h,i}^r={\widetilde{{\mathcal {V}}_h^r}}|_{{\mathcal {T}}_{h,i}}, \, i=1,2. \end{aligned}$$
(5.4)

and we let \({\mathcal {V}}_h^r={\mathcal {V}}_{h,1}^r \times {\mathcal {V}}_{h,2}^r\). Given the initial condition we find \(u_h(0)=u_h(\cdot ,0) \in {\mathcal {V}}_h^r\) such that

$$\begin{aligned} (u_h(x,y,0),v_h)_{\Omega _1\cup \Omega _2}+\gamma _MJ_1(u_h(x,y,0),v_h)=(f(x,y),v_h)_{\Omega _1\cup \Omega _2}, \quad \forall v_h \in {\mathcal {V}}_h^r. \end{aligned}$$
(5.5)

We propose the following weak formulation: Find \(u_h(\cdot , t) \in {\mathcal {V}}_h^r\) such that for almost all \(t \in (0,T]\)

$$\begin{aligned} \left( (u_h)_t,v_h \right) _{\Omega _1\cup \Omega _2}+\gamma _MJ_1((u_h)_t,v_h)+a_h(u_h,v_h)+\gamma _AJ_0(u_h,v_h)=0, \end{aligned}$$
(5.6)

for \(\forall v_h \in {\mathcal {V}}_h^r\). Here

$$\begin{aligned} a_h(u_h,v_h)&=- ({\mathbf {F}}(u_h), \nabla v_h)_{\Omega _1\cup \Omega _2} -\sum _{i=1}^{2}\sum _{e\in {\mathcal {E}}_{h,i}} (\{ {\mathbf {F}}(u_h) \cdot {\mathbf {n}}\}_e, [v_h]_e)_e-(\frac{\lambda _e}{2}[u_h]_e , [v_h]_e)_e \nonumber \\&\quad -\int _\Gamma \left( [{\mathbf {F}}(u_h) \cdot {\mathbf {n}}v_h]_\Gamma +[{\mathbf {F}}(u_h)]_\Gamma [\lambda v_h]_\Gamma \right) \ ds, \end{aligned}$$
(5.7)

and

$$\begin{aligned} J_s(u_h, v_h)=\sum _{i=1}^2\sum _{e \in {\mathcal {F}}_{h,i}} \sum _{k=0}^{r} \omega _kh^{2 k+s}\left( \left[ \partial ^ku_{h,i}\right] _e,\left[ \partial ^{k} v_{h,i}\right] _{e} \right) _e. \end{aligned}$$
(5.8)

5.2 Numerical Example

Let \(\Omega =[x_{\min }, x_{\max }] \times [y_{\min }, y_{\max }]\) and the interface \(\Gamma \) be the line \(x+y=c_0\) where \(c_0 \) is a constant. The subdomain \(\Omega _1=\{ (x,y) \in \Omega : x+y\le c_0\}\), \(\Omega _2=\{ (x,y) \in \Omega : x+y\ge c_0\}\). We choose \(x_{\min }=y_{\min }=-1\), \(x_{\max }=y_{\max }=1\), and \(c_0 > x_{\max }+y_{\min }\). The unit normal to \(\Gamma \) is \({\mathbf {n}}=\frac{1}{\sqrt{2}}(1,1)\) and the time step is chosen as \(\Delta t = \frac{0.5h}{ (2r+1)\max _\Omega (|{\mathbf {a}}|)}\) . The boundary conditions are

$$\begin{aligned}&u(x_{\min },y,t)=g(x_{\min },y,t), \end{aligned}$$
(5.9)
$$\begin{aligned}&u(x,y_{\min },t)=g(x,y_{\min },t), \end{aligned}$$
(5.10)
$$\begin{aligned}&\text {outflow BC on the remaining boundaries.} \end{aligned}$$
(5.11)

5.2.1 Convergence Study

Let \({\mathbf {a}}_1=(3,1)\) and \({\mathbf {a}}_2=(2,1)\) and set \(c_0=0.5\). A solution to Eq. (5.1) is

$$\begin{aligned} u_1(x,y,t)&=\sin (\pi (x+y-4t)), \quad (x,y)\in \Omega _1, \end{aligned}$$
(5.12)
$$\begin{aligned} u_2(x,y,t)&=\frac{4}{3}\sin (4/3\pi (x+y-3t-c_0/4)), \quad (x,y)\in \Omega _2, \end{aligned}$$
(5.13)

and with \(g = u_1\) it satisfies the boundary conditions. Note that on the interface, \(x+y=c_0\), we have \(u_1=\sin (\pi (c_0-4t))\) and \(u_2=\frac{4}{3}\sin (4/3\pi (3/4c_0-3t))\). Thus, the solution given by Eqs. (5.12)–(5.13) satisfies the interface condition (5.3).

We solve the problem on a uniform mesh until \(t=1\) with a time step \(\Delta t =0.5 h / ((2r+1) \sqrt{10})\) for \(r=1,2\), (i.e. P1, P2 elements) and \(h = 2/N_x\), with \(N_x=20,40,80,160,300\). In Fig. 14 we show the \(L^2\)-error versus mesh size h. The convergence order of the method follows the optimal order \(r + 1\).

Fig. 14
figure 14

The \(L^2\)-error at t = 1 versus mesh size h for the problem in Sect. 5.2.1 in two space dimensions. Polynomials of degree r = 1, 2 are used and convergence order r + 1 is obtained

5.2.2 Conservation Study

Let \({\mathbf {a}}_1=(3,1)\) and \({\mathbf {a}}_2=(1,2)\) and set \(c_0=0.25\) and denote \({\mathcal {C}}\) the circle with center \((-0.3,-0.3)\) and radius 0.3. We consider the initial condition

$$\begin{aligned} f(x,y)=&\left\{ \begin{array}{ll} 1 &{} \text{ if }~ (x,y) \in {\mathcal {C}},\\ 0 &{} \text{ else }, \end{array} \right. \end{aligned}$$

and boundary data \(g=0\). We solve this problem using the proposed scheme with \(r=1\) on a uniform mesh where \(N_x = N_y = 200\) and a time step defined as above. We use two different sets of penalty parameters \(\lambda _1\) and \(\lambda _2\) where the first set satisfies the conservation condition (3.20) while the second set does not. In Fig. 15 we show the numerical solution at different time instances with \(\lambda _i\), \(i=1,2\) satisfying the conservation condition. The mass concentrated in the circle \({\mathcal {C}}\) is away from the interface initially, but evolves and passes through the interface. In Fig. 16 we show that when penalty parameters satisfy (3.20), the method is conservative. In contrast, if the conservation condition is not satisfied, the conservation error can be large and increases significantly when the part with a mass reaches and passes through the interface. Note that the exact solution is not smooth, but with condition (3.20) the method is still conservative.

Fig. 15
figure 15

Solution obtained at different time instances for \(r=1\). Here we have chosen \(\lambda _1 = 0\) and \(\lambda _2 = -1\). The white line is the interface \(\Gamma \). Blue corresponds to \(u=0\), orange to \(u=1\) and red to \(u=4/3\)

Fig. 16
figure 16

Comparison of the conservation error for different choices of \(\lambda _i\)

6 Conclusion

We have presented two high order CutFEM based on the DG framework, applicable to conservation laws with discontinuous coefficients in the flux across stationary and moving interfaces, respectively. Our methods use standard DG-elements, but do not require the elements to be aligned with interfaces where coefficients are discontinuous. Ghost penalty stabilization is included in the weak forms to allow for similar time-step restrictions as in the standard DG approach. We have established discrete conservation, accuracy and stability for the methods. The proposed methods are described and analyzed in one-dimensional settings, but we also present computations in two dimensions for a stationary interface case, which demonstrates that the methodology can directly be extended to higher dimension.

The first method is based on a method of lines approach, and is an extension of the method in [10] to handle stationary material interfaces. The mass matrix appearing in the semi-discrete system is block-diagonal with most blocks as in the standard DG approach, but with one larger diagonal block, which couples the degrees of freedom associated with elements in the vicinity of the interface. The non-diagonal entries are caused partly by the contributions from integrals in the cut region, and partly by the ghost penalty stabilization, which couples elements cut by the interface with their neighbours. In one space dimension this coupling is not a big issue. However, one can produce a block-diagonal matrix with less coupling, in particular in higher dimension, by applying stabilization restrictively as proposed in [20]. Our focus in this work has been on the interface treatment and we developed CutFEM that are globally conservative. By changing the stabilization to the macro element stabilization in [20] our method would also preserve the local conservation property of the discontinuous Galerkin formulation on macro elements.

The second method is for moving interfaces. It is a space-time CutFEM based on discontinuous elements in both space and time. The method is stable and conservative, but implicit. In particular we have shown, numerically and analytically, that using a weak form based on integration by parts in time is essential for discrete conservation. Since we are using standard DG techniques as building blocks we believe that the extension of this method to multiple space dimensions is also straightforward. The implicit character of our space-time CutFEM is however a drawback. We demonstrate in a scalar case how a more efficient method can be achieved by using the space-time elements only locally in the vicinity of interfaces. This idea moves the difficulty from the non-aligned moving interface to a stationary aligned interface, where the space-time elements need to be coupled to standard method of lines DG methods while maintaining stability, accuracy and conservation.

In computations we have observed that the temporal accuracy is sometimes degraded in the coupled case, and more work is required to understand and avoid this degradation. We also believe that a more difficult extension is to generalize the coupling between space-time elements and the standard method-of lines DG methods to systems and to multi-dimensions, while maintaining stability, accuracy and conservation, and allowing for explicit time-stepping in large parts of the domain.