Fem Engineering
Fem Engineering
H. Kasumba
October 6, 2021
1 Introduction
The finite element method (FEM) is a numerical technique for solving a wide range of complex
physical phenomena, particularly those exhibiting geometrical and material non-linearities (such
as those that are often encountered in the physical and engineering sciences). These problems can
be structural in nature, thermal (or thermo-mechanical), electrical, magnetic, acoustic etc. plus
any combination of. It is used most frequently to tackle problems that aren’t readily amenable to
analytical treatments.
Figure 1:
Physical problems are governed by differential equations which satisfy Boundary conditions Initial
conditions
One variable: Ordinary differential equation (ODE) Multiple independent variables: Partial dif-
ferential equation (PDE)
1
Figure 2:
Z 1 Z 1
′′
(1) −u (x)ϕ(x) dx = f (x)ϕ(x) dx
0 0
2
Integrating by parts the left hand side of (1), we obtain
Z 1 Z 1
′ ′ ′ ′
−u (1)ϕ(1) + u (0)ϕ(0) + u (x)ϕ (x) dx = f (x)ϕ(x) dx
0 0
Next, we choose ϕ(x) such that it has compact support in [0, 1], i.e., ϕ(0) = ϕ(1) = 0. Then, the
variational formulation becomes
Z 1 Z 1
′ ′
(2) u (x)ϕ (x) dx = f (x)ϕ(x) dx
0 0
Then
F (u) = F (u∗u − u∗ )
Z 1 Z 1
1 ∗
= 2
[(u + w)x ] dx − f (u∗ + w) dx where w = u − u∗
0 2 0
1 1 ∗ 2
Z Z 1
∗
= 2
(u ) + 2ux wx + (wx ) dx − (f u∗ + f w) dx
2 0 x 0
1 1 ∗ 2
Z 1 Z 1
1 1 2
Z Z
∗ ∗
= (u ) − f u dx + ux wx − f w dx + w dx
2 0 x 0 0 2 0 x
| {z } | {z }
=0 ≥0
1 1 2
Z
∗
F (u) = F (u ) + w dx
2 0 x
| {z }
≥0
⇒ F (u∗ ) ≤ F (u) for all u ∈ V
3
Proof. u solution to minimization problem implies that
F (u) ≤ F (u + ϵv), ϵ ∈ R, ∀v ∈ V.
The functional
1 1 1 1 1
ϵ2
Z Z Z Z Z
1 ′ 2 ′ ′ ′ 2
g(ϵ) := F (u + ϵv) = (u ) dx + ϵ u v dx + (v ) dx − f u dx − ϵ f v dx.
2 0 0 2 0 0 0
where v(x) is a test function satisfying the boundary conditions, i.e., v(0) = v(1) = 0.
The mesh will be called uniform if the points xi are equidistant, that is,
1
xi = ih, with h = , 0 ≤ i ≤ n.
n
4
The points xi are called vertices or nodes of the mesh.
3. We replace the Hilbert space V on which we pose the variational formulation by a subspace Vh
of finite dimension.
Motivation
Suppose the value of u(x) at nodes xi and xi+1 are known such that
where
xi+1 − x
ψi (x) = , ψi (xi ) = 1, ψi (xi+1 ) = 0.
h
Similarly,
x − xi
ψi+1 (x) = , ψi+1 (xi ) = 0, ψi+1 (xi+1 ) = 1.
h
5
The above functions are known as shape functions. The union of 2 shape functions in neighboring
elements gives a global basis function at a node xi :
x−x
h
i−1
x ∈ (xi−1 , xi ),
xi+1 −x
(4) ϕi (x) = h
x ∈ (xi , xi+1 ),
0 otherwise
6
On assuming the hat basis functions, obviously uh (x) is also a piecewise linear function,
although this is not usually the case for the true solution u(x).
i.e.,
Z 1 Z 1
(5) u′h v ′ dx = f v dx,
0 0
Z n−1
1X Z 1
(6) ⇒ ui ϕ′i v ′ dx = f v dx
0 i=1 0
n−1
X Z 1 Z 1
(7) ⇒ ui ϕ′i v ′ dx = f v dx
i=1 0 0
Now the test function v(x) is chosen to be ϕ1 , ϕ2 , · · · , ϕn−1 successively, to get the system of linear
equations (noting that further errors are introduced).
AU = F,
where
a(ϕ1 , ϕ1 ) a(ϕ1 , ϕ2 ) ··· a(ϕ1 , ϕn−1 )
a(ϕ2 , ϕ1 ) a(ϕ2 , ϕ2 ) ··· a(ϕ2 , ϕn−1 )
A=
.. .. .. ..
. . . .
a(ϕn−1 , ϕ1 ) a(ϕn−1 , ϕ2 ) · · · a(ϕn−1 , ϕn−1 )
U1 (f, ϕ1 )
Z 1
U2 (f, ϕ2 )
U = .. , F = , a(ϕi , ϕj ) = ϕ′i ϕ′j dx.
..
. . 0
Un−1 (f, ϕn−1 )
Example 3.1. Consider the two point boundary value problem
7
(b) Divide the interval (0,1) into 3 subintervals of equal length h = 13 and let Vh be the corre-
sponding space of continuous piecewise linear functions vanishing as x = 0 and x = 1.
Ax = b,
Solution
Let V := {ϕ ∈ H 1 (0, 1) | ϕ(0) = 0, ϕ(1) = 0}.
where
3x x ∈ (0, 1/3), 3x − 1 x ∈ (1/3, 2/3),
(8) ϕ1 (x) = 2 − 3x x ∈ (1/3, 2/3), ϕ2 (x) = 3 − 3x x ∈ (2/3, 1),
0 otherwise 0 otherwise
8
Note
supp(ϕ1 ) = (0, 2/3)
supp(ϕ2 ) = (1/3, 1)
supp(ϕ1 ∩ ϕ2 ) = (1/3, 2/3)
3 x ∈ (0, 1/3), 3 x ∈ (1/3, 2/3),
(9) ϕ′1 (x) = −3 x ∈ (1/3, 2/3), ϕ′2 (x) = −3 x ∈ (2/3, 1),
0 otherwise 0 otherwise
1
(10) 6u1 − 3u2 =
3
Next, choose v(x) = ϕ2 (x). Then
"Z # "Z #
2/3 2/3 Z 1 Z 1
−u1 9 dx + u2 9 dx + 9 dx = ϕ2 (x) dx.
1/3 1/3 2/3 0
1
(11) −3u1 + 6u2 = .
3
Collecting the above results, we find
2 −1 1 1
A=3 , b=
−1 2 3 1
Since
1 20 −11 −9 −11 693
Det(A) = 16det + 9det = ̸= 0
2 −11 11 0 11 2
Matrix A is invertible and the linear system
Ax = b,
is uniquely solvable.
Example 3.2. Consider the two point boundary value problem
9
(a) Derive the variational formulation of (P). (03 marks)
(b) Divide the interval (0,1) into 3 subintervals of equal length h = 31 and let Vh be the corre-
sponding space of continuous piecewise linear functions vanishing as x = 0.
(i) Use Vh to formulate a finite element method for (P). (04 marks)
(ii) Verify that the stiffness matrix A and the load vector b are given by
16 −9 0 1
1 1
A = −9 20 −11 , b = 1 .
2 3
0 −11 11 7
(15 marks)
Note supp(ϕ1 ) = (0, 2/3),supp(ϕ2 ) = (1/3, 1),supp(ϕ3 ) = (2/3, 1) supp(ϕ1 ∩ϕ2 ) = (1/3, 2/3),
supp(ϕ2 ∩ ϕ3 ) = (2/3, 1).
3 x ∈ (0, 1/3), 3 x ∈ (1/3, 2/3),
(12) ϕ′1 (x) = −3 x ∈ (1/3, 2/3), ϕ′2 (x) = −3 x ∈ (2/3, 1),
0 otherwise 0 otherwise
3 x ∈ (2/1, 1),
(13) ϕ′3 (x) =
0 otherwise
10
Since v ∈ Vh , choose v(x) = ϕ1 (x). Then
"Z # "Z #
1/3 Z 2/3 2/3
u1 (1 + x)9 dx + (1 + x)9 dx − u2 (1 + x)9 dx + u3 · 0 =
0 1/3 1/3
Z 1
ϕ1 (x) dx + 2ϕ1 (1).
0
11
4 Implementation of FEM
weak formulation . Z 1 Z 1
′ ′
u v dx = f v dx,
0 0
Discretization
n−1
X Z 1 Z 1
(17) ui ϕ′i ϕ′j dx = f ϕj dx
i=1 0 0
Note: Z 1 Nk Z
X
ϕ′i ϕ′j dx = ϕ′i ϕ′j dx
0 k=1 ek
Figure 3:
given by
xi+1 − x 1
ϕi (x) = , ϕi (x)′ = −
h h
x − xi 1
ϕi+1 (x) = , ϕi+1 (x)′ =
h h
The local stiffness matrix is given by
" R xi+1 ′ 2 R xi+1 ′ ′ #
x i
(ϕ i ) dx x i
ϕi ϕi+1 dx
(18) Kie = R xi+1 R xi+1 ′ 2
′ ′
ϕi ϕi+1 dx xi (ϕi+1 ) dx
" x1i
− h1
#
h
(19) =
− h1 h1
Local load vector.
Assume f = 1, then
" R xi+1 #
xi
ϕi dx
(20) Fie = R xi+1
xi
ϕi+1 dx
h
" #
2
(21) =
h
2
12
4.1 Implementation of the sum
In element 1
S([1, 2], [1, 2]) = S([1, 2], [1, 2]) + K1e
1 −1 0 0
1 −1 1 0 0
S=
h 0 0 0 0
0 0 0 0
In element 2
S([2, 3], [2, 3]) = S([2, 3], [2, 3]) + K2e
The global stiffness matrix becomes
1 −1 0 0
1 −1 2 −1 0
S=
h 0 −1 1 0
0 0 0 0
In element 3
S([3, 4], [3, 4]) = S([3, 4], [3, 4]) + K3e
The global stiffness matrix becomes
1 −1 0 0
1 −1 2 −1 0
S=
h 0 −1 2 −1
0 0 −1 1
13
4.1.2 Global Load Vector
Assume f = 1, then
h
" #
2
(22) Fie =
h
2
Then
0 1 1 1
0 h 1 h 1+1
⇒ h 2
0 ⇒ 2
F = ⇒
0 2 1 2 1+1
0 0 0 1
The entire system reads
1 −1 0 0 u1 1
1 −1 2 −1 0 u2
1 2
=
h 0 −1 2 −1 u3 h 2
0 0 −1 1 u4 1
14