Professional Documents
Culture Documents
Xiaoming He
Department of Mathematics & Statistics
Missouri University of Science & Technology
Email: hex@mst.edu
Homepage: https://web.mst.edu/~hex/
1 / 152
Weak/Galerkin formulation FE Space FE discretization Boundary treatment FE Method General extensions Conclusions
Outline
1 Weak/Galerkin formulation
2 FE Space
3 FE discretization
4 Boundary treatment
5 FE Method
6 General extensions
7 Conclusions
2 / 152
Weak/Galerkin formulation FE Space FE discretization Boundary treatment FE Method General extensions Conclusions
Outline
1 Weak/Galerkin formulation
2 FE Space
3 FE discretization
4 Boundary treatment
5 FE Method
6 General extensions
7 Conclusions
3 / 152
Weak/Galerkin formulation FE Space FE discretization Boundary treatment FE Method General extensions Conclusions
Target problem
Solve
d du(x)
− c(x) = f (x), a < x < b,
dx dx
u(a) = ga , u(b) = gb
for u(x).
Why do we start from this problem?
An easy look at the basic idea of the finite element method.
Numerical methods for partial differential equations: finite
element method, finite difference method, finite volume
method, boundary element method, etc., which use different
techniques to discretize partial differential equations.
4 / 152
Weak/Galerkin formulation FE Space FE discretization Boundary treatment FE Method General extensions Conclusions
Weak formulation
5 / 152
Weak/Galerkin formulation FE Space FE discretization Boundary treatment FE Method General extensions Conclusions
Weak formulation
6 / 152
Weak/Galerkin formulation FE Space FE discretization Boundary treatment FE Method General extensions Conclusions
Weak formulation
Then
Z b Z b
0 0 0 0
−c(b)u (b)v (b) + c(a)u (a)v (a) + cu v dx = fv dx.
a a
7 / 152
Weak/Galerkin formulation FE Space FE discretization Boundary treatment FE Method General extensions Conclusions
1D Sobolev spaces
Definition (Support)
If u is a function, then its support supp(u) is the closure of the set
on which u is nonzero.
Lemma (I)
A function compactly supported in an open interval I is zero on
and near the boundary of I .
8 / 152
Weak/Galerkin formulation FE Space FE discretization Boundary treatment FE Method General extensions Conclusions
1D Sobolev spaces
Definition
C0∞ (I ) is the set of all functions that are infinitely differentiable on
I and compactly supported in I .
9 / 152
Weak/Galerkin formulation FE Space FE discretization Boundary treatment FE Method General extensions Conclusions
1D Sobolev spaces
10 / 152
Weak/Galerkin formulation FE Space FE discretization Boundary treatment FE Method General extensions Conclusions
1D Sobolev spaces
Lemma (II)
If u is differentiable, then u is weakly differentiable and its weak
derivative is u 0 .
Remark
In the Sobolev spaces, which will be defined below, u 0 is used to
represent the weak derivative.
11 / 152
Weak/Galerkin formulation FE Space FE discretization Boundary treatment FE Method General extensions Conclusions
1D Sobolev spaces
Definition (H 1 space)
H 1 (I ) = {v ∈ L2 (I ) : v 0 ∈ L2 (I )}
where I = (a, b).
12 / 152
Weak/Galerkin formulation FE Space FE discretization Boundary treatment FE Method General extensions Conclusions
Weak formulation
a(u, v ) = (f , v )
13 / 152
Weak/Galerkin formulation FE Space FE discretization Boundary treatment FE Method General extensions Conclusions
Galerkin formulation
a(uh , vh ) = (f , vh )
Z b Z b
0 0
⇔ cuh vh dx = fvh dx
a a
for any vh ∈ Uh .
Basic idea of Galerkin formulation: use finite dimensional
space to approximate infinite dimensional space.
Question: How to obtain Uh ?
14 / 152
Weak/Galerkin formulation FE Space FE discretization Boundary treatment FE Method General extensions Conclusions
Outline
1 Weak/Galerkin formulation
2 FE Space
3 FE discretization
4 Boundary treatment
5 FE Method
6 General extensions
7 Conclusions
15 / 152
Weak/Galerkin formulation FE Space FE discretization Boundary treatment FE Method General extensions Conclusions
Mesh
16 / 152
Weak/Galerkin formulation FE Space FE discretization Boundary treatment FE Method General extensions Conclusions
17 / 152
Weak/Galerkin formulation FE Space FE discretization Boundary treatment FE Method General extensions Conclusions
Theorem (I)
Uh is an (N + 1)−dimensional subspace of C [a, b]. (Math 6601:
Numerical Analysis)
Proof:
First, it is easy to verify that Uh is a subspace of C [a, b].
If we can find a continuous piecewise linear basis of N + 1
functions for Uh , then the proof is completed.
Consider φj (x) ∈ Uh such that
0, if j 6= i,
φj (xi ) = δij =
1, if j = i.
for i, j = 1, · · · , N + 1.
18 / 152
Weak/Galerkin formulation FE Space FE discretization Boundary treatment FE Method General extensions Conclusions
20 / 152
Weak/Galerkin formulation FE Space FE discretization Boundary treatment FE Method General extensions Conclusions
Outline
1 Weak/Galerkin formulation
2 FE Space
3 FE discretization
4 Boundary treatment
5 FE Method
6 General extensions
7 Conclusions
22 / 152
Weak/Galerkin formulation FE Space FE discretization Boundary treatment FE Method General extensions Conclusions
Discretization formulation
a(uh , vh ) = (f , vh )
Z b Z b
0 0
⇔ cuh vh dx = fvh dx
a a
for any vh ∈ Uh .
Since uh ∈ Uh = span{φj }N+1
j=1 , then
N+1
X
uh = uj φj
j=1
Discretization formulation
N+1
X Z b Z b
⇒ uj cφ0j φ0i dx = f φi dx, i = 1, · · · , N + 1.
j=1 a a
24 / 152
Weak/Galerkin formulation FE Space FE discretization Boundary treatment FE Method General extensions Conclusions
Discretization formulation
Define the stiffness matrix
Z b N+1
A= [aij ]N+1
i,j=1 = cφ0j φ0i dx .
a i,j=1
Define the load vector
Z b N+1
~b = [bi ]N+1 = f φi dx .
i=1
a i=1
Define the unknown vector
~ = [uj ]N+1 .
X j=1
Discretization formulation
Remark
In fact, since
0, if j 6= k,
φj (xk ) = δjk =
1, if j = k.
then
N+1
X
uh (xk ) = uj φj (xk ) = uk .
j=1
28 / 152
Weak/Galerkin formulation FE Space FE discretization Boundary treatment FE Method General extensions Conclusions
29 / 152
Weak/Galerkin formulation FE Space FE discretization Boundary treatment FE Method General extensions Conclusions
30 / 152
Weak/Galerkin formulation FE Space FE discretization Boundary treatment FE Method General extensions Conclusions
31 / 152
Weak/Galerkin formulation FE Space FE discretization Boundary treatment FE Method General extensions Conclusions
32 / 152
Weak/Galerkin formulation FE Space FE discretization Boundary treatment FE Method General extensions Conclusions
33 / 152
Weak/Galerkin formulation FE Space FE discretization Boundary treatment FE Method General extensions Conclusions
34 / 152
Weak/Galerkin formulation FE Space FE discretization Boundary treatment FE Method General extensions Conclusions
35 / 152
Weak/Galerkin formulation FE Space FE discretization Boundary treatment FE Method General extensions Conclusions
37 / 152
Weak/Galerkin formulation FE Space FE discretization Boundary treatment FE Method General extensions Conclusions
38 / 152
Weak/Galerkin formulation FE Space FE discretization Boundary treatment FE Method General extensions Conclusions
Algorithm II:
Initialize the matrix: b = zeros(N + 1, 1);
Compute the integrals and assemble them into ~b:
FOR i = 2, · · · , N:
Compute
f (x) hi−1 dx + xi i+1 f (x) xi+1h−x dx;
R xi x−x Rx
b(i) = xi−1
END Rx
Compute b(1) = x12 f (x) x2h−x dx;
Rx
Compute b(N + 1) = xNN+1 f (x) x−x h
N
dx;
39 / 152
Weak/Galerkin formulation FE Space FE discretization Boundary treatment FE Method General extensions Conclusions
Outline
1 Weak/Galerkin formulation
2 FE Space
3 FE discretization
4 Boundary treatment
5 FE Method
6 General extensions
7 Conclusions
40 / 152
Weak/Galerkin formulation FE Space FE discretization Boundary treatment FE Method General extensions Conclusions
41 / 152
Weak/Galerkin formulation FE Space FE discretization Boundary treatment FE Method General extensions Conclusions
Algorithm III:
Deal with the Dirichlet boundary conditions:
A(1, :) = 0;
A(1, 1) = 1;
A(N + 1, :) = 0;
A(N + 1, N + 1) = 1;
b(1) = ga ;
b(N + 1) = gb ;
43 / 152
Weak/Galerkin formulation FE Space FE discretization Boundary treatment FE Method General extensions Conclusions
Outline
1 Weak/Galerkin formulation
2 FE Space
3 FE discretization
4 Boundary treatment
5 FE Method
6 General extensions
7 Conclusions
44 / 152
Weak/Galerkin formulation FE Space FE discretization Boundary treatment FE Method General extensions Conclusions
Basic algorithm
Input a, b, and N. Compute h = b−a N and
xj = a + (j − 1)h (j = 1, · · · , N + 1).
Remark
The above algorithm uses the Algorithms I, II, and III, which are
designed for some particular cases with a special method. It is not
general enough to deal with different types of PDEs. Therefore, we
will discuss a more universal framework in the following.
45 / 152
Weak/Galerkin formulation FE Space FE discretization Boundary treatment FE Method General extensions Conclusions
46 / 152
Weak/Galerkin formulation FE Space FE discretization Boundary treatment FE Method General extensions Conclusions
Define your global indices for all the mesh elements and mesh
nodes. Let N denote the number of mesh elements and Nm
denote the number of mesh nodes. Here Nm = N + 1.
Define matrix P to be an information matrix consisting of the
coordinates of all mesh nodes.
Define matrix T to be an information matrix consisting of the
global node indices of the mesh nodes of all the mesh
elements.
47 / 152
Weak/Galerkin formulation FE Space FE discretization Boundary treatment FE Method General extensions Conclusions
For example, for the mesh used in this chapter, we can use
the j th column of the matrix P to store the coordinates of the
j th mesh node and the nth column of the matrix T to store
the global node indices of the mesh nodes of the nth mesh
element:
P = x1 x2 · · · xNm −1 xNm
= x1 x2 · · · xN xN+1 ,
1 2 · · · Nm − 2 N m − 1
T =
2 3 · · · Nm − 1 Nm
1 2 ··· N − 1 N
= .
2 3 ··· N N +1
48 / 152
Weak/Galerkin formulation FE Space FE discretization Boundary treatment FE Method General extensions Conclusions
49 / 152
Weak/Galerkin formulation FE Space FE discretization Boundary treatment FE Method General extensions Conclusions
Define your global indices for all the mesh elements and finite
element nodes (or the finite element basis functions). Let Nb
denote the total number of the finite element basis functions
(= the number of unknowns = the total number of the finite
element nodes). Here Nb = N + 1.
Then
Nb
X
uh = uj φj .
j=1
51 / 152
Weak/Galerkin formulation FE Space FE discretization Boundary treatment FE Method General extensions Conclusions
Remark
For many types of finite elements, such as the quadratic elements
which will be discussed later and some elements which will be
introduced in Chapter 2, Pb and Tb are different from P and T
since the nodes for the finite element basis functions are different
from those of the mesh.
52 / 152
Weak/Galerkin formulation FE Space FE discretization Boundary treatment FE Method General extensions Conclusions
Local assembly
53 / 152
Weak/Galerkin formulation FE Space FE discretization Boundary treatment FE Method General extensions Conclusions
Local assembly
54 / 152
Weak/Galerkin formulation FE Space FE discretization Boundary treatment FE Method General extensions Conclusions
Local assembly
Compute all non-zero local integrals on each element for A:
On the nth element En = [xn , xn+1 ], we get non-zero local
integrals only when the trial and test basis functions are
corresponding to the finite element nodes of the element.
That is, we only consider the trial and test basis functions to
be φn or φn+1 .
There are only four non-zero local integrals on En with the
global basis functions φn and φn+1 :
Z xn+1 Z xn+1 Z xn+1 Z xn+1
cφ0n φ0n dx, cφ0n+1 φ0n dx, cφ0n φ0n+1 dx, cφ0n+1 φ0n+1 dx.
xn xn xn xn
55 / 152
Weak/Galerkin formulation FE Space FE discretization Boundary treatment FE Method General extensions Conclusions
Local assembly
Recall
x2 −x
h , if x1 ≤ x ≤ x2 ,
φ1 (x) =
0, otherwise,
x−xj−1
if xj−1 ≤ x ≤ xj ,
h ,
xj+1 −x
φj (x) = if xj ≤ x ≤ xj+1 ,
h ,
0, otherwise.
(i = 2, · · · , N)
x−xN
φN+1 (x) = h , if xN ≤ x ≤ xN+1 ,
0, otherwise,
Define two local linear basis functions:
xn+1 − x x − xn
ψn1 = φn |En = , ψn2 = φn+1 |En = .
h h
So in one element, the number of local basis functions
Nlb = 2.
56 / 152
Weak/Galerkin formulation FE Space FE discretization Boundary treatment FE Method General extensions Conclusions
Local assembly
Then the only four non-zero local integrals become
Z xn+1 Z xn+1 Z xn+1 Z xn+1
0 0 0 0 0 0 0 0
cψn1 ψn1 dx, cψn2 ψn1 dx, cψn1 ψn2 dx, cψn2 ψn2 dx.
xn xn xn xn
Local assembly
58 / 152
Weak/Galerkin formulation FE Space FE discretization Boundary treatment FE Method General extensions Conclusions
Local assembly
instead of Z xn+1
cφ0j φ0i dx (i, j = n, n + 1),
xn
59 / 152
Weak/Galerkin formulation FE Space FE discretization Boundary treatment FE Method General extensions Conclusions
Local assembly
Recall that the nth column of the matrix Tb stores the global
node indices of the finite element nodes of the nth mesh
element:
1 2 ··· N − 1 N
Tb = .
2 3 ··· N N +1
Hence Tb (α, n) and Tb (β, n) give the global node indices of
the local trial and test basis functions ψnα and
ψnβ (α, β = 1, 2).
That is, for n = 1, · · · , N,
Z xn+1
0 0
cψnα ψnβ dx (α, β = 1, 2)
xn
Local assembly
Algorithm IV:
Initialize the matrix: A = sparse(Nb , Nb );
Compute the integrals and assemble them into A:
FOR n = 1, · · · , N:
FOR α = 1, · · · , Nlb :
FOR β = 1, · · · , Nlb
R :xn+1 0 0
Compute r = xn cψnα ψnβ dx;
Add r to A(Tb (β, n), Tb (α, n));
END
END
END
61 / 152
Weak/Galerkin formulation FE Space FE discretization Boundary treatment FE Method General extensions Conclusions
Local assembly
62 / 152
Weak/Galerkin formulation FE Space FE discretization Boundary treatment FE Method General extensions Conclusions
Local assembly
63 / 152
Weak/Galerkin formulation FE Space FE discretization Boundary treatment FE Method General extensions Conclusions
Local assembly
To make a general subroutine for different cases, more information
needed for computing and assembling the integral should be
treated as input parameters or input functions of this subroutine:
the coefficient function c;
the Gauss quadrature points and weights for numerical
integrals;
the mesh information matrices P and T , which can also
provide the number of mesh elements N = size(T , 2) and the
number of mesh nodes Nm = size(P, 2);
the finite element information matrices Pb and Tb for the trial
and test functions respectively, which can also provide the
number of local basis functions Nlb = size(Tb , 1) and the
number of the global basis functions Nb = size(Pb , 2) (= the
number of unknowns);
the type of the basis function for the trial and test functions
respectively. 64 / 152
Weak/Galerkin formulation FE Space FE discretization Boundary treatment FE Method General extensions Conclusions
Local assembly
65 / 152
Weak/Galerkin formulation FE Space FE discretization Boundary treatment FE Method General extensions Conclusions
Local assembly
66 / 152
Weak/Galerkin formulation FE Space FE discretization Boundary treatment FE Method General extensions Conclusions
Local assembly
Compute all non-zero local integrals on each element for ~b:
On the nth element En = [xn , xn+1 ], we get non-zero local
integrals only when the test basis functions are corresponding
to the finite element nodes of the element.
That is, we only consider the test basis functions to be φn or
φn+1 .
There are only two non-zero local integrals on En with the
global basis functions φn and φn+1 :
Z xn+1 Z xn+1
f φn dx, f φn+1 dx.
xn xn
67 / 152
Weak/Galerkin formulation FE Space FE discretization Boundary treatment FE Method General extensions Conclusions
Local assembly
Using ψn1 and ψn2 , these two non-zero local integrals become
Z xn+1 Z xn+1
f ψn1 dx, f ψn2 dx.
xn xn
Local assembly
69 / 152
Weak/Galerkin formulation FE Space FE discretization Boundary treatment FE Method General extensions Conclusions
Local assembly
instead of Z xn+1
f φi dx (i = n, n + 1),
xn
70 / 152
Weak/Galerkin formulation FE Space FE discretization Boundary treatment FE Method General extensions Conclusions
Local assembly
Recall that the nth column of the matrix Tb stores the global
node indices of the finite element nodes of the nth mesh
element:
1 2 ··· N − 1 N
Tb = .
2 3 ··· N N +1
Hence Tb (β, n) gives the global node indices of the local test
basis functions ψnβ (β = 1, 2).
That is, for n = 1, · · · , N,
Z xn+1
f ψnβ dx (β = 1, 2)
xn
71 / 152
Weak/Galerkin formulation FE Space FE discretization Boundary treatment FE Method General extensions Conclusions
Local assembly
Algorithm V:
Initialize the vector: b = zeros(Nb , 1);
Compute the integrals and assemble them into ~b:
FOR n = 1, · · · , N:
FOR β = 1, · · · , Nlb
R :x
Compute r = xnn+1 f ψnβ dx;
b(Tb (β, n), 1) = b(Tb (β, n), 1) + r ;
END
END
72 / 152
Weak/Galerkin formulation FE Space FE discretization Boundary treatment FE Method General extensions Conclusions
Local assembly
73 / 152
Weak/Galerkin formulation FE Space FE discretization Boundary treatment FE Method General extensions Conclusions
Local assembly
74 / 152
Weak/Galerkin formulation FE Space FE discretization Boundary treatment FE Method General extensions Conclusions
Local assembly
To make a general subroutine for different cases, more information
needed for computing and assembling the integral should be
treated as input parameters or input functions of this subroutine:
the right hand side function f ;
the quadrature points and weights for numerical integrals;
the mesh information matrices P and T , which can also
provide the number of mesh elements N = size(T , 2) and the
number of mesh nodes Nm = size(P, 2);
the finite element information matrices Pb and Tb for the test
functions, which can also provide the number of local basis
functions Nlb = size(Tb , 1) and the number of the global basis
functions Nb = size(Pb , 2) (= the number of unknowns);
the type of the basis function for the test functions.
75 / 152
Weak/Galerkin formulation FE Space FE discretization Boundary treatment FE Method General extensions Conclusions
76 / 152
Weak/Galerkin formulation FE Space FE discretization Boundary treatment FE Method General extensions Conclusions
Algorithm VI:
Deal with the Dirichlet boundary conditions:
FOR k = 1, · · · , nbn:
IF boundarynodes(1, k) shows Dirichlet condition, THEN
i = boundarynodes(2, k);
A(i, :) = 0;
A(i, i) = 1;
b(i) = g (Pb (i));
ENDIF
END
77 / 152
Weak/Galerkin formulation FE Space FE discretization Boundary treatment FE Method General extensions Conclusions
Enriched algorithm
78 / 152
Weak/Galerkin formulation FE Space FE discretization Boundary treatment FE Method General extensions Conclusions
Enriched algorithm
Recall Algorithm V:
Initialize the vector: b = zeros(Nb , 1);
Compute the integrals and assemble them into ~b:
FOR n = 1, · · · , N:
FOR β = 1, · · · , Nlb
R :x
Compute r = xnn+1 f ψnβ dx;
b(Tb (β, n), 1) = b(Tb (β, n), 1) + r ;
END
END
79 / 152
Weak/Galerkin formulation FE Space FE discretization Boundary treatment FE Method General extensions Conclusions
Enriched algorithm
~ = ~b for X
Solve AX ~ by using a direct or iterative method.
80 / 152
Weak/Galerkin formulation FE Space FE discretization Boundary treatment FE Method General extensions Conclusions
Numerical example
81 / 152
Weak/Galerkin formulation FE Space FE discretization Boundary treatment FE Method General extensions Conclusions
Numerical example
Any Observation?
82 / 152
Weak/Galerkin formulation FE Space FE discretization Boundary treatment FE Method General extensions Conclusions
Numerical example
83 / 152
Weak/Galerkin formulation FE Space FE discretization Boundary treatment FE Method General extensions Conclusions
Outline
1 Weak/Galerkin formulation
2 FE Space
3 FE discretization
4 Boundary treatment
5 FE Method
6 General extensions
7 Conclusions
84 / 152
Weak/Galerkin formulation FE Space FE discretization Boundary treatment FE Method General extensions Conclusions
Basic framework
85 / 152
Weak/Galerkin formulation FE Space FE discretization Boundary treatment FE Method General extensions Conclusions
Recall:
Assume that we have a uniform partition of [a, b] into N
elements with mesh size h = b−a
N .
Let xi = a + (i − 1)h (i = 1, · · · , N + 1) denote the mesh
nodes, which are also the finite element nodes of the 1D linear
finite elements.
Let En = [xn , xn+1 ] (n = 1, · · · , N) denote the mesh elements.
Let Nm denote the number of mesh nodes. Here Nm = N + 1.
Let Nb denote the number of global finite element basis
functions. Here Nb = N + 1.
Let Nlb denote the number of local finite element basis
functions in one element. Here Nlb = 2.
86 / 152
Weak/Galerkin formulation FE Space FE discretization Boundary treatment FE Method General extensions Conclusions
87 / 152
Weak/Galerkin formulation FE Space FE discretization Boundary treatment FE Method General extensions Conclusions
Hence
xn+1 − x x − xn
ψn1 (x) = , ψn2 (x) = .
xn+1 − xn xn+1 − xn
Since xn+1 − xn = h, then the two local linear basis functions
are
xn+1 − x
ψn1 (x) = ,
h
x − xn
ψn2 (x) = ,
h
which match the non-zero pieces of the global linear basis
functions obtained in Chapter 1.
89 / 152
Weak/Galerkin formulation FE Space FE discretization Boundary treatment FE Method General extensions Conclusions
90 / 152
Weak/Galerkin formulation FE Space FE discretization Boundary treatment FE Method General extensions Conclusions
for j = 1, · · · , N + 1 and n = 1, · · · , N.
That is,
ψ11 , on E1 ,
φ1 =
0, otherwise,
ψn1 , on En such that j = n,
φj = ψn2 , on En such that j = n + 1, j = 2, · · · , N;
0, otherwise,
ψN2 , on EN ,
φN+1 =
0, otherwise,
91 / 152
Weak/Galerkin formulation FE Space FE discretization Boundary treatment FE Method General extensions Conclusions
which are the global node indices of the two finite element
nodes An1 = xn and An2 = xn+1 in the element [xn , xn+1 ].
Since the local basis functions ψn1 and ψn2 are one-to-one
corresponding to the finite element nodes An1 = xn and
An2 = xn+1 in the element [xn , xn+1 ], the nth column of the
information matrix Tb also gives the global indices of the local
basis functions ψn1 and ψn2 , which are n and n + 1.
94 / 152
Weak/Galerkin formulation FE Space FE discretization Boundary treatment FE Method General extensions Conclusions
Hence
ψn1 , if j = Tb (1, n),
φj |En = ψn2 , if j = Tb (2, n),
0, otherwise.
for j = 1, · · · , N + 1 and n = 1, · · · , N.
This is the reason why we use Tb (α, n) and Tb (β, n)
(α, β = 1, 2) to give the global node indices of the local trial
and test basis functions ψnα and ψnβ (α, β = 1, 2) of the nth
mesh element in Chapter 1!
95 / 152
Weak/Galerkin formulation FE Space FE discretization Boundary treatment FE Method General extensions Conclusions
For a given function ψ̂(x̂) where x̂ ∈ [0, 1], we can define the
corresponding function for x ∈ [a, b] as follows:
x −a
ψ(x) = ψ̂(x̂) = ψ̂( ).
b−a
x−xn x−xn
Consider [a, b] = [xn , xn+1 ]. Then x̂ = xn+1 −xn = h .
From the above affine mapping and the reference basis functions
ψ̂1 (x̂) = 1 − x̂ and ψ̂2 (x̂) = x̂,
we can use the “reference → local” framework to obtain the same
local basis functions as before:
x − xn
ψn1 (x) = ψ̂1 (x̂) = ψ̂1 ( )
h
x − xn h − x + xn xn+1 − x
= 1− = = ,
h h h
x − xn x − xn
ψn2 (x) = ψ̂2 (x̂) = ψ̂2 ( )= .
h h
98 / 152
Weak/Galerkin formulation FE Space FE discretization Boundary treatment FE Method General extensions Conclusions
Â1 = 0 → An1 = xn ,
Â2 = 1 → An2 = xn+1 .
for i, j = 1, 2.
Remark: If you want to use the reference basis functions ψ̂j and the
affine mapping x̂ = x−x h
n
to provide the local basis functions
ψnj (x) = ψ̂j (x̂) instead of directly using the local basis functions,
you will need to use chain rule to obtain the derivative of the local
dψnj (x) d ψ̂ (x̂)
basis functions. For example, dx = djx̂ ddxx̂ .
99 / 152
Weak/Galerkin formulation FE Space FE discretization Boundary treatment FE Method General extensions Conclusions
100 / 152
Weak/Galerkin formulation FE Space FE discretization Boundary treatment FE Method General extensions Conclusions
101 / 152
Weak/Galerkin formulation FE Space FE discretization Boundary treatment FE Method General extensions Conclusions
102 / 152
Weak/Galerkin formulation FE Space FE discretization Boundary treatment FE Method General extensions Conclusions
ψ̂1 (x̂) = a1 x̂ 2 + b1 x̂ + c1 ,
ψ̂2 (x̂) = a2 x̂ 2 + b2 x̂ + c2 ,
ψ̂3 (x̂) = a3 x̂ 2 + b3 x̂ + c3 ,
such that
0, if j 6= i,
ψ̂j (Âi ) = δij =
1, if j = i,
for i, j = 1, 2, 3.
103 / 152
Weak/Galerkin formulation FE Space FE discretization Boundary treatment FE Method General extensions Conclusions
104 / 152
Weak/Galerkin formulation FE Space FE discretization Boundary treatment FE Method General extensions Conclusions
Hence
a1 = 2, b1 = −3, c1 = 1,
a2 = 2, b2 = −1, c2 = 0,
a3 = −4, b3 = 4, c3 = 0.
105 / 152
Weak/Galerkin formulation FE Space FE discretization Boundary treatment FE Method General extensions Conclusions
106 / 152
Weak/Galerkin formulation FE Space FE discretization Boundary treatment FE Method General extensions Conclusions
107 / 152
Weak/Galerkin formulation FE Space FE discretization Boundary treatment FE Method General extensions Conclusions
109 / 152
Weak/Galerkin formulation FE Space FE discretization Boundary treatment FE Method General extensions Conclusions
x − xn 2
x − xn x − xn
ψn1 (x) = ψ̂1 (x̂) = ψ̂1 ( )= 2 −3 + 1,
h h h
x − xn 2 x − xn
x − xn
ψn2 (x) = ψ̂2 (x̂) = ψ̂2 ( )= 2 − ,
h h h
x − xn 2
x − xn x − xn
ψn3 (x) = ψ̂3 (x̂) = ψ̂3 ( )= −4 +4 .
h h h
110 / 152
Weak/Galerkin formulation FE Space FE discretization Boundary treatment FE Method General extensions Conclusions
for i, j = 1, 2, 3.
111 / 152
Weak/Galerkin formulation FE Space FE discretization Boundary treatment FE Method General extensions Conclusions
112 / 152
Weak/Galerkin formulation FE Space FE discretization Boundary treatment FE Method General extensions Conclusions
for i, j = 1, · · · , 2N + 1.
Then define the global finite element space to be
Uh = span{φj }2N+1
j=1 .
113 / 152
Weak/Galerkin formulation FE Space FE discretization Boundary treatment FE Method General extensions Conclusions
In fact,
ψn1 , if j = 2n − 1,
ψn2 , if j = 2n + 1,
φj |En =
ψ , if j = 2n,
n3
0, otherwise,
for j = 1, · · · , 2N + 1 and n = 1, · · · , N.
114 / 152
Weak/Galerkin formulation FE Space FE discretization Boundary treatment FE Method General extensions Conclusions
which are the global node indices of the two finite element
nodes An1 = y2n−1 , An2 = y2n+1 , and An3 = y2n in the
element [xn , xn+1 ].
Since the local basis functions ψn1 , ψn2 , and ψn3 are
one-to-one corresponding to the finite element nodes
An1 = y2n−1 , An2 = y2n+1 , and An3 = y2n in the element
[xn , xn+1 ], the nth column of the information matrix Tb also
gives the global indices of the local basis functions ψn1 , ψn2 ,
and ψn3 which are 2n − 1, 2n + 1 and 2n.
115 / 152
Weak/Galerkin formulation FE Space FE discretization Boundary treatment FE Method General extensions Conclusions
Hence
ψn1 , if j = Tb (1, n),
ψn2 , if j = Tb (2, n),
φj |En =
ψn3 , if j = Tb (3, n),
0, otherwise,
for j = 1, · · · , 2N + 1 and n = 1, · · · , N.
116 / 152
Weak/Galerkin formulation FE Space FE discretization Boundary treatment FE Method General extensions Conclusions
117 / 152
Weak/Galerkin formulation FE Space FE discretization Boundary treatment FE Method General extensions Conclusions
118 / 152
Weak/Galerkin formulation FE Space FE discretization Boundary treatment FE Method General extensions Conclusions
119 / 152
Weak/Galerkin formulation FE Space FE discretization Boundary treatment FE Method General extensions Conclusions
Any Observation?
120 / 152
Weak/Galerkin formulation FE Space FE discretization Boundary treatment FE Method General extensions Conclusions
121 / 152
Weak/Galerkin formulation FE Space FE discretization Boundary treatment FE Method General extensions Conclusions
122 / 152
Weak/Galerkin formulation FE Space FE discretization Boundary treatment FE Method General extensions Conclusions
123 / 152
Weak/Galerkin formulation FE Space FE discretization Boundary treatment FE Method General extensions Conclusions
Code? Just add −ra c(a) to the corresponding entry of the load vector ~b!
You can find the corresponding entry by repeating the derivation of the
matrix formulation from the above weak formulation.
124 / 152
Weak/Galerkin formulation FE Space FE discretization Boundary treatment FE Method General extensions Conclusions
Code? Just add rb c(b) to the corresponding entry of the load vector ~b!
You can find the corresponding entry by repeating the derivation of the
matrix formulation from the above weak formulation.
125 / 152
Weak/Galerkin formulation FE Space FE discretization Boundary treatment FE Method General extensions Conclusions
Consider
d du(x)
c(x) = f (x) (a ≤ x ≤ b), u 0 (a) = ra , u 0 (b) = rb .
dx dx
Recall
Z b Z b
0 0 0 0
−c(b)u (b)v (b) + c(a)u (a)v (a) + cu v dx = fv dx.
a a
Hence
Z b Z b
0 0
−rb c(b)v (b) + ra c(a)v (a) + cu v dx = fv dx.
a a
127 / 152
Weak/Galerkin formulation FE Space FE discretization Boundary treatment FE Method General extensions Conclusions
Code? Just add pb c(b) to the corresponding entry of the load vector ~b
and qb c(b) to the corresponding entry of the stiffness matrix A! You can
find the corresponding entries by repeating the derivation of the matrix
formulation from the above weak formulation.
128 / 152
Weak/Galerkin formulation FE Space FE discretization Boundary treatment FE Method General extensions Conclusions
Hence
Z b Z b
−[pb − qb u(b)]c(b)v (b) + ra c(a)v (a) + cu 0 v 0 dx = fv dx
a a
Z b Z b
⇒ qb c(b)u(b)v (b) + cu 0 v 0 dx = fv dx−ra c(a)v (a) + pb c(b)v (b).
a a
Code? Just add −ra c(a) and pb c(b) to the corresponding entries of the
load vector ~b and qb c(b) to the corresponding entry of the stiffness
matrix A! You can find the corresponding entries by repeating the
derivation of the matrix formulation from the above weak formulation.
129 / 152
Weak/Galerkin formulation FE Space FE discretization Boundary treatment FE Method General extensions Conclusions
Consider
d du(x)
− c(x) = f (x) (a ≤ x ≤ b), u 0 (a) + qa u(a) = pa , u 0 (b) = rb .
dx dx
Consider
d du(x)
− c(x) = f (x) (a ≤ x ≤ b),
dx dx
u 0 (a) + qa u(a) = pa , u 0 (b) + qb u(b) = pb .
130 / 152
Weak/Galerkin formulation FE Space FE discretization Boundary treatment FE Method General extensions Conclusions
131 / 152
Weak/Galerkin formulation FE Space FE discretization Boundary treatment FE Method General extensions Conclusions
Recall
Definition (L2 space)
Z b
2
L (I ) = {v : I → R : v 2 dx < ∞}
a
where I = (a, b).
Definition (H 1 space)
H 1 (I ) = {v ∈ L2 (I ) : v 0 ∈ L2 (I )}
where I = (a, b).
132 / 152
Weak/Galerkin formulation FE Space FE discretization Boundary treatment FE Method General extensions Conclusions
133 / 152
Weak/Galerkin formulation FE Space FE discretization Boundary treatment FE Method General extensions Conclusions
qR
H 1 semi-norm error: |u − uh |1 = 0 0 2
I (u − uh ) dx.
qR
H 1 norm: kuk1 = 1
R
2 02
I u dx + I u dx for u ∈ H (I ).
H 1 norm error:
qR
0 2
R
ku − uh k1 = 2 0
I (u − uh ) dx + I (u − uh ) dx.
134 / 152
Weak/Galerkin formulation FE Space FE discretization Boundary treatment FE Method General extensions Conclusions
Nb
P
By using uh = uj φj , the definition of Tb , and the definition
j=1
of the local basis functions ψnk , we get
135 / 152
Weak/Galerkin formulation FE Space FE discretization Boundary treatment FE Method General extensions Conclusions
Define
Nlb
X
wn (x) = uTb (k,n) ψnk (x).
k=1
Then
136 / 152
Weak/Galerkin formulation FE Space FE discretization Boundary treatment FE Method General extensions Conclusions
Algorithm VII:
Approximate the maximum absolute errors on all elements
and then choose the largest one as the final approximation:
FOR n = 1, · · · , N:
Compute rn ≈ max |u(x) − wn (x)|;
xn ≤x≤xn+1
END
error max rn .
1≤n≤N
137 / 152
Weak/Galerkin formulation FE Space FE discretization Boundary treatment FE Method General extensions Conclusions
Define
Nlb
X
wn = uTb (k,n) ψnk .
k=1
Then
v
u N Z
uX xn+1
ku − uh k0 = t (u − wn )2 dx.
n=1 xn
Rx
Each integral xnn+1 (u − wn )2 dx can be computed by
numerical integration.
139 / 152
Weak/Galerkin formulation FE Space FE discretization Boundary treatment FE Method General extensions Conclusions
Define
Nlb
X
0
wn = uTb (k,n) ψnk .
k=1
Then
v
u N Z
uX xn+1
|u − uh |1 = t (u 0 − wn )2 dx.
n=1 xn
Rx
Each integral xnn+1 (u 0 − wn )2 dx can be computed by
numerical integration.
141 / 152
Weak/Galerkin formulation FE Space FE discretization Boundary treatment FE Method General extensions Conclusions
That is,
v
u N Z
xn+1 Nlb
(s)
uX X
t (u (s) − wn,s )2 dx, wn,s = uTb (k,n) ψnk .
n=1 xn k=1
Algorithm VIII:
Initialize the error error = 0; input the parameter s;
Compute the integrals and add them into the total error:
FOR n = 1, · · · , N:
!2
Nlb
R xn+1 (s)
u (s) −
P
error = error + xn uTb (k,n) ψnk dx;
k=1
END
√
error = error ;
143 / 152
Weak/Galerkin formulation FE Space FE discretization Boundary treatment FE Method General extensions Conclusions
h ku − uh k∞ ku − uh k0 |u − uh |1
1/4 1.4041 × 10−2 7.1969 × 10−3 1.0528 × 10−1
1/8 3.6803 × 10−3 1.7951 × 10−3 5.2731 × 10−2
1/16 9.4048 × 10−4 4.4854 × 10−4 2.6376 × 10−2
1/32 2.3760 × 10−4 1.1212 × 10−4 1.3189 × 10−2
1/64 5.9704 × 10−5 2.8029 × 10−5 6.5949 × 10−3
1/128 1.4964 × 10−5 7.0072 × 10−6 3.2975 × 10−3
Table: L∞ norm error, L2 norm error and H 1 semi-norm error
Any Observation?
144 / 152
Weak/Galerkin formulation FE Space FE discretization Boundary treatment FE Method General extensions Conclusions
145 / 152
Weak/Galerkin formulation FE Space FE discretization Boundary treatment FE Method General extensions Conclusions
h ku − uh k∞ ku − uh k0 |u − uh |1
1/4 3.3128 × 10−4 2.1041 × 10−4 5.4212 × 10−3
1/8 3.9240 × 10−5 2.6144 × 10−5 1.3534 × 10−3
1/16 4.7518 × 10−6 3.2631 × 10−6 3.3823 × 10−4
1/32 5.8390 × 10−7 4.0774 × 10−7 8.4550 × 10−5
1/64 7.2343 × 10−8 5.0962 × 10−8 2.1137 × 10−5
1/128 9.0022 × 10−9 6.3702 × 10−9 5.2842 × 10−6
Table: L∞ norm error, L2 norm error and H 1 semi-norm error
Any Observation?
146 / 152
Weak/Galerkin formulation FE Space FE discretization Boundary treatment FE Method General extensions Conclusions
147 / 152
Weak/Galerkin formulation FE Space FE discretization Boundary treatment FE Method General extensions Conclusions
Outline
1 Weak/Galerkin formulation
2 FE Space
3 FE discretization
4 Boundary treatment
5 FE Method
6 General extensions
7 Conclusions
148 / 152
Weak/Galerkin formulation FE Space FE discretization Boundary treatment FE Method General extensions Conclusions
The framework of finite element methods are universal for all partial
differential equations.
If the original equations are symmetric positive definite, the linear
systems arising from finite element methods are also symmetric
positive definite, which is important for many fast matrix solvers.
It is natural for finite element methods to deal with problem
domains with curved boundary, interface or singularities once the
mesh is properly constructed.
It is natural for many finite element methods to keep the
conservation law.
The finite element methods provide piecewise functions defined on
the whole problem domain as numerical solutions, not just the
numerical solutions at mesh nodes.
The finite element methods have mature frameworks for
mathematical analysis.
149 / 152
Weak/Galerkin formulation FE Space FE discretization Boundary treatment FE Method General extensions Conclusions
152 / 152