lecture-slides-week3
lecture-slides-week3
Department of Mathematics
School of Mathematical and Computer Sciences
Heriot-Watt University, UK
and
Department of Mathematics
School of Mathematical and Physical Sciences
National Technical University of Athens, Greece
email: [email protected]
Jan 2023
1
FEM for 2D elliptic problems
71
The mesh and the finite element space
Vh = span{ϕi , i = 1, . . . , N}
for some numbering of the interior nodes of the triangulation, with N their
cardinality.
73
A finite element method
Method
Find uh ∈ Vh , such that
∫ ∫
∇uh · ∇vh dx = f vh dx ∀vh ∈ Vh
Ω Ω
∑
N ∫ ∫
Uj ∇ϕj · ∇ϕi dx = f ϕi dx i = 1, . . . , N
j=1 Ω Ω
74
A finite element method
i.e., solve the N × N-linear system
AU = F
with A = [aij ]N T T
i,j=1 , U = (U1 , . . . , UN ) and F = (F1 , . . . , FN ) , whereby
∫ ∫
aij = ∇ϕj · ∇ϕi dx, and Fi = f ϕi dx.
Ω Ω
As we shall see below, computing aij and Fi for general meshes is a non-trivial, yet
well defined, process.
Example
Use FEM to approximate u : Ω → R, such that
75
Example
1.5
0.5
−0.5
−1
0.6
0.4
0.2
−0.2
−0.4
0.6
0.4
0.2
0
−0.2
−0.4
−0.6
76
Calculation of the FEM system for a simple problem
We shall calculate the FEM linear system for Ω = (0, 1) × (0, 1), which we
subdivide into triangles, with nodes (xi , yj ) such that
(0, 1) • • • • • •
y
• • • • • •
• • • • • •
• • • • • •
• • • • • •
• • • • • •
(0, 0) x (1, 0)
77
Calculation of the FEM system for a simple problem
To each node (xi , yj ), we associate a basis (pyramid) function ϕi,j which is linear
on every element and continuous, with
78
Pyramid function ϕi,j
xi,j
79
Calculation of the FEM system for a simple problem
The corresponding linear system for this case reads (after multiplication by −h):
−hAU = −hF, viz.,
U1,1 F1,1
U2,1 F2,1
.. ..
.
.
B −I 0 0 . . . 0 UN,1 FN,1
−I B −I 0 . . . 0 U
1,2
F1,2
0 −I B −I . . . 0 . ..
.
.. .. .. .. .. .. . = h .
,
. .
. . . . U N,2
FN,2
0 ... 0 −I B −I . ..
.. .
0 ... 0 0 −I B
U1,N F1,N
∫ . .
where Fi,j = Ω fϕi,j dx .. ..
UN,N FN,N
Remark
The stiffness matrix A coincides with the finite difference matrix of the five point
scheme: −ui−1,j − ui+1,j + 4ui,j − ui,j−1 − ui,j−1 = h2 f(xi,j ), i, j = 1, . . . , N
81
Assembly
The assembly of the stiffness matrix and the load vector for a general
mesh/triangulation is an involved, yet quite streamlined procedure.
Gmsh: https://gmsh.info/
Mesh generators output (among other things) two key data structures:
82
Data structures: node
1
4 6 2 3
0.5 0
0.8 6 0.5 0.5 7
6 7
6 0 0.5 7
6 7
0.6 6 0.5 1 7
node = 6 7
6 1 0.5 7
3 2 5 6 1 1 7
0.4 6 7
4 0 0 5
0.2 1 0
7 1 8
0
Figure 8.9: Example 8.8. Position of nodes and respective node array.
e Z
83
Data structures: connectivity
1
4 6
0.8 ○
4 2 3
1 3 7
6 8 5 1 7
0.6 ○
5 6 7
6 2 1 5 7
connectivity = 6 7
6 4 2 6 7
0.4 3 2 5 4 2 5 6 5
○
6 ○
3
3 1 2
0.2 ○
1 ○
2
7 1 8
0
T̂ := {x ∈ Rd : 0 ≤ x1 + · · · + xd ≤ 1}
(1, 0) x̂ x
85
Reference map
We want (1, 0) of T̂ to be mapped to x1 of T, (0, 1) of T̂ to be mapped to x2 ,
and (0, 0) of T̂ to be mapped to x3 .
(1, 0) x̂ x
ψ1 (x̂, ŷ) := x̂, ψ2 (x̂, ŷ) := ŷ, and ψ3 (x̂, ŷ) := 1 − x̂ − ŷ,
Therefore,
87
Basis functions under map
If ∇
ˆ denotes the gradient w.r.t. x̂ variables, we have
( )
wx xx̂ + wy yx̂
∇v
ˆ = = BT ∇w,
wx xŷ + wy yŷ
∂(x, y)
since the Jacobian = BT .
∂(x̂, ŷ)
88
Assembly
We seek to compute each component
∑∫
aij = ∇ϕj · ∇ϕi dx dy,
T∈T T
The final step in the assembly is to transfer the entries of each AT to the global
stiffness matrix A,
with k the column number of the node i, on the row corresponding to T in the
connectivity, and ℓ the column number of the node j on the row corresponding
to T in the connectivity .
90
Implementation of boundary conditions: Dirichlet type
Split the total number of nodes Ntotal into total number of interior nodes, Nint ,
and of boundary nodes, N∂ , with N∂ := Ntotal − Nint .
Rearrange the numbering so that the nodes xj , j = 1, . . . , Nint are interior, while
xj , j = Nint + 1, . . . , Ntotal are the boundary nodes.
For a boundary condition u(x) = g(x) for x ∈ ∂Ω, the FE solution is of the form
∑
Nint ∑
N total
uh = Uj ϕ j + g(xj )ϕj
j=1 j=Nint +1
So, a FEM: find uh ∈ Ṽh , with uh (xj ) = g(xj ), j = Nint + 1, . . . , Ntotal , s.t.
∑
Nint ∑
N total
91
Implementation of boundary conditions: Dirichlet type
We now discuss a popular, practical way, (albeit not optimal computationally,) of
implementing the Dirichlet boundary condition.
Starting from the assembled stiffness matrix, say, A and load vector, say, F
inclusive of the boundary basis functions, perform the following:
Ntotal
and U∂ interior and boundary values, resp.,Fint = {Fi }N i=1 and g := {g(xi )}i=Nint +1 .
int
92