Geilo Winter School 2012 Lecture 1: Introduction To FEM: Anders Logg
Geilo Winter School 2012 Lecture 1: Introduction To FEM: Anders Logg
Anders Logg
1 / 35
Course outline
Sunday
L1 Introduction to FEM
Monday
L2 Fundamentals of continuum mechanics (I)
L3 Fundamentals of continuum mechanics (II)
L4 Introduction to FEniCS
Tuesday
L5 Solid mechanics
L6 Static hyperelasticity in FEniCS
L7 Dynamic hyperelasticity in FEniCS
Wednesday
L8 Fluid mechanics
L9 Navier–Stokes in FEniCS
2 / 35
What is FEM?
• Integral equations
• PDE → Ax = b
3 / 35
The FEM cookbook
(i)
4 / 35
The PDE (i)
Consider Poisson’s equation, the Hello World of partial
differential equations:
−∆u = f in Ω
u = u0 on ∂Ω
We find that: Z Z
∇u · ∇v dx = f v dx
Ω Ω
6 / 35
The variational problem (ii)
for all v ∈ V̂
The trial space V and the test space V̂ are (here) given by
V = {v ∈ H 1 (Ω) : v = u0 on ∂Ω}
V̂ = {v ∈ H 1 (Ω) : v = 0 on ∂Ω}
7 / 35
From continuous (ii) to discrete (iii) variational
problem
We approximate the continuous variational problem with a
discrete variational problem posed on finite dimensional
subspaces of V and V̂ :
Vh ⊂ V
V̂h ⊂ V̂
Vh = span {φj }N
j=1
9 / 35
From discrete variational problem (iii) to
discrete system of equations (iv), contd.
Rearrange to get:
N
X Z Z
Uj ∇φj · ∇φi dx = f φi dx
j=1 |Ω {z } | Ω {z }
Aij bi
Au = f in Ω
AU = b
Aij = a(φj , φi )
bi = L(φi )
11 / 35
Important topics
• How to choose Vh ?
• How to solve AU = b?
12 / 35
How to choose Vh
13 / 35
Finite element function spaces
uh
14 / 35
The finite element definition (Ciarlet 1975)
on T of dimension n
a basis for the dual space V 0 ; that is, the space of bounded
linear functionals on V
15 / 35
The finite element definition (Ciarlet 1975)
T V L
v(x̄)
v(x̄) · n
R
T v(x)w(x) dx
16 / 35
The linear Lagrange element: (T, V, L)
17 / 35
The linear Lagrange element: L
18 / 35
The linear Lagrange element: Vh
uh (x, y)
T = {T }
19 / 35
The quadratic Lagrange element: (T, V, L)
20 / 35
The quadratic Lagrange element: L
21 / 35
The quadratic Lagrange element: Vh
22 / 35
Families of elements
23 / 35
Families of elements
24 / 35
Computing the sparse matrix A
25 / 35
Naive assembly algorithm
A=0
for i = 1, . . . , N
for j = 1, . . . , N
Aij = a(φj , φi )
end for
end for
26 / 35
The element matrix
Aij = a(φj , φi )
27 / 35
The assembly algorithm
A=0
for T ∈ T
Add AT to A according to ιT
end for
28 / 35
Adding the element matrix AT
ι1T (1) 2
3
ι1T (2)
AT,32
ι1T (3)
29 / 35
Solving AU = b
30 / 35
Direct methods
• Gaussian elimination
• Requires ∼ 2 3
3N operations
• LU factorization: A = LU
• Solve requires ∼ 2 3
3N operations
• Reuse L and U for repeated solves
• Solve requires ∼ 1 3
3N operations
• Reuse L for repeated solves
31 / 35
Iterative methods
Krylov subspace methods
• GMRES (Generalized Minimal RESidual method)
• CG (Conjugate Gradient method)
• Works if A is symmetric and positive definite
Multigrid methods
• GMG (Geometric MultiGrid)
Preconditioners
• ILU, ICC, SOR, AMG, Jacobi, block-Jacobi, additive
Schwarz, . . .
32 / 35
Which method should I use?
Rules of thumb
33 / 35
Current timings (2012–01–20)
10-1
10-2
10-3
34 / 35
Homework!
http://fenicsproject.org/
http://home.simula.no/~logg/teaching/geilo2012/
35 / 35