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

lecture-slides-week3

The document discusses the finite element method (FEM) for solving 2D elliptic problems, specifically the Poisson problem in weak form. It outlines the process of constructing the finite element space, defining basis functions, and assembling the stiffness matrix and load vector from a triangulated mesh. Additionally, it provides examples and calculations for a specific problem, demonstrating how to compute the FEM system and the associated matrices.

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)
3 views

lecture-slides-week3

The document discusses the finite element method (FEM) for solving 2D elliptic problems, specifically the Poisson problem in weak form. It outlines the process of constructing the finite element space, defining basis functions, and assembling the stiffness matrix and load vector from a triangulated mesh. Additionally, it provides examples and calculations for a specific problem, demonstrating how to compute the FEM system and the associated matrices.

Uploaded by

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

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.

76
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.
77
he basis functions are pyramid functions, associated with e
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.

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

79
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).

80
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

81
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).

82
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 φi,j (x, y) = x−xi y−yj
1+ h + h , if (x, y) ∈ T4 ;
T5 

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

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

 h ,
0, otherwise.
Figure: The support of φi,j .

83
Pyramid function φi,j

xi,j

84
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 ;
  1


 0, if (x, y) ∈ T2 ; 

 − h , if (x, y) ∈ T2 ;
 
 h1 ,
 if (x, y) ∈ T3 ;  0,
 if (x, y) ∈ T3 ;
1 1
(φi,j )x (x, y) = h, if (x, y) ∈ T4 ; , (φi,j )y (x, y) = h, if (x, y) ∈ T4 ;
  1


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

 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 
   
 0 −I B
1 −I . . . 0    0 −1 4 −1 ... 0 
 
A=−  . .. .. .. .. .. , B =  .. .. .. .. ..  . (3
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 .
85
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     
   U1,2 
  
 F 1,2 

 0 −I B −I . . . 0   .   . 
  .  .
 .. .. . . . .  .  = h . 
 ,
 . . . . . . . . .
. 
 
  UN,2 
 FN,2 
 
 0 ... 0 −I B −I   .   .. 
.
0 −I B  . 
   . 
0 ... 0  
 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
86
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

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

where Z
88
Fi,j = f i,j dV. (8.22)
Data structures: connectivity

1
4 6
0.8 ○
4 2 3
1 3 7
6 8 5 1 7

5 6 7
0.6 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.

For given node and connectivity arrays, we can compute the stiffness matrix
Figure 8.10: Example 8.8. Elements and respective connectivity array.
and load vector.
te the reference element (or, reference simplex, as is also known). Then, each element T 2 T can be
sented as the image of an affine map FT : Rd ! Rd mapping the reference element T̂ into T , viz.,
89
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
90
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 .
/ 0
b11
b12
for a matrix B = ∈ R2×2 , s.t. F((0, 0)T ) = x3 . Requiring
b21
b22
/ 0 / 0 / 0 / 0
x1 1 b11 x3
= FT = + ,
y1 0 b21 y3
we get b11 = x1 − x3 and b21 = y1 − y3 ,while, demanding
/ 0 / 0 / 0 / 0
x2 0 b12 x3
= FT = + ,
y2 1 b22 y3
we get b12 = x2 − x3 and b22 = y2 − y3 .
Therefore, / 0
x1 − x3 x2 − x3
FT (x̂) = x̂ + x3 .
y1 − y3 y2 − y3
91
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!

92
Basis functions under map

On each element there are 3 Linear/affine


local basis basis
functions.
ch element there are 3 local basis functions.
243

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
/ 0
wx xx̂ + wy yx̂
ˆ
∇v = = BT ∇w,
wx xŷ + wy yŷ

∂(x, y)
since the Jacobian = BT .
∂(x̂, ŷ)

93
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


! ! 1 21 2
∇φj ·∇φi dx dy = B−T ∇φ
ˆ j (FT (x̂)) · B−T ∇φ
ˆ i (FT (x̂)) det(B) dx̂ dŷ =: IT ,
T T̂
T
since det ∂(x,y)
∂(x̂,ŷ) = det(B ) = det(B). Since, the pulled-back basis functions
correspond to reference element basis functions, we have
!
3 −T 4 3 −T 4
IT = B ∇ψ" · B ∇ψk det(B) dx̂ dŷ =: (AT )k,"
ˆ ˆ

for some k, ! = 1, 2, 3. Direct computation reveals
 2

|x2 − x3 | (x2 − x3 ) · (x3 − x1 ) (x2 − x3 ) · (x1 − x2 )
1
AT =  (x2 − x3 ) · (x3 − x1 ) |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


94
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 .
95
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

96
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


/ 0/ 0 / 0
Aint,int Aint,boun Uint Fint
=
0 IN∂ ×N∂ U∂ g
N∂ ,Nint
with Aint,int = {aij }N int
i,j=1 , Aint,boun = {aij } i=1,j=1 , IN∂ ×N∂ the identity matrix, Uint
Ntotal
and U∂ interior and boundary values, resp.,Fint = {Fi }N int
i=1 and g := {g(xi i=Nint +1 .
)}
97
Poisson problem with Neumann boundary condition
Consider the Poisson problem
−∆u = f on Ω and n · ∇u = g on ∂Ω
In weak form: find u ∈ H1 (Ω), such that
! ! !
∇u · ∇v dx = fv dx + gv dS ∀v ∈ H1 (Ω).
Ω Ω ∂Ω

Remark:
A compatibility condition may be required: let v = 1 (it is allowed!); then
! !
f dx = − g dS.
Ω ∂Ω

Also, we may need to choose solution space well to ensure uniqueness:


For instance, consider
−∆u = f on Ω and n · ∇u = 0 on ∂Ω
The solution u is unique up to a constant function.
98
Poisson problem with Neumann boundary condition

In this case we deal with the total number of nodes Ntotal .


FEM for the above: find Uj ∈ R, j = 1, . . . , Ntotal , such that
N
#total ! ! !
Uj ∇φj · ∇φi dx = fφi dx + gφi dS i = 1, . . . , Ntotal
j=1 Ω Ω ∂Ω

99

You might also like