Seventh South African Conference on Computational and Applied Mechanics SACAM10 Pretoria, 10−13 January 2010 c SACAM A stable and conservative method of locally adapting the design order of finite difference schemes Sofia Eriksson ∗,1 , Qaisar Abbas ∗ and Jan Nordström∗,†,# ∗ Department of Information Technology, Scientific Computing, Uppsala University, SE-751 05 Uppsala, Sweden. 1 [email protected] † School of Mechanical, Industrial and Aeronautical Engineering, University of the Witvatersrand, PO WITS 2050, Johannesburg, South Africa. # Department of Aeronautics and Systems Integration, FOI, The Swedish Defence Research Agency, SE-164 90 Stockholm, Sweden. Keywords: Finite difference methods, high order accuracy, shock calculations, conservation, stability, summation-by-parts Abstract A procedure to switch the order of accuracy of finite difference schemes is developed. The development is based on existing Summation-By-Parts operators and a weak interface treatment. The resulting scheme is proven to be stable and accurate. Numerical experiments verify the theoretical accuracy for smooth solutions. In addition shock calculations is performed, using a scheme where the developed switching procedure is combined with the MUSCL technique for shock capturing. 1 Introduction The most common and perhaps most intuitive way of imposing boundary condition is to use strong implementation, also called injection. Then the numerical solution has exactly the same value at the boundary as the continuous solution, by construction. Weakly implemented boundary conditions means that the numerical solution not necessarily equal the data at the boundary but is allowed to deviate somewhat. The deviation from the boundary data decreases with increased resolution, so that the design order of the scheme is preserved. The deviation should not be interpreted as a drawback, on the contrary it can serve as an error estimate for the solution in the interior. However, the most important advantage with weak boundary treatment is that combined with the Summation-By-Parts (SBP) operators, one can prove that it yields a stable and accurate boundary treatment, [1, 2, 3, 4]. The technique of using penalty terms to make the solution fulfill the boundary conditions can be generalized to hold also for block interfaces, although instead of data the solution in the other block is used, [5, 6, 7]. Block interfaces can be useful when generating grids for complex geometries - or as in our case - if one wants to change the properties of the scheme from one computational domain to another. At a block interface the grid points come in pairs of two. This has the benefit of producing two solution values at the same position, where the difference between the two solutions can be used (just as for ordinary boundaries) to estimate the error for the rest of the solution. However, if one needs to move the interface, e.g. to keep track of a moving shock, one can use the multivalued interface treatment as a basic procedure, merge the double points into single ones and obtain a sliding interface treatment. This will be the procedure used in this paper. The procedure can be used when the order of a numerical scheme has to be lowered in a small region (e.g. at a shock). Another possible application is to instead increase the order of the scheme in regions of interest, for example when following a propagating wave pulse. 2 Interface treatment for a hyperbolic problem To introduce our technique we consider the hyperbolic scalar partial differential equation ut + aux = 0, −1 ≤ x ≤ 1 (1) which have an interface at x = 0, such that uLt + auLx = 0 holds in the left domain (−1 ≤ R x ≤ 0) and uR t + aux = 0 holds in the right domain (0 ≤ x ≤ 1). The interface condition is L R u (0, t) = u (0, t). Since we have the same equation in both domains the interface is just an imaginary barrier. We want to mimic the continuous case above numerically, and we start by describing the original multi-valued interface treatment. Let v L,R denote the semi-discrete vector representations of uL,R , such that viL,R (t) corresponds to uL,R (xi , t). The grid points have index i = 0, 1, . . . , NL − 1, NL in the left domain and i = 0, 1, . . . , NR − 1, NR in the right domain. For L as notation for the NL th element of v L . simplicity we use vN L − v0R is small The interface condition uL (0, t) = uR (0, t) will be imposed weakly, such that vN (goes to zero with decreased grid spacing). The differential operator d/dx is represented by the difference operator on matrix form PL−1 QL in the left domain and PR−1 QR in the right domain. The operators PL−1 QL and PR−1 QR can be designed to have the order of accuracy 2, 4, 6 or 8 in the interior and 1, 2, 3 or 4 at the boundary. This will lead to a global order of accuracy of 2, 3, 4 or 5, see [1, 2]. The resulting numerical approximation of (1) is L vtL + aPL−1 QL v L = τL PL−1 eN (vN − v0R ) L vtR + aPR−1 QR v R = τR PR−1 e0 (v0R − vN ) (2) in the left and right domain, respectively (ignoring outer boundary conditions). The vectors eN = [0 · · · 0 1]T and e0 = [1 0 · · · 0]T ensures that the penalty parameters τL,R correct the scheme where they should. If τL = τR + a, then (2) will be conservative. Hence we let τL = (a − θ)/2 and τR = (−a − θ)/2. After assuring conservation we check the stability properties. Note that the SBP properties of the operators gives PL,R > 0 and that QL,R are skew-symmetric, except for Q00 L,R = −1/2 NN T and QL,R = 1/2. The energy estimate is formed by multiplying (2) by vL,R PL,R from the left, adding the transpose, and thereafter adding the two estimates. Defining kvk2P ≡ v T P v yields kv L k2PL + kv R k2PR t T L L −a + 2τL −(τL + τR ) vN vN = R −(τL + τR ) a + 2τR v0R v0 L L T 1 −1 vN vN = −θ R −1 1 v0R v0 (3) which is stable if θ ≥ 0. The choice θ = |a| will give a fully up-wind implementation of the interface condition. Note that we have omitted the outer boundaries, only taking the terms originated from the interface into consideration. 2.1 Transformation to a scheme with adjustable accuracy Using the original operators from (2) we define L v PL 0 V= R P̄ = v 0 PR QL 0 Q̄ = 0 QR (4) L and v0R are both where P̄ and Q̄ are (NL + NR + 2) × (NL + NR + 2) matrices. Observe that vN approximations of the same continuous solution value, i.e. u(x = 0, t). Now our ambition is to be able to move the interface, and hence we need to modify the scheme such that it operates without double grid points at the interface. This require a new discrete solution vector W , which is one element shorter than the vector V , i.e. W is an (NL + NR + 1) × 1 vector. Theorem 2.1. Consider solving the partial differential equation in (1) numerically. It is possible to construct a finite difference scheme e =0 Wt + aPe−1 QW (5) e = Pe−1 Q e has design on Summation-By-Parts (SBP) form, such that the differential operator D order L in the left part of the computational domain and design order R in the right part of the computational domain. On the interface the order will be min (L/2, R/2). For details on SBP properties, see [2, 6]. The scheme in (5) is conservative and stable, given that outer boundary conditions are imposed correctly. The derivation of theorem 2.1 will not be given here, we will just present the final form of the e = IeQ̄IeT , where the matrix Ie is similar to the identity new operators. The difference matrix is Q matrix, except it has dimensions (NL + NR + 1) × (NL + NR + 2) and is slightly modified in e are given below, the interior. Ie and Q 1 .. .. .. ... . . . N −1,N N −1,N −1 . . . Q Q 1 0 0 0 L L N,N −1 N,N 0,0 0,1 e = . . . Q . (6) 0 1 1 0 Ie = + Q Q . . . Q , Q R R L L 1,0 1,1 0 0 0 1 QR QR . . . .. . . . . . . . . . . 1 In the same way we obtain the norm Pe = IeP̄ IeT = diag(PL0 , . . . , PLN −1 , β, PR1 , . . . , PRN ), i where PL,R ≡ (PL,R )ii and β = PLN + PR0 . e is skew-symmetric in the interior just The new scheme is perfectly stable since Pe > 0 and Q N,N 0,0 eN N = Q as QL and QR , since Q + QR = 1/2 − 1/2 = 0. Moreover, the SBP properties L automatically leads to a conservative scheme. 3 Numerical simulations In the computations we use the spatial domain 0 ≤ x ≤ 1, letting N + 1 be the total amount of grid points, indexed as i = 0, 1, . . . , N . At the locations i = iL and i = iR we switch the order of the scheme from higher (4th) order to second order. First we will present some simulations verifying the theory, and thereafter show some results from shock calculations to demonstrate applicability. 3.1 Verification of the method on a hyperbolic test problem Consider the time-independent problem ux = S(x) with boundary condition u(0) = g0 , having u = sin(7x)−cos(4x) as the manufactured solution. We solve this equation using the adjustable scheme e = S + τ Pe−1 e0 (v0 − g0 ) Pe−1 Qv (7) where e0 = [1 0 · · · 0]T and S is the discrete representation of S(x) such that Si ≡ S(xi ). As penalty parameter we use τ = −1 (for the time-dependent problem τ ≤ −1/2 guarantees stability, τ = −1 gives the up-wind implementation). We solve (7) using a scheme that changes order at iL = N/4 and iR = 3N/4. Thus the scheme will be 2nd order for 0.25 . x . 0.75 and 4th order outside. The resulting solution and error (using N = 32 and N = 64) are shown in Figure 1 below. Figure 1(b) shows the error and it is clear that the scheme has changed at x ≈ 0.25 and x ≈ 0.75. Table 1 shows the same 1 0.02 u, exact v, N=32 v, N=64 Error e=v−u Solution u,v 2 0 −1 0 0.2 0.4 x 0.6 (a) Solution 0.8 1 v−u, N=32 v−u, N=64 0.01 0 −0.01 0 0.2 0.4 x 0.6 0.8 1 (b) Error Figure 1: For 0.25 . x . 0.75 the scheme is 2nd order accurate, while 4th order outside. simulations as in Figure 1 for various number of grid points N . In the first columns we have used iL = N/4 and iR = 3N/4 (as in Figure 1) and in the last two columns iL = N/2 − 8 and iR = N/2+8, such that the number of lower order points in the scheme remains constant as the mesh is refined. If the proportions of lower (2nd) and higher (4th) order points in the scheme N 32 64 128 256 512 1024 For iL,R = N/2 ± N/4 L2 (v − u) RoC 6.9149e-03 2.0015e-03 1.79 5.3109e-04 1.91 1.3617e-04 1.96 3.4435e-05 1.98 8.6558e-06 1.99 For iL,R = N/2 ± 8 L2 (v − u) RoC 6.9149e-03 2.1092e-03 1.71 3.2130e-04 2.71 4.3156e-05 2.90 5.7368e-06 2.91 7.8469e-07 2.87 Table 1: Rate of convergence (RoC) for two different approaches of adjusting the order. do not change, the overall order of accuracy will be the lower one. If the amount of 2nd order points in the schemes remains constant as the mesh is refined we obtain third order accuracy, which is what a non-modifed 4th order scheme would give. Both these results coincide with the theoretical results, see [2]. 4 Shock calculations The most obvious application for this methodology is shock calculations. For scalar onedimensional conservation laws (ut + Fx = 0), we have the MUSCL scheme converted into SBP-form, see [8], vt + P −1 QF = −P −1 D1T BM D1 v. (8) Here D1 is a first order undivided difference operator, and BM = diag(b1 , b2 , , . . . , bi , . . . ) is a diagonal matrix constructed such that (8) corresponds to the standard MUSCL formulation. The terms involving BM will be referred to as the MUSCL dissipation. This scheme is second order accurate in smooth regions and goes to first order near a discontinuity/shock to avoid non-physical oscillations. Since the MUSCL scheme in Eq. (8) is on SBP-form, it can be coupled to the adaptive scheme derived above. In the vicinity of a shock, the scheme is first turned from 4th to 2nd order by the adjustable scheme. Next, we add the MUSCL treatment in form of a dissipative term close to the discontinuity. This yields e = −Pe−1 D1T B eM D1 v vt + Pe−1 QF (9) eM = ΦBM . We have constructed a matrix Φ which limits the MUSCL scheme, such where B that it is applied only in the shock region. In (9), which we will refer to as the Hybrid scheme, the MUSCL dissipation is turned on in the shock region leading to a standard MUSCL scheme and it is turned off in the smooth region leading to a higher order scheme. Recall that the norm Pe differs from the standard norm P , and for the (4-2-4)th-order switching it is visualized in Figure 2(a). The complete switching procedure including the limiter Φ is visualized in Figure 2(b). After finding the shock at grid index iS , we switch scheme from 4th order to 2nd order at index iL = iS − w and back at iR = iS + w. This leads to a scheme with 2w + 1 grid points with 1.5 1 1 Norm P 1.5 Matrix P Shock position MUSCL ON/OFF Shock region 0.5 0.5 0 0 0 0.2 0.4 x 0.6 0.8 1 (a) N = 81 0.2 0.3 0.4 0.5 0.6 0.7 (b) N = 81 Figure 2: (a) Pe (normalized with grid size) for a (4-2-4)th-order switching with iL ≈ N/2 and iR ≈ 3N/4. (b) The switching procedure depicted, including the role of the discrete function Φ. first to second order accuracy around the shock (at iL and iR it is first order). In the second order region, we can choose to activate the MUSCL scheme (by having Φi = 1) in the domain i = iS ± wM , where wM < w. The variables w and wM can be varied. For example, in Figure 2(b) we have w = 5 and wM = 2. As described above, we use Φ to prevent MUSCL to activate outside the 2nd order region. In addition the MUSCL scheme has a standard limiter φ which determines where it should be 2nd order and where it should be 1st order. Here the MUSCL scheme is based on a minmod limiter, which is defined as φ(r) = max[0, min(1, r)], where r is the ratio between two successive upstream gradients. If φi = 1 the solution is considered smooth and the scheme is 2nd order, and if φi = 0 the scheme is 1st order. In the following simulations we have considered linear and non-linear scalar one-dimensional hyperbolic test problems. All the computations are performed using the classical 4th-order Runge-Kutta method for the time integration. 4.1 Linear problems We study the advection equation ut + ux = 0, u(0, t) = g0 (t) 0≤x≤1 u(x, 0) = u0 (x) with boundary condition g0 (t) and initial condition u0 (x). We will compare the results obtained using the new hybrid scheme with the ones obtained using the standard MUSCL scheme. We consider a combination of a Gaussian pulse and a step function as the initial solution, i.e. −100(x−0.2)2 e + 1, 0 ≤ x ≤ 0.6 u0 (x) = (10) 0.5, 0.6 < x ≤ 1. This means that we have both smooth and discontinuous data in the domain. T=0.1500, N=81 Initial soluton Numerical solution Exact solution 0.1 1.5 u!v solution vector 2 T=0.1500, N=81 0.2 0 1 !0.1 0.5 0 0.2 0.4 x 0.6 0.8 !0.2 0 1 0.2 0.4 0.6 Domain x (a) Solution 0.8 1 0.8 1 (b) Error Figure 3: Solution and error using the MUSCL scheme. T=0.1500, N=81 Initial soluton Numerical solution Exact solution 0.1 1.5 u!v solution vector 2 T=0.1500, N=81 0.2 0 1 !0.1 0.5 0 0.2 0.4 x 0.6 0.8 1 !0.2 0 0.2 (a) Solution 0.4 0.6 Domain x (b) Error Figure 4: Solution and error using the Hybrid scheme. Figure 3 is done using the MUSCL scheme, whereas Figure 4 is showing the solution and error obtained from the Hybrid scheme. Here we have considered w = 10 and wM = 6. Looking at Figures 3 and 4 we observe that the MUSCL scheme cuts of the top of the Gaussian pulse. The Hybrid scheme does not. Close to the discontinuity the solutions in both figures are similar, since in that region the schemes are the same. 4.2 Non-linear problems We have considered the Burgers equation (F = u2 /2), i.e. ut + u2 /2 x = 0, 0 ≤ x ≤ 1, (11) with a sine wave as initial condition. The solutions are computed until t = 0.1 which is just before a shock has formed. An analytical solution is computed using a Newton iteration method [9]. It can be seen in Figures 5 and 6 that the solution obtained from the Hybrid scheme is more accurate than the one from the non-modified MUSCL. T=0.1000, N=81 T=0.1000, N=81 0.03 Initial soluton Exact solution Numerical solution 0.02 0.5 u!v solution vector 1 0 0.01 0 !0.5 !1 0 !0.01 0.2 0.4 x 0.6 0.8 !0.02 0 1 0.2 (a) Solution 0.4 0.6 Domain x 0.8 1 0.8 1 (b) Error Figure 5: Solution and error from the MUSCL scheme. T=0.1000, N=81 T=0.1000, N=81 0.03 Initial soluton Exact solution Numerical solution 0.02 0.5 u!v solution vector 1 0 0.01 0 !0.5 !1 0 !0.01 0.2 0.4 x 0.6 (a) Solution 0.8 1 !0.02 0 0.2 0.4 0.6 Domain x (b) Error Figure 6: Solution and error from the Hybrid scheme, w = 6 and wM = 5. N 21 41 81 161 321 MUSCL Hybrid w = 6, wM = 5 l2 -error p l2 -error p 0.0209 0.0250 0.0083 1.38 0.0069 1.94 0.0027 1.64 0.0020 1.83 0.0008 1.69 0.0005 1.89 0.0003 1.68 0.0002 1.21 Table 2: L2 -error and rate of convergence at T = 0.1 for the Burger’s equation The l2 -norm of the errors and the order of convergence from the two schemes are shown in Table 2. From the table we can see that the Hybrid scheme produces a solution that is slightly more accurate than the one from the MUSCL scheme. For the Hybrid scheme the order of convergence p drops suddenly in the last row of Table 2. Presently we have no clear explanation for that. Note that most of the errors are generated where the gradients are large. Here the scheme will be the same and hence the maximum errors in the solution will be approximately the same. 5 Conclusion We have developed a stable way to locally change the order of a finite difference scheme. The resulting scheme has at least the same overall accuracy as the lowest included scheme, which is verified by numerical experiments. This procedure can serve as a very efficient way of doing accurate calculations even in the presence of shocks. We combine our adaptive accuracy scheme with the MUSCL shock capturing technique and compare the results with the ones obtained using only MUSCL. Future work include adaptive meshing, such that the mesh is coarse and the scheme high order in smooth domains whereas highly resolved and first order accurate close to shocks. The extension to parabolic equations such as the heat equation can be done. References [1] K. Mattsson and J. Nordström. Summation by parts operators for finite difference approximations of second derivatives. Journal of Computational Physics, (199):503–540, 2004. [2] M. Svärd and J. Nordström. On the order of accuracy for difference approximations of initial-boundary value problems. Journal of Computational Physics, 218:333–352, 2006. [3] M. Svärd, M. H. Carpenter, and J. Nordström. A stable high-order finite difference scheme for the compressible Navier-Stokes equations, far-field boundary conditions. Journal of Computational Physics, 225:1020–1038, 2007. [4] M. Svärd and J. Nordström. A stable high-order finite difference scheme for the compressible Navier-Stokes equations: Wall boundary conditions. Journal of Computational Physics, 227:4805–4824, 2008. [5] J. Gong and J. Nordström. Stable, accurate and efficient interface procedures for viscous problems. Report 2006-027, Uppsala University, Sweden, Apr 2006. [6] M. H. Carpenter, J. Nordström, and D. Gottlieb. A stable and conservative interface treatment of arbitrary spatial accuracy. Journal of Computational Physics, (148):341–365, 1999. [7] J. Nordström, J. Gong, E. van der Weide, and M. Svärd. A stable and conservative high order multi-block method for the compressible Navier-Stokes equations. Journal of Computational Physics, 228:9020–9035, 2009. [8] Q. Abbas, E. van der Weide, and J. Nordström. Accurate and stable calculations involving shocks using a new hybrid scheme. AIAA Paper No. 2009–3985, 2009. [9] A. Harten, B. Engquist, S. Osher, and S. Chakrawarthy. Uniformly high order accurate non-oscillatory schemes III. Journal of Computational Physics, 71:231–303, 1987.

* Your assessment is very important for improving the work of artificial intelligence, which forms the content of this project

Download PDF

advertisement