Академический Документы
Профессиональный Документы
Культура Документы
Discretization methods:
standard finite difference methods
standard finite element methods
the group finite element method
We get nonlinear algebraic equations
Solution method: iterate over linear equations
1
− 2 (ui−1 − 2ui + ui+1 ) = f (ui )
h
1
(α(ui+1/2 )(ui+1 − ui ) − α(ui−1/2 )(ui − ui−1 )) = 0
h2
1
2
([α(ui+1 ) + α(ui )](ui+1 − ui ) − [α(ui ) + α(ui−1 )](ui − ui−1 )) = 0
2h
⇒ nonlinear system of algebraic equations
P P
We write u = k uk ϕk instead of u = k ck ϕk since
ck = u(xk ) = uk and uk is used in the finite difference schemes
Note that X
f( ϕk (x)uk )
k
is a complicated function of u0 , . . . , uN
F.ex.: f (u) = u2
Z !2
1 X
ϕk u k ϕi dx
0 k
h 2 2 2
ui−1 + 2ui (ui−1 + ui+1 ) + 6ui + ui+1
12
X n
X
f (u) = f ( uj ϕj (x)) ≈ f (uj )ϕj
j j=1
R1 R1P
Resulting term: 0
f (u)ϕi dx = 0 j ϕi ϕj f (uj ) gives
X Z 1
ϕk ϕi dx f (uj )
j 0
h
(f (ui−1 ) + 4f (ui ) + f (ui+1 ))
6 Nonlinear PDEs – p.7/148
FEM for a nonlinear coefficient
We now look at
1 1
(α(ui ) + α(ui+1 ))(ui+1 − ui ) − (α(ui−1 ) + α(ui ))(ui − ui−1 ) = 0
2 2
F (u) = 0
or
F0 (u0 , . . . , uN ) = 0
...
FN (u0 , . . . , uN ) = 0
Have
A(u)u − b = 0, Au − b(u) = 0, F (u) = 0
Idea: solve nonlinear problem as a sequence of linear
subproblems
Must perform some kind of linearization
Iterative method: guess u0 , solve linear problems for u1 , u2 , . . .
and hope that
lim uq = u
q→∞
A(uq )uq+1 = b, q = 0, 1, . . .
Relative criteria:
||uq+1 − uq || ≤ ǫu ||uq ||
or (more expensive)
Auq+1 = b(uq ), q = 0, 1, . . .
Relaxation:
M (u; uq ) = F (uq ) + J (u − uq ), J ≡ ∇F
∂Fi
Ji,j =
∂uj
Iteration no. q:
solve linear system J (uq )(δu)q+1 = −F (uq )
update: uq+1 = uq + (δu)q+1
Can use relaxation: uq+1 = uq + ω(δu)q+1
∂Fi
Ji,j =
∂uj
⇒ Jacobian is tridiagonal
Nonlinear PDEs – p.15/148
The Jacobian matrix; FDM (2)
1
Fi ≡ 2 (ui−1 − 2ui + ui+1 ) − f (ui ) = 0
h
Derivation:
∂Fi 1
Ji,i−1 = = 2
∂ui−1 h
∂Fi 1
Ji,i+1 = = 2
∂ui+1 h
∂Fi 2
Ji,i = = − 2 + f ′ (ui )
∂ui h
Must form the Jacobian matrix J in each iteration and solve
J δuq+1 = −F (uq )
∂Fi
First term of the Jacobian Ji,j = ∂uj :
Z X Z Z 1
∂ 1 1
∂ X ′ ′
ϕ′i ϕ′k uk dx = ϕi ϕk uk dx = ϕ′i ϕ′j dx
∂uj 0 0 ∂uj 0
k k
Second term:
Z 1 X Z 1 X
∂ ′
− f( us ϕs )ϕi dx = − f( us ϕs )ϕj ϕi dx
∂uj 0 s 0 s
P
because when u = s us ϕs ,
∂ ′ ∂u ′ ∂
P ′
∂uj f (u) = f (u) ∂uj = f (u) ∂uj s u s ϕ s = f (u)ϕj Nonlinear PDEs – p.17/148
A 2D/3D transient nonlinear PDE (1)
∂u
̺C = ∇ · [κ(u)∇u]
∂t
un − un−1
= ∇ · [α(un )∇un ]
∆t
with α = κ/(̺C)
n
P n
Next step: Galerkin formulation, where u = j j ϕj is the
u
unknown and un−1 is just a known function
Fi (un0 , . . . , unN ) = 0, i = 0, . . . , N
where
Z
n n−1
n n
Fi ≡ u −u v + ∆tα(u )∇u · ∇v dΩ
Ω
Picard iteration:
Use “old” un,q in α(un ) term, solve linear problem for un,q+1 ,
q = 0, 1, . . .
Z
Ai,j = (ϕi ϕj + ∆tα(un,q )∇ϕi · ∇ϕj ) dΩ
Ω
Z
bi = un−1 ϕi dΩ
Ω
∂Fi
Ji,j =
∂unj
Z
Ji,j = (ϕi ϕj + ∆t(α′ (un,q )ϕj ∇un,q · ∇ϕi + α(un,q )∇ϕi · ∇ϕj )) dΩ
Ω
d2 q+1
− 2u = f (uq ), q = 0, 1, . . .
dx
∇ · (||∇u||q ∇u) = 0
∂u
̺(u) = ∇ · (α(u)∇u)
∂t
∂u
−α(u) = H(u)(u − uS ),
∂n
Tromsø
70˚
Bodø
EN
ED
SW
65˚
Trondheim
AY
RW Stockholm
Oslo
NO
Bergen
60˚
5˚
10˚
15˚
η(x,y,t)
z
y
x
H(x,y,t)
PDEs:
∂η ∂ ∂ ∂H
= − (uH) − (vH) −
∂t ∂x ∂y ∂t
∂u ∂η
= − , x ∈ Ω, t > 0
∂t ∂x
∂v ∂η
= − , x ∈ Ω, t > 0
∂t ∂y
ℓ ℓ+ 21 ℓ+ 12
ηi+ 1 1, ui,j+ 1 , vi+ 1 ,j+1
2 ,j+ 2 2 2
ℓ+ 21
vi+ 1 ,j+1
2
ℓ+ 12 ℓ+ 21
ui,j+ 1 ℓ
r ui+1,j+ 1
2 ηi+ 1
,j+ 1 2
2 2
ℓ+ 21
vi+ 1 ,j
2
Shallow water waves – p.43/148
A global staggered mesh
∂η ∂ ∂
= − (uH) − (vH)
∂t ∂x ∂y
1 1 1
at (i + , j + , ℓ − )
2 2 2
ℓ− 12
[Dt η = −Dx (uH) − Dy (vH)]i+ 1 ,j+ 1
2 2
1 h ℓ ℓ−1
i 1 h ℓ− 21 ℓ− 21
i
ηi+ 1 ,j+ 1 − ηi+ 1 1 = − (Hu)i+1,j+ 1 − (Hu)i,j+ 1
∆t 2 2 2 ,j+ 2 ∆x 2 2
1 h ℓ− 12 ℓ− 21
i
− (Hv)i+ 1 ,j+1 − (Hv)i+ 1 ,j
∆y 2 2
∂u ∂η 1
= − at (i, j + , ℓ)
∂t ∂x 2
ℓ
[Dt u = −Dx η]i,j+ 1
2
1 h ℓ+ 12 ℓ− 12
i 1 h ℓ ℓ
i
u 1 − ui,j+ 1 = − ηi+ 1 ,j+ 1 − ηi− 1 1
∆t i,j+ 2 2 ∆x 2 2 2 ,j+ 2
∂v ∂η 1
= − at (i + , j, ℓ)
∂t ∂y 2
ℓ
[Dt v = −Dy η]i+ 1
2,j
1 h ℓ+ 12 ℓ− 1
i 1 h ℓ ℓ
i
vi+ 1 ,j − vi+ 12,j = η 1 1 − ηi+ 1 ,j− 1
∆t 2 2 ∆y i+ 2 ,j+ 2 2 2
∂2η
= ∇ · [H(x, y)∇η]
∂t2
(CFL condition)
If H const, exact numerical solution is possible for
one-dimensional wave propagation
p
The velocity of a tsunami is gH(x, y, t).
The back part of the wave moves at higher speed ⇒ the wave
becomes more peak-formed
Deep water (H ∼ 3 km): wave length 40 km, height 1 m
Shallow water waves – p.54/148
Tsunamis experienced from shore
Wave breaking: the top has larger effective depth and moves faster
than the front part (requires a nonlinear PDE)
∂u
+ v · ∇u = α∇2 u + f
∂t
|v · ∇u| V U/L VL
Pe = 2
∼ 2
=
|α∇ u| αU/L α
∂v 1
+ v · v = − ∇p + ν∇2 v + f
∂t ̺
∇·v =0
Important dimensionless number: Reynolds number Re
convection |v · ∇v| V 2 /L VL
Re = = ∼ =
diffusion |ν∇2 v| αV /L2 ν
2 ′ ′′ ′ ′′ α
v · ∇u = α∇ u → vu = αu → u = ǫu , ǫ=
v
Define
uni+ 1 ,j,k − uni− 1 ,j,k
[Dx u]ni,j,k ≡ 2 2
h
with similar definitions of Dy , Dz , and Dt
Another difference:
uni+1,j,k − uni−1,j,k
[D2x u]ni,j,k ≡
2h
Compound difference:
1
[Dx Dx u]ni n n n
= 2 ui−1 − 2ui + ui+1
h
[Dx Dx u = −f ]i
n=20, epsilon=0.1
1.2
1 centered
exact
0.8
0.6
0.4
u(x)
0.2
0
-0.2
-0.4
-0.6
-0.8
0 0.2 0.4 0.6 0.8 1
x
n=20, epsilon=0.01
1.2
1 centered
exact
0.8
0.6
0.4
u(x)
0.2
0
-0.2
-0.4
-0.6
-0.8
0 0.2 0.4 0.6 0.8 1
x
n=80, epsilon=0.01
1.2
1 centered
exact
0.8
0.6
0.4
u(x)
0.2
0
-0.2
-0.4
-0.6
-0.8
0 0.2 0.4 0.6 0.8 1
x
n=20, epsilon=0.001
1.2
1 centered
exact
0.8
0.6
0.4
u(x)
0.2
0
-0.2
-0.4
-0.6
-0.8
0 0.2 0.4 0.6 0.8 1
x
1 + h/(2ǫ)
β1 = 1, β2 =
1 − h/(2ǫ)
β2i − β2
ui = n
β2 − β2
1 + h/(2ǫ)
⇒ <0 ⇒ h > 2ǫ
1 − h/(2ǫ)
Problem:
u1 = 0, un = 1
The scheme can be written as
n=20, epsilon=0.1
1.2
1 upwind
exact
0.8
0.6
0.4
u(x)
0.2
0
-0.2
-0.4
-0.6
-0.8
0 0.2 0.4 0.6 0.8 1
x
n=20, epsilon=0.01
1.2
1 upwind
exact
0.8
0.6
0.4
u(x)
0.2
0
-0.2
-0.4
-0.6
-0.8
0 0.2 0.4 0.6 0.8 1
x
ui = β i ⇒ β1 = 1, β2 = 1 + h/ǫ
ui = C1 + C2 β2i
Using boundary conditions:
β2i − β2
ui = n
β2 − β2
Truncation error:
centered is more accurate than upwind
Exact analysis:
centered is more accurate than upwind when centered is stable
(i.e. monotone ui ), but otherwise useless
ǫ = 10−6 ⇒ 500 000 grid points to make h ≤ 2ǫ
Upwind gives best reliability, at a cost of a too thick boundary layer
Galerkin formulation of
u1 = 0, un = 1
or
[D2x u = ǫDx Dx u]i
Stability problems when h > 2ǫ
′ h ′′
u (x) = (ǫ + )u (x), x ∈ (0, 1), u(0) = 0, u(1) = 1
2
Take
wi (x) = ϕi (x) + τ ϕ′i (x)
or alternatively written
Model problem:
v · ∇u = α∇2 u
or written out:
∂u ∂u
vx + vy = α∇2 u
∂x ∂y
Non-physical oscillations occur with centered differences or
Galerkin methods when the left-hand side terms are large
Remedy: upwind differences
Downside: too much diffusion
Important result: extra stabilizing diffusion is needed only in the
streamline direction, i.e., in the direction of v = (vx , vy )
d X
X d
∂2u
αδij = α∇2 u
i=1 j=1
∂xi ∂xj
w = v + τ ∗ v · ∇v
R
for the convective (left-hand side) term: w v · ∇u dΩ
This expands to
Z Z
vv · ∇udΩ + τ ∗ v · ∇u v · ∇vdΩ
The latterP
term can be viewed as the Galerkin formulation of (write
v · ∇u = i ∂u/∂xi etc.)
Xd X d
∂ ∗ ∂u
τ vi vj
i=1 j=1
∂x i ∂xj
y
du/dn=0 or u=0
1
y = x tan θ + 0.25
v
u=1 du/dn=0
θ
0.25
u=0
u=0 1 x
Methods:
1. Classical SUPG:
Brooks and Hughes: "A streamline upwind/Petrov-Galerkin finite
element formulation for advection domainated flows with particular
emphasis on the incompressible Navier-Stokes equations", Comp.
Methods Appl. Mech. Engrg., 199-259, 1982.
2. An additional discontinuity-capturing term
∗ v · ∇u
w = v + τ v · ∇v + τ̂ ∇u
||∇u||2
was proposed in
Hughes, Mallet and Mizukami: "A new finite element formulation
for computational fluid dynamics: II. Beyond SUPG", Comp.
Methods Appl. Mech. Engrg., 341-355, 1986.
−0.65
0
1 1
Z 0
X
Convection-dominated flow – p.90/148
SUPG
−0.65
0
1 1
Z 0
X
Convection-dominated flow – p.91/148
Time-dependent problems
Model problem:
∂u
+ v · ∇u = ǫ∇2 u
∂t
Can add artificial streamline diffusion term
Can use perturbed weighting function
w = v + τ ∗ v · ∇v
on all terms
How to choose τ ∗ ?
∂ ∂
= −U
∂t ∂x
Result:
n n
∂u 1 2 2 ∂2u
un+1 n
= u − U ∆t + U ∆t
∂x 2 ∂x2 Convection-dominated flow – p.93/148
Taylor-Galerkin methods (2)
1 2
[δt+ u + U D2x u = U ∆tDx Dx u]ni
2
1 2
[δt+ u + U D2x u = U ∆tDx Dx u]ni
2
In multi-dimensional problems,
∂u
+ v · ∇u = 0
∂t
we have
∂
= −v · ∇
∂t
and (∇ · v = 0)
2 Xd X d
∂ ∂ ∂
= ∇ · (vv · ∇) = v v
r s
∂t2 r=1 s=1
∂x r ∂xs
1
[Dt+ u + v · ∇u = ∆t∇ · (vv · ∇u)]n
2
Convection-dominated flow – p.95/148
Taylor-Galerkin methods (4)
−∇2 u = f on an n = q × q × q grid
FDM/FEM result in Ax = b system
FDM: 7 entries pr. row in A are nonzero
FEM: 7 (tetrahedras), 27 (trilinear elms.), or 125 (triquadratic
elms.) entries pr. row in A are nonzero
A is sparse (mostly zeroes)
Fraction of nonzeroes: Rq −3
(R is nonzero entries pr. row)
Important to work with nonzeroes only!
Ax = b, A ∈ IRn,n , x, b ∈ IRn .
Split A: A = M − N
Write Ax = b as
M x = N x + b,
and introduce an iteration
M xk = N xk−1 + b, k = 1, 2, . . .
M xk = N xk−1 + b, k = 1, 2, . . .
The iteration converges if G = M −1 N has its largest eigenvalue,
̺(G), less than 1
Rate of convergence: R∞ (G) = − ln ̺(G)
To reduce the initial error by a factor ǫ,
||x − xk || ≤ ǫ||x − x0 ||
one needs
− ln ǫ/R∞ (G)
iterations
Split: A = L + D + U
L and U are lower and upper triangular parts, D is A’s diagonal
Jacobi iteration: M = D (N = −L − U )
Gauss-Seidel iteration: M = L + D (N = −U )
SOR iteration: Gauss-Seidel + relaxation
SSOR: two (forward and backward) SOR steps
Rate of convergence R∞ (G) for −∇2 u = f in 2D with u = 0 as
BC:
Jacobi: πh2 /2
Gauss-Seidel: πh2
SOR: π2h
SSOR: > πh
SOR/SSOR is superior (h vs. h2 , h → 0 is small)
M =D
Put everything, except the diagonal, on the rhs
2D Poisson equation −∇2 u = f :
Solve for diagonal element and use old values on the rhs:
for k = 1, 2, . . .
Set
xk = ωx∗ + (1 − ω)xk−1
weighted mean of xk−1 and xk if ω ∈ (0, 1)
∂u
α = ∇2 u + f
∂t
M =L+D
For our 2D Poisson eq. scheme:
1 k k−1 k−1
uki,j = u k 2
+ ui−1,j + ui+1,j + ui,j+1 + h fi,j
4 i,j−1
i.e. solve for diagonal term and use the most recently computed
values on the right-hand side
SOR is relaxed Gauss-Seidel iteration:
compute x∗ from Gauss-Seidel it.
set xk = ωx∗ + (1 − ω)xk−1
ω ∈ (0, 2), with ω = 2 − O(h2 ) as optimal choice
Very easy to implement!
Ax = b, A ∈ IRn,n , x, b ∈ IRn .
k
X
r k = b − Axk = rk−1 − αj Aq j
j=1
Residual:
k
X
r k = b − Axk = r k−1 − αj Aq j
j=1
(r k , q i ) = 0
Galerkin’s method (r ∼ R, q j ∼ Nj , αj ∼ uj ):
(rk , q i ) = 0, i = 1, . . . , k
k
X
(Aq i , q j )αj = (rk−1 , q i ), i = 1, . . . , k
j=1
Residual:
k
X
r k = b − Axk = r k−1 − αj Aq j
j=1
∂
(rk , rk ) = 0
∂αi
k
X
(Aq i , Aq j )αj = (rk−1 , Aq i ), i = 1, . . . , k
j=1
Vk = span{r 0 , Ar 0 , . . . , Ak−1 r 0 }
k
X
q k+1 = rk + βj q j
j=1
k
X
q k+1 = Aqk + βj q j
j=1
(Aq i , q j ), (Aq i , Aq j )
Define
hu, vi ≡ (Au, v) = uT Av
and
[u, v] ≡ (Au, Av) = uT AT Av
Galerkin: require A-orthogonal qj vectors, which then results in
hrk , q i i
βi = −
hq i , q i i
(rk−1 , q k )
αk =
hq k , q k i
xk = xk−1 + αk q k
k
X
xk = xk−1 + αj q j
j=k−K+1
1 2√
ln κ
2 ǫ
largest eigenvalue of A
κ=
smalles eigenvalue of A
M −1 Ax = M −1 b
M = LU
Equation: −∇2 u = 1
Boundary condition: u = 0
7-pt star standard finite difference scheme
Grid size: 20 × 20 × 20 = 8000 points and 20 × 30 × 30 = 27000
points
Source code:
$NOR/doc/Book/src/linalg/LinSys4/
All details in HPL Appendix D
Input files:
$NOR/doc/Book/src/linalg/LinSys4/experiments
Solver’s CPU time written to standard output
Convection-diffusion equations:
$NOR/doc/Book/src/app/Cd/Verify
Files: linsol_a.i etc as for LinSys4 and Poisson2
Elasticity equations:
$NOR/doc/Book/src/app/Elasticity1/Verify
Files: linsol_a.i etc as for the others
Run experiments and learn!
Multigrid methods are the most efficient methods for solving linear
systems
Multigrid methods have optimal complexity O(n)
Multigrid can be used as stand-alone solver or preconditioner
Multigrid applies a hierarchy of grids
Multigrid is not as robust as Conjugate Gradient-like methods and
incomplete factorization as preconditioner, but faster when it
works
Multigrid is complicated to implement
Diffpack has a multigrid toolbox that simplifies the use of multigrid
dramatically
exp (ikh) 1
ξ = exp (−iω̃∆t) = , |ξ| = √
2 − exp (−ikh) 5 − 4 cos kh
1
|ξ| = √ , p = kh ∈ [0, π]
5 − 4 cos p
0.9
0.8
0.7
0.6
0.5
0.4
simple restriction
weighted restriction
1 2 3 4 5 q-1
1 2 3 4 5 6 7 8 9 q
1 2 3 4 5 q−1
1 2 3 4 5 6 7 8 9 q
q γq =1 γq =2
4