advection - university of notre damegtryggva/cfd-course/2013-lecture-11.pdfgodunov theorem (1959):!...
TRANSCRIPT
Computational Fluid Dynamics
Advection!
Grétar Tryggvason!Spring 2013!
http://www.nd.edu/~gtryggva/CFD-Course/!Computational Fluid Dynamics
What we know so far:!!First-order methods result in a low accuracy and dissipative solution, particularly at a shock. The solution does, however, not oscillate (preserves monotonicity). !!Second-order methods capture shocks better but produce wiggly solutions.!!For the nonlinear advection equation, the first order captures the solution reasonably well, since the characteristics terminate in the shock!
Computational Fluid Dynamics
Godunov Theorem!
Computational Fluid Dynamics
Question: How can we avoid oscillatory behavior?!(How can we preserve monotonicity)!
Godunov Theorem (1959):!
“Monotone behavior of a numerical solution cannot be assured for linear finite-difference methods with more than first-order accuracy.”!
Godunov’s Theorem!
Computational Fluid Dynamics Godunov Theorem - 1!
0=∂∂+
∂∂
xf
Utf
For linear equation!
we have:!2
22
2
2
;xf
Utf
xf
Utf
∂∂=
∂∂
∂∂−=
∂∂
A general linear scheme can be written as:!
∑ ++ =
k
nkjk
nj fcf 1
Expanding in Taylor series around!nkjf +
njf
)(2
32
222
hOxfhk
xfkhff n
jnkj +
∂∂+
∂∂+=+
Computational Fluid Dynamics Godunov Theorem - 2!
Substituting!
Also, can be Taylor expanded in time around!
∑ ∑∑ +∂∂+
∂∂+=+
k kk
kkk
nj
nj hOck
xfhkc
xfhcff )(
232
2
221
(a)=(b) (2nd order accurate):!2
2;;1 ⎟⎠⎞⎜
⎝⎛ Δ=Δ−== ∑∑∑ h
tUckhtUkcc
kk
kk
kk
1+njf
njf
)(2
32
221 tO
tft
tftff n
jnj Δ+
∂∂Δ+
∂∂Δ+=+
)(2
32
222 tO
xftU
xftUf nj Δ+
∂∂Δ+
∂∂Δ−=
(a)!
(b)!
Computational Fluid Dynamics Godunov Theorem - 3!
Condition for monotonicity:!11
11 then,If ++++ >> n
jnj
nj
nj ffff
Since! ∑ ++ =
k
nkjk
nj fcf 1
( )∑ +++++
+ −=−k
nkj
nkjk
nj
nj ffcff 1
111
> 0 The above should be valid for arbitrary!
00 111 >−⇔> ++
+nj
njk ffc
njf
Is it possible?!
Computational Fluid Dynamics Godunov Theorem - 4!
Hence we get:!
22;;1 ⎟
⎠⎞⎜
⎝⎛ Δ=Δ−== ∑∑∑ h
tUckhtUkcc
kk
kk
kk
ckk∑⎛⎝⎜
⎞⎠⎟
k2ckk∑⎛⎝⎜
⎞⎠⎟= kck
k∑⎛⎝⎜
⎞⎠⎟
2
ek2
k∑⎛⎝⎜
⎞⎠⎟
k2ek2
k∑⎛⎝⎜
⎞⎠⎟= kek
2
k∑⎛⎝⎜
⎞⎠⎟
2
Define:! )0(2 >= kkk cec
This violates Cauchy inequality! a ⋅a( ) b ⋅b( ) ≥ a ⋅b( )2
Monotone 2nd Order scheme is impossible! !
a
b a = e1,e2,e3,…,ek,…( ); b = 1e1, 2e2,3e3,…,kek,…( )
a ⋅a( ) b ⋅b( ) = a ⋅b( )2or!
where!
Computational Fluid Dynamics
The key word in Godunov’s theorem is linear. To overcome its limitations, look for nonlinear scheames:!
1. Use central differencing and introduce numerical!!viscosity where needed (Artificial viscosity)!
!2. Limit the fluxes in such a way that oscillations are
avoided (high-order Godunov methods, flux-corrected transport, TVD shemes, etc.)!
Computational Fluid Dynamics
Godunov’s Method!
Computational Fluid Dynamics
Godunov Method – Finite Volume Method + Riemann solver!
∂f∂t
+∂∂x
F( f )[ ] = 0
Consider a 1-D Conservation Eq:!
Integrating across the j-th cell:!
Godunov Method!
Fj-1/2 Fj+1/2 !
1+jff j−1
jf
x!j ! j+1 !j-1 !
0)()( 2/12/1
2/1
2/1=−+
∂∂
−+∫+
−jj
x
xxFxFfdx
tj
j
Define the cell-average:! fav =1Δx j
f dxxj−1/2
x j+1/2∫Δx j
∂fav∂t
+ F(x j+1/2 ) − F(x j−1/2 ) = 0
Δx j = x j+1/2 − x j−1/2
Computational Fluid Dynamics
Integrating over time!
where the time integration is done by solving !Riemann Problem for each cell boundary:!
favn+1 = fav
n −ΔtΔx j
1Δt
Fj+1/2 dt −1Δt
Fj−1/2 dtt
t+Δt
∫t
t+Δt
∫⎡⎣⎢
⎤⎦⎥
tΔ
[ ] 0)( =∂∂+
∂∂
fFxt
f
⎪⎩
⎪⎨⎧
>≤
=++
+
2/11
2/1)0,(jj
jj
xxf
xxfxf 1+jf
jf
x!j ! j+1 !
t!
2/1+= jcdtdx
t+Δt !
Godunov Method!
Computational Fluid Dynamics
Wave Diagram: !
1+jff j−1
jf
j ! j+1 !j-1 !
Shock!Shock!Rarefaction!
Wave!
Godunov Method!Computational Fluid Dynamics
Godunov Method: The Procedure !
1. Construct a cell average value !
fav =1Δx j
f dxxj−1/2
x j+1/2∫2. Solve a Riemann problem to find the time ! integration of fluxes!!3. Construct new!!4. Go to 1. !
avf
ttt Δ+=
Godunov Method!
Computational Fluid Dynamics
Special Case: Linear Advection Equation!
0,0 >=∂∂+
∂∂
Uxf
Utf
for which the Riemann problem is trivial and we get!
( )nj
nj
njav
njav ff
htUff 1,
1, −+ −Δ−=
jj UfF =+ 2/1
1st Order Upwind Scheme!
Godunov Method!Computational Fluid Dynamics
fi+1
Consider the following initial conditions:!
1f j−1 fi
Fj−1 / 2 = Ufj−1n = U
Fj+1 / 2 = Ufjn = 0
f jn+1 = fj
n −Δth(Fj+1 / 2
n − Fj−1 / 2n )
Godunov Method!
Computational Fluid Dynamics Godunov Method!
Advect—Average—Advect—Average—etc!The averaging leads to numerical diffusion, even though the advection is exact!!
Computational Fluid Dynamics Godunov Method!
Numerical versus exact solution!
Computational Fluid Dynamics
For nonlinear equations and systems the full Rieman problem must be solved!Since only the fluxes are needed, often approximate solvers are used!
Godunov Method!Computational Fluid Dynamics
Higher Order Upwind schemes!
Computational Fluid Dynamics
Even though the fluxes were computed EXACTLY, the solution was very inaccurate due to numerical diffusion. Since the advection is exact, the problem must lie with the averaging of the solution and the assumption of a constant state in each cell!!To generate more accurate schemes, we need to reconstruct a more accurate representation of the function in each cell.!
Higher Order Methods!Computational Fluid Dynamics
For the first order spatial fluxes, the value in each cell was assumed to be a constant. For higher order computations of the spatial fluxes, the slope inside each cell is found!
�
Fj+1/ 2n+1/ 2 = F f L( ) j+1/ 2
n+1/ 2, f R( ) j+1/ 2
n+1/ 2( )
Once the value at the cell boundary has been found, the flux is found using these values!
Higher Order Methods!
Computational Fluid Dynamics
For the Lax-Wendroff scheme the time and space discretization are closely linked.!!In the Beam-Warming method, on the other hand, the time integration is independent of the spatial discretization!!
Higher Order Methods!Computational Fluid Dynamics
The separation of space and time discretization is generalized in the Method of Lines, where we convert the PDE into a set of ODEs for each grid point by writing:!
df j
dt=−1h
Fj+1/ 2n − Fj−1/ 2
n( )The time integration can, in principle, be done by any standard ODE solver, although in practice we often use second order Runge-Kutta methods!
Higher Order Methods!
Computational Fluid Dynamics
To get a second order time integration, use a half-step predictor to give second order accuracy in time: !
�
f jn+1/ 2 = f j
n − Δt2h
Fj+1/ 2n − Fj−1/ 2
n( )
�
f jn+1 = f j
n − Δth
Fj+1/ 2n+1/ 2 − Fj−1/ 2
n+1/ 2( )Then correct by a midpoint rule:!
where the fluxes are found at the half step!
j-1 j j+1
Higher Order Methods!Computational Fluid Dynamics
For a method that is second order in time we therefore must find the fluxes twice. For the method on the last slide we find!
�
Fj+1/ 2n = F f j
n, f j+1n( )
at the beginning of the step.!And!
at the half step. For a first order in space methods we take the values on either side to be the cell averages but for higher order methods the variables are extrapolated to the cell boundaries to give higher order fluxes.!
�
Fj+1/ 2n+1/ 2 = F f L( ) j+1/ 2
n+1/ 2, f R( ) j+1/ 2
n+1/ 2( )
Higher Order Methods!
Computational Fluid Dynamics
A fairly general family of higher order methods can be constructed by weighing the slopes in each cell in different ways:!!
Higher Order Methods!Computational Fluid Dynamics
j ! j+1 !j-1 ! j+2 !
1+jf 2+jf
jf1−jf
Ljf 2/1+
f j+1/2L = f j +
h2
1−κ2
⎛⎝⎜
⎞⎠⎟S− +
1+κ2
⎛⎝⎜
⎞⎠⎟S+⎡
⎣⎢⎤⎦⎥
Higher order fluxes!
�
f j+1/ 2L = f j + h
2S
�
S+ =f j+1 − f j
hS− =
f j − f j−1h
Define slopes:!
Define a weighted average:!
�
k = 0 use 12 S
+ + S−( )k =1 use S+ only
k = −1 use S− only
Higher Order Methods!
Computational Fluid Dynamics
f j+1/2L = f j +
h2
1−κ2
⎛⎝⎜
⎞⎠⎟S− +
1+κ2
⎛⎝⎜
⎞⎠⎟S+⎡
⎣⎢⎤⎦⎥
= f j +h2
1−κ2
⎛⎝⎜
⎞⎠⎟
f j − f j−1h
⎛⎝⎜
⎞⎠⎟+1+κ2
⎛⎝⎜
⎞⎠⎟
f j+1 − f jh
⎛⎝⎜
⎞⎠⎟
⎡
⎣⎢
⎤
⎦⎥
= f j +1−κ4
f j − f j−1( ) + 1+κ4 f j+1 − f j( )
Using!
�
S+ =f j+1 − f j
hS− =
f j − f j−1h
We find!
Higher Order Methods!Computational Fluid Dynamics
Rjf 2/1+
�
f j+1/ 2R = f j+1 −
1−κ4
f j+1 − f j( ) − 1+ κ4
f j+2 − f j+1( )
Similarly!
�
f j+1/ 2R = f j+1 −
h2S
�
S+ =f j+2 − f j+1
hS− =
f j+1 − f jh
j ! j+1 !j-1 ! j+2 !
1+jf 2+jf
jf1−jf
Higher Order Methods!
Computational Fluid Dynamics
j ! j+1 !j-1 ! j+2 !
1+jf 2+jf
jf1−jf
Ljf 2/1+
Rjf 2/1+
�
f j+1/ 2L = f j + 1−κ
4f j − f j−1( ) + 1+ κ
4f j+1 − f j( )
�
f j+1/ 2R = f j+1 −
1−κ4
f j+1 − f j( ) − 1+ κ4
f j+2 − f j+1( )
1for −=κ
Evaluation of the function at the cell boundary:!
Different values of k give different second order schemes!
Higher Order Methods!Computational Fluid Dynamics
Selecting k differently allows us to recover a number of standard schemes:!
�
f j+1/ 2L = f j + 1−κ
4f j − f j−1( ) + 1+ κ
4f j+1 − f j( )
κ = −1κ = 0κ = 1 / 2κ = 1 / 3κ = 1
Second order upwind!Fromm’s scheme!QUICK!Third order upwind!Centered scheme!
Higher Order Methods!
Computational Fluid Dynamics
�
f jn+1/ 2 = f j
n − Δt2h
Fj+1/ 2n − Fj−1/ 2
n( )
�
f jn+1 = f j
n − Δth
Fj+1/ 2n+1/ 2 − Fj−1/ 2
n+1/ 2( )
�
Fj+1/ 2n+1/ 2 = F f L( ) j+1/ 2
n+1/ 2, f R( ) j+1/ 2
n+1/ 2( )
Predictor step!
Final step!
where! is a higher order flux!
Can use first order fluxes for the predictor step!
10 20 30 40 50 60 70 80-0.5
0
0.5
1
1.5
upwind!
K=-1!
K=0!
K=1!Example: Linear Advection !
Higher Order Methods!Computational Fluid Dynamics
Notice that we can also write the flux as!
�
f j+1/ 2L = f j + 1−κ
4f j − f j−1( ) + 1+ κ
4f j+1 − f j( )
f j+1/ 2
L =12
f j + f j+1( ) − 1−κ4
f j+1 − 2 f j + f j−1( )Where the fluxes appear as centered approximations with a stabilizing artificial dissipation !
Higher Order Methods!
Computational Fluid Dynamics
An even more general family of schemes can be constructed by writing!
Where!
f j+1/ 2
L = f j +12
B f j − f j−1, f j+1 − f j( )
f j+1/ 2
L = f j +12Ψ(r) f j − f j−1( )
r =
f j+1 − f j
f j − f j−1
Where B is a function of the slopes to the left and the right. Often we take !
B f j − f j−1, f j+1 − f j( ) = Ψ(r) f j − f j−1( )
Giving!
Flux Limiter!
Higher Order Methods!Computational Fluid Dynamics
The k scheme can be written in terms of the flux limiter!
Ψ(r) =
1+κ2
r + 1−κ2
f j+1/ 2L = f j +
12Ψ(r) f j − f j−1( )
= f j +12
1+κ2
r + 1−κ2
⎛⎝⎜
⎞⎠⎟
f j − f j−1( )
= f j +12
1+κ2
f j+1 − f j
f j − f j−1
⎛
⎝⎜
⎞
⎠⎟ +
1−κ2
⎛
⎝⎜⎜
⎞
⎠⎟⎟
f j − f j−1( )
= f j +1+κ
4f j+1 − f j( ) + 1−κ
4f j − f j−1( )
r =
f j+1 − f j
f j − f j−1
As can be seen by substitution:!
Higher Order Methods!
Computational Fluid Dynamics
For the k scheme we have:!!
Ψ(r) =
1+κ2
r + 1−κ2
r =
f j+1 − f j
f j − f j−1
Ψ(r) =12
; κ = −1
Ψ(r) =r2+
12
; κ = 0
Ψ(r) = r; κ = 1
Second order upwind!
Fromm’s scheme!
Centered scheme!
f j+1/ 2
L = f j +12Ψ(r) f j − f j−1( )
Higher Order Methods!Computational Fluid Dynamics
We can also write other schemes in this way. !For example:!
r =
f j+1 − f j
f j − f j−1
First order upwind!Lax-Wendroff!Beam-Warming!
f j+1/ 2
L = f j +12Ψ(r) f j − f j−1( )
Ψ(r) = 0Ψ(r) = 1Ψ(r) = r
Higher Order Methods!
Computational Fluid Dynamics
But what about the oscillations?!
Computational Fluid Dynamics
The formulation of second order schemes in terms of slopes allows us to understand the reason for oscillations near discontinuity. The construction of slopes leads to overshoots:!!
j ! j+1 !j-1 ! j+2 !
1+jf 2+jf
jf1−jf
Oscillations!
Computational Fluid Dynamics
To prevent oscillations near shocks when using high order schemes, we have already talked about artificial viscosity where we attempt to smooth out oscillations around the shocks.!!The more modern approach is to prevent the apparence of oscillations by either:!!Limit the slopes when the variables are extrapolated to the cell boundaries!!Limit the fluxes near shocks to prevent under or over shoot!
Oscillations!Computational Fluid Dynamics
j ! j+1 !j-1 ! j+2 !
1+jf 2+jf
jf1−jf
Near shocks the linear reconstruction leads to over and undershoots.!
To prevent oscillations, apply LIMITERS to reduce the slopes where they will cause oscillations but leave then where they do not!
Many possible limiters can be designed!
Oscillations!
Computational Fluid Dynamics
Example: Linear Advection Equation!
∂f∂t
+ U∂f∂x
= 0
�
F =Uf
�
Fj+1/ 2 =Uf j+1/ 2L
�
Ψ r( ) =r + r1+ r
rj+1/ 2 =
f j − f j−1
f j+1 − f j
�
Ψ = 2 if f j+1 − f j = 0
j ! j+1 !j-1 !
1+jf
jf1−jf
Oscillations!Computational Fluid Dynamics
10 20 30 40 50 60 70 80-0.5
0
0.5
1
1.5
upwind! Second order!
Limited!
Oscillations!
Computational Fluid Dynamics
The realization that we could enforce monotonicity in otherwise high order schemes using nonlinear limiters revolutionized the computation of flows with shocks. The idea originated with Bram van Leer and Jay Boris but has since been taken further by a large number of researchers. It is still an active area of research.!!A large number of limiters have been proposed and we will examine a few of those in more detail.!
Oscillations!Computational Fluid Dynamics
Stability in !terms of Fluxes!
Computational Fluid Dynamics
f j−1 f j f j+1
Fj−1 / 2 = Ufj−1n = 1
Fj+1 / 2 = Ufjn = 0
Consider the following initial conditions:!
1
During one time step, U∆t of f flows into cell j, increasing the average value of f by U∆t/h.!
U = 1
Δ th
= 1.5 ⋅U = 1.5
Stability in terms of fluxes!Computational Fluid Dynamics
fi+1
Consider the following initial conditions:!
1f j−1 fi
Fj−1 / 2 = Ufj−1n = U
Fj+1 / 2 = Ufjn = 0
f jn+1 = fj
n −Δth(Fj+1 / 2
n − Fj−1 / 2n ) = 0 − 1.5(0 −1) = 1.5
Stability in terms of fluxes!
Computational Fluid Dynamics
f j+11
f j−1 f j
Fj−1 / 2 = Ufj−1n =U Fj+1 / 2 = Ufj
n = 1.5U
f jn+1 = fj
n −Δth(Fj+1 / 2
n − Fj−1 / 2n ) = 0 − 1.5(1.5 − 1) = 0.75
f j+1n+1 = fj+1
n −Δth(Fj+ 3/ 2
n − Fj+1/ 2n ) = 0 −1.5(0 −1.5) = 2.25
Stability in terms of fluxes!Computational Fluid Dynamics
f j+11
f j−1 f j
Fj−1 / 2 = Ufj−1n =U
Fj+1 / 2 = Ufjn = 0.75U
Taking a third step will result in an even larger positive value, and so on until the compute encounters a NaN (Not a Number).!
Fj+1 / 2 = Ufjn = 2.25U
Stability in terms of fluxes!
Computational Fluid Dynamics
If U∆t/h > 1, the average value of f in cell j will be larger than in cell j-1. In the next step, f will flow out of cell j in both directions, creating a larger negative value of f. Taking a third step will result in an even larger positive value, and so on until the compute encounters a NaN (Not a Number).!
Stability in terms of fluxes!Computational Fluid Dynamics
MOVIE FROM MATLAB!% one-dimensional advection by first order upwind.!n=80; nstep=100; dt=0.0125; length=2.0;!h=length/(n-1);y=zeros(n,1);f=zeros(n,1);f(1)=1.0;!!for m=1:nstep,m! hold off, plot(f); axis([1, n, -0.5, 1.5]);! pause(0.01);! y=f;! for i=2:n-1,! f(i)=y(i)-(dt/h)*(y(i)-y(i-1)); %upwind! end;!end;!!
Stability in terms of fluxes!
Computational Fluid Dynamics
fj+1
Consider the following initial conditions:!
1fj−1 fj
Fj−1/ 2 =U2( fj−1
n + fjn ) =1.0 Fj+1/ 2 =
U2( fj
n + f j+1n ) = 0.5
fjn+1 = fj
n −Δth(Fj+1/ 2
n − Fj−1/ 2n ) = 1.0 − 0.5(0.5 −1) =1.25
So cell j will overflow immediately!!
By considering the fluxes, it is easy to see why the centered difference approximation is always unstable.!
Stability in terms of fluxes!