finite vol 1

Upload: edwinfisika

Post on 08-Apr-2018

217 views

Category:

Documents


0 download

TRANSCRIPT

  • 8/7/2019 Finite Vol 1

    1/34

    Finite Volume Schemes: an introductionFirst lecture

    Annamaria Mazzia

    Dipartimento di Metodi e Modelli Matematici per le Scienze ApplicateUniversita di Padova

    [email protected]

    Scuola di dottorato in

    Scienze dellIngegneria Civile e AmbientaleCorso di Metodi Numericimarzo 2008

  • 8/7/2019 Finite Vol 1

    2/34

    Outline

    Hyperbolic Conservation Laws

    Classical and Weak solutionsThe Riemann problem

    Finite Volume Methods in 1D

    Finite Volume Methods in 2D

    The lectures about Finite Volume and Mixed Hybrid FiniteElement will be on line athttp://dispense.dmsa.unipd.it/mazzia

    A. Mazzia (DMMMSA) Finite Volume a.a. 2007/2008 2 / 34

  • 8/7/2019 Finite Vol 1

    3/34

    Hyperbolic Conservation Laws

    Finite Volumes (FV) schemes are most useful for modelling

    hyperbolic conservation laws, which, in their simplest(scalar) form may be expressed by the PDE

    ut + f = 0

    on a domain , with u(x, t) specified on inflow boundaries.

    Example: the equation for conservation of mass ingroundwater contamination problem.Assumptions: no diffusion, no mechanical dispersion,

    density of the contaminant and the water constant,velocity of the fluid mixture constant,Let (x, t) be the density of the contaminant at point xand time t and v(x, t) be the velocity of the fluidmixture.

    A. Mazzia (DMMMSA) Finite Volume a.a. 2007/2008 3 / 34

  • 8/7/2019 Finite Vol 1

    4/34

    The total pollutant mass in two sections 1 and 2 is givenby

    x2

    x1(x, t) dx. If no source or sinks are present, the

    mass can change only because of the mixture flowingacross the endsections in x1 or x2.The rate of mass change is given by:

    d

    dt

    x2

    x1

    (x, t) dx = (x1, t)v(x1, t) (x2, t)v(x2, t)

    By integrating in time from tk to tk+1 we obtain theintegral form of the conservation law. Assuming andv differentiable, with simple calculations we obtain the

    differential form of the conservation law:

    t + (v)x = 0

    A. Mazzia (DMMMSA) Finite Volume a.a. 2007/2008 4 / 34

  • 8/7/2019 Finite Vol 1

    5/34

    Classical and Weak solutions

    Solution of hyberbolic conservation laws may be obtainedif initial and boundary conditions are given.The simplest problem is the initial value problem, orCauchy problem, defined for < x < and t 0. Wemust specify initial conditions only:

    ut + f = 0u(x, 0) = u0(x) < x < .

    Classical solutions of this problem are constant along thecharacteristics curves defined by x(t) such that

    dx

    dt= f(u(x(t), t)) t 0

    x(0) = x0

    A. Mazzia (DMMMSA) Finite Volume a.a. 2007/2008 5 / 34

  • 8/7/2019 Finite Vol 1

    6/34

    Shock waves

    u is constant along these characteristics and thecharacteristics travel at constant velocity which is equal tof(u0(x0)).Generally, classical solutions exist only for t [0, T] where

    T = 1

    infx u

    0(x)f(u0(x))

    .

    At the time t = T the characteristics first cross, the function

    u(x, t) has an infinite slope the wave is said to breakbyanalogy with waves on a beach and a shock forms.

    A. Mazzia (DMMMSA) Finite Volume a.a. 2007/2008 6 / 34

  • 8/7/2019 Finite Vol 1

    7/34

    Weak solutions

    To allow discontinuities, which arise in a natural way in thissituation, we define a weak solution of conservation law.

    Definition (Weak solution)

    A function u(x, t), bounded and measurable, is called aweak solution of the conservation law, if for each C

    (R R+), the following equality holds:

    0

    +

    [tu+ xf(u)] dx dt = +

    (x, 0)u(x, 0) dx.

    A. Mazzia (DMMMSA) Finite Volume a.a. 2007/2008 7 / 34

  • 8/7/2019 Finite Vol 1

    8/34

    The Riemann problem

    Definition (The Riemann problem)

    A Riemann problem is the conservation law together withinitial data consisting of two constant states separated bya single discontinuity,

    u0(x) =

    ul x < 0,ur x > 0.

    Example: The Riemann problem in Burgersequation

    ut + (1

    2u2)x = 0

    A. Mazzia (DMMMSA) Finite Volume a.a. 2007/2008 8 / 34

  • 8/7/2019 Finite Vol 1

    9/34

    If ul > ur, there is a unique weak solution,

    u(x, t) = ul x < st

    ur x > st.

    s =(ul + ur)

    2is the shock speed

    If ul < ur, there are infinitely many weak solutions, sincebetween the points ult < x < urt, there is noinformation available from the characteristics. Todetermine the correct physical behavior we adopt

    the vanishing viscosity approach by adding the termuxx depending on small parameter

    ut + (1

    2u2)x = uxx.

    A. Mazzia (DMMMSA) Finite Volume a.a. 2007/2008 9 / 34

  • 8/7/2019 Finite Vol 1

    10/34

    If the initial data is smooth and very small then,before the wave begins to break, the uxx term isnegligible compared to other terms and the solutions

    to the two PDEs look nearly identical. As the wavebegins to break, the term uxx grows much faster thanux and at some point the uxx term is comparable tothe other terms and begins to play a role. This term

    keeps the solution smooth for all time, preventing thebreakdown of solutions that occurs for the hyperbolicproblem. The weak solution is called rarefaction waveor expansion fan:

    u(x, t) =

    ul x < ultx/t ult x urtur x > urt

    A. Mazzia (DMMMSA) Finite Volume a.a. 2007/2008 10 / 34

  • 8/7/2019 Finite Vol 1

    11/34

    ul

    ur

    0

    Shock wave

    0

    ul

    ur

    Rarefaction wave

    A. Mazzia (DMMMSA) Finite Volume a.a. 2007/2008 11 / 34

  • 8/7/2019 Finite Vol 1

    12/34

    Some common numerical schemes

    To solve numerically hyberbolic conservation laws somecommon numerical schemes are:

    Finite Differences

    Finite Volumes

    Finite Elements

    Discontinuous Galerkin

    We will see more in detail (but not too much...) the FiniteVolume approach.

    A. Mazzia (DMMMSA) Finite Volume a.a. 2007/2008 12 / 34

  • 8/7/2019 Finite Vol 1

    13/34

    Properties of the ideal scheme

    The ideal scheme for the resolution of hyperbolicconservation laws would reflect the properties of theunderlying physical and mathematical system:

    Conservative: for correct capturing of discontinuities;

    Accurate: obvious....;

    Free of spurious oscillations: spurious oscillations haveno physical meaning. This goal is remarkably difficult toachieve;

    Continuous: for convergence to the steady statesolution.

    A. Mazzia (DMMMSA) Finite Volume a.a. 2007/2008 13 / 34

  • 8/7/2019 Finite Vol 1

    14/34

    The Finite Volume method

    In the Finite Volume method the three main steps to followare:

    Partition the computational domain into controlvolumes (or control cells) - wich are not necessarily the

    cells of the mesh.Discretize the integral formulation of the conservationlaws over each control volume (by applying thedivergence theorem).

    Solve the resulting set of algebraic equations orupdate the values of the dependent variables.

    A. Mazzia (DMMMSA) Finite Volume a.a. 2007/2008 14 / 34

  • 8/7/2019 Finite Vol 1

    15/34

    FV in 1D

    We will see two FV schemes in 1D: Godunovs method andvan Leers method.

    Godunovs method uses the exact solution of the localRiemann problem and does not produce oscillations

    around discontinuities, but it is only first order accurateand the solutions display large numerical viscosity.

    van Leers method can be viewed as a generalizationof Godunovs method, it is a high resolution method,

    characterized by second order accuracy on smoothsolutions and the absence of spurious oscillations.

    Both methods are conservative.

    A. Mazzia (DMMMSA) Finite Volume a.a. 2007/2008 15 / 34

    C

  • 8/7/2019 Finite Vol 1

    16/34

    Conservative method

    Definition

    Given a uniform grid with time step t and spatial meshsize x, a numerical method is said to be conservative ifthe corresponding scheme can be written as:

    v

    n+1

    j = v

    n

    j (g

    n

    j+ 12 g

    n

    j 12 ), jZ

    n 0

    where vnj approximates u(xj, tn) at the point

    (xj = jx, tn = nt), =

    t

    xand g : R2k R is a

    continuous function, called the numerical flux(function),that defines a (2k + 1)-point scheme.

    gnj+ 1

    2

    = g(vnjk+1, . . . , vn

    j+k).

    A. Mazzia (DMMMSA) Finite Volume a.a. 2007/2008 16 / 34

    M i i f h i h

  • 8/7/2019 Finite Vol 1

    17/34

    Motivation of the conservative scheme

    vnj can be view as an approximation of

    unj =

    1x

    xj+1/2

    xj1/2

    u(x, tn) dx.

    unj is the average of u(, tn) on the cell [xj1/2, xj+1/2]

    (where xj1/2 = xj x2 ).

    From the integral form of the conservation law, wehave:

    xj+1/2xj1/2

    u(x, tn+1) dx =xj+1/2

    xj1/2

    u(x, tn) dx

    [

    tn+1

    tnf(u(xj+1/2, t)) dt

    tn+1

    tnf(u(xj1/2, t)) dt].

    A. Mazzia (DMMMSA) Finite Volume a.a. 2007/2008 17 / 34

  • 8/7/2019 Finite Vol 1

    18/34

    Dividing by x and using unj we get

    un+1j = unj 1x

    [tn+1

    tnf(u(xj+1/2, t)) dt

    tn+1

    tnf(u(xj1/2, t)) dt].

    The numerical flux function can be considered as anaverage flux through xj+1/2 over the time interval[tn, tn+1],

    gnj+1/2 =

    1

    t

    tn+1

    tnf(u(xj+1/2, t)) dt.

    A. Mazzia (DMMMSA) Finite Volume a.a. 2007/2008 18 / 34

    G d h

  • 8/7/2019 Finite Vol 1

    19/34

    Godunovs scheme

    1. Projection step Given data vnj at time tn, construct a

    piecewise constant function vnj (

    x,

    tn

    )defined by

    vnj (x, tn) = vnj xj1/2 x xj+1/2.

    | | |x_(j1) x_j x_(j+1)

    v_(j1)

    v_j

    v_(j+1)

    A. Mazzia (DMMMSA) Finite Volume a.a. 2007/2008 19 / 34

    2 Evolution step Solve the local Riemann problem at the

  • 8/7/2019 Finite Vol 1

    20/34

    2. Evolution step Solve the local Riemann problem at thecell interfaces, that is, on each subinterval [xj, xj+1] andfor t tn, solve

    vn

    j

    t+ f(v

    nj )

    x= 0

    vnj (x, tn) =

    vnj , xj < x < xj+1/2

    vnj+1, xj+1/2 < x < xj+1

    3. Projection step Define the approximation vn+1j at time

    tn+1 by averaging the Riemann problem solution vnj at

    the time tn+1, so that

    vn+1j = 1x

    xj+1/2xj1/2

    vnj (x, tn+1) dx.

    These values are then used to define new piecewiseconstant data vn+1j (x, t

    n+1) and the process repeats.

    A. Mazzia (DMMMSA) Finite Volume a.a. 2007/2008 20 / 34

    E l

  • 8/7/2019 Finite Vol 1

    21/34

    Example

    In the simple case of a linear advection equation

    ut + aux = 0, with a > 0, the third step gives

    vn+1j = vn

    j at

    x(vnj v

    nj1).

    | | |x_(j1) x_j x_(j+1)

    a t

    a t

    u_(j1)

    u_j

    u_(j1)

    A. Mazzia (DMMMSA) Finite Volume a.a. 2007/2008 21 / 34

    St bilit diti

  • 8/7/2019 Finite Vol 1

    22/34

    Stability condition

    The CFL (Courant-Friedrichs-Lewy) condition

    maxu

    |f(u)| 1

    2

    ,

    where =t

    xis a necessary stability condition stating that

    the domain of dependence of the method includes the

    domain of dependence of the PDE.

    A. Mazzia (DMMMSA) Finite Volume a.a. 2007/2008 22 / 34

    van Leers method

  • 8/7/2019 Finite Vol 1

    23/34

    van Leers method

    First and third steps of Godunovs methods are of anumerical nature and can be modified withoutinfluencing the physics, in order to define spatially highorder accurate scheme.

    van Leers scheme is a spatially second orderaccurate scheme (known also as MUSCL (MonotoneUpstream-centered Scheme for Conservation Laws)method).

    The straightforward replacement of the first-order

    scheme by a second-order accurate interpolationleads to the generation of oscillations arounddiscontinuities.

    A. Mazzia (DMMMSA) Finite Volume a.a. 2007/2008 23 / 34

  • 8/7/2019 Finite Vol 1

    24/34

    To overcome this limitations, non linear componentsare introduced.

    This concept was introduced by van Leer under theform of limiters, i.e. functions that control the gradientof the computed solution to prevent the appearanceof unphysical over/under shoots.

    A. Mazzia (DMMMSA) Finite Volume a.a. 2007/2008 24 / 34

  • 8/7/2019 Finite Vol 1

    25/34

    1 Reconstruction step: the dependent variable isinterpolated using a piecewise linear function v

    starting from the cell averages vnj , vnj1, vnj+1. To this enddefine Snj to be the slope on the jth cell calculatedusing vnj1 and v

    nj+1. Then

    vn(x) =

    vnj + (x xj)Sn

    jx x

    j1/2 < x < xj+1/2,

    vn(xj1/2) x xj1/2

    vn(xj+1/2) x xj+1/2.

    Note that taking Snj = 0 for all j and n recoversGodunovs method;

    A. Mazzia (DMMMSA) Finite Volume a.a. 2007/2008 25 / 34

    2 Evolution step: the waves are propagated across cell

  • 8/7/2019 Finite Vol 1

    26/34

    2 Evolution step: the waves are propagated across cellinterfaces according to an exact or approximatesolution of a local Riemann problem that uses theinterpolated values vn(x) as initial conditions. Onesolves

    tw +

    xf(w) = 0 x R, tn t tn+1

    w(x, tn) = vn(x).

    This step yields w(, tn+1).

    3 Cell-averaging step: vn+1j is obtained by projecting the

    solution w(x, tn+1) onto the piecewise constant

    functions

    vn+1j =1

    x

    xj+1/2xj1/2

    w(x, tn+1) dx.

    A. Mazzia (DMMMSA) Finite Volume a.a. 2007/2008 26 / 34

    b)

  • 8/7/2019 Finite Vol 1

    27/34

    d)

    xx x j j+1j-1x x x

    j+1jj-1

    x x xj-1 j j+1 x x x j-1 j j+1

    tv

    a) b)

    c)

    a) reconstruction; b) limiting; c) evolution; d)cell-averaging step.

    A. Mazzia (DMMMSA) Finite Volume a.a. 2007/2008 27 / 34

    Slope limiter

  • 8/7/2019 Finite Vol 1

    28/34

    Slope limiter

    The numerical scheme is completely defined afterspecification of the slope limiter Sn

    j

    .Poor choice of slopes may give oscillations in the solution.Generation of oscillations can be prevented by acting ontheir production mechanism and introducing nonlinearcorrection factors, so called the limiters, that force the

    method to be total variation diminishing(TVD).

    DefinitionA numerical method to solve hyperbolic conservation lawsis called total variation diminishing if

    +j=

    |vn+1j+1 vn+1

    j | +

    j=

    |vnj+1 vn

    j |

    A. Mazzia (DMMMSA) Finite Volume a.a. 2007/2008 28 / 34

  • 8/7/2019 Finite Vol 1

    29/34

    To obtain a slope limiter, let

    Snj = Sn

    j nj

    where Snj represents the actual slope approximation andj = (

    nj ) is a limiter function, defined in such a way that

    the method is TVD and nj is the ratio of two consecutivegradients, i.e.:

    nj =vnj v

    nj1

    vnj+1 vn

    j

    .

    A. Mazzia (DMMMSA) Finite Volume a.a. 2007/2008 29 / 34

    Limiter functions

  • 8/7/2019 Finite Vol 1

    30/34

    Limiter functions

    Various limiter functions can be found in literature. Forexample:

    van Leers limiter:

    () =||+

    1 + ||,

    minmod limiter that represents the lowest boundary of

    the second-order TVD region:

    () =

    min(, 1) if > 0

    0 if 0.

    the superbee limiter, that represents the upper limit ofthe second-order TVD region and has beenintroduced by Roe:

    () = max[0, min(2, 1), min(, 2)].

    A. Mazzia (DMMMSA) Finite Volume a.a. 2007/2008 30 / 34

    Numerical example with periodic boundary

  • 8/7/2019 Finite Vol 1

    31/34

    Numerical example with periodic boundary

    conditions

    ut + ux = 0, with initial condition u0(x) periodic ofperiod 2 defined on the interval [1, 1] as

    u0(x) =

    1 1 x 0.750 0.75 < x < 0.251 0.25 x 0.250 0.25 < x < 0.751 0.75 x 1

    We solve this problem at time t = 2 s with = 0.5, bysetting t = 1 102 s and x = 2 102 m.

    A. Mazzia (DMMMSA) Finite Volume a.a. 2007/2008 31 / 34

  • 8/7/2019 Finite Vol 1

    32/34

    1.0 0.5 0.0 0.5 1.00.0

    0.2

    0.4

    0.6

    0.8

    1.0

    (a) Godunovscheme

    1.0 0.5 0.0 0.5 1.00.0

    0.2

    0.4

    0.6

    0.8

    1.0

    (b) van Leerschemevan Leer limiter

    1.0 0.5 0.0 0.5 1.00.0

    0.2

    0.4

    0.6

    0.8

    1.0

    (c) van Leers schememinmod limiter

    1.0 0.5 0.0 0.5 1.00.0

    0.2

    0.4

    0.6

    0.8

    1.0

    (d) van Leers schemesuperbee limiter

    A. Mazzia (DMMMSA) Finite Volume a.a. 2007/2008 32 / 34

    Numerical example with non periodic

  • 8/7/2019 Finite Vol 1

    33/34

    Numerical example with non periodic

    boundary conditions

    ut + ux = 0, with the following initial condition:

    u(x, 0) = u0(x) =

    sin(x) 0 x 20 otherwise.

    We solve this problem at time t = 2 s with = 0.5 and

    x = 4 10

    2

    m.

    A. Mazzia (DMMMSA) Finite Volume a.a. 2007/2008 33 / 34

  • 8/7/2019 Finite Vol 1

    34/34

    0.0 2.0 4.01.0

    0.5

    0.0

    0.5

    1.0

    (a) Godunovs scheme

    0.0 2.0 4.01.0

    0.5

    0.0

    0.5

    1.0

    (b) van Leers schemevan Leer limiter

    0.0 2.0 4.01.0

    0.5

    0.0

    0.5

    1.0

    (c) van Leers schememinmod limiter

    0.0 2.0 4.01.0

    0.5

    0.0

    0.5

    1.0

    (d) van Leers schemesuperbee limiter

    A. Mazzia (DMMMSA) Finite Volume a.a. 2007/2008 34 / 34