1 Introduction

Variable-coefficient problems arise in a wide variety of applications including geophysics (material heterogeneities in the solid Earth, spatially varying fluid properties in volcanic conduits), aeroacoustics (Euler equations), electromagnetics (Max-well’s equations with heterogeneous permeabilty and permittivity), and problems with complex geometries in which coordinate transformations are used [2, 8, 10, 14]. Coefficients can be pre-defined explicitly, or obtained through other means (such as the numerical solution of a steady-state equation) and can be non-smooth at known (or unknown) locations.

Exact solutions to the governing equations are often quite difficult to obtain in most applications, thus numerical solutions are sought in order to study the temporal evolution of the phenomena under consideration. Care should be taken, however, so that the discretization predicts an accurate approximation to the growth or decay that is physically present. In order to assess whether this is done, analytical solutions for canonical problems are an asset.

In this work we provide analytic solutions to the scalar and vector advection equation with variable wave speeds, which allow us to study the performance of a class of high-order-accurate finite difference methods satisfying a summation-by-parts (SBP) property [11, 12, 23]. SBP methods together with a weak enforcement of boundary conditions through the simultaneous-approximation-term (SAT) technique provide a framework for provably stable numerical discretizations for problems with sufficient smoothness properties and exist for a large class of operators including finite difference, finite volume and finite element methods, see [3, 21, 24] and references therein. We apply an SBP-SAT discretization to the governing equations using a skew-symmetric splitting, which mixes conservative and non-conservative forms, and for smooth problems has the desirable property that the semi-discrete energy rate mimics that of the continuous problem [4, 15, 19]. The technique of skew-symmetric splitting is widely used when solving a variety of challenging physical problems that involve variable coefficients, nonlinearities and shocks, including the nonlinear Burgers’ equation and the shallow water equations [5, 6, 20, 22].

When coefficients are non-smooth at known locations, they are often treated as interfaces, and numerical solutions are obtained within the sub-domains where the coefficients are smooth. See, for example, [14], for an overview of finite-volume methods applied to these types of problems. However, in practice these locations are not always known and it is unclear how these discretization methods perform when applied without some special procedure (such as an interface treatment) to problems with non-smooth wave speeds. In this paper we will experimentally investigate how accuracy and stability are affected when naively applying these operators to problems with discontinuous wave speeds, using new exact analytical solutions.

The paper is organized as follows: in Sect. 2 we derive the exact solution to the scalar advection equation with variable wave speed and introduce the skew-symmetric SBP-SAT framework for computing numerical approximations. Piecewise linear wave speeds (which are non-smooth in some cases) are considered and convergence rates with and without the incorporation of an interface are reported. In Sect. 3 we derive exact solutions to the vector advection equation, as well as derive the spectrum of the associated differential operator. The SBP-SAT framework for the vector problem is detailed, convergence rates are reported, and comparisons made between continuous and discrete spectra. We summarize our findings and discuss future studies in Sect. 4.

2 The Scalar Equation

We begin by considering the scalar advection equation in non-conservative form on the domain \(x \in [0, 1]\), namely

$$\begin{aligned} u_t + a(x)u_x&= 0 \end{aligned}$$
(1a)
$$\begin{aligned} u(t,0)&= h(t) \end{aligned}$$
(1b)
$$\begin{aligned} u(0,x)&= f(x). \end{aligned}$$
(1c)

In this work we seek continuous solutions to (1), assuming the wave speed \(a(x) > 0\) is potentially non-smooth, with an integrable reciprocal, i.e. that

$$\begin{aligned} I_a(x) = \int _{0}^x 1/a(y) dy \end{aligned}$$
(2)

exists. If a(x) is differentiable on (0, 1) (which is not true for all the cases we consider), we can apply the splitting

$$\begin{aligned} a(x)u_x = \frac{1}{2}\left[ (au)_x + a(x)u_x\right] - \frac{1}{2}a_x u \end{aligned}$$
(3)

and an energy estimate for (1) can be obtained by multiplying by u and integrating over the domain. Taking \(h(t) = 0\), this leads to

$$\begin{aligned} \frac{d||u||_2^2}{dt} = -a(1)u(t,1)^2 + \displaystyle \int _0^1 a_x u^2 dx. \end{aligned}$$
(4)

If \(a_x \in L ^\infty (0,1)\), we have the final estimate [19]

$$\begin{aligned} ||u(t,\cdot )||^2_2 \le e^{||a_x||_\infty t}\left[ ||f||^2_2 - \displaystyle \int _0^t a(1)e^{-||a_x||_\infty \tau }u^2(\tau ,1)d\tau \right] . \end{aligned}$$
(5)

Alternatively (for example, if a(x) is not differentiable), we can define the weighted norm

$$\begin{aligned} ||u||_{a^{-1}}^2 = \displaystyle \int _0^1 \frac{1}{a(x)} u^2(t,x) dx \end{aligned}$$
(6)

if \(a(x) \ge \kappa > 0\) (i.e. a(x) is bounded away from 0 by a constant \(\kappa \), which is true for all the cases we consider), which leads to the energy estimate

$$\begin{aligned} ||u(t,\cdot )||^2_{a^{-1}} = ||f||^2_{a^{-1}} - \displaystyle \int _0^t u^2(\tau ,1)d\tau . \end{aligned}$$
(7)

Energy estimates are useful for determining both location and number of boundary conditions needed to bound the solution, as well as provide a means for proving uniqueness of solutions to linear problems and insights into reasons for error-growth and error-boundedness, see [9, 17, 18]. In the section that follows we show existence (by construction) of a continuous solution to (1), and uniqueness and stability to perturbations in data follow from (5) or (7).

2.1 Analytic, Closed-Form Solution Via the Laplace Method

To solve (1) analytically, we start by denoting the Laplace transform of a locally integrable function h(t) by

$$\begin{aligned} {\mathcal {L}}[h] = \displaystyle \int _0^\infty h(t) e^{-st} \, dt, \quad s \in {\mathbb {C}}. \end{aligned}$$
(8)

Laplace transforming (1) in time and solving the resulting ordinary differential equation yields the solution in Laplace space given by

$$\begin{aligned} {\hat{u}}(s,x) = {\hat{h}}(s)e^{-sI_a(x)} + \displaystyle \int _{0}^x \frac{f(\xi )}{a(\xi )}e^{-s(I_a(x) - I_a(\xi ))}d\xi , \end{aligned}$$
(9)

where we use a hat to denote the Laplace transformed function. We denote the last term on the right of (9) by

$$\begin{aligned} F(s,x) = \displaystyle \int _{0}^x \frac{f(\xi )}{a(\xi )}e^{-s(I_a(x) - I_a(\xi ))}d\xi . \end{aligned}$$
(10)

Next we apply integration by substitution by letting

$$\begin{aligned} \tau = I_a(x)-I_a(\xi ), \end{aligned}$$
(11)

so that integration in (10) is with respect to \(\tau \) rather than \(\xi \). This allows us to re-write (10) as

$$\begin{aligned} F(s,x)&= \displaystyle \int _{0}^{I_a(x)} f(\xi )e^{-s \tau }d\tau \end{aligned}$$
(12)
$$\begin{aligned}&=\displaystyle \int _{0}^{\infty } f(\xi )H(\xi )e^{-s \tau }d\tau , \end{aligned}$$
(13)

where H is the Heaviside function and we understand that \(\xi = \xi (\tau ,x)\).

This procedure allows us to recognize that \(F(s,x) = {\mathcal {L}}[f(\xi )H(\xi )]\) where \(\xi \) is the characteristic variable defined implicitly through (11). Note that (11) should be interpreted as the time required to transport information a distance \(x-\xi \) at speed a(x). Inverting (9) thus provides the solution in the time domain

$$\begin{aligned} u(t,x) = h(t - I_a(x))H(t - I_a(x)) + f(\xi (t,x))H(\xi (t,x)). \end{aligned}$$
(14)

Note that (14) provides the solution in closed form if \(I_a(x)\) is invertible, in which case we can use (11) to solve for \(\xi (t,x)\), namely

$$\begin{aligned} \xi (t,x) = I_a^{-1}(I_a(x) - t). \end{aligned}$$
(15)

In the case of constant coefficients, we recover the well-known characteristic variable \(\xi (t, x) = x - at\).

2.1.1 An Example

The exact solution (14) requires the calculation of the characteristic variable \(\xi \), as well as \(I_a(x)\). As an illustration, consider a wave speed given by

$$\begin{aligned} a(x) = {\left\{ \begin{array}{ll} 1 + \epsilon x &{}\text{ if } 0 \le x < 1/2 \\ 1 + \epsilon /2 &{} \text{ if } 1/2 \le x \le 1 \end{array}\right. }, \end{aligned}$$
(16)

which is piecewise linear, non-smooth (at \(x = 1/2\)), and where \(\epsilon \) is a small, positive number. Then

$$\begin{aligned} I_a(x) = {\left\{ \begin{array}{ll} \frac{1}{\epsilon } \ln (1 + \epsilon x) &{}\text{ if } 0 \le x < 1/2 \\ \frac{1}{\epsilon } \ln (1 + \epsilon /2) + 1/(1+\epsilon /2)(x-1/2) &{} \text{ if } 1/2 \le x \le 1 \end{array}\right. }, \end{aligned}$$
(17)

and using (11) to solve for \(\xi \) yields

$$\begin{aligned} \xi (t,x) = {\left\{ \begin{array}{ll} \frac{(1 + \epsilon x)e^{-t\epsilon } - 1}{\epsilon } &{}\text{ if } 0 \le x < 1/2 \\ d(t,x) H\left( 1/2 - d(t,x)\right) \\ + (x - ct)H\left( x-ct - 1/2\right) &{} \text{ if } 1/2 \le x \le 1 \end{array}\right. }, \end{aligned}$$
(18)

where \(d(t,x) = \frac{1}{\epsilon }\left[ ce^{(\epsilon /c)(x-1/2) - \epsilon t} -1\right] \), and \(c = 1 + \epsilon /2\). Thus the exact solution (14) is known in closed form.

2.2 Discretization and Stability

To compute numerical solutions to (1), we consider finite difference methods satisfying a summation-by-parts (SBP) rule, with weak enforcement of boundary conditions through the simultaneous-approximation-term (SAT), which provide a provably stable, high-order accurate semi-discretization [1, 3, 11, 12, 23, 24]. These operators represent centered differences in the interior of the domain, with a transition to one-sided differences near the domain boundaries. We apply the diagonal norm SBP-SAT operators from [23] that have been derived with a formal order of accuracy given by \(p = 2, 3, 4\) and 5. These operators have an interior order of accuracy given by \(2p-2\) and boundary accuracy of \(p-1\). The operators are denoted by matrix \(\mathbf{D}\) which approximates \(\partial / \partial x\).

We let \(\mathbf{u} = \mathbf{u}(t)\) denote the grid vector approximating the function u(tx), i.e. \(u_i \approx u(t,x_i)\), where \(x_i = ih, i = 0, \ldots N\) is a discretization of the unit interval into \(N+1\) equidistantly-spaced grid points with grid spacing \(h = 1/N\). Now \(\mathbf{D} = \mathbf{H}^{-1}{} \mathbf{Q}\) where \(\mathbf{H}\) is a diagonal, positive definite matrix defining the discrete inner product and norm, given by

$$\begin{aligned} (\mathbf{u}, \mathbf{v})_\mathbf{H} = \mathbf{u}^T \mathbf{H} \mathbf{v}, \quad ||\mathbf{u}||_\mathbf{H}^2 = \mathbf{u}^T \mathbf{H} \mathbf{u}. \end{aligned}$$
(19)

The matrix \(\mathbf{Q}\) is almost skew-symmetric, i.e. \(\mathbf{Q} + \mathbf{Q}^T = \text {diag}[-1, \ldots \, 0, \, 0, \, 0,\ldots 1]\). This construction allows the integration-by-parts rule

$$\begin{aligned} \displaystyle \int _0^1 u \frac{dv}{dx} dx = u(1)v(1)-u(0)v(0) - \displaystyle \int _0^1 \frac{du}{dx} v dx \end{aligned}$$
(20)

to be mimicked discretely, namely

$$\begin{aligned} \mathbf{u}^T \mathbf{H} \mathbf{D}{} \mathbf{v} = u_N v_N-u_0 v_0 - (\mathbf{Du})^T \mathbf{H} \mathbf{v}. \end{aligned}$$
(21)

To explore convergence rates of high-order accurate SBP-SAT methods we apply the skew-symmetric discretization from [19] to Eq. (1), which will allow us to obtain a semi-discrete energy estimate mimicking (4). Note that we apply this method without any special procedure applied near points where wave speed a(x) might be non-smooth. The discretization is given by

$$\begin{aligned} \mathbf{u}_t + \frac{1}{2}\left[ \mathbf{AD} + \mathbf{DA}\right] \mathbf{u} - \frac{1}{2}{} \mathbf{UD}{} \mathbf{a}&= \sigma \mathbf{H}^{-1}( u_0-h(t))\mathbf{e}_0, \end{aligned}$$
(22a)
$$\begin{aligned} \mathbf{u}(0)&= \mathbf{f}, \end{aligned}$$
(22b)

where \(\mathbf{e}_0 = [1, \, 0, \, 0,\, \ldots ,\, 0]^T\) and f is the vector of initial data evaluated on the grid. The right side of (22a) represents the SAT term that enforces boundary condition (1b) weakly using the penalty parameter \(\sigma \). Matrix \(\mathbf{A}\) has the values of a(x) injected onto its diagonal, vector \(\mathbf{a}\) has values of a(x) evaluated at the grid, and matrix \(\mathbf{U}\) = diag\([u_0,\, u_1, \, \ldots u_N]\) so that \(\mathbf{UD}{} \mathbf{a} \approx a_x u\). Multiplying (22a) by \(\mathbf{u}^T \mathbf{H}\) (and taking \(h(t) = 0\)) and adding its transpose yields

$$\begin{aligned} \frac{d ||\mathbf{u}||^2_\mathbf{H}}{dt} = (a_0 + 2\sigma )u_0^2 - a_N u_N^2 + (\mathbf{u}, \mathbf{UD}{} \mathbf{a})_\mathbf{H}, \end{aligned}$$
(23)

which mimics (4) (exactly if \(\sigma = -a_0/2\)) and requires \(\sigma \le -a_0/2\) for stability. With grid refinement, (22) yields a semi-discrete energy rate (23) which converges to (4) for smooth coefficients.

2.3 Convergence Rates

We investigate the convergence rate of the scheme (22) using the analytic solution. Throughout this work we apply Matlab’s ode45, a fourth order accurate, adaptive Runge–Kutta time stepping scheme with error control. We set absolute and relative tolerances to \(10^{-12}\) to minimize temporal error accumulation. Letting \(\epsilon \) be a positive parameter, we consider four cases for a linearly varying wave speed a(x), namely \(a(x) = 1\), \( a(x) = 1 + \epsilon x\),

$$\begin{aligned} a(x)&= {\left\{ \begin{array}{ll} 1 &{}\text{ if } 0 \le x < 1/2 \\ 1 - \epsilon /2 + \epsilon x &{} \text{ if } 1/2 \le x \le 1, \end{array}\right. } \end{aligned}$$
(24)
$$\begin{aligned} a(x)&= {\left\{ \begin{array}{ll} 1 &{}\text{ if } 0 \le x < 1/2\\ 1 + \epsilon /2 &{} \text{ if } 1/2 \le x \le 1, \end{array}\right. } \end{aligned}$$
(25)

and refer to each, respectively, as case 1–4. Case 1 corresponds to constant a(x) and allows us to illustrate known results, while case 2 corresponds to \(a(x) \in C^\infty \). Case 3 represents \(a(x) \in C^0 \backslash C^1\), and case 4 represents wave speeds with a jump discontinuity, i.e. \(a(x) \notin C^0\). The exact solutions for all four cases are detailed in “Appendix A”.

Fig. 1
figure 1

Time snapshots of the exact solution (smooth curves) and numerical solution (dotted curves) for a piecewise linear wave speed corresponding to aa(x) constant (case 1) b\(a(x) \in C^\infty \) (case 2) c\(a(x) \in C^0 \backslash C^1\) (case 3) and d\(a(x) \notin C^0\) (case 4)

Fig. 2
figure 2

Time snapshots of absolute error, plotted in dashed lines, between the exact and numerical solutions for a piecewise linear wave speed corresponding to aa(x) constant (case 1) b\(a(x) \in C^\infty \) (case 2) c\(a(x) \in C^0 \backslash C^1\) (case 3) and d\(a(x) \notin C^0\) (case 4)

In Fig. 1 we take \(\epsilon = 0.8\) and plot the wave speed a(x) for all four cases, as well as the exact and numerical solution at various snapshots in time using SBP operators with \(p = 3\) and \(N = 2^7+1\) grid points. For this illustration, we have set the initial data to be a Gaussian, namely \(f(x) = e^{-(x-0.25)^2/.001}\), and boundary data \(h(t) = 0\). Figure 1a illustrates the standard results for constant wave speed (case 1), showing information propagating to the right at a constant speed, with initial data plotted in blue dots, and at later times in green and black dots. Figure 1b corresponds to \(a(x) \in C^\infty \) (case 2), where information travels at a faster rate (and is consequently spread out - as evidenced by the increasing width of the initial Gaussian) compared to the constant wave speed counterpart from Fig. 1a. Figure 1c corresponds to piecewise linear wave speeds \(a(x) \in C^0 \backslash C^1\) (case 3) which is not smooth at \(x = 1/2\). Once the information crosses this point it is propagated at an increasingly faster speed. Figure 1d corresponds to wave speeds with a jump discontinuity (case 4, with \(a(x) \notin C^0\)) and information travels at a constant, faster speed once information crosses \(x = 1/2\).

In Fig. 2 we plot the absolute error in space

$$\begin{aligned} \text {e}(t,x_i) = |u(t,x_i) - u_i(t)| \end{aligned}$$
(26)

at the same snapshots in time as in Fig. 1. Figure 2a reveals error growing in magnitude as the wave propagates at a constant speed. Figures 2b, c show similar features to that of Fig. 2a, but due to increasing wave speeds, information has reached the right boundary by \(t = 1/2\). For \(a(x) \notin C^0\) (case 4), Fig. 2d reveals error propagating backwards once information crosses \(x = 1/2\). This result is not unexpected as the use of centered difference approximations can propagate error in both directions.

Fig. 3
figure 3

Convergence rates for SBP operators with global order of accuracy \(p = 2, 3, 4, 5\) for a piecewise linear wave speed corresponding to aa(x) constant (case 1) b\(a(x) \in C^\infty \) (case 2) c\(a(x) \in C^0 \backslash C^1\) (case 3) and d\(a(x) \notin C^0\) (case 4). Total error computed at \(t = 1/2\). a, b give expected rates, while c reveals second order convergence for all p, and d reveals a drop to first order convergence for all p

Fig. 4
figure 4

Total error as a function of time, computed in the discrete \(\mathbf{H}\)-norm with \(N = 2^7 + 1\) gridpoints, for a piecewise linear wave speed corresponding to aa(x) constant (case 1) b\(a(x) \in C^\infty \) (case 2) c\(a(x) \in C^0 \backslash C^1\) (case 3) and d\(a(x) \notin C^0\) (case 4). Error remains bounded in time for all cases

We denote the total error in the discrete \(\mathbf{H}\)-norm at time t by

$$\begin{aligned} E(t) = ||u(t,\cdot ) - \mathbf{u}(t)||_\mathbf{H}, \end{aligned}$$
(27)

where \(u(t,\cdot )\) is the exact solution evaluated on the grid. In Fig. 3 we show convergence results, where the total error is computed at \(t = 1/2\), for SBP operators with \(p = 2, 3, 4, 5\). Figure 3a corresponds to constant wave speeds (case 1) and we observe convergence rates that are slightly higher than those theoretically predicted. Figure 3b corresponds to \(a(x) \in C^\infty \) (case 2) and reveals convergence at the theoretical rates. Wave speeds corresponding to \(a(x) \in C^0 \backslash C^1\) (case 3), show convergence rates drop to second order for all p, as seen in Fig. 3c. We also observe in Fig. 3c that for small N the total error is reduced with increasing p but that for large N the total error is only reduced when going from \(p = 2\) to \(p = 3\) (and not reduced further for higher order methods). Wave speeds with a jump discontinuity (case 4) show convergence rates drop to 1 for all p considered (consistent with theoretical estimates from [7, page 194]) as evidenced by Fig. 3d, and for large N the total error is not reduced at all with higher order methods.

We are also interested in how the total error evolves over longer time periods, thus we plot E(t) up to \(t = 3\) in Fig. 4 with \(N = 2^7 + 1\) grid points. Because the initial Gaussian pulse exits the domain by \(t = 1\), we modify the boundary data to send in periodic pulses, namely, we set the boundary data to be

$$\begin{aligned} h(t) = \displaystyle \sum _{j = 0}^5 e^{-(t-0.25(2j+1)^2/0.001}. \end{aligned}$$
(28)

Figure 4a–c show results from cases 1–3 and we see that increasing the order of accuracy decreases the maximum error levels (also evident in the convergence plots in Fig. 3a–c), and that error remains bounded for all time. Figure 4d corresponds to \(a(x) \notin C^0\) (case 4). Although the error remains bounded in time, maximum levels decrease when going from \(p = 2\) to \(p = 3\), but do not decrease further with even higher-order accurate methods. And as evidenced in Fig. 3d, with larger N we would not expect any decrease in maximum error level for increasing p. We found that although convergence rates drop to 2 for a piecewise linear wave speed \(a(x) \in C^0\backslash C^1\), error decreases with increasing p (at least on coarse grids) and error decreases on fine grids when increasing p from 2 to 3. For a piecewise constant wave speed with a jump discontinuity, there is some gain when increasing p from 2 to 3 on coarse grids, but no decrease in error on fine grids. In all cases we considered, we found that high order methods are still accurate even for wave speeds that contain discontinuities, and do no worse than the low-order methods. However, high-order methods come at a greater computational cost due to the wider stencil present and smaller time-step requirements.

2.3.1 Introducing an Interface

Theoretical convergence rates can be restored in the previous cases if an interface is placed at the location where the wave speed is non-smooth. However, keep in mind that in many practical applications this location is not known.

The wave speeds we consider in this section are non-smooth at \(x = 1/2\). Placing an interface here renders equation (1) a coupled set of equations (one on each side of the interface). On the left side of \(x = 1/2\) we have

$$\begin{aligned} u_t^L + a^L(x)u_x^L&= 0, \quad x \in (0, 1/2), \end{aligned}$$
(29a)
$$\begin{aligned} u^L(t,0)&= h(t), \end{aligned}$$
(29b)
$$\begin{aligned} u^L(0,x)&= f^L(x), \quad x \in (0, 1/2) \end{aligned}$$
(29c)

and on the right side we have

$$\begin{aligned} u_t^R + a^R(x)u_x^R&= 0, \quad x \in (1/2, 1) \end{aligned}$$
(30a)
$$\begin{aligned} u^R(t,1/2)&= u^L(t,1/2) \end{aligned}$$
(30b)
$$\begin{aligned} u^R(0,x)&= f^R(x), \quad x \in (1/2, 1). \end{aligned}$$
(30c)

Note that (30b) couples (29) and (30), enforcing continuity of the solution across the interface. Wave speeds \(a^L(x)\) and \(a^R(x)\) are defined and smooth everywhere on \(x \in [0, 1/2]\) and \(x \in [1/2, 1]\), respectively. For example, case 3 now refers the two wave speeds

$$\begin{aligned} a^L(x)&= 1 \end{aligned}$$
(31)
$$\begin{aligned} a^R(x)&= 1 + \epsilon x. \end{aligned}$$
(32)

Applying the energy method to (2930) (with \(h(t) = 0\)) as done in Sect. 2, yields the estimate

$$\begin{aligned} \frac{d \left( ||u^L||_2^2 + ||u^R||_2^2\right) }{dt}&= \left[ a^R(1/2) - a^L(1/2)\right] u^L(t,1/2)^2 + \nonumber \\&- a^R(1) u^R(t,1)^2 + \displaystyle \int _0^{1/2} a^L_x(u^L)^2 dx + \displaystyle \int _{1/2}^1 a^R_x(u^R)^2 dx. \end{aligned}$$
(33)

Note that the first term on the right of (33) vanishes for a continuous wave speed, corresponds to energy dissipation if \(a^R(1/2) < a^L(1/2)\) and to growth if \(a^R(1/2) > a^L(1/2)\).

To solve (29)–(30) numerically, we discretize each side of the domain with \(N/2+1\) grid points, namely

$$\begin{aligned} x_i^L = ih, \quad x_i^R = 1/2 + ih,\quad i = 0, \ldots , N/2\quad h = 1/N. \end{aligned}$$
(34)

Using the skew-symmetric discretization as before, the semi-discrete equations are given by the (coupled) initial value problem

$$\begin{aligned} \mathbf{u}^L_t + \frac{1}{2}\left[ \mathbf{A}^L\mathbf{D} + \mathbf{DA}^L\right] \mathbf{u}^L - \frac{1}{2}{} \mathbf{U}^L\mathbf{D}{} \mathbf{a}^L&= \sigma _1 \mathbf{H}^{-1}( u^L_0-h(t))\mathbf{e}_0 \nonumber \\&\quad + \sigma _2\mathbf{H}^{-1}(u^L_N-u^R_0)\mathbf{e}_N, \end{aligned}$$
(35a)
$$\begin{aligned} \mathbf{u}^R_t + \frac{1}{2}\left[ \mathbf{A}^R\mathbf{D} + \mathbf{DA}^R\right] \mathbf{u}^R - \frac{1}{2}{} \mathbf{U}^R\mathbf{D}{} \mathbf{a}^R&= \sigma _3 \mathbf{H}^{-1}(u^R_0- u^L_N)\mathbf{e}_0, \end{aligned}$$
(35b)
$$\begin{aligned} \mathbf{u}^L(0)&= \mathbf{f}^L, \end{aligned}$$
(35c)
$$\begin{aligned} \mathbf{u}^R(0)&= \mathbf{f}^R, \end{aligned}$$
(35d)

where vectors \(\mathbf{f}^L\) and \(\mathbf{f}^R\) are f(x) evaluated at the left and right grids, respectively. The energy method applied to (35) (taking \(h(t) = 0\)) yields

$$\begin{aligned} \frac{d \left( ||\mathbf{u}^L||_\mathbf{H}^2 + ||\mathbf{u}^R||_\mathbf{H}^2\right) }{dt} =\,&(\mathbf{u}^L,\mathbf{U}^L\mathbf{Da}^L)_\mathbf{H} + (\mathbf{u}^R,\mathbf{U}^R\mathbf{Da}^R)_\mathbf{H}+ (a_0^L + 2\sigma _1)(u^L_0)^2\nonumber \\&- a_N^R (u^R_N)^2 + (a_0^R - a_N^L)(u_N^L)^2 + \mathbf{y}^T\mathbf{M}{} \mathbf{y} \end{aligned}$$
(36)

where matrix \(\mathbf{M} = \begin{bmatrix} -a^0_R + 2\sigma _2 \quad&-\sigma _2 - \sigma _3\ -\sigma _2 - \sigma _3&2\sigma _3 + a_0^R \end{bmatrix}\) and vector \(\mathbf{y} = [u^L_N\quad u^R_0]^T\). We take \(\sigma _1 = -a^L_0/2\) so that the continuous energy estimate (33) is mimicked exactly, with some added dissipation if \(\mathbf{M}\) is negative semi-definite. This is true with the choice \(\sigma _2 = 0, \sigma _3 = -a_0^R\), corresponding to fully up-winding at the interface. See [13] for a discussion of other choices of penalty parameters. With the interface present, Fig. 5 shows that the theoretical convergence rates are recovered, and Fig. 6 shows that the total error in the \(\mathbf{H}\)-norm is reduced in all cases when using higher order methods.

Fig. 5
figure 5

Convergence rates after introducing an interface, for SBP operators with global order of accuracy \(p = 2, 3, 4, 5\), for a piecewise linear wave speed corresponding to aa(x) constant (case 1) b\(a(x) \in C^\infty \) (case 2) c\(a(x) \in C^0 \backslash C^1\) (case 3) and d\(a(x) \notin C^0\) (case 4). Total error computed at \(t = 1/2\). By introducing an interface the theoretical convergence rates are obtained in all cases

Fig. 6
figure 6

Total error as a function of time after introducing an interface, for \(N = 2^7+2\) total grid points, computed in the discrete \(\mathbf{H}\)-norm for a piecewise linear wave speed corresponding to aa(x) constant (case 1) b\(a(x) \in C^\infty \) (case 2) c\(a(x) \in C^0 \backslash C^1\) (case 3) and d\(a(x) \notin C^0\) (case 4). Error remains bounded in time, with maximum levels reduced with higher order methods in all cases

3 The Vector Equation

Next, we consider the linear system of equations in non-conservative form

$$\begin{aligned} u_t + a(x)u_x&= 0, \end{aligned}$$
(37a)
$$\begin{aligned} v_t - b(x)v_x&= 0, \end{aligned}$$
(37b)

where \(a(x), b(x) > 0\), \(x \in (0, 1)\) and \(t \ge 0\). For simplicity in the analysis, we assume non-zero initial data for u, and zero initial data for v (non-zero initial data for v can be included but increases the complexity of the constructed analytical solution). Thus we take

$$\begin{aligned} u(0,x)&= f(x), \end{aligned}$$
(38a)
$$\begin{aligned} v(0,x)&= 0, \end{aligned}$$
(38b)

and boundary conditions given by

$$\begin{aligned} u(t,0)&= \alpha v(t,0), \end{aligned}$$
(39a)
$$\begin{aligned} v(t,1)&= \beta u(t,1), \end{aligned}$$
(39b)

where \(\alpha = \sqrt{b(0)/a(0)}\) and \(\beta = \sqrt{a(1)/b(1)}\) are chosen so that the boundary terms in the continuous energy estimate cancel exactly.

Multiplication of (37) by uv (respectively), and integrating over the domain yields the energy estimate (if \(a_x, b_x \in L^\infty (0,1)\))

$$\begin{aligned} \frac{d}{dt} \left( ||u||_2^2 + ||v||_2^2\right) = \displaystyle \int _0^1 (a_x u^2 - b_x v^2) dx. \end{aligned}$$
(40)

Alternatively, as done in the scalar case, we can compute the energy estimate using a weighted norm, which yields

$$\begin{aligned} \frac{d}{dt} \left( ||u||_{a^{-1}}^2 + ||v||_{b^{-1}}^2\right) = (\alpha ^2-1)v^2(t,0) + (\beta ^2 - 1)u^2(t,1) \end{aligned}$$
(41)

Note that (40) illustrates that for constant wave speeds, the energy is conserved. The relation (41) illustrates how energy growth/decay is dictated by the boundary conditions: \(\alpha , \beta > 1\) dictates energy growth, while for \(\alpha , \beta < 1\) there is energy decay. As we will see from the spectrum (computed in the next section), growth/decay of solutions is more specifically dictated by the sign of \(\ln (\alpha \beta )\).

3.1 The Continuous Spectrum

To compute the continuous spectrum for (37)–(39) we set initial data for u and v to zero (i.e. we also take \(f(x) = 0\) in (38)), and we define \(I_a(x), I_b(x)\) by (2). Laplace transforming (37)–(38) in time yields the system of differential equations

$$\begin{aligned} s{\hat{u}} + a(x){\hat{u}}_x&= 0, \end{aligned}$$
(42a)
$$\begin{aligned} s{\hat{v}} - b(x){\hat{v}}_x&= 0, \end{aligned}$$
(42b)

which corresponds to

$$\begin{aligned} s\begin{bmatrix} {\hat{u}} \\ {\hat{v}} \end{bmatrix} - {\mathcal {D}}\begin{bmatrix} {\hat{u}} \\ {\hat{v}} \end{bmatrix} = 0, \quad {\mathcal {D}} = \begin{bmatrix} -a(x)\partial / \partial x&\quad 0 \\ 0&\quad b(x) \partial / \partial x \end{bmatrix}. \end{aligned}$$
(43)

Thus s corresponds to the eigenvalues of the differential operator \({\mathcal {D}}\).

The solution to (42) are the functions

$$\begin{aligned} {\hat{u}}(s,x)&= C_1(s) e^{-sI_a(x)}, \end{aligned}$$
(44a)
$$\begin{aligned} {\hat{v}}(s,x)&= C_2(s) e^{+sI_b(x)}, \end{aligned}$$
(44b)

where \(e^{-sI_a(x)}\) and \(e^{+sI_b(x)}\) are the eigenfunctions of \({\mathcal {D}}\). To solve for the unknown constants in (44) we insert boundary conditions (39), yielding the linear system \(A(s)c(s) = 0\), where matrix

$$\begin{aligned} A(s) = \begin{bmatrix} 1&\quad -\alpha \\ \beta e^{-sI_a(1)}&\quad -e^{+sI_b(1)} \end{bmatrix}, \end{aligned}$$
(45)

and vector \(c(s) = [C_1(s) \,\, C_2(s)]^T\). Non-trivial solutions for \(C_1(s), C_2(s)\) will exist when det \(A(s) = 0\). This occurs for discrete eigenvalues \(s_n\) given by

$$\begin{aligned} s_n = \frac{2\pi n i + \ln (\alpha \beta )}{I_a(1) + I_b(1)}, \quad \text {for} \, n \in {\mathbb {Z}}. \end{aligned}$$
(46)

These eigenvalues form the spectrum of operator \({\mathcal {D}}\), and lie on a vertical line in the complex plane, corresponding to \(\eta _c\) = Re(\(s_n\)) \(= \ln (\alpha \beta ) / \left[ I_a(1) + I_b(1)\right] \). Since \(I_a(1), I_b(1) > 0\), the sign of \(\eta _c\) is determined by the sign of \(\ln (\alpha \beta )\).

3.2 Construction of the Analytic Solution

For general initial data f(x), solutions to Eqs. (37)–(38) in Laplace space take the form

$$\begin{aligned} {\hat{u}}(s,x)&= C_1(s) e^{-sI_a(x)} + F(s,x), \end{aligned}$$
(47a)
$$\begin{aligned} {\hat{v}}(s,x)&= C_2(s) e^{+sI_b(x)}, \end{aligned}$$
(47b)

where F(sx) is defined by (10). Applying the boundary conditions (39) allows us to solve for the coefficients

$$\begin{aligned} C_1(s)&= R(s)\displaystyle \int _0^1 \frac{f(w)}{a(w)}e^{sI_a(w)} \, dw, \end{aligned}$$
(48)
$$\begin{aligned} C_2(s)&= C_1(s) / \alpha , \end{aligned}$$
(49)

where

$$\begin{aligned} R(s) = \frac{\alpha \beta e^{-sI_a(1)}}{e^{sI_b(1)} - \alpha \beta e^{-sI_a(1)}} . \end{aligned}$$
(50)

Now R(s) can be expressed as the geometric series

$$\begin{aligned} R(s)&= \displaystyle \sum _{n=0}^\infty \left[ \alpha \beta e^{-s(I_a(1) + I_b(1))} \right] ^{n+1} = \displaystyle \sum _{n=1}^\infty (\alpha \beta )^{n} e^{-st_n} \end{aligned}$$
(51)

where

$$\begin{aligned} t_n = n(I_a(1) + I_b(1)), \end{aligned}$$
(52)

which converges for

$$\begin{aligned} \text {Re}(s) > \frac{\ln (\alpha \beta )}{I_a(1) + I_b(1)}. \end{aligned}$$
(53)

Note that (53) corresponds to the half-plane to the right of the line of eigenvalues \(s_n\) given by (46). Relation (52) corresponds to the time it takes information to travel across the domain and back at speeds a(x), b(x) (respectively) n times.

Substituting (5152) into (47) we re-write the solution as

$$\begin{aligned} {\hat{u}}(s,x)&= \displaystyle \sum _{n = 1}^\infty (\alpha \beta )^n\displaystyle \int _0^1 \frac{f(\omega _n)}{a(\omega _n)}e^{-s(I_a(x)-I_a(\omega _n)+t_n)} d\omega _n + F(s,x), \end{aligned}$$
(54a)
$$\begin{aligned} {\hat{v}}(s,x)&= \frac{1}{\alpha } \displaystyle \sum _{n = 1}^\infty (\alpha \beta )^n\displaystyle \int _0^1 \frac{f(\gamma _n)}{a(\gamma _n)}e^{-s(-I_b(x)-I_a(\gamma _n)+t_n)} d\gamma _n. \end{aligned}$$
(54b)
Fig. 7
figure 7

Four cases of piecewise linear wave speeds, where a(x), b(x) are a constant, b\(\in C^\infty \)c\(\in C^0 \backslash C^1\) and d\(\notin C^0\)

Inverse Laplace transforming (54) (applying the same substitution techniques used in Sect. 2) yields the solution in the time domain

$$\begin{aligned} u(t,x)&= f(\xi )H(\xi ) + \displaystyle \sum _{n=1}^\infty (\alpha \beta )^{n}f(\omega _n)H(\omega _n)H[t - (t_n + I_a(x) - I_a(1))], \end{aligned}$$
(55a)
$$\begin{aligned} v(t,x)&= \frac{1}{\alpha }\displaystyle \sum _{n=1}^\infty (\alpha \beta )^{n} f(\gamma _n)H(\gamma _n)H[t - (t_n - I_b(x) - I_a(1))], \end{aligned}$$
(55b)

where \(\xi , \omega _n, \gamma _n\) are characteristic variables defined implicitly through the relations

$$\begin{aligned} I_a(\xi )&= I_a(x) - t, \end{aligned}$$
(56a)
$$\begin{aligned} I_a(\omega _n)&= I_a(x) + t_n - t, \end{aligned}$$
(56b)
$$\begin{aligned} I_a(\gamma _n)&= -I_b(x) + t_n - t. \end{aligned}$$
(56c)

Note that (55) provides the solution in closed form and further illustrates that solutions decay if \(\alpha \beta < 1\) (corresponding to \(\eta _c < 0\)), grow if \(\alpha \beta > 1\) (corresponding to \(\eta _c > 0\)) and neither grow nor decay if \(\alpha \beta = 1\) (corresponding to \(\eta _c = 0\)).

In practice, to evaluate the exact solution (55) up to a specified time T, we use (52) to find the smallest \(k \in {\mathbb {N}}\) such that both \(T - \left( t_k + I_a(x) - I_a(1)\right) < 0\) and \(T - \left( t_k - I_b(x) - I_a(1)\right) < 0\) holds for all \(x \in [0, 1]\), then truncate the series in (55) at \(n = k\).

Fig. 8
figure 8

Time snapshots of the numerical solutions u and v (plotted in blue circles and red dots, respectively) for wave speeds aa(x), b(x) constant b\(a(x), b(x) \in C^\infty \)c\(a(x), b(x) \in C^0 \backslash C^1\), and d\(a(x), b(x) \notin C^0\)

3.2.1 An Example

To illustrate how to construct the analytic solution, we consider wave speeds that vary as

$$\begin{aligned} a(x)&= {\left\{ \begin{array}{ll} 1 - \epsilon x &{}\text{ if } 0 \le x < 1/2 \\ 1 - \epsilon /2 &{} \text{ if } 1/2 \le x \le 1 \end{array}\right. } \end{aligned}$$
(57)
$$\begin{aligned} b(x)&= {\left\{ \begin{array}{ll} 1 + \epsilon x &{}\text{ if } 0 \le x < 1/2 \\ 1 + \epsilon /2 &{} \text{ if } 1/2 \le x \le 1 \end{array}\right. }, \end{aligned}$$
(58)

which are piecewise linear, non-smooth (at \(x = 1/2\)), and where \(\epsilon \) is a small, positive number. Solving (56) for \(\xi , \omega _n\) and \(\gamma _n\) (which requires \(I_a, I_b\) to be invertible) yields

$$\begin{aligned} \xi (t,x)&= {\left\{ \begin{array}{ll} -(1/\epsilon )(1-\epsilon x)e^{\epsilon t - 1} &{}\text{ if } 0 \le x < 1/2 \\ -d_1(t,x)H\left( 1/2 +d_1(t,x)\right) \\ \quad +(x-t/c_1)H\left( x-t/c_1 - 1/2\right) &{} \text{ if } 1/2 \le x \le 1 \end{array}\right. }, \end{aligned}$$
(59)
$$\begin{aligned} \omega _n(t,x)&= \xi (t-t_n,x), \end{aligned}$$
(60)
$$\begin{aligned} \gamma _n(t,x)&= {\left\{ \begin{array}{ll} \frac{1}{\epsilon }(1 + \epsilon x + e^{\epsilon (t_n-t)})/(1 + \epsilon x)&{}\text{ if } 0 \le x < 1/2 \\ d_2(t,x) H\left( 1/2 -d_2(t,x)\right) \\ \quad + d_3(t,x)H\left( d_3(t,x) - 1/2\right) &{} \text{ if } 1/2 \le x \le 1 \end{array}\right. }, \end{aligned}$$
(61)

where

$$\begin{aligned} d_1(t,x) =&\frac{1}{\epsilon }\left[ c_1e^{-\epsilon (x-1/2)/c_1 + \epsilon t} -1 \right] , \end{aligned}$$
(62)
$$\begin{aligned} d_2(t,x) =&\frac{1}{\epsilon }\left[ ce^{c(x-1/2) - \epsilon (t_n-t)}-1\right] , \end{aligned}$$
(63)
$$\begin{aligned} d_3(t,x) =&(x-(t_n-t)/c), \end{aligned}$$
(64)

\(c_1 = 1-\epsilon /2\) and \(c = 1 + \epsilon /2\) (as in Sect. 2). These characteristic variables, along with \(I_a(x), I_b(x)\) (which are easily computable), allow us to form the exact solution (55).

3.3 The Numerical Approximation for the System

We again discretize the domain using \(N+1\) gridpoints, and apply the skew-symmetric SBP-SAT discretization of [19] to (3739) given by

$$\begin{aligned} \mathbf{u}_t + \frac{1}{2}\left[ \mathbf{AD} + \mathbf{DA}\right] \mathbf{u} - \frac{1}{2}{} \mathbf{UD}{} \mathbf{a}&= \sigma _L\mathbf{H}^{-1}(u_0 - \alpha v_0)\mathbf{e}_0, \end{aligned}$$
(65a)
$$\begin{aligned} \mathbf{v}_t - \frac{1}{2}\left[ \mathbf{BD} + \mathbf{DB}\right] \mathbf{v} + \frac{1}{2}{} \mathbf{VD}{} \mathbf{b}&= \sigma _R\mathbf{H}^{-1}(v_N - \beta u_N)\mathbf{e}_N, \end{aligned}$$
(65b)

where \(\mathbf{e}_N = [0, \, 0, \, \ldots ,\, 0,\, 1]^T\), \(\sigma _L, \sigma _R\) are penalty parameters, and all other terms are defined in Sect. 2. The discrete energy method applied to (65) yields

$$\begin{aligned} \frac{d\left( ||\mathbf{u}||_\mathbf{H}^2 + ||\mathbf{v}||_\mathbf{H}^2 \right) }{dt} = (\mathbf{u},\mathbf{UDa})_\mathbf{H} - (\mathbf{v},\mathbf{VDb})_\mathbf{H} + \mathbf{y}_0^T \mathbf{M}_0 \mathbf{y}_0 + \mathbf{y}_N^T \mathbf{M}_N \mathbf{y}_N \end{aligned}$$
(66)

where vectors \(\mathbf{y}_0^T = [u_0 \quad v_0]\), \(\mathbf{y}_N^T = [u_N \quad v_N]\) and matrices

$$\begin{aligned} \mathbf{M}_0 = \begin{bmatrix} a_0 + 2\sigma _L \quad&-\alpha \sigma _L\\ -\alpha \sigma _L&-b_0 \end{bmatrix}, \quad \mathbf{M}_N = \begin{bmatrix} -a_N&-\beta \sigma _R\\ -\beta \sigma _R&\quad b_N + 2\sigma _R \end{bmatrix}. \end{aligned}$$

The semi-discrete estimate (66) mimics the continuous (40), with some additional damping by choosing penalty parameters \(\sigma _L = -a_0\), \(\sigma _R = -b_N\) which render \(\mathbf{M}_0\) and \(\mathbf{M}_N\) negative semi-definite.

As in Sect. 2, we consider four cases of piecewise linear wave speeds a(x), b(x) with different smoothness conditions. Constant wave speeds will always correspond to eigenvalues with \(\eta _c = 0\), while non-constant coefficients can generate eigenvalues \(s_n\) with real part \(\eta _c\) in either the left or right half planes, or on the imaginary axis.

3.4 Convergence Rates

To verify convergence of the method, we consider wave speeds illustrated in Fig. 7, the latter three corresponding to \(\eta _c < 0\). These are given by case 1, with \(a(x) = b(x) = 1\), case 2 with \(a(x), b(x) \in C^\infty \), defined by \(a(x) = 1-\epsilon x\), \(b(x) = 1 + \epsilon x\). Case 3 corresponds to \(a(x), b(x) \in C^0 \backslash C^1\), namely

$$\begin{aligned} a(x)&= {\left\{ \begin{array}{ll} 1-\epsilon x &{}\text{ if } 0 \le x < 1/2 \\ 1 - \epsilon /2 &{} \text{ if } 1/2 \le x \le 1, \end{array}\right. } \end{aligned}$$
(67)
$$\begin{aligned} b(x)&= {\left\{ \begin{array}{ll} 1+\epsilon x &{}\text{ if } 0 \le x < 1/2 \\ 1 + \epsilon /2 &{} \text{ if } 1/2 \le x \le 1, \end{array}\right. }, \end{aligned}$$
(68)

and case 4, corresponding to \(a(x), b(x) \notin C^0\), namely

$$\begin{aligned} a(x)&= {\left\{ \begin{array}{ll} 1 &{}\text{ if } 0 \le x < 1/2 \\ 1 - \epsilon /2 &{} \text{ if } 1/2 \le x \le 1, \end{array}\right. } \end{aligned}$$
(69)
$$\begin{aligned} b(x)&= {\left\{ \begin{array}{ll} 1 &{}\text{ if } 0 \le x < 1/2 \\ 1 + \epsilon /2 &{} \text{ if } 1/2 \le x \le 1 \end{array}\right. }. \end{aligned}$$
(70)

The exact solutions for all four cases are detailed in “Appendix A”.

Fig. 9
figure 9

Convergence rates for SBP operators with order of accuracy \(p = 2, 3, 4, 5\) for four cases of piecewise linear wave speeds a(x), b(x) that are a constant (case 1) b\(\in C^\infty \) (case 2) c\(\in C^0 \backslash C^1\) (case 3) and d\(\notin C^0\) (case 4). Total error computed at \(t = 2\). a, b reveal convergence at the expected rates, while rates drop to second order for (c) and first order for (d)

We take \(\epsilon = 0.8\), and initialize the problem by

$$\begin{aligned} f(x)&= 1/2e^{-(x-0.25)/0.001} + e^{-(x-0.75)/0.001} \end{aligned}$$
(71)
$$\begin{aligned} g(x)&= 0, \end{aligned}$$
(72)

i.e. f(x) is the sum of two Gaussians of different heights (to facilitate their tracking in time). In Fig. 8 we plot the numerical solutions at constant time increments, with approximations to u shown in blue circles and to v shown in red dots. Figure 8a is a proof of concept result for constant wave speeds. The two initial pulses that form u (in blue circles) propagate to the right at which point v (in red dots) reflects off the right boundary and propagates to the left. There is no dissipation of energy since \(\eta _c = 0\). In contrast, Fig. 8b illustrates how u (in blue circles) initially propagates to the right more slowly (and the initial pulses narrow) than in the case of constant coefficients, because a(x) is a decreasing function. v (in red dots) reflects off the right boundary with a decreased amplitude (because \(\beta < 0\)), and the reflected red pulse is wider because \(b(x) > a(x)\). Figure 8c–d also reveal reflections off the right boundary with decreased amplitude (again because \(\beta < 0\)), and the pulse narrows or widens depending on the value of the wave speed carrying it. These latter three cases correspond to energy dissipation, as \(\eta _c < 0\), which we will illustrate in more detail in the next section.

We again compute the error in the discrete \(\mathbf{H}\)-norm, this time at \(t = 2\). Results are given in Fig. 9 for the four cases of wave speeds. Constant wave speeds (case 1) and smoothly linearly varying wave speeds (case 2) yield the standard convergence results. As in the scalar case, wave speeds with \(a(x), b(x) \in C^0 \backslash C^1\) (case 3) and \(a(x), b(x) \notin C^0\) (case 4) reveal convergence rates reduced to 2 and 1, respectively.

Figure 9 also reveals that for smooth coefficients (cases 1 and 2), the error is reduced when increasing p. However, for large N and wave speeds \(a(x), b(x) \in C^0 \backslash C^1\) (case 3), the error is reduced when increasing p from 2 to 3 to 4, but there is no decrease with \(p = 5\). With \(a(x), b(x) \notin C^0\) (case 4), there is some gain in increasing p from 2 to 3, but not to 4 or 5. In summary, as found in the scalar case the higher order methods are still accurate when wave speeds contain discontinuities and do no worse than the lower order methods except that higher-order methods come at a greater computational cost due to the wider stencil present and smaller time step requirements.

Theoretical convergence rates can be reinstated as in the scalar case if interfaces are placed where the wave speeds are not smooth (i.e. at \(x = 1/2\)). The details for incorporating an interface are given in “Appendix B”.

3.5 Comparing Continuous and Discrete Spectra

Next we compute the discrete spectrum for the semi-discrete equations with and without an interface. For the equations without an interface, for example, we re-write (65) as

$$\begin{aligned} \mathbf{Y}_t - \varvec{{\mathcal {D}}}_h \mathbf{Y} =\mathbf{0}, \end{aligned}$$
(73)

where \(\mathbf{Y}^T = [\mathbf{u}^T\quad \mathbf{v}^T]\) and

$$\begin{aligned} \varvec{{\mathcal {D}}}_h = \begin{bmatrix} \mathbf{M}_a&\quad 0 \\ 0&\quad \mathbf{M}_b \end{bmatrix} + \begin{bmatrix} \mathbf{H}^{-1}&\quad 0 \\ 0&\quad \mathbf{H}^{-1} \end{bmatrix}{} \mathbf{S}, \end{aligned}$$

for

$$\begin{aligned} \mathbf{M}_a&= -\frac{1}{2}\left[ \mathbf{AD} + \mathbf{DA}\right] + \frac{1}{2}\text {diag}(\mathbf{Da}), \end{aligned}$$
(74)
$$\begin{aligned} \mathbf{M}_b&=\frac{1}{2}\left[ \mathbf{BD} + \mathbf{DB}\right] - \frac{1}{2}\text {diag}(\mathbf{Db}), \end{aligned}$$
(75)

and penalty matrix \(\mathbf{S}\) (of size \(2N \times 2N\)), a matrix of all zeros except with \(\sigma _L\) in the (1, 1) position, \(-\alpha \sigma _L\) in the (1, N) position, \(-\beta \sigma _R\) in the (2NN) position, and \(\sigma _R\) in the (2N, 2N) position. The eigenvalues of \(\varvec{{\mathcal {D}}}_h\) thus constitute the spectrum of the discrete operator. The discrete spectrum for the semi-discrete equations with an interface, given in (97), can be computed similarly.

We are interested in how well the discrete spectrum approximates that of the continuous operator, when \(\eta _c\) lies in different regions of the complex plane. Specifically, we want to explore in which cases dissipative strict stability is obtained. A strictly stable method is one for which the growth/decay rate of the discrete scheme converges to the growth/decay rate of the continuous problem [16]. This is important for long-time calculations so that high frequency errors do not grow and destroy the accuracy, see [16] for more details. We say it is of dissipative type if the eigenvalues of discrete operator converge to the continuous ones from the left hand side. Convergence from the left is important since our discretization should not allow for growth at a rate faster than that predicted by the physical problem.

Fig. 10
figure 10

Continuous spectrum (plotted in blue stars) for linearly varying wave speeds corresponding to \(\eta _c = 0\). Discrete spectra also shown, for increasing N, for a(x), b(x) a constant (case 1), b\(\in C^\infty \) (case 2), c\(\in C^0 \backslash C^1\) (case 3) and d\(\notin C^0\) (case 4)

We consider four cases of linearly-varying wave speeds corresponding to either \(\eta _c = 0, \eta _c < 0\), or \(\eta _c > 0\). As an initial study we consider constant wave speeds \(a(x) = b(x) = 1\) (corresponding to \(\eta _c = 0\)) and refer to this as case 1 throughout this section. In Fig. 10a we plot the continuous spectrum \(s_n\) in blue stars, along with the discrete spectra for \(p = 3\) and different numbers of grid points N. Increasing N shows convergence to the continuous spectrum from the left, an indication of dissipative strict stability.

Next, we consider linearly varying wave speeds with \(\eta _c = 0\), with case 2 referring to \(a(x) = b(x) = 1-\epsilon x\), case 3 referring to

$$\begin{aligned} a(x) = b(x) = {\left\{ \begin{array}{ll} 1 - \epsilon x &{}\text{ if } 0 \le x < 1/2 \\ 1 - \epsilon /2 &{} \text{ if } 1/2 \le x \le 1 \end{array}\right. }, \end{aligned}$$
(76)

and case 4 referring to

$$\begin{aligned} a(x) = b(x) = {\left\{ \begin{array}{ll} 1 &{}\text{ if } 0 \le x < 1/2 \\ 1 - \epsilon /2 &{} \text{ if } 1/2 \le x \le 1 \end{array}\right. }. \end{aligned}$$
(77)

We again plot the continuous and discrete spectra for increasing N and \(\epsilon = 0.8\), shown in Fig. 10b–d. This time, wave speeds \(a(x), b(x) \in C^\infty \) (case 2) and with a discontinuous derivative (case 3) reveal convergence from the left. A discontinuous wave speed (case 4) results in discrete eigenvalues that have positive real parts, indicating that dissipative strict stability is not obtained. Because \(\eta _c = 0\), this in fact corresponds to an instability. Note that energy estimate (40) does not apply for discontinuous coefficients, thus there is no (or a very weak) theoretical bound and instabilities cannot be ruled out. The eigenvalues that lie to the right of the imaginary axis in Fig. 10d correspond to unstable modes that are associated with poorly resolved eigenfunctions. While not explored in the present study, a sufficient amount of artificial dissipation could be added to the scheme to push these unstable modes to the left half-plane and stabilize the scheme.

Next we consider the non-constant, linearly varying wave speeds with \(\eta _c < 0\), defined in Sect. 3.4 (cases 2-4), again with \(\epsilon = 0.8\). Figure 11 shows continuous and discrete spectra for wave speeds \(a(x), b(x) \in C^\infty \) (case 2) and convergence from the left is observed. Fig. 11b, c show similar plots for \(a(x), b(x) \in C^0 \backslash C^1\) (case 3) and \(a(x), b(x) \notin C^0\) (case 4), respectively. The discrete spectrum for both of these cases lies in the left half plane (an indication of stability), however, some are to the right of the continuous, indicating that dissipative strict stability is no longer obtained.

Fig. 11
figure 11

Continuous spectrum (plotted in blue stars) for linearly varying wave speeds corresponding to \(\eta _c < 0\). Discrete spectra also shown, for increasing N, for a(x), b(x) a\(\in C^\infty \) (case 2), b\(\in C^0 \backslash C^1\) (case 3) and c\(\notin C^0\) (case 4)

As a final study, we consider linearly varying wave speeds with \(\eta _c > 0\), with case 2 now referring to \(a(x) = 1 + \epsilon x, b(x) = 1 - \epsilon x\), case 3 referring to

$$\begin{aligned} a(x)&= {\left\{ \begin{array}{ll} 1 + \epsilon x &{}\text{ if } 0 \le x < 1/2 \\ 1 + \epsilon /2 &{} \text{ if } 1/2 \le x \le 1 \end{array}\right. }, \end{aligned}$$
(78a)
$$\begin{aligned} b(x)&= {\left\{ \begin{array}{ll} 1 - \epsilon x &{}\text{ if } 0 \le x < 1/2 \\ 1 - \epsilon /2 &{} \text{ if } 1/2 \le x \le 1 \end{array}\right. }, \end{aligned}$$
(78b)

and case 4 referring to

$$\begin{aligned} a(x)&= {\left\{ \begin{array}{ll} 1 &{}\text{ if } 0 \le x < 1/2 \\ 1 + \epsilon /2 &{} \text{ if } 1/2 \le x \le 1 \end{array}\right. }, \end{aligned}$$
(79a)
$$\begin{aligned} b(x)&= {\left\{ \begin{array}{ll} 1 &{}\text{ if } 0 \le x < 1/2 \\ 1 - \epsilon /2 &{} \text{ if } 1/2 \le x \le 1 \end{array}\right. }. \end{aligned}$$
(79b)

In Fig. 12 we plot the continuous and discrete spectra for these cases, again with \(\epsilon = 0.8\). Figure 12a, b reveal discrete spectra converging to the continuous from the left for a wave speed in \(C^\infty \) (case 2) and for a wave speed in \(C^0 \backslash C^1\). Figure  12c, however, reveals that for wave speeds with a jump discontinuity (case 4) there exist discrete eigenvalues with real parts that lie to the right of the continuous.

Fig. 12
figure 12

Continuous spectrum (plotted in blue stars) for linearly varying wave speeds corresponding to \(\eta _c > 0\). Discrete spectra also shown, for increasing N, for a(x), b(x) a\(\in C^\infty \) (case 2), b\(\in C^0 \backslash C^1\) (case 3) and c\(\notin C^0\) (case 4)

Fig. 13
figure 13

Continuous spectrum (plotted in blue stars) for linearly varying wave speeds corresponding to a(x), b(x) a\(\notin C^0, \eta _c = 0\)b\(\in C^0 \backslash C^1\), \(\eta _c < 0\), c\(\notin C^0\), \(\eta _c < 0\) and d\(\notin C^0\), \(\eta _c > 0\). Discrete spectra also shown when including an interface, for increasing N

Fig. 14
figure 14

Time series of energy \({\mathcal {E}}(t)\) and energy decay rate r(t) for \(\eta _c = 0\), with wave speeds a(x), b(x) a constant, b\(\in C^\infty \), c\(\in C^0 \backslash C^1\) and d\(\notin C^0\)

Fig. 15
figure 15

Time series of energy \({\mathcal {E}}(t)\) and energy decay rate r(t) for \(\eta _c < 0\), with wave speeds a(x), b(x) a\(\in C^\infty \), b\(\in C^0 \backslash C^1\) and c\(\notin C^0\) and for \(\eta _c > 0\), with wave speeds a(x), b(x) d\(\in C^\infty \), e\(\in C^0 \backslash C^1\) and f\(\notin C^0\)

In Fig. 13 we plot the continuous and discrete spectra after introducing an interface at \(x = 1/2\), for the cases where dissipative strict stability was not obtained. For \(\eta _c = 0\) and \(\eta _c > 0\) corresponding to a wave speed with a jump discontinuity, Fig. 13a, d illustrate that dissipative strict stability can be recovered by including an interface. For \(\eta _c < 0\), however, some of the discrete eigenvalues still lie to the right of the continuous spectrum, as observed in Fig. 13b, c. A similar result has been found for the scalar case, where dissipative strict stability is not obtained for discontinuous wave speeds even when including an interface, see [13].

3.6 Energy Growth and Decay

In this section we study growth rates of the exact and numerical solutions in the time domain and compare them with theoretical prediction from the continuous spectrum. Note that in this section we consider discretizations that do not include an interface where wave speeds are non-smooth. We compute the time series of the energy (the squared \(\mathbf{H}\)-norm of the numerical solution), namely,

$$\begin{aligned} {\mathcal {E}}(t) = ||\mathbf{u}||_\mathbf{H}^2 + ||\mathbf{v}||_\mathbf{H}^2, \end{aligned}$$
(80)

with initial conditions given by (71). In Figs. 14, 15 and 16 we plot the energy \({\mathcal {E}}(t)\) for the exact (in solid blue) and the numerical solution (in red), with \(N = 2^9+1\) grid points, and interior order of accuracy \(p = 3\). We also plot (in dashed green) the right hand side of the semi-discrete energy estimate (66), letting

$$\begin{aligned} r(t) = (\mathbf{u},\mathbf{UDa})_\mathbf{H} - (\mathbf{v},\mathbf{VDb})_\mathbf{H} + \mathbf{y}_0^T \mathbf{M}_0 \mathbf{y}_0 + \mathbf{y}_N^T \mathbf{M}_N \mathbf{y}_N \end{aligned}$$
(81)

denote the energy decay rate, i.e. \(\dot{{\mathcal {E}}} = r(t)\). We consider the four cases of wave speeds given in the previous section, corresponding to \(\eta _c = 0, \eta _c < 0\) and \(\eta _c > 0\). In all figures we also plot (in black circles) a theoretical measure of growth given by \(||f||^2 e^{2\eta _c t}\) (i.e. the exponential growth/decay of the squared-norm of the initial data as predicted by the continuous spectrum).

Figure 14a shows the time series for the constant coefficient case, where \(\eta _c = 0\), for \(0 \le t \le 10\). The energy \({\mathcal {E}}(t)\) corresponding to the exact solution neither grows nor decays, as predicted by the spectrum as well as the energy estimate (40). That the energy corresponding to the numerical solution does not grow is evidence of stability of the numerical discretization as illustrated by the corresponding discrete spectrum in Fig. 10a. Figure 14b–d show the temporal evolution for the three cases of non-constant wave speeds corresponding to \(\eta _c = 0\). There is no exponential growth or decay, simply oscillatory motion predicted by purely imaginary eigenvalues. Note that the energy decay rate r(t) (in dashed green) is non-zero, as would be expected by non-constant a(x), b(x), and corresponds to the time derivative of \({\mathcal {E}}(t)\).

Fig. 16
figure 16

Long time series of energy \({\mathcal {E}}(t)\) for \(\eta _c = 0\) and \(a(x), b(x) \notin C^0\)

Figure 15 shows the temporal evolution for the three cases of non-constant wave speeds corresponding to \(\eta _c < 0\) and those corresponding to \(\eta _c > 0\), and we see a good match between the decay/growth of the exact and numerical energies as compared to theoretical rate, at least on the time interval \(0 \le t \le 10\). The lack of dissipative strict stability is primarily an issue for long-time simulations for which small differences in exact and numerical growth rates can destroy the accuracy of the approximation, see [16]. For \(\eta _c = 0\), a loss of dissipative strict stability implies, even more importantly, a loss of numerical stability. The spectra plotted in Fig. 10d, for example, shows this loss of stability for a discontinuous wave speed corresponding to \(\eta _c = 0\) where discrete eigenvalues cross the imaginary axis. The long-time series (\(0 \le t \le 3000\)) for this case is plotted in Fig. 16, where exponential growth of the energy of the numerical solution is clearly observed.

4 Conclusions

We have investigated high-order-accurate, skew-symmetric SBP-SAT methods for hyperbolic problems with non-smooth variable coefficients. These skew-symmetric methods are based on a splitting that assumes that the variable coefficients are differentiable everywhere. However, when the coefficients are piecewise continuous and discontinuous, the splitting is no longer justified. In this case, it is not understood what the consequences are in terms of accuracy and stability. To begin addressing this question, we have derived analytic solutions to the scalar and vector advection equation with spatially-variable wave speeds and used these to compute convergence rates of numerical solutions when considering piecewise linear wave speeds that are non-smooth in some cases. Smooth wave speeds show convergence at the theoretically predicted rates for formal order of accuracy \(p = 2, 3, 4, 5\), while wave speeds in \(C^0 \backslash C^1\) reveal a reduction to second-order convergence for all p considered. Wave speeds with a jump discontinuity reveal a reduction to first order convergence for all p considered. We showed however, that theoretical convergence rates can be recovered by including an interface where wave speeds are not smooth.

We computed the spectrum of the differential operator for the vector equation and compared it with that of the discrete operator. For wave speeds that generate continuous eigenvalues with negative real part, the skew-symmetric SBP-SAT method is stable for all wave speeds considered. However, for non-smooth wave speeds, some eigenvalues of the discrete operator lie to the right of the continuous spectrum, even with an interface present, an indication that dissipative strict stability is not achieved. For wave speeds corresponding to purely imaginary eigenvalues, stability is obtained for smooth wave speeds and continuous wave speeds with a discontinuous derivative. Wave speeds with jump discontinuity, however, generate discrete eigenvalues with positive real part, an indication of an instability. Stability is recovered in this case, however, if an interface is included where the wave speed is not smooth. For wave speeds corresponding to eigenvalues of the continuous operator with positive real part, the discrete spectrum converges from the left to the continuous spectrum for smooth coefficients and for that with a discontinuous derivative. For the discontinuous wave speeds we considered, however, we again observe discrete eigenvalues that lie to the right of the continuous spectrum, indicating a numerical growth rate that is faster than that dictated by the continuous problem. This issue is mitigated by incorporating an interface where the wave speeds are not smooth.

We have considered piecewise linear wave speeds with different smoothness conditions, and reported on convergence rates of numerical solutions and discrete spectra. If the wave speeds are not smooth we found that convergence rates for high-order accurate methods drop significantly, and (for large N) the overall error remains constant with increasing order of accuracy p. The higher-order methods in this case offer no added benefit and would be more computationally expensive than the lower order methods due to the larger stencil (and smaller time-step required). We also found that smooth, linear wave speeds as well as continuous, linear wave speeds with a discontinuous derivative correspond to methods with dissipative strict stability. Without any special treatment, such as including an interface, discontinuous wave speeds can lead to instabilities. Finally, our results suggest the need for a theory on how well the discrete spectrum approximates the continuous one for general wave speeds, if they are to be used to understand the stability of more general physical problems.