Académique Documents
Professionnel Documents
Culture Documents
0 X
x0 x1 xi 1 xi xi+1 xN 1 xN
First-order derivatives
∂u u(x̄ + ∆x) − u(x̄) u(x̄) − u(x̄ − ∆x)
(x̄) = lim = lim
∂x ∆x→0 ∆x ∆x→0 ∆x
u(x̄ + ∆x) − u(x̄ − ∆x)
= lim (by definition)
∆x→0 2∆x
Approximation of first-order derivatives
Geometric interpretation
u forward ba
kward
entral ∂u
ui+1 −ui
∂x i ≈ ∆x forward difference
∂u
ui −ui−1
∂u
ui+1 −ui−1
∂x i ≈ 2∆x central difference
xi 1 xi xi+1 x ∞
P (x−xi )n ∂nu
Taylor series expansion u(x) = n! ∂xn i , u ∈ C ∞ ([0, X])
n=0
∂u (∆x)2 ∂ 2 u (∆x)3 ∂ 3 u
T1 : ui+1 = ui + ∆x + 2
+ 3
+ ...
∂x
i 2 ∂x i 6 ∂x i
∂u (∆x)2 ∂ 2 u (∆x)3 ∂ 3 u
T2 : ui−1 = ui − ∆x + − + ...
∂x i 2 ∂x2 i 6 ∂x3 i
Analysis of truncation errors
≈ =
∂x i ∆x ∆x
di+1/2 ui+1 − (di+1/2 + di−1/2 )ui + di−1/2 ui−1
=
(∆x)2
Approximation of mixed derivatives
∂2u ∂ ∂u ∂ ∂u y
2D: ∂x∂y = ∂x ∂y = ∂y ∂x
“ ” “ ”
∂u ∂u
−
∂2u
„ «
∂y ∂y
i+1,j i−1,j
= + O(∆x)2 yj +1
∂x∂y i,j 2∆x
yj
„ «
∂u ui+1,j+1 − ui+1,j−1
= + O(∆y)2 yj 1
∂y i+1,j 2∆y
„ «
∂u ui−1,j+1 − ui−1,j−1
= + O(∆y)2
∂y i−1,j 2∆y xi 1 xi xi+1 x
u0 = a c∆x2 = u1 − u0 − b∆x
⇒
u1 = a + b∆x + c∆x2 −3u0 + 4u1 − u2
b=
u2 = a + 2b∆x + 4c∆x2 2∆x
Analysis of the truncation error
∂u αui + βui+1 + γui+2
One-sided approximation ≈
∂x i ∆x
∂u (∆x)2 ∂ 2 u (∆x)3 ∂ 3 u
ui+1 = ui + ∆x + + + ...
∂x i 2 ∂x2 i 6 ∂x3 i
2
2 3
3
∂u (2∆x) ∂ u (2∆x) ∂ u
ui+2 = ui + 2∆x + + + ...
∂x i 2 ∂x2 i 6 ∂x3 i
αui +βui+1 +γui+2 α+β+γ ∂u ∆x ∂2u
∆x = ∆x ui + (β + 2γ) ∂x i + 2 (β + 4γ) ∂x2 + O(∆x2 )
i
Second-order accurate if α + β + γ = 0, β + 2γ = 1, β + 4γ = 0
−3ui +4ui+1 −ui+2
α = − 23 , β = 2, γ = − 21 ⇒ ∂u
∂x i = 2∆x + O(∆x2 )
Application to second-order derivatives
∂2u αui + βui+1 + γui+2
One-sided approximation ≈
∂x2 i ∆x2
∂u (∆x)2 ∂ 2 u (∆x)3 ∂ 3 u
ui+1 = ui + ∆x + + + ...
∂x i 2 ∂x2 i 6 ∂x3 i
2
2 3
3
∂u (2∆x) ∂ u (2∆x) ∂ u
ui+2 = ui + 2∆x + + + ...
∂x i 2 ∂x2 i 6 ∂x3 i
αui +βui+1 +γui+2 α+β+γ β+2γ ∂u β+4γ ∂2u
∆x2 = ∆x2 ui + ∆x ∂x i + 2 ∂x2 + O(∆x)
i
First-order accurate if α + β + γ = 0, β + 2γ = 0, β + 4γ = 2
∂u
ui −2ui+1 +ui+2
α = 1, β = −2, γ=1 ⇒ ∂x i = ∆x2 + O(∆x)
High-order approximations
∂u 2ui+1 + 3ui − 6ui−1 + ui−2
= + O(∆x)3 backward difference
∂x i 6∆x
∂u −ui+2 + 6ui+1 − 3ui − 2ui−1
= + O(∆x)3 forward difference
∂x i 6∆x
∂u −ui+2 + 8ui+1 − 8ui−1 + ui−2
= + O(∆x)4 central difference
∂x i 12∆x
∂2u −ui+2 + 16ui+1 − 30ui + 16ui−1 − ui−2
= + O(∆x)4 central difference
∂x2 i 12(∆x) 2
One-dimensional mesh 0 1
x0 x1 xi 1 xi xi+1 xN 1 xN
1
ui ≈ u(xi ), fi = f (xi ) xi = i∆x, ∆x = , i = 0, 1, . . . , N
N
Central difference approximation O(∆x)2
− ui−1 −2ui +u i+1
= fi , ∀i = 1, . . . , N − 1
(∆x)2
u0 = uN = 0 Dirichlet boundary conditions
Result: the original PDE is replaced by a linear system for nodal values
Example: 1D Poisson equation
∂u
Non-homogeneous Neumann BC ∂x (1) = g1 only F changes
uN +1 − uN −1
= g1 ⇒ uN +1 = uN −1 + 2∆xg1
2∆x
uN −1 − 2uN + uN +1 −uN −1 + uN 1 g1
− = fN −→ = fN +
(∆x)2 (∆x)2 2 ∆x
∂u
Non-homogeneous Robin BC ∂x (1) + αu(1) = g2 A and F change
uN +1 − uN −1
+ αuN = g2 ⇒ uN +1 = uN −1 − 2∆xαuN + 2∆xg2
2∆x
uN −1 − 2uN + uN +1 −uN −1 + (1 + α∆x)uN 1 g2
− = fN −→ = fN +
(∆x)2 (∆x)2 2 ∆x
Example: 2D Poisson equation
y h h ve-point sten
il
Boundary value problem 1
− ∂ 2 u2 − ∂ 2 u2 = f in Ω = (0, 1) × (0, 1) yj +1
∂x ∂y
h
yj
u=0 on Γ = ∂Ω h
yj 1
1
Uniform mesh: ∆x = ∆y = h, N= h xi 1 xi xi+1 x
0 1
2D Poisson equation Γ 3
− ∂ 2 u2 − ∂ 2 u2 = f in Ω Ω Γ Ω
∂x ∂y δ
4 R 0 Q 2
u = g0 on Γ Q
h
P 1
Difference equation
stencil of Q
u1 + u2 − 4u0 + u3 + u4
− = f0
h2 curvilinear boundary
Linear interpolation
u4 (h − δ) + u0 δ δ h
u(R) = = g0 (R) ⇒ u4 = −u0 + g0 (R)
h h−δ h−δ
δ h
Substitution yields −u1 + u2 − 4 + h−δ u0 + u3 = h2 f0 + g0 (R) h−δ
inverse mapping
y a b a b
physi
al domain
omputational domain
body-tted grid
artesian grid
x
The original PDE must be rewritten in terms of (ξ, η) instead of (x, y) and
discretized in the computational domain rather than the physical one.
∂u ∂u ∂u ∂u
Derivative transformations , ,... −→ , ,...
∂x ∂y ∂ξ ∂η
| {z } | {z }
difficult to compute easy to compute
PDE transformations for a direct mapping
Direct mapping ξ = ξ(x, y), η = η(x, y)
Chain rule ∂u ∂u ∂ξ ∂u ∂η ∂u ∂u ∂ξ ∂u ∂η
= + , = +
∂x ∂ξ ∂x ∂η ∂x ∂y ∂ξ ∂y ∂η ∂y
2 2
∂2u ∂u ∂ 2 ξ ∂u ∂ 2 η ∂ 2 u ∂ξ ∂η ∂ 2 u ∂ξ ∂ 2 u ∂η
= + +2 + 2 + 2
∂x2 ∂ξ ∂x2 ∂η ∂x2 ∂ξ∂η ∂x ∂x ∂ξ ∂x ∂η ∂x
2 2
∂2u ∂u ∂ 2 ξ ∂u ∂ 2 η ∂ 2 u ∂ξ ∂η ∂ 2 u ∂ξ ∂ 2 u ∂η
= + +2 + 2 + 2
∂y 2 ∂ξ ∂y 2 ∂η ∂y 2 ∂ξ∂η ∂y ∂y ∂ξ ∂y ∂η ∂y
∂ξ ∂ξ ∂η ∂η ∂x ∂x ∂y ∂y
Metrics transformations , , , −→ , , ,
∂x ∂y ∂x ∂y ∂ξ ∂η ∂ξ ∂η
| {z } | {z }
unknown known
Chain rule
∂u ∂u ∂x ∂u ∂y ∂u ∂x ∂y ∂u
∂ξ = ∂x ∂ξ + ∂y ∂ξ ∂ξ ∂ξ ∂ξ ∂x
⇒ =
∂y
∂u ∂u ∂x ∂u ∂y ∂u ∂x ∂u
∂η = ∂x ∂η + ∂y ∂η ∂η ∂η ∂η ∂y
| {z }
J
∂(x,y)
where J = ∂(ξ,η) is the Jacobian which can be inverted using Cramer’s rule
Derivative transformations
∂u 1 ∂u ∂y ∂u ∂y ∂u 1 ∂u ∂x ∂u ∂x
= − , = −
∂x det J ∂ξ ∂η ∂η ∂ξ ∂y det J ∂η ∂ξ ∂ξ ∂η
Direct versus inverse mapping
∂x ∂x
x = x(ξ, η) dx = ∂ξ dξ + ∂η dη dx ∂x ∂x
dξ
∂ξ ∂η
⇒ =
∂y ∂y
y = y(ξ, η) ∂y ∂y dy dη
dy = ∂ξ dξ + ∂η dη ∂ξ ∂η
−1
∂ξ ∂ξ ∂x ∂x ∂y
∂x ∂y ∂ξ ∂η 1 ∂η − ∂x
∂η
⇒ = =
∂η ∂η ∂y ∂y det J − ∂y ∂x
∂x ∂y ∂ξ ∂η ∂ξ ∂ξ