0% found this document useful (0 votes)
6 views

lecture-slides-week3

The document discusses the application of Finite Element Methods (FEM) for solving Partial Differential Equations, specifically focusing on the Poisson problem in a weak form. It outlines the process of defining the finite element space, constructing the linear system, and calculating the stiffness matrix and load vector for a given mesh. Additionally, it highlights the importance of mesh generation and provides examples of software used for this purpose.

Uploaded by

miru park
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views

lecture-slides-week3

The document discusses the application of Finite Element Methods (FEM) for solving Partial Differential Equations, specifically focusing on the Poisson problem in a weak form. It outlines the process of defining the finite element space, constructing the linear system, and calculating the stiffness matrix and load vector for a given mesh. Additionally, it highlights the importance of mesh generation and provides examples of software used for this purpose.

Uploaded by

miru park
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 23

Finite Element Methods

for Partial Differential Equations


MAC-MIGS and SMSTC

Emmanuil (Manolis) Georgoulis

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

Problem (Poisson Problem in weak form)


Find u ∈ V := H10 (Ω), such that
∫ ∫
a(u, v) := ∇u · ∇v dx = fv dx =: ℓ(v) ∀v ∈ V
Ω Ω

for the above billinear form a : V × V → R and linear functional ℓ : V → R.

71
The mesh and the finite element space

meshsize: h|T = hT := diam T ∀T∈T

Irregular mesh: hanging node • regular mesh

We define the approximation space


Vh := {v ∈ C(Ω) : v|∂Ω = 0 and v|T ∈ P1 (T), T ∈ T }
whereby P1 (T) := span{1, x, y} the space of linear polynomials on T.
72
basis functions are pyramid functions, associated wit
On Vh ...
ϕi

2D linear finite element and “pyramid” basis functions

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
Ω Ω

How do we use this in practice?

Linear w.r.t. vh so, Method is equivalent to: find uh ∈ Vh , such that


∫ ∫
∇uh · ∇ϕi dx = f ϕi dx i = 1, . . . , N
Ω Ω
∑N
or, find Uj ∈ R, j = 1, . . . , N, (i.e.. uh = j=1 Uj ϕj ), such that


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

−∆u =100 sin(πx), in Ω


u =0, on ∂Ω,

with Ω the domain and mesh as above (slide 71).

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)

Figure: Triangulation of Ω = (0, 1) × (0, 1).

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

ϕi,j (xk , yl ) = δ(i,j),(k,l)

If we calculate the pyramid function ϕi,j


T2 explicitly, we find
T1  x−xi y−yj
T3 
 1− h − h , if (x, y) ∈ T1 ;

 y−yj
(i, j) 
 1− h , if (x, y) ∈ T2 ;
• 
 x−xi
 1+ h , if (x, y) ∈ T3 ;
T4 T6 x−xi y−yj
ϕi,j (x, y) = 1+ h + h , if (x, y) ∈ T4 ;
T5 


 1+
y−yj
h , if (x, y) ∈ T5 ;



 1−
x−xi
h , if (x, y) ∈ T6 ;

0, otherwise.
Figure: The support of ϕi,j .

78
Pyramid function ϕi,j

xi,j

79
Calculation of the FEM system for a simple problem

We calculate ∇ϕi,j = ((ϕi,j )x , (ϕi,j )y ):


 1  1

 − h , if (x, y) ∈ T1 ; 
 −h, if (x, y) ∈ T1 ;

 


 0, if (x, y) ∈ T2 ; 
 − 1
h, if (x, y) ∈ T2 ;
 1
 

 h, if (x, y) ∈ T3 ;  0, if (x, y) ∈ T3 ;
1 1
(ϕi,j )x (x, y) = , if (x, y) ∈ T4 ; , (ϕi,j )y (x, y) = h, if (x, y) ∈ T4 ;


h 


 0, if (x, y) ∈ T5 ;  1
 h, if (x, y) ∈ T5 ;

 1 

 −
 h , if (x, y) ∈ T6 ; 
 0, if (x, y) ∈ T6 ;
 
0, otherwise. 0, otherwise.
It is now not too hard to see, that the resulting matrix
   
B −I 0 0 ... 0 4 −1 0 0 ... 0
 −I B −I 0 ... 0   −1 4 −1 0 ... 0 
   
1 0 −I B −I . . . 0  
 0
 −1 4 −1 ... 0 

A=−  . .. .. .. .. .. , B =  .. .. .. .. .. 
h  .. . . . . 
.   . . . . . ... 
  
 0 ... 0 −I B −I   0 ... 0 −1 4 −1 
0 ... 0 0 −I B 0 ... 0 0 −1 4
where 0 is N × N zero matrix, I is N × N identity matrix, and B ∈ RN×N .
80
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.

The starting point is, typically, the construction of a mesh.

Mesh generation software is used in most cases. Examples include:

Triangle: https://www.cs.cmu.edu/ quake/triangle.html

Gmsh: https://gmsh.info/

Mesh generators output (among other things) two key data structures:

an array for the geometry, often referred to as node array

an array for the topology, often referred to as connectivity array

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

0 0.2 0.4 0.6 0.8 1

(a) Position of nodes on the plane. (b) node array.

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

0 0.2 0.4 0.6 0.8 1


(a) The mesh. (b) connectivity array.

Figure 8.10: Example 8.8. Elements and respective connectivity array.


For given node and connectivity arrays, we can compute the stiffness matrix
and load vector.
e reference element (or, reference simplex, as is also known). Then, each element T 2 T can
d as the image of an affine map FT : Rd ! Rd mapping the reference element T̂ into T , viz.,
84
Reference element

A key tool is the use of a reference element T̂, e.g.,

T̂ := {x ∈ Rd : 0 ≤ x1 + · · · + xd ≤ 1}

the reference simplex (in our case d = 2, so we talk of a reference triangle).

and maps FT : Rd → Rd , mapping T̂ onto T, i.e.,

FT (T̂) = T for every T ∈ T .


ŷ y
(0, 1) FT x2
T x
1
T̂ x3

(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 .

Hence, for x̂ := (x̂, ŷ)T ∈ T̂, we consider the linear map


FT (x̂) = Bx̂ + x3 .
( )
b11
b12
for a matrix B = ∈ R2×2 , s.t. F((0, 0)T ) = x3 . Requiring
b21
b22
( ) ( ) ( ) ( )
x1 1 b11 x3
= FT = + ,
y1 0 b21 y3
we get b11 = x1 − x3 and b21 = y1 − y3 ,while, demanding
( ) ( ) ( ) ( )
x2 0 b12 x3
= FT = + ,
y2 1 b22 y3
we get b12 = x2 − x3 and b22 = y2 − y3 .
Therefore, ( )
x1 − x3 x2 − x3
FT (x̂) = x̂ + x3 .
y1 − y3 y2 − y3
86
Basis functions under map
ŷ y
(0, 1) FT x2
T x
1
T̂ x3

(1, 0) x̂ x
ψ1 (x̂, ŷ) := x̂, ψ2 (x̂, ŷ) := ŷ, and ψ3 (x̂, ŷ) := 1 − x̂ − ŷ,

Let now basis function ϕi corresponding to the node xi in the mesh.

node xi corresponds to one of the nodes x1 , x2 , x3 in the local element numbering


connectivity gives the identification of local-to-global numbering

Therefore,

ϕi (FT (·)) equals one of the reference basis functions ψ1 , ψ2 , ψ3 accordingly!

87
Basis functions under map

ach element there are 3 localLinear/affine basis


basis functions.
element there are 3 local basis functions.

Let function w : T → R. We define v : T̂ → R, with v(x̂) := w(FT (x̂)).

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

each of which, upon change of variables using map FT , becomes


∫ ∫ ( )( )
∇ϕj ·∇ϕi dx dy = B−T ∇ϕ
ˆ j (FT (x̂)) · B−T ∇ϕ
ˆ i (FT (x̂)) det(B) dx̂ dŷ =: IT ,
T T̂
∂(x,y)
since det = det(BT ) = det(B). Since, the pulled-back basis functions
∂(x̂,ŷ)
correspond to reference element basis functions, we have

( −T ) ( )
IT = B ∇ψˆ ℓ · B−T ∇ψ ˆ k det(B) dx̂ dŷ =: (AT )k,ℓ

for some k, ℓ = 1, 2, 3. Direct computation reveals
 
|x2 − x3 |2 (x2 − x3 ) · (x3 − x1 ) (x2 − x3 ) · (x1 − x2 )
1  (x2 − x3 ) · (x3 − x1 )
AT = |x3 − x1 |2 (x3 − x1 ) · (x1 − x2 )  .
2 det(B) (x − x ) · (x − x ) (x − x ) · (x − x ) |x − x |2
2 3 1 2 3 1 1 2 1 2

is referred to as the local stiffness matrix


89
Assembly
So, given a local finite element basis and a mapping, we can compute the
elemental contributions of
∑∫
aij = ∇ϕj · ∇ϕi dx dy,
T∈T T

by calculating the local stiffness matrices AT .

The final step in the assembly is to transfer the entries of each AT to the global
stiffness matrix A,

To that end, we resort to the connectivity array as follows:

Iterating from 1 to Nel (i,.e., all elements T in the mesh), set

aij → aij + (AT )k,ℓ

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.

a(uh , vh ) = ℓ(vh ) ∀vh ∈ Ṽh ∩ H10 (Ω).

becomes: find Uj ∈ R, j = 1, . . . , Nint , s.t.


Nint ∑
N total

Uj a(ϕj , ϕi ) = ℓ(ϕi ) − g(xj )a(ϕj , ϕi ), i = 1, . . . , Nint


j=1 j=Nint +1

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:

replace each row of A corresponding to basis functions of boundary nodes by


the respective row of the identity matrix

replace each row of F corresponding to basis functions of boundary nodes by


the respective boundary value

Then, the linear system becomes


( )( ) ( )
Aint,int Aint,boun Uint Fint
=
0 IN∂ ×N∂ U∂ g
N∂ ,Nint
with Aint,int = {aij }N
i,j=1 , Aint,boun = {aij }i=1,j=1 , IN∂ ×N∂ the identity matrix, Uint
int

Ntotal
and U∂ interior and boundary values, resp.,Fint = {Fi }N i=1 and g := {g(xi )}i=Nint +1 .
int

92

You might also like