MF 206 A22 Lect 3
MF 206 A22 Lect 3
MF 206 A22 Lect 3
Lecture 3
Marica Pelanti
marica.pelanti@ensta-paris.fr
Differential form
∂T ~ ·F
~H = 0
ρch +∇
∂t
1D Heat equation
∆x
ρch ∂T
∂t
+ ∂F
∂x
H
=0
xi−2 xi−1 xi xi+1 xi+2
ith CV
FH = −κ ∂T
∂x
→ ρch ∆x ∂T
∂t
i
+ (−κ ∂T )
∂x i+1/2
− (−κ ∂T )
∂x i−1/2
=0
Ti+1 −Ti Ti+1 −Ti T −T
( ∂T )
∂x i+1/2
≈ ∆x
⇒ ρch ∂T ∂t
i κ
− ∆x ∆x
− i ∆xi−1 = 0
∂Ti α κ
⇒ ∂t
− (∆x)2
(Ti+1 − 2Ti + Ti−1 ) = 0, α= ch ρ
= thermal diffusivity
2
∂T
Same as Finite Difference discretization in space of PDE ∂t
− α ∂∂xT2 = 0
2
T −2T +T
Ti∗ ≈ T (xi , t∗ ), ∂ T
∂x2
≈ i+1 ∆xi2 i−1
i
MF206 (ENSTA Paris) Lecture 3 2021-2022 5 / 34
Finite Difference and Finite Volume Methods
2D
j + 23
j+1
j + 21
(xi , yj ) CV (i, j)
j
j − 21
j−1
j − 23
i− 32 i− 21 i+ 21 i+ 32
i−1 i i+1
~ · ~v = 0 ,
∇ Mass
~
∂~v ~ v = − ∇p + ν ∇2~v ,
+ ~v · ∇~ Momentum
∂t ρ
∂T
ρcv ~
+ ~v · ∇T = κ∇2 T + Φ . Energy
∂t
+ Initial and Boundary Conditions (on solid rigid walls: no-slip condition ~v = 0 )
Velocity-Pressure formulation
Conservative form
~ · ~v = 0 ,
∇ ~ · ~v = 0 ,
∇
~
∂~v ~ v = − ∇p + ν ∇2~v .
+ ~v · ∇~
∂~v ~ p~~ ~
+ ∇ · ~v ⊗ ~v + I − ν ∇~v = 0 .
∂t ρ ∂t ρ
Z
~v · ~n dS = 0 ,
S
Z Z Z Z
∂~v 1 ~ v · ~n dS = 0 .
dV + ~v (~v · ~n)dS + p~n dS − ν ∇~
V ∂t S ρ S S
∂u ∂v
+ = 0, (1a)
∂x ∂y
2
∂2u
∂u ∂u ∂u 1 ∂p ∂ u
+u +v =− +ν + , (1b)
∂t ∂x ∂y ρ ∂x ∂x2 ∂y 2
2
∂2v
∂v ∂v ∂v 1 ∂p ∂ v
+u +v =− +ν 2
+ . (1c)
∂t ∂x ∂y ρ ∂y ∂x ∂y 2
∂2ω ∂2ω
∂ω ∂ω ∂ω
+u +v =ν + , (2a)
∂t ∂x ∂y ∂x2 ∂y 2
∂2ψ ∂2ψ
2
+ = −ω . (2b)
∂x ∂y 2
~ = −~
⇒ ∇2 ψ ω ~
vector Poisson equation for ψ
+ vector convection-diffusion equation for ω
~ : ∂~
ω ~ × (~
+∇ ω × ~v ) = ν∇2 ω
~
∂t
~ · ~v = 0 ,
∇ mass (continuity) eq.
~
∂~v ~ v = − ∇p + ν ∇2~v .
+ ~v · ∇~ momentum eq.
∂t ρ
Collocated grid ui , pi ∆x
i− 32 i− 21 i+ 21 i+ 32
j + 32
j+1 p
vi,j+ 1 u
j + 12 2
v
pi,j ui+ 1 ,j
2
j
j − 12
j−1
j − 32
i− 32 i− 21 i+ 12 i+ 23
i−1 i i+1
~ h · ~v n+1 = 0 ,
∇
~v n+1 − ~v n 1~
= −Ah (~v n ) − ∇ hp
n+1
+ ν∇2h ~v n .
∆t ρ
~v
Ah = discrete spatial differential operator for convective term ~v · ∇~
~ h , ∇2h = discrete spatial differential operators for ∇
∇ ~ and ∇2
Projection Method
II. Projection
v∗
v n+1 −~ ~ h p n+1 ~ h pn+1
~
∆t
= − ρ1 ∇ ⇒ ~v n+1 = ~v ∗ − ∆t
ρ
∇
~ h · ~v n+1 = ∇
Take divergence: ∇ ~ h · ~v ∗ − ∆t ~ h · (∇
∇ ~ h pn+1 )
ρ
~ h · ~v n+1 = 0
Mass equation: ∇
ρ ~
⇒ ∇2h pn+1 = ∇
∆t h
· ~v ∗ Pressure Poisson Equation
Algorithm
ρ ~
∇2h pn+1 = ∇h · ~v ∗
∆t this is a splitted operator resolution
∆t ~ n+1
~v n+1 = ~v ∗ − ∇h p
ρ
~ h · ~v n+1 = 0 ,
∇
~v n+1 − ~v n 1~
= −Ah (~v n ) − ∇ hp
n+1
+ ν∇2h ~v n .
∆t ρ
~ h · ~v n = 0 and ∇
Using ∇ ~ h · ~v n+1 = 0
~ h · Ah (~v n )
⇒ ∇2h pn+1 = −ρ∇ Pressure Poisson Equation
~ h · (∇
Note: ∇ ~ h p n+1 ) = ∇2h pn+1 and
~ h · (∇2h ~v n ) = ∇
∇ ~ h · (∇
~ h (∇
~ h · ~v n ) − ∇
~h×∇
~ h × ~v n ) = ∇2h · (∇
~ h · ~v n ) = 0.
~ h · Ah (~v n )
∇2h pn+1 = −ρ∇ ∇2h pn+1 = ρ ~
∇ · ~v ∗
∆t h
j+1 p
vi,j+ 1 u
2
j + 12 v
pi,j ui+ 1 ,j
2
j
Mass equation
j +1 p
Mass conservation law vi,j+ 1 u
R j + 12 2
v
Sp
~v · ~n dS = 0 pi,j ui+ 1 ,j
2
j
hui+ 1 ,j −hui− 1 ,j +hvi,j+ 1 −hvi,j− 1 = 0
2 2 2 2
j − 12
⇒ ui+ 1 ,j − ui− 1 ,j + vi,j+ 1 − vi,j− 1 = 0
2 2 2 2 j −1
i−1 i i+1
n = outward unit normal
~
i− 12 i+ 21
Note: same result with Finite Difference approach
~ ·~
PDE: ∇ u= ∂u
+ ∂v
=0
∂x ∂y
u −u v −v
∂u
i+ 1 ,j i− 1 ,j ∂v
i,j+ 1 i,j− 1
Take centered differences: ∂x i,j
≈ 2
h
2
, ∂x i,j
≈ 2
h
2
u −u v −v
i+ 1 ,j i− 1 ,j i,j+ 1 i,j− 1
~ ·~
∇ u = 0 at (i, j) ⇒ 2 2
+ 2 2
=0
h h
x-momentum equation
∂u 1 ~ · ~n dS = 0
R R R R
Vu ∂t
dV + u(~v · ~n)dS +
Su ρ Su
p nx dS − ν Su
∇u
j +1 p
Unsteady term
vi,j+ 1 u
∂u
= h2 ∂t
∂ 1
j + 12
R R 2
Vu ∂t
dV h2 Vu
udV v
pi,j ui+ 1 ,j
∂ui+1/2,j j 2
→ h2 ∂t
Pressure term j − 12
R
Su
p nx dS → h(pi+1,j − pi,j ) j −1
i−1 i i+1
i− 21 i+ 12
Convective term
u(~v · ~n)dS → h u2i+1,j − u2i,j + (uv)i+ 1 ,j+ 1 − (uv)i+ 1 ,j− 1
R
Su 2 2 2 2
Diffusive term
~ · ~n dS → h ∂u ∂u ∂u ∂u
R
Su
∇u ∂x i+1,j
− ∂x i,j
+ ∂y
− ∂y
i+ 1
2
1
,j+ 2 i+ 1
2
,j− 1
2
~
nEast = (1, 0), ~
nNorth = (0, 1), ~ nSouth = (0, −1)
nWest = (−1, 0), ~
MF206 (ENSTA Paris) Lecture 3 2021-2022 24 / 34
Projection Method Space discretization on staggered grid
x-momentum equation
u(~v · ~n)dS → h u2i+1,j − u2i,j + (uv)i+ 1 ,j+ 1 − (uv)i+ 1 ,j− 1
R
Convective term Su 2 2 2 2
2
Interpolate the velocities: (u2 )i,j = 21 (ui+ 1 ,j + ui− 1 ,j )
2 2
(uv)i+ 1 ,j+ 1 = 12 (ui+ 1 ,j+1 + ui+ 1 ,j ) 1
2
(vi,j+ 1 + vi+1,j+ 1 ) .
2 2 2 2 2 2
~ · ~ndS → h ∂u ∂u ∂u ∂u
R
Diffusive term S ∇u ∂x i+1,j
− ∂x i,j
+ ∂y 1 1
− ∂y
u 1 i+ 2 ,j+ 2 i+ 2 ,j− 1
2
j +1 p
Same as FD 5-point (∇2 u)i+ 1 ,j vi,j+ 1 u
2
j + 12 2
v
u −u pi,j ui+ 1 ,j
∂u
i+ 1 ,j i− 1 ,j 2
∂x i,j
= 2
h
2 j
u −u
i+ 1 ,j+1 i+ 1 ,j j − 12
∂u 2 2
∂y
= h
i+ 1
2
,j+ 1
2
j −1
i−1 i− 1 i i+ 12 i+1
2
MF206 (ENSTA Paris) Lecture 3 2021-2022 25 / 34
Projection Method Space discretization on staggered grid
y-momentum equation
∂v 1 ~ · ~n dS = 0
R R R R
Vv ∂t
dV + v(~v · ~n)dS +
Sv ρ Sv
p ny dS − ν Sv
∇v
j +1 p
vi,j+ 1 u
j + 12 2
v
∂v
∂v
h2 i,j+1/2
R
dV → pi,j ui+ 1 ,j
Vv ∂t ∂t 2
j
j − 12
R
Sv
p ny dS → h(pi,j+1 − pi,j )
j −1
i−1 i i+1
i− 21 i+ 12
2 2
R
v(~v · ~n)dS → h vi,j+1
Sv
− vi,j + (uv)i+ 1 ,j+ 1 − (uv)i− 1 ,j+ 1
2 2 2 2
2
2 1
(v )i,j = 2 (vi,j+ 1 + vi,j− 1 )
2 2
~ · ~n dS → v
R
Sv
∇v i,j+ 3 + vi,j− 1 + vi+1,j+ 1 + vi−1,j+ 1 − 4vi,j+ 1
2 2 2 2 2
x−momentum
∂u
i+ 1 ,j
∂t
2
= − h1 (u2 )i+1,j − (u2 )i,j + (uv)i+ 1 ,j+ 1 − (uv)i+ 1 ,j− 1
2 2 2 2
1
− hρ (pi+1,j − pi,j )
ν
+ h2 ui+ 3 ,j + ui− 1 ,j + ui+ 1 ,j+1 + ui+ 1 ,j−1 − 4ui+ 1 ,j
2 2 2 2 2
y-momentum
∂v
i,j+ 1
2
∂t
= − h1 (v 2 )i,j+1 − (v 2 )i,j + (uv)i+ 1 ,j+ 1 − (uv)i− 1 ,j+ 1
2 2 2 2
1
− hρ (pi,j+1 − pi,j )
ν
+ h2 vi,j+ 3 + vi,j− 1 + vi+1,j+ 1 + vi−1,j+ 1 − 4vi,j+ 1 .
2 2 2 2 2
2 2
(u2 )i,j = 21 (ui+ 1 ,j + ui− 1 ,j ) (v 2 )i,j = 12 (vi,j+ 1 + vi,j− 1 )
2 2 2 2
(uv)i+ 1 ,j+ 1 = 12 (ui+ 1 ,j+1 + ui+ 1 ,j ) 1
(v
2 i,j+ 1
+ vi+1,j+ 1 )
2 2 2 2 2 2
~ h · ~v n+1 = 0,
∇
v n+1 −~
vn ~ h p n+1 +ν∇2h ~v n .
~
∆t
= −Ah (~v n )− ρ1 ∇
un+1
i+ 1 ,j
− un+1
i− 1 ,j
n+1
+ vi,j+ n+1
1 − vi,j− 1 = 0 ,
2 2 2 2
un+1 −un 1
i+ 1 ,j i+ ,j
2
∆t
2
= − h1 (u2 )n 2 n n n
i+1,j − (u )i,j + (uv)i+ 1 ,j+ 1 − (uv)i+ 1 ,j− 1
2 2 2 2
1
− hρ (pn+1
i+1,j − pn+1
i,j ) + ν
h2
u n
i+ 3 ,j
+ u n
i− 1 ,j
+ u n
i+ 1 ,j+1
+ u n
i+ 1 ,j−1
− 4uni+ 1 ,j
,
2 2 2 2 2
v n+1 1 −v n
i,j+ 1
i,j+
2
∆t
= − h1 (v 2 )n
2 2 n n n
i,j+1 − (v )i,j + (uv)i+ 1 ,j+ 1 − (uv)i− 1 ,j+ 1
2 2 2 2
1
− hρ (pn+1
i,j+1 − p n+1
i,j ) + ν
h2
v n
i,j+ 3 + v i,j− 1 + v n
i+1,j+ 1 + v n
i−1,j+ 1 − n
4vi,j+ 1 .
2 2 2 2 2
(u2 )n 2 n n
i,j , (v )i,j , (uv)i+ 1 ,j+ 1 interpolated
2 2
n+1 ∗
vi,j+ 1 = vi,j+ 1 −
∆t
hρ
(pn+1
i,j+1
n+1
− pi,j )
2 2
∂u un+1 n+1
i+1 −ui−1 ∂u ∂u2 ∂p 2
Mass eq.: ∂x
=0 → 2h
=0 Momentum eq.: ∂t
+ ∂x
= − ρ1 ∂x + ν ∂∂xu2
u∗ n
i −ui
(un 2 n
i+1 ) −(ui−1 )
2
un n n
i+1 −2ui +ui−1
Temporary velocity u∗i : ∆t
+ 2h
=ν h2
Projection: un+1
i = u∗i − ∆t
2hρ
(pn+1
i+1 − pn+1
i−1 )
pn+1 n+1
i+2 −2pi +pn+1
PPE: 4h2
i−2
= ρ
2h∆t
(u∗i+1 − u∗i−1 )
i− 32 i− 21 i+ 21 i+ 32
un+1
1 −u
n+1
1
i+ i−
Mass eq.: ∂u
∂x
=0 → 2
h
2
=0 Momentum eq. → u∗i+ 1
2
Projection: un+1
i+ 1
= u∗i+ 1 − ∆t
hρ
(pn+1
i+1 − pn+1
i )
2 2
pn+1 n+1
i+1 −2pi +pn+1
PPE: h2
i−1
= ρ
h∆t
(u∗i+ 1 − u∗i− 1 )
2 2
Ny p
u
v
ghost p
ghost u
ghost v
1 Nx
LUL
Lid-driven cavity flow problem Projection method, Re = ν = 100, N = 50
Ghia–Ghia–Shin 1982
Stability conditions
For stability necessary that prediction step (no pressure term included) is stable,
numerical evidence indicates that this also sufficient.
h2
2ν
∆t ≤ min , .
max(u2 + v 2 ) 4ν
1
Nondimensional variables: ν = Re
, Re = Reynolds number
∆t → 0 for Re → 0 and Re → ∞
Improvements of method:
• Better stability for convective terms for high Reynolds numbers.
• Implicit viscous terms for low Reynolds numbers.