Académique Documents
Professionnel Documents
Culture Documents
Peter Arbenz
Computer Science Department, ETH Zürich
E-mail: arbenz@inf.ethz.ch
FEM & sparse linear system solving, Lecture 1, Sept 22, 2017 1/51
FEM and sparse linear system solving
Introduction
FEM & sparse linear system solving, Lecture 1, Sept 22, 2017 2/51
FEM and sparse linear system solving
Introduction
FEM & sparse linear system solving, Lecture 1, Sept 22, 2017 3/51
FEM and sparse linear system solving
Introduction
FEM & sparse linear system solving, Lecture 1, Sept 22, 2017 4/51
FEM and sparse linear system solving
Introduction
Literature
M. G. Larson, F. Bengzon: The Finite Element Method:
Theory, Implementation, and Applications. Springer, 2013.
H. Elman, D. Sylvester, A. Wathen. Finite elements and fast
iterative solvers (2nd ed.). Oxford University Press, 2014.
Y. Saad. Iterative methods for sparse linear systems (2nd ed.).
SIAM, 2003. (www-users.cs.umn.edu/~saad/books.html)
T. Davis. Direct Methods for Sparse Linear Systems. SIAM,
2006.
V. Dolean, P. Jolivet, F. Nataf. An Introduction to Domain
Decomposition Methods. SIAM, 2015.
F. Hecht. FreeFem++ http://www.freefem.org/
FEM & sparse linear system solving, Lecture 1, Sept 22, 2017 5/51
FEM and sparse linear system solving
Introduction
Organization
I 13 lectures
I complementary exercises
I to get hands-on experience
I based on Matlab and FreeFem++
I Matlab’s finite element toolbox (≤ 2D)
I FEM used to construct matrices
I Direct / iterative methods uses to solve the resulting systems
of equations
I Examination
I 30’ oral examination
I in exam session
FEM & sparse linear system solving, Lecture 1, Sept 22, 2017 6/51
FEM and sparse linear system solving
Strong formulation
Poisson equation
∂u = grad u · n
∂n
FEM & sparse linear system solving, Lecture 1, Sept 22, 2017 9/51
FEM and sparse linear system solving
Strong formulation
Origins of the Poisson equation
FEM & sparse linear system solving, Lecture 1, Sept 22, 2017 10/51
FEM and sparse linear system solving
Strong formulation
Examples
Example 1
Solution for Ω = (−1, 1)2 , right hand side f = 1, g = 0 where
ΓD = ∂Ω.
Finite differences
The Poisson equation −∆u = f (plus some boundary conditions)
on a domain with axis-parallel boundary is often solved by finite
differences on a rectangular grid.
We define a rectangular grid with grid points that are a distance h
apart. In each grid point the Laplacian of u can be expanded as
∂2 ∂2
−∆u(x1 , x2 ) = − u(x ,
1 2x ) − u(x1 , x2 )
∂x12 ∂x22
1
≈ (4u(x1 , x2 ) − u(x1 + h, x2 ) − u(x1 − h, x2 )
h2
−u(x1 , x2 + h) − u(x1 , x2 − h)) + O(h2 )
FEM & sparse linear system solving, Lecture 1, Sept 22, 2017 13/51
FEM and sparse linear system solving
Strong formulation
Finite differences
16 × 16 grid
grid width h
Ω = (0, 15h) × (0, 15h)
FEM & sparse linear system solving, Lecture 1, Sept 22, 2017 14/51
FEM and sparse linear system solving
Strong formulation
Finite differences
Structure of a FD matrix
FEM & sparse linear system solving, Lecture 1, Sept 22, 2017 16/51
FEM and sparse linear system solving
Strong formulation
Finite differences
Complicated domains
FEM & sparse linear system solving, Lecture 1, Sept 22, 2017 17/51
FEM and sparse linear system solving
Piecewise polynomial approximation in 1D
Polynomial spaces
FEM & sparse linear system solving, Lecture 1, Sept 22, 2017 19/51
FEM and sparse linear system solving
Piecewise polynomial approximation in 1D
Piecewise polynomial spaces
(x − xi−1 )/hi ,
if x ∈ Ii ,
ϕi (x) = (xi+1 − x)/hi+1 , if x ∈ Ii+1 ,
0, otherwise.
FEM & sparse linear system solving, Lecture 1, Sept 22, 2017 20/51
FEM and sparse linear system solving
Piecewise polynomial approximation in 1D
Piecewise polynomial spaces
FEM & sparse linear system solving, Lecture 1, Sept 22, 2017 21/51
FEM and sparse linear system solving
Piecewise polynomial approximation in 1D
Interpolation
Interpolation error f − πf
There are many norms to measure the difference f − πf in
1. the infinity norm
kv k∞ = max |v (x)|
x∈I
FEM & sparse linear system solving, Lecture 1, Sept 22, 2017 23/51
FEM and sparse linear system solving
Piecewise polynomial approximation in 1D
Interpolation
kf − πf kL2 (I ) ≤ C h2 kf 00 kL2 (I )
k(f − πf )0 kL2 (I ) ≤ C hkf 00 kL2 (I )
Ry
Proof: Fundamental thm of calculus → e(y ) = e(x0 ) + x0 e 0 dx
FEM & sparse linear system solving, Lecture 1, Sept 22, 2017 24/51
FEM and sparse linear system solving
Piecewise polynomial approximation in 1D
Interpolation
FEM & sparse linear system solving, Lecture 1, Sept 22, 2017 25/51
FEM and sparse linear system solving
Piecewise polynomial approximation in 1D
L2 -projection
Consequences:
kf − Ph f k2L2 (I ) ≤ kf − πf k2L2 (I )
n
X
kf − Ph f k2L2 (I ) ≤C hi4 kf 00 k2L2 (Ii )
i=1
FEM & sparse linear system solving, Lecture 1, Sept 22, 2017 27/51
FEM and sparse linear system solving
Piecewise polynomial approximation in 1D
Compute the L2 -projection
FEM & sparse linear system solving, Lecture 1, Sept 22, 2017 28/51
FEM and sparse linear system solving
Piecewise polynomial approximation in 1D
Compute the L2 -projection
Matrix form
Z
Mass matrix: mij = ϕj ϕi dx, i, j = 0, 1, . . . , n.
I
Z
Load vector: bi = f ϕi dx, i = 0, 1, . . . , n.
I
(n + 1) × (n + 1) linear system for the n + 1 unknown coefficients ξj
n
X
bi = mij ξj , i = 0, 1, . . . , n.
j=0
FEM & sparse linear system solving, Lecture 1, Sept 22, 2017 29/51
FEM and sparse linear system solving
Piecewise polynomial approximation in 1D
Quadrature
Quadrature rules
To compute the L2 -projection, compute integrals approximately
Z
J = f (x)dx
I
R
Let’s use Simpson’s formula to integrate mij = I ϕj ϕi dx
(x − xi−1 )/hi , if x ∈ Ii
ϕi = (x − x)/hi+1 , if x ∈ Ii+1
i+1
0, otherwise
Entries of M: mij = 0 for for |i − j| > 1.
Z Z xi Z xi+1
2 2
mii = ϕi dx = ϕi dx + ϕi 2 dx
I xi−1 xi
0 + 4( 21 )2 + 1 1 + 4( 12 )2 + 0 hi hi+1
= hi + hi+1 = + , i = 1, 2, · · · , n−1
6 6 3 3
First and last diagonal entries of M are : h31 , h3n respectively
Z Z xi+1
hi+1
mii+1 = ϕi+1 ϕi dx = ϕi+1 ϕi dx =
I xi 6
Superdiagonal entries are same as subdiagonal entries.
FEM & sparse linear system solving, Lecture 1, Sept 22, 2017 31/51
FEM and sparse linear system solving
Piecewise polynomial approximation in 1D
Computer implementation: assembly of the mass matrix
h1 h1
h31 h1
6
h2 h2
6 3 + 3 6
h2 h2
+ h33 h3
M=
6 3 6
.. .. ..
. . .
hn−1 hn−1 hn hn
6 3 + 3 6
hn hn
6 3
h1 h1
3 6
h1 h1 h2 h2
6 3 3 6
h2 h2
= + 6 3 + ··· +
hn hn
3 6
hn hn
6 3
FEM & sparse linear system solving, Lecture 1, Sept 22, 2017 32/51
FEM and sparse linear system solving
Piecewise polynomial approximation in 1D
Computer implementation: assembly of the mass matrix
h1 h1
3 6
h1 h1 h2 h2
6 3 3 6
h2 h2
= + 6 3 + ··· +
hn hn
3 6
hn hn
6 3
n
X hi 2 1 ∗
= Ii I
6 1 2 i
i=1
FEM & sparse linear system solving, Lecture 1, Sept 22, 2017 34/51
FEM and sparse linear system solving
Piecewise polynomial approximation in 1D
Basic algorithm to compute L2 -projection
FEM & sparse linear system solving, Lecture 1, Sept 22, 2017 36/51
FEM and sparse linear system solving
The finite element method in 1D
The finite element method for a model problem
FEM & sparse linear system solving, Lecture 1, Sept 22, 2017 37/51
FEM and sparse linear system solving
The finite element method in 1D
Variational formulation
Variational formulation
To derive the finite element method, we first rewrite the
differential equation as a variational equation. Multiplying
f = −u 00 by a test function v and integrating by parts we get
Z L Z L Z L
fv dx = − u 00 vdx = u 0 v 0 dx − u 0 (L)v (L) + u 0 (0)v (0).
0 0 0
FEM & sparse linear system solving, Lecture 1, Sept 22, 2017 38/51
FEM and sparse linear system solving
The finite element method in 1D
Finite element approximation
FEM & sparse linear system solving, Lecture 1, Sept 22, 2017 39/51
FEM and sparse linear system solving
The finite element method in 1D
Derivation of a linear system of equations
Unknown coefficients: ξj , j = 1, 2, . . . , n − 1
Z Z n−1
X n−1
X Z
ξj ϕ0j ϕ0i dx ϕ0j ϕ0i dx,
f ϕi dx = = ξj i = 1, 2, . . . , n−1
I I j=1 j=1 I
FEM & sparse linear system solving, Lecture 1, Sept 22, 2017 40/51
FEM and sparse linear system solving
The finite element method in 1D
Derivation of a linear system of equations
Matrix form
Z Z
bi = f ϕi ; aij = ϕ0j ϕ0i dx, i, j = 1, 2, . . . , n − 1
I I
(n − 1) × (n − 1) linear system for the n-1 unknown coefficients ξj
n−1
X
bi = aij ξj , i = 1, 2, . . . , n − 1
j=1
A ξ = b.
A : (n − 1) × (n − 1) matrix → stiffness matrix
b : (n − 1) × 1 → load vector
FEM & sparse linear system solving, Lecture 1, Sept 22, 2017 41/51
FEM and sparse linear system solving
The finite element method in 1D
Basic Algorithm to Compute the Finite Element Solution
FEM & sparse linear system solving, Lecture 1, Sept 22, 2017 42/51
FEM and sparse linear system solving
The finite element method in 1D
Error Estimate: e = u − uh
FEM & sparse linear system solving, Lecture 1, Sept 22, 2017 43/51
FEM and sparse linear system solving
The finite element method in 1D
Error Estimate: e = u − uh
FEM & sparse linear system solving, Lecture 1, Sept 22, 2017 44/51
FEM and sparse linear system solving
The finite element method in 1D
A model problem with variable coefficients
for all v ∈ Vh .
Step 3: In order to compute the finite element approximation uh ,
write it as the linear combination of {ϕi }ni=0 , hat functions are
basis of Vh . ϕ0 and ϕn : half hats at end points x = 0 and x = L.
n
X
uh = ξj ϕj
j=0
Step 4: Insert
n
X
uh = ξj ϕj
j=0
into
Z Z
0 0
auh v dx+κL uh (L)v (L)+κ0 uh (0)v (0) = fvdx+κL gL v (L)+κ0 g0 v (0)
I I
and choose v = ϕi , i = 0, . . . , n,
(x − xi−1 )/hi , if x ∈ Ii
ϕi = (x − x)/hi+1 , if x ∈ Ii+1
i+1
0, otherwise
and you will get ...
FEM & sparse linear system solving, Lecture 1, Sept 22, 2017 47/51
FEM and sparse linear system solving
The finite element method in 1D
Computer implementation: stiffness matrix A+R and load vector b + r
(A + R)ξ = b + r.
Entries of (n + 1) × (n + 1) matrices A, R and of (n + 1) vectors b
and r are:
Z
aij = aϕ0j ϕ0i dx
I
rij = κL ϕj (L)ϕi (L) + κ0 ϕj (0)ϕi (0)
Z
bi = f ϕi dx
I
ri = κL gL ϕi (L) + κ0 g0 ϕi (0)
FEM & sparse linear system solving, Lecture 1, Sept 22, 2017 48/51
FEM and sparse linear system solving
The finite element method in 1D
Computer implementation: entries of stiffness matrix A + R and load vector b + r
FEM & sparse linear system solving, Lecture 1, Sept 22, 2017 49/51
FEM and sparse linear system solving
The finite element method in 1D
Computer implementation: entries of stiffness matrix A + R and load vector b + r
a1
− ha11
h1 κ0
− a1 a1
+ a2
− ha22
h1 h1 h2
− ha22 a2
+ a3
− ha33
h2 h3
A+R = +
.. .. .. ..
. . .
.
− han−1 an−1 an
− hann
n−1 hn−1 + hn
− hann − hann κL
κ0 g0
f (x0 )h1 /2
f (x1 )(h1 + h2 )/2
0
0
f (x2 )(h2 + h3 )/2
b+r = + ..
..
.
.
f (xn−1 )(hn−1 + hn )/2 0
f (xn )(hn )/2 κL gL
FEM & sparse linear system solving, Lecture 1, Sept 22, 2017 50/51
FEM and sparse linear system solving
The finite element method in 1D
Computer implementation: entries of stiffness matrix A + R and load vector b + r
= A I 1 + A I2 + · · · + A In + R
Exercise
http:
//people.inf.ethz.ch/arbenz/FEM17/exercises/ex1.pdf
FEM & sparse linear system solving, Lecture 1, Sept 22, 2017 51/51