solving the shallow water equationsfinite volume methods for hyperbolic problems, cambridge...

28
Technische Universit¨ at M ¨ unchen Solving the Shallow Water Equations Oliver Meister December 3 rd 2012 Oliver Meister: Solving the Shallow Water Equations HPC – Algorithms and Applications, December 3 rd 2012 1

Upload: others

Post on 31-May-2020

5 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Solving the Shallow Water EquationsFinite Volume Methods for Hyperbolic Problems, Cambridge University Press, 6th edition, 2007 Oliver Meister: Solving the Shallow Water Equations

Technische Universitat Munchen

Solving the Shallow Water Equations

Oliver Meister

December 3rd 2012

Oliver Meister: Solving the Shallow Water Equations

HPC – Algorithms and Applications, December 3rd 2012 1

Page 2: Solving the Shallow Water EquationsFinite Volume Methods for Hyperbolic Problems, Cambridge University Press, 6th edition, 2007 Oliver Meister: Solving the Shallow Water Equations

Technische Universitat Munchen

References

• R. Leveque:Finite Volume Methods for Hyperbolic Problems,Cambridge University Press, 6th edition, 2007

Oliver Meister: Solving the Shallow Water Equations

HPC – Algorithms and Applications, December 3rd 2012 2

Page 3: Solving the Shallow Water EquationsFinite Volume Methods for Hyperbolic Problems, Cambridge University Press, 6th edition, 2007 Oliver Meister: Solving the Shallow Water Equations

Technische Universitat Munchen

Motivation: Conservation laws

General form of conservation laws in 1D:

qt (x , t) + f (q(x , t))x = 0 (1)

where:• x , t ∈ R: space and time variables• q : R× R→ Rd : conserved quantity vector (function over

space and time)• f : Rd → Rd : flux function, simplest case: f (q) = u · q for a

constant velocity u ∈ R.

Quasilinear form:

qt (x , t) + f ′(q(x , t))qx = 0 (2)

Oliver Meister: Solving the Shallow Water Equations

HPC – Algorithms and Applications, December 3rd 2012 3

Page 4: Solving the Shallow Water EquationsFinite Volume Methods for Hyperbolic Problems, Cambridge University Press, 6th edition, 2007 Oliver Meister: Solving the Shallow Water Equations

Technische Universitat Munchen

Motivation: Conservation laws

General form of conservation laws in 1D:

qt (x , t) + f (q(x , t))x = 0 (1)

where:• x , t ∈ R: space and time variables• q : R× R→ Rd : conserved quantity vector (function over

space and time)• f : Rd → Rd : flux function, simplest case: f (q) = u · q for a

constant velocity u ∈ R.Quasilinear form:

qt (x , t) + f ′(q(x , t))qx = 0 (2)

Oliver Meister: Solving the Shallow Water Equations

HPC – Algorithms and Applications, December 3rd 2012 3

Page 5: Solving the Shallow Water EquationsFinite Volume Methods for Hyperbolic Problems, Cambridge University Press, 6th edition, 2007 Oliver Meister: Solving the Shallow Water Equations

Technische Universitat Munchen

Motivation: Conservation laws

Finite Volumes: subdivision of domain into grid cells, eachdenoted by a range Ci := (xi− 1

2, xi+ 1

2).

Integration over x for all cells Ci gives the integral form:

ddt

∫Ci

q(x , t)dx = f (q(xi− 12, t))− f (q(xi+ 1

2, t)) (3)

Integration over t for all time steps tn:x

i+ 12∫

xi− 1

2

q(x , tn+1)− q(x , tn)dx =

tn+1∫tn

f (q(xi− 12, t))− f (q(xi+ 1

2, t))dt

(4)

Oliver Meister: Solving the Shallow Water Equations

HPC – Algorithms and Applications, December 3rd 2012 4

Page 6: Solving the Shallow Water EquationsFinite Volume Methods for Hyperbolic Problems, Cambridge University Press, 6th edition, 2007 Oliver Meister: Solving the Shallow Water Equations

Technische Universitat Munchen

Motivation: Conservation laws

Finite Volumes: subdivision of domain into grid cells, eachdenoted by a range Ci := (xi− 1

2, xi+ 1

2).

Integration over x for all cells Ci gives the integral form:

ddt

∫Ci

q(x , t)dx = f (q(xi− 12, t))− f (q(xi+ 1

2, t)) (3)

Integration over t for all time steps tn:x

i+ 12∫

xi− 1

2

q(x , tn+1)− q(x , tn)dx =

tn+1∫tn

f (q(xi− 12, t))− f (q(xi+ 1

2, t))dt

(4)

Oliver Meister: Solving the Shallow Water Equations

HPC – Algorithms and Applications, December 3rd 2012 4

Page 7: Solving the Shallow Water EquationsFinite Volume Methods for Hyperbolic Problems, Cambridge University Press, 6th edition, 2007 Oliver Meister: Solving the Shallow Water Equations

Technische Universitat Munchen

Motivation: Conservation laws

Discretization:Average q over space by Qn

i := 14x

∫Ci

q(x , tn)dx .

Average f (q) over time by F ni+ 1

2:= 14t

tn+1∫tn

f (q(xi+ 12, t))dt .

⇒ Qn+1i = Qn

i −4t4x

(F ni+ 1

2− F n

i− 12) (5)

Problem: Assume Qni is known, how do we get F n

i− 12, F n

i+ 12

in

order to compute Qn+1i ?

Oliver Meister: Solving the Shallow Water Equations

HPC – Algorithms and Applications, December 3rd 2012 5

Page 8: Solving the Shallow Water EquationsFinite Volume Methods for Hyperbolic Problems, Cambridge University Press, 6th edition, 2007 Oliver Meister: Solving the Shallow Water Equations

Technische Universitat Munchen

Motivation: Conservation laws

Discretization:Average q over space by Qn

i := 14x

∫Ci

q(x , tn)dx .

Average f (q) over time by F ni+ 1

2:= 14t

tn+1∫tn

f (q(xi+ 12, t))dt .

⇒ Qn+1i = Qn

i −4t4x

(F ni+ 1

2− F n

i− 12) (5)

Problem: Assume Qni is known, how do we get F n

i− 12, F n

i+ 12

in

order to compute Qn+1i ?

Oliver Meister: Solving the Shallow Water Equations

HPC – Algorithms and Applications, December 3rd 2012 5

Page 9: Solving the Shallow Water EquationsFinite Volume Methods for Hyperbolic Problems, Cambridge University Press, 6th edition, 2007 Oliver Meister: Solving the Shallow Water Equations

Technische Universitat Munchen

Motivation: Conservation laws

Discretization:Average q over space by Qn

i := 14x

∫Ci

q(x , tn)dx .

Average f (q) over time by F ni+ 1

2:= 14t

tn+1∫tn

f (q(xi+ 12, t))dt .

⇒ Qn+1i = Qn

i −4t4x

(F ni+ 1

2− F n

i− 12) (5)

Problem: Assume Qni is known, how do we get F n

i− 12, F n

i+ 12

in

order to compute Qn+1i ?

Oliver Meister: Solving the Shallow Water Equations

HPC – Algorithms and Applications, December 3rd 2012 5

Page 10: Solving the Shallow Water EquationsFinite Volume Methods for Hyperbolic Problems, Cambridge University Press, 6th edition, 2007 Oliver Meister: Solving the Shallow Water Equations

Technische Universitat Munchen

An unstable method

Problem: Assume Qni is known, how do we get F n

i− 12, F n

i+ 12

in

order to compute Qn+1i ?

Possible solution: Use a numerical flux function

F ni+ 1

2= F(Qn

i ,Qni+1)

First attempt:

F(Qni ,Q

ni+1) :=

12

(f (Qni ) + f (Qn

i+1))

Resulting method:Qn+1

i = Qni −

4t24x (f (Qn

i+1)− f (Qni−1)).

⇒ Central difference term, unstable.

Oliver Meister: Solving the Shallow Water Equations

HPC – Algorithms and Applications, December 3rd 2012 6

Page 11: Solving the Shallow Water EquationsFinite Volume Methods for Hyperbolic Problems, Cambridge University Press, 6th edition, 2007 Oliver Meister: Solving the Shallow Water Equations

Technische Universitat Munchen

An unstable method

Problem: Assume Qni is known, how do we get F n

i− 12, F n

i+ 12

in

order to compute Qn+1i ?

Possible solution: Use a numerical flux function

F ni+ 1

2= F(Qn

i ,Qni+1)

First attempt:

F(Qni ,Q

ni+1) :=

12

(f (Qni ) + f (Qn

i+1))

Resulting method:Qn+1

i = Qni −

4t24x (f (Qn

i+1)− f (Qni−1)).

⇒ Central difference term, unstable.

Oliver Meister: Solving the Shallow Water Equations

HPC – Algorithms and Applications, December 3rd 2012 6

Page 12: Solving the Shallow Water EquationsFinite Volume Methods for Hyperbolic Problems, Cambridge University Press, 6th edition, 2007 Oliver Meister: Solving the Shallow Water Equations

Technische Universitat Munchen

An unstable method

Problem: Assume Qni is known, how do we get F n

i− 12, F n

i+ 12

in

order to compute Qn+1i ?

Possible solution: Use a numerical flux function

F ni+ 1

2= F(Qn

i ,Qni+1)

First attempt:

F(Qni ,Q

ni+1) :=

12

(f (Qni ) + f (Qn

i+1))

Resulting method:Qn+1

i = Qni −

4t24x (f (Qn

i+1)− f (Qni−1)).

⇒ Central difference term, unstable.

Oliver Meister: Solving the Shallow Water Equations

HPC – Algorithms and Applications, December 3rd 2012 6

Page 13: Solving the Shallow Water EquationsFinite Volume Methods for Hyperbolic Problems, Cambridge University Press, 6th edition, 2007 Oliver Meister: Solving the Shallow Water Equations

Technische Universitat Munchen

Upwind Method

Modification:

Qn+1i =

{Qn

i −4t4x (f (Qn

i )− f (Qni−1)) f ′(Qn

i ) ≥ 0Qn

i −4t4x (f (Qn

i+1)− f (Qni )) f ′(Qn

i ) < 0

Upwind method, works if f ′ ≥ 0 or f ′ < 0. But what aboutsystems of equations or if the sign of f ′ changes?

Oliver Meister: Solving the Shallow Water Equations

HPC – Algorithms and Applications, December 3rd 2012 7

Page 14: Solving the Shallow Water EquationsFinite Volume Methods for Hyperbolic Problems, Cambridge University Press, 6th edition, 2007 Oliver Meister: Solving the Shallow Water Equations

Technische Universitat Munchen

Upwind Method

Modification:

Qn+1i =

{Qn

i −4t4x (f (Qn

i )− f (Qni−1)) f ′(Qn

i ) ≥ 0Qn

i −4t4x (f (Qn

i+1)− f (Qni )) f ′(Qn

i ) < 0

Upwind method, works if f ′ ≥ 0 or f ′ < 0. But what aboutsystems of equations or if the sign of f ′ changes?

Oliver Meister: Solving the Shallow Water Equations

HPC – Algorithms and Applications, December 3rd 2012 7

Page 15: Solving the Shallow Water EquationsFinite Volume Methods for Hyperbolic Problems, Cambridge University Press, 6th edition, 2007 Oliver Meister: Solving the Shallow Water Equations

Technische Universitat Munchen

Lax-Friedrichs Method

Problem: Assume Qni is known, how do we get F n

i− 12, F n

i+ 12

in

order to compute Qn+1i ?

Possible solution: Use a numerical flux function

F ni+ 1

2= F(Qn

i ,Qni+1)

Another attempt:

F(Qni ,Q

ni+1) :=

12

(f (Qni ) + f (Qn

i+1))− 4t4x

(Qni+1 −Qn

i )

Resulting method:Qn+1

i = 12(Qn

i−1 + Qni+1) + 4t

24x (f (Qni+1)− f (Qn

i−1)).⇒ Lax-Friedrichs Method, stable but diffusive.

Oliver Meister: Solving the Shallow Water Equations

HPC – Algorithms and Applications, December 3rd 2012 8

Page 16: Solving the Shallow Water EquationsFinite Volume Methods for Hyperbolic Problems, Cambridge University Press, 6th edition, 2007 Oliver Meister: Solving the Shallow Water Equations

Technische Universitat Munchen

Lax-Friedrichs Method

Problem: Assume Qni is known, how do we get F n

i− 12, F n

i+ 12

in

order to compute Qn+1i ?

Possible solution: Use a numerical flux function

F ni+ 1

2= F(Qn

i ,Qni+1)

Another attempt:

F(Qni ,Q

ni+1) :=

12

(f (Qni ) + f (Qn

i+1))− 4t4x

(Qni+1 −Qn

i )

Resulting method:Qn+1

i = 12(Qn

i−1 + Qni+1) + 4t

24x (f (Qni+1)− f (Qn

i−1)).

⇒ Lax-Friedrichs Method, stable but diffusive.

Oliver Meister: Solving the Shallow Water Equations

HPC – Algorithms and Applications, December 3rd 2012 8

Page 17: Solving the Shallow Water EquationsFinite Volume Methods for Hyperbolic Problems, Cambridge University Press, 6th edition, 2007 Oliver Meister: Solving the Shallow Water Equations

Technische Universitat Munchen

Lax-Friedrichs Method

Problem: Assume Qni is known, how do we get F n

i− 12, F n

i+ 12

in

order to compute Qn+1i ?

Possible solution: Use a numerical flux function

F ni+ 1

2= F(Qn

i ,Qni+1)

Another attempt:

F(Qni ,Q

ni+1) :=

12

(f (Qni ) + f (Qn

i+1))− 4t4x

(Qni+1 −Qn

i )

Resulting method:Qn+1

i = 12(Qn

i−1 + Qni+1) + 4t

24x (f (Qni+1)− f (Qn

i−1)).⇒ Lax-Friedrichs Method, stable but diffusive.

Oliver Meister: Solving the Shallow Water Equations

HPC – Algorithms and Applications, December 3rd 2012 8

Page 18: Solving the Shallow Water EquationsFinite Volume Methods for Hyperbolic Problems, Cambridge University Press, 6th edition, 2007 Oliver Meister: Solving the Shallow Water Equations

Technische Universitat Munchen

Godunov’s method for linear systems

Assumption: flux function f is linear.

1. Reconstruct piecewise constant function q(x , tn) from cellaverages Qn

i .2. Evolve hyperbolic equation exactly to obtain q(x , tn+1) a

time 4t later.3. Average over q(x , tn+1) to obtain Qn+1

i again.

How does step 2 work?

Oliver Meister: Solving the Shallow Water Equations

HPC – Algorithms and Applications, December 3rd 2012 9

Page 19: Solving the Shallow Water EquationsFinite Volume Methods for Hyperbolic Problems, Cambridge University Press, 6th edition, 2007 Oliver Meister: Solving the Shallow Water Equations

Technische Universitat Munchen

Godunov’s method for linear systems

How does step 2 work? Solve a Riemann problem:

Let q(x , t) ∈ Rd be a vector of d conservative variables forx , t ∈ R. f linear⇒ f (q) = A · q for a matrix A ∈ Rd×d .Then qt + A · qx = 0.Assuming A is diagonalizable we can find a diagonal matrix ofEigenvalues Λ so that A = RΛR−1.Set w := R−1q then

qt + A · qx = 0⇒ wt + Λ · wx = 0

is a modified system with a diagonal matrix Λ.

Oliver Meister: Solving the Shallow Water Equations

HPC – Algorithms and Applications, December 3rd 2012 10

Page 20: Solving the Shallow Water EquationsFinite Volume Methods for Hyperbolic Problems, Cambridge University Press, 6th edition, 2007 Oliver Meister: Solving the Shallow Water Equations

Technische Universitat Munchen

Godunov’s method for linear systems

Evolving the system from time step 0 to time step t usingwt + Λwx = 0:

1. w(x ,0) = R−1 · q(x ,0)

2. wp(x , t) = wp(x − λpt ,0) for each component p3. q(x , t) = R · w(x , t)

Oliver Meister: Solving the Shallow Water Equations

HPC – Algorithms and Applications, December 3rd 2012 11

Page 21: Solving the Shallow Water EquationsFinite Volume Methods for Hyperbolic Problems, Cambridge University Press, 6th edition, 2007 Oliver Meister: Solving the Shallow Water Equations

Technische Universitat Munchen

Godunov’s method for linear systems

Note that since q is piecewise constant, the solution of theRiemann problem on the interface is constant over time. Wedenote the value by Qi− 1

2= q(Qi−1,Qi). This gives us a

generalized flux formulation:

• Solve the Riemann problem on each interface xi− 12

toobtain q(Qi−1,Qi).

• Define flux F ni− 1

2= f (q(Qi−1,Qi)).

• Apply the flux differencing formula:

⇒ Qn+1i = Qn

i −4t4x

(F ni+ 1

2− F n

i− 12)

Oliver Meister: Solving the Shallow Water Equations

HPC – Algorithms and Applications, December 3rd 2012 12

Page 22: Solving the Shallow Water EquationsFinite Volume Methods for Hyperbolic Problems, Cambridge University Press, 6th edition, 2007 Oliver Meister: Solving the Shallow Water Equations

Technische Universitat Munchen

Godunov’s method for nonlinear systems

Shallow Water Equations: nonlinear system of equationsDifference to linear systems: Riemann problem usually notsolvable, but approximation is possible.

Goal: For each cell interface, find matrix A ∈ Rd×d such that thesystem

qt + Ai− 12qx = 0

approximates the original system

qt + f ′(q)qx = 0

by Ai− 12→ f ′(q) as Qi−1,Qi → q.

Oliver Meister: Solving the Shallow Water Equations

HPC – Algorithms and Applications, December 3rd 2012 13

Page 23: Solving the Shallow Water EquationsFinite Volume Methods for Hyperbolic Problems, Cambridge University Press, 6th edition, 2007 Oliver Meister: Solving the Shallow Water Equations

Technische Universitat Munchen

Godunov’s method with Roe linearization

Useful assumption: A single wave with speed s connects Qiand Qi+1, so that f (Qi)− f (Qi−1) = s · (Qi −Qi−1). Ourapproximation must meetAi− 1

2(Qi −Qi+1) = s · (Qi −Qi−1) = f (Qi)− f (Qi−1).

Idea: q(ξ) := Qi−1 + ξ · (Qi −Qi−1), then f (Qi)− f (Qi−1) =1∫0

df (q(ξ))dξ dξ =

1∫0

f ′(q(ξ))q′(ξ)dξ =

[1∫0

f ′(q(ξ))dξ

](Qi −Qi−1).

⇒ f (Qi)− f (Qi−1) =

1∫0

f ′(q(ξ))dξ

(Qi −Qi−1)

So a suitable choice for A is1∫0

f ′(q(ξ))dξ.

Oliver Meister: Solving the Shallow Water Equations

HPC – Algorithms and Applications, December 3rd 2012 14

Page 24: Solving the Shallow Water EquationsFinite Volume Methods for Hyperbolic Problems, Cambridge University Press, 6th edition, 2007 Oliver Meister: Solving the Shallow Water Equations

Technische Universitat Munchen

Godunov’s method with Roe linearization

Useful assumption: A single wave with speed s connects Qiand Qi+1, so that f (Qi)− f (Qi−1) = s · (Qi −Qi−1). Ourapproximation must meetAi− 1

2(Qi −Qi+1) = s · (Qi −Qi−1) = f (Qi)− f (Qi−1).

Idea: q(ξ) := Qi−1 + ξ · (Qi −Qi−1), then f (Qi)− f (Qi−1) =1∫0

df (q(ξ))dξ dξ =

1∫0

f ′(q(ξ))q′(ξ)dξ =

[1∫0

f ′(q(ξ))dξ

](Qi −Qi−1).

⇒ f (Qi)− f (Qi−1) =

1∫0

f ′(q(ξ))dξ

(Qi −Qi−1)

So a suitable choice for A is1∫0

f ′(q(ξ))dξ.

Oliver Meister: Solving the Shallow Water Equations

HPC – Algorithms and Applications, December 3rd 2012 14

Page 25: Solving the Shallow Water EquationsFinite Volume Methods for Hyperbolic Problems, Cambridge University Press, 6th edition, 2007 Oliver Meister: Solving the Shallow Water Equations

Technische Universitat Munchen

Godunov’s method with Roe linearization

Useful assumption: A single wave with speed s connects Qiand Qi+1, so that f (Qi)− f (Qi−1) = s · (Qi −Qi−1). Ourapproximation must meetAi− 1

2(Qi −Qi+1) = s · (Qi −Qi−1) = f (Qi)− f (Qi−1).

Idea: q(ξ) := Qi−1 + ξ · (Qi −Qi−1), then f (Qi)− f (Qi−1) =1∫0

df (q(ξ))dξ dξ =

1∫0

f ′(q(ξ))q′(ξ)dξ =

[1∫0

f ′(q(ξ))dξ

](Qi −Qi−1).

⇒ f (Qi)− f (Qi−1) =

1∫0

f ′(q(ξ))dξ

(Qi −Qi−1)

So a suitable choice for A is1∫0

f ′(q(ξ))dξ.

Oliver Meister: Solving the Shallow Water Equations

HPC – Algorithms and Applications, December 3rd 2012 14

Page 26: Solving the Shallow Water EquationsFinite Volume Methods for Hyperbolic Problems, Cambridge University Press, 6th edition, 2007 Oliver Meister: Solving the Shallow Water Equations

Technische Universitat Munchen

Godunov’s method with Roe linearization

Usually, instead of integrating over ξ a transformation z(ξ) isused to integrate a path on, because the resulting matrix maynot be diagonalizable.

f (Qi)− f (Qi−1) =

1∫0

f ′(q(z(ξ)))dξ

(Zi − Zi−1)

where Zi = z(Qi),Zi−1 = z(Qi−1) and

Qi −Qi−1 =

1∫0

dq(z(ξ)))

dzdξ

(Zi − Zi−1)

Oliver Meister: Solving the Shallow Water Equations

HPC – Algorithms and Applications, December 3rd 2012 15

Page 27: Solving the Shallow Water EquationsFinite Volume Methods for Hyperbolic Problems, Cambridge University Press, 6th edition, 2007 Oliver Meister: Solving the Shallow Water Equations

Technische Universitat Munchen

Roe solver for the 1D Shallow Water Equations

Nonlinear system of equations (ignoring source terms):[h

hu

]t

+

[hu

hu2 + 12gh2

]x

= 0

With q :=

[h

hu

]they can be described as follows:

qt +

[q2

q22

q1+ 1

2gq21

]x

= 0

Oliver Meister: Solving the Shallow Water Equations

HPC – Algorithms and Applications, December 3rd 2012 16

Page 28: Solving the Shallow Water EquationsFinite Volume Methods for Hyperbolic Problems, Cambridge University Press, 6th edition, 2007 Oliver Meister: Solving the Shallow Water Equations

Technische Universitat Munchen

Roe solver for the 1D Shallow Water Equations

Choose as parameter vector z := 1√hq. Leaving out

intermediate steps we obtain:

A =

[0 1

−u2 + gh 2u

]as our Roe matrix with the arithmetic average h and the Roeaverage u. Applying Godunov’s method for the time step, wehave a full numerical scheme now.

Oliver Meister: Solving the Shallow Water Equations

HPC – Algorithms and Applications, December 3rd 2012 17