SLIDE 1 Scientific Computing I
Module 8: Discretisation of PDEs Michael Bader
Lehrstuhl Informatik V
Winter 2005/2006
SLIDE 2 Part I: Finite Differences
1
Grid Generation
2
Discretisation
3
System of Linear Equations
4
Discretisation Stencil
5
Accuracy
SLIDE 3 Part II: Finite Element Methods
6
FEM Main Ingredients
7
Weak Forms and Weak Solutions
8
Test and Ansatz Space
9
Discretisation
10 A Road to Theory 11 Choosing Basis Functions
Nodal Basis Hierarchical Basis
12 Element Stiffness Matrices
Example: 1D Poisson Example: 2D Poisson Workflow
SLIDE 4 The Model Problem
2D Poisson Equation on unit square: ∂ 2 ∂x2u(x,y)+ ∂ 2 ∂y2u(x,y) = f(x,y) in Ω = (0,1)2 Dirichlet boundary conditions: u(x,y) = g(x,y)
SLIDE 5
Part I Finite Differences
SLIDE 6 Grid Generation
generate a grid on the given domain
xi,j xi−1,j xi+1,j xi,j+1 xi,j−1 hx hy
hx hz hy
Compute values of unknown function u at each grid point: uij ≈ u(xij) uijk ≈ u(xijk)
SLIDE 7 Finite Difference Discretisation
Replace derivatives (at each grid point) by difference quotients: ∂ 2u ∂x2 (xi,j) ≈ u(xi+1,j)−2u(xi,j)+u(xi−1,j) h2
x
∂ 2u ∂x2 (xi,j) ≈ u(xi+1,j)−2u(xi,j)+u(xi−1,j) h2
x
leads to linear system of equations:
1 h2
+ui,j−1 +ui−1,j
f(xi,j) xi,j ∈ (0,1)2 u(xi,j) = g(xi,j) xi,j ∈ ∂Ω
SLIDE 8
System of Linear Equations
write linear system as Ahxh = fh Ah is a sparse matrix (band structure): Ah = 1 h2 Bh −I −I ... ... ... ... −I −I Bh Bh = tridiag(−1,4,−1) Ah block-tridiagonal (5-diagonal) matrix boundary values to right-hand side
SLIDE 9 Stencil Notation
illustrate matrix structure as a discretisation stencil represents one line of the matrix elements placed according to the geometrical position stencils for the Poisson equation: 1D :
−2 1
1 1 −4 1 1
SLIDE 10 Accuracy
for 5-point Poisson stencil;
- rder of accuracy: uh −u = O(h2) = O(N−2)
curse of dimension: for that, we need O(Nd) points Possibilities of an improvement: use higher-order discretisation
via higher order terms of Taylor series leads to larger stencils (involving more neighbouring grid points)
use locally refined (adaptive) grids
SLIDE 11
Part II Finite Element Methods
SLIDE 12 Finite Elements – Main Ingredients
1
compute a function as numerical solution; search in a function space Vh: uh = ∑
j
ujϕj(x), span{ϕ1,...ϕJ} = Vh
2
solve weak form of PDE to reduce regularity properties u′′ = f − →
3
choose basis function with a local support, e.g.: ϕj(xi) = δij
SLIDE 13 Weak Forms and Weak Solutions
consider a PDE Lu = f (e.g. Lu = ∆u) transformation to the weak form: Lu,v =
∀v ∈ V V a certain class of functions “real solution” u also solves the weak form Lu,v a bilinear form; often written as: a(Lu,v) = f,v ∀v ∈ V
SLIDE 14 Weak Form of the Poisson Equation
Poisson equation with Dirichlet conditions: −∆u = f in Ω,u = 0
weak form: −
∀v apply Green’s formula (and boundary conditions):
∀v weaker requirements for a solution u: twice differentiabale → first derivative integrable
SLIDE 15 Choose Test and Ansatz Space
search for weak solutions u in a certain function space W
j
ujϕj(x)
∀v ∈ V where span{ϕj} = W (“ansatz space”) choose a basis {ψi} of the test space V; then:
j
ujϕj(x)
∀ψi leads to system of equations for unknowns uj usually V and W chosen identically (Ritz-Galerkin method)
SLIDE 16 Discretisation – Finite Elements
L linear ⇒ system of linear equations
∑
j
- ψiLϕj(x)dx
- =:Aij
- uj =
- ψif dx
∀ψi aim: make matrix A sparse → most Aij = 0 approach: local basis functions on a discretisation grid ψj,ϕj zero everywhere except in grid cells adjacent to grid point xj Aij = 0, if ψi and ϕj don’t overlap
SLIDE 17 A Road to Theory
weak formulation is equivalent to variational approach: solution u minimises an energy functional best approximation property:
h
uh∈V u−uha
in terms of the norm induced by the bilinear form a (energy norm) thus: error bounded by interpoplation error (in energy norm)
SLIDE 18
Example Problem: Poisson 1D
1D Poisson’s equation on Ω = [0,1], homogeneous Dirichlet boundary conditions weak form:
1
0 ∇v ·∇udx =
1
0 vf dx
∀v compuational grid: xi = ih, (for i = 1,...,n−1); mesh size h = 1/n V = W: piecewise linear functions (on intervals [xi,xi+1])
SLIDE 19 Nodal Basis
ϕi(x) :=
1 h(x −xi−1)
xi−1 < x < xi
1 h(xi+1 −x)
xi < x < xi+1
0,6 0,4 0,8 0,2 1 1 0,4 0,2 x 0,8 0,6
SLIDE 20
Nodal Basis – System of Equations
stiffness matrix: 1 h 2 −1 −1 2 ... ... ... −1 −1 2 right hand sides (assume f(x) = α ∈ R):
1
0 ϕi(x)f(x)dx =
1
0 ϕi(x)α dx = αh
system of equations very similar to finite differences
SLIDE 21 Hierarchical Basis
0,6 0,4 0,8 0,2 1 1 0,4 0,2 x 0,8 0,6
leads to diagonal stiffness matrix! (for 1D Poisson) solution function identical to that with nodal basis (same function space)
SLIDE 22 Element Stiffness Matrices
domain Ω splitted into finite elements Ω(i) element-wise evaluation of the integrals:
= ∑
i
= ∑
i
leads to system of equations for each element: A(i)x = b(i) accumulate to obtain global system:
∑
i
A(i)
=:A
x = ∑
i
b(i)
SLIDE 23 Example: 1D Poisson
Notation: notation: omit zero columns/rows (leaves only unknowns that are in Ω(i)) 1D Poisson: Ω = [0,1] splitted into Ω(i) = [xi−1,xi] nodal basis; leads to element stiffness matrix: A(i) =
−1 −1 1
[1∗ −1] + [−1 1∗ ] → [−1 2 −1]
SLIDE 24
Example: 2D Poisson
−∆u = f on domain Ω = [0,1]2 splitted into Ω(i,j) = [xi−1,xi]×[xj−1,xj] bilinear basis functions ϕij(x,y) = ϕi(x)ϕj(y) “pagoda” functions
SLIDE 25
Example: 2D Poisson (2)
leads to element stiffness matrix: A(i) = 2 −1
2
−1
2
−1 −1
2
2 −1 −1
2
−1
2
−1 2 −1
2
−1 −1
2
−1
2
2 accumulation leads to 9-point stencil −1 −1 −1 −1 8 −1 −1 −1 −1
SLIDE 26 Typical workflow
1
choose elements:
quadratic or cubic cells triangles (structured, unstructured) tetrahedra, etc.
2
set up basis functions for each element Ωh; at all nodes xi ∈ Ωh ϕi(xi) = 1 ϕi(xj) = for all j = i
3
for element stiffness matrix, compute all Aij =
ϕiLϕj dΩ
4
accumulate global stiffness matrix