Applied Comp Methods Notes1
Applied Comp Methods Notes1
Applied Comp Methods Notes1
Lecture Notes
−∆u = f in Ω,
(1.1)
u=0 on Γ.
Here, f is a given function and ∆ is the Laplace operator or Laplacian defined by
∂2u ∂2u
∆u = +
∂x21 ∂x22
where x = (x1 , x2 ) ∈ IR2 are Cartesian coordinates. Even though the Poisson equation looks
very special it is an important model case representing several problems from physics based on
energy minimisation. Variations of the techniques we will study apply to a wide class of second
order so-called elliptic problems.
It is known that there are cases where no classical (i.e. twice continuously differentiable)
solution of (1.1) exists. In order to deal with a uniquely solvable problem one therefore derives
a weaker formulation.
It is convenient to write the Laplace operator in the following form:
∆u = div ∇u
1
We will also need the normal derivative of a function w defined by
∂w ∂w ∂w
∂n w := := n · ∇w = n1 + n2 on Γ.
∂n ∂x1 ∂x2
Lemma 1.1 (First Green formula) For sufficiently smooth functions v and w = (w1 , w2 ) there
holds Z Z Z
∇v · w dx = v n · w ds − v div w dx. (1.2)
Ω Γ Ω
The first integral on the right-hand side denotes integration with respect to the arc length s along
Γ.
Remark 1.1 Remember that, for a differentiable curve Γ with parameter representation γ =
(γ1 , γ2 ) : (0, R) → Γ ⊂ IR2 , integration along Γ with respect to the arc length is defined by
Z R Z R r
dγ dγ (t) 2 dγ (t) 2
Z
1 2
f ds = f (γ(t)) (t) dt =
f (γ(t)) + dt
Γ 0 dt 0 dt dt
Multiplying the Poisson equation by a sufficiently smooth function v, integrating over Ω and
using the first Green formula we find that there holds
Z Z Z Z
f v dx = −∆u v dx = ∇u · ∇v dx − ∂n uv ds.
Ω Ω Ω Γ
with Z Z
a(u, v) := ∇u · ∇v dx and (f, v) := f v dx.
Ω Ω
Problem (1.3) is called the variational or weak formulation of (1.1). In this particular case there
is an equivalent minimisation problem:
1
u∈V : F (u) ≤ F (v) ∀v ∈ V where F (v) := a(v, v) − (f, v). (1.4)
2
2
Notations and definitions. For the discussion and analysis of (1.3) we need to introduce
some definitions and derivatives used for the space H01 (Ω).
Let V be a linear space. L : V → IR is called a linear form if
for all u, v, w ∈ V and all β, θ ∈ IR. The bilinear form a is called symmetric if
a(v, v) > 0 ∀v ∈ V, v 6= 0.
Every inner product h·, ·i on V ×V defines a norm k·k on V , and there holds the Cauchy-Schwarz
inequality
|hv, wi| ≤ kvk kwk ∀v, w ∈ V. (1.5)
Also, remember that a complete normed space with inner product is called a Hilbert space.
Now we introduce a weak form of derivatives.
Definition 1.1 Let I ⊂ IR be an interval. An element v ∈ L2 (I) (we call it function) is weakly
differentiable if there exists g ∈ L2 (I) such that
Z Z
′
vφ dx = − gφ dx ∀φ ∈ C0∞ (I).
I I
Here, the derivative φ′ is the classical one. When such a g exists then one defines v ′ := g.
Note that the weak derivative coincides with the classical derivative for a differentiable
function. This follows from the integration-by-parts formula. The extension of this definition to
higher orders is by induction and to higher dimensions by replacing the above integration-by-
parts formula by first Green’s formula (cf. Lemma 1.1).
Summary. The boundary value problem (1.1) has the weak formulation (1.3) where a(·, ·)
is a symmetric bilinear form on H01 (Ω) × H01 (Ω) (one can prove that it is also positive definite)
and where (f, ·) is a linear form on H01 (Ω). L2 (Ω) and
3
are Hilbert spaces (derivatives are defined in the weak sense) with inner products and norms
Z
1/2
kvkL2 (Ω) := Ω v 2 dx
R
(v, w) := (v, w)L2 (Ω) := vw dx, ,
Ω 1/2
(v, w)H 1 (Ω) := Ω vw + ∇v · ∇w dx, kvkH 1 (Ω) := Ω v 2 + |∇v|2 dx
R R
.
Moreover, H01 (Ω) provided with the H 1 (Ω)-norm is a closed subspace of H 1 (Ω).
The spaces H 1 (Ω) and H01 (Ω) are called Sobolev spaces.
Theorem 1.1 Any solution of (1.1) solves (1.3), and the problems (1.3) and (1.4) are equivalent.
Any solution of (1.3) which is sufficiently regular solves (1.1).
Proof. We have already seen that any solution of (1.1) solves (1.3). Now we show that (1.3)
and (1.4) are equivalent. Let u solve (1.3) and let v ∈ V . Then set w = v − u so that v = u + w
with w ∈ V . We obtain
1
F (v) = F (u + w) = a(u + w, u + w) − (f, u + w)
2
1 1
= a(u, u) − (f, u) + a(u, w) − (f, w) + a(w, w) ≥ F (u)
2 2
since by (1.3), a(u, w) − (f, w) = 0 and a(w, w) ≥ 0. Therefore, u solves (1.4). Now, if u is a
solution of (1.4) then for any v ∈ V and any real number ǫ there holds
F (u) ≤ F (u + ǫv),
1 ǫ2
g(ǫ) := F (u + ǫv) = a(u, u) + ǫa(u, v) + a(v, v) − (f, u) − ǫ(f, v)
2 2
is differentiable, has a minimum at ǫ = 0 and, thus, g′ (0) = 0. This yields
4
By the continuity of ∆u + f this requires that
∆u + f = 0 pointwise on Ω.
Since u is continuous, the search for u ∈ V = H01 (Ω) in particular means that the homogeneous
Dirichlet boundary condition is satisfied. This proves that u solves (1.1). 2
Exercise 1.1 Derive the variational formulation and corresponding minimisation problem of
the boundary value problem
Here we assume that any two triangles are disjoint or intersect at a single vertex or an entire
edge. The triangulation Th is also called a mesh on Ω. With any such mesh we associate the
mesh size or mesh width defined by
5
in discrete variational form. Of course, as in the proof of Theorem 1.1 one sees that (1.6) and
(1.7) are equivalent. Historically, (1.6) is called the Ritz method and (1.7) the Galerkin method.
To calculate uh (theoretically or on a computer) one transforms the discrete problem (i.e.
(1.6) or (1.7)) into a system of linear equations.
One can identify any element of Vh by its values at the nodes Nj (j = 1, . . . , M ) of the
mesh (the set of vertices of the triangles). In particular, the dimension of Vh is the number M
of interior nodes of the mesh Th (the values on boundary nodes, the ones on Γ, are fixed by
definition of Vh ). It is immediate that the functions ϕj ∈ Vh defined by
1 if i = j
ϕj (Ni ) = δij ≡ , i, j = 1, . . . , M
0 if i 6= j
form a basis of Vh (see Figure 1.1), they are called basis functions.
ϕj
Nj
The support of ϕj consists of all elements that have Nj as a vertex. Note that this number
of elements depends on the mesh construction and can be different for different nodes. One can
represent any v ∈ Vh as a linear combination of the basis functions,
M
X
v= ηj ϕj where ηj = v(Nj ).
j=1
6
Lemma 1.2 The solution uh of (1.7) is given by (1.8) where ξ is the solution of the linear
system
Aξ = b (1.9)
where A = (aij ) is the M × M stiffness matrix with elements
Z
aij = a(ϕi , ϕj ) = ∇ϕi · ∇ϕj dx, i, j = 1, . . . , M,
Ω
There holds aK (ϕi , ϕj ) = 0 unless both nodes Ni and Nj are vertices of the triangle K. There-
fore, to calculate aK (ϕi , ϕj ), one only needs to consider the numbers i, j ∈ {1, . . . , M } which
correspond to nodes Ni , Nj of K. For arbitrary (but fixed) K ∈ Th let Ni , Nj , Nk denote its
three vertices. We then call the 3 × 3-matrix
aK (ϕi , ϕi ) aK (ϕi , ϕj ) aK (ϕi , ϕk )
AK := aK (ϕj , ϕj ) aK (ϕj , ϕk ) (1.11)
sym aK (ϕk , ϕk )
7
the element or local stiffness matrix for K. In order to calculate the stiffness matrix A one
calculates all the element stiffness matrices AK and then forms A by using (1.10). This process
is called the assembly of A. A is sometimes called global stiffness matrix to distinguish it from
the local matrices. An analogous procedure is used to construct the load vector b.
To calculate AK one obviously needs only the restrictions of the basis functions ϕi , ϕj , ϕk
onto K. Let us denote these restrictions by
ψi := ϕi |K , ψj := ϕj |K , ψk := ϕk |K .
Each of these three functions is linear (on K) and has the value 1 at exactly one vertex and
vanishes at the other two vertices. Any linear function w on K can be represented by
Exercise 1.2 Consider the triangle K̃ with vertices Ñ1 = (0, 0), Ñ2 = (h, 0) and Ñ3 = (0, h).
Define the local (linear) basis functions associated with the vertices and show that the local
stiffness matrix for K̃ is given by
1 − 21 − 12
à = (ãij )3i,j=1 = − 21 1
2 0 .
1 1
−2 0 2
Also, convince yourself that a translation or rotation of K̃ does not alter this matrix.
x2
1
K26 K28 K30 K32
K25 K27 K29 K31
K2 1 K4 2 K6 3 K8
K1 K3 K5 K7
x1
0 1
8
Example 1.1 Let us consider a square Ω with side length 1 and let Th be a uniform triangulation
of Ω with h = 1/4, see Figure 1.2. (Here, for simplicity, h denotes the smallest side length of
the triangles which is proportional to their diameter since they are shape regular.) The nodes
Ni appear as numbers i = 1, . . . , 9 and the elements are Ki , i = 1, . . . , 32. We use the local
stiffness matrix à = (ãij ) from Exercise 1.2 and formula (1.10) to assemble the global stiffness
matrix. For instance, noting that the supports of ϕ4 , ϕ1 ϕ4 and ϕ2 ϕ4 are ∪i∈{10,11,12,19,18,17} Ki ,
K10 ∪ K11 and K11 ∪ K12 , respectively, we obtain
X
a4,4 = aKi (ϕ4 , ϕ4 ) = ã1,1 + ã3,3 + ã2,2 + ã1,1 + ã3,3 + ã2,2
i∈{10,11,12,19,18,17}
= 1 + 1/2 + 1/2 + 1 + 1/2 + 1/2 = 4,
X
a1,4 = aKi (ϕ1 , ϕ4 ) = ã3,1 + ã1,3 = −1/2 − 1/2 = −1,
i∈{10,11}
X
a2,4 = aKi (ϕ1 , ϕ4 ) = ã2,3 + ã3,2 = 0 + 0 = 0.
i∈{11,12}
4 −1 0 −1 0 0 0 0 0
−1 4 −1 0 −1 0 0 0 0
0 −1 4 0 0 −1 0 0 0
−1 0 0 4 −1 0 −1 0 0
A=
0 −1 0 −1 4 −1 0 −1 .
0
0 0 −1 0 −1 4 0 0 −1
0 0 0 −1 0 0 4 −1 0
0 0 0 0 −1 0 −1 4 −1
0 0 0 0 0 −1 0 −1 4
Exercise 1.3 Consider the situation described in Example 1.1 but with h = 1/3 instead of
h = 1/4. For right-hand side function f (x) = 1 (x ∈ Ω) assemble the linear system (1.9),
determine the solution uh of (1.7) and calculate uh (1/2, 1/2).
uh ∈ Vh ⊂ V : a(uh , v) = L(v) ∀v ∈ Vh
9
translates into the Galerkin orthogonality
a(u − uh , v) = 0 ∀v ∈ Vh . (1.13)
−∆u + u = f in Ω,
(1.14)
u=0 on Γ.
and can also be written in the general form (1.12) with V = H01 (Ω), a(u, v) = (∇u, ∇v) + (u, v)
and L(v) = (f, v). We note that in fact a(u, v) = hu, vi is the standard inner product in H01 (Ω)
such that the variational formulation renders like
Introducing a finite element space Vh ⊂ H01 (Ω) one has a corresponding finite element scheme
and the Galerkin orthogonality (1.13) becomes
hu − uh , vi = 0 ∀v ∈ Vh . (1.16)
The relation (1.16) means that the finite element error u − uh is orthogonal to the finite element
space Vh . In particular, uh is the projection with respect to the inner product h·, ·i of u onto
Vh . Figure 1.3 gives a geometric description of this fact for the case V = IR2 with Euclidean
inner product and a one-dimensional subspace Vh ⊂ V . This property proves the following best
approximation property:
Note that with the finite element method for (1.14) we calculate the projection of the exact
solution u onto Vh without actually knowing it. It only requires the solution of a sparse linear
system Aξ = b with symmetric, positive definite matrix A.
−∆u + u = f in Ω,
(1.18)
∂n u = g on Γ.
10
u
Vh
uh
Here, f and g are given functions and ∂n u denotes, as introduced before, the outward normal
derivative of u on Γ. The boundary condition is called Neumann boundary condition.
The variational formulation of (1.18) is
where Z
a(u, v) := (∇u, ∇v) + (u, v) and (g, v)Γ := gv ds.
Γ
Correspondingly, the minimisation problem is
where
1
F (v) := a(v, v) − (f, v) − (g, v)Γ .
2
Theorem 1.2 Any solution u of (1.18) solves (1.19). If u is a sufficiently regular solution of
(1.19) then it solves (1.18). Moreover, problems (1.19) and (1.20) are equivalent.
Proof. The equivalence of (1.19) and (1.20) is analogous to the situation in Theorem 1.1. Now
assume that u solves (1.18). We multiply the differential equation in (1.18) by a test function
v ∈ H 1 (Ω) and integrate over Ω. Using that ∂n u = g on Γ, the first Green formula (Lemma 1.1)
gives
Z Z Z Z
(f, v) = (−∆u + u) v dx = − ∂n uv ds + ∇u · ∇v dx + uv dx
Ω Γ Ω Ω
= −(g, v)Γ + (∇u, ∇v) + (u, v) = a(u, v) − (g, v)Γ .
This is (1.19). Now let u be a sufficiently smooth function that solves (1.19). Using again
Green’s first formula we obtain
Z Z
(f, v) + (g, v)Γ = a(u, v) = ∂n uv ds + (−∆u + u) v dx,
Γ Ω
11
that is Z Z
(−∆u + u − f ) v dx + (∂n u − g) v ds = 0 ∀v ∈ H 1 (Ω). (1.21)
Ω Γ
−∆u + u − f = 0 in Ω.
Taking this relation (it is the wanted differential equation) into account (1.21) becomes
Z
(∂n u − g) v ds = 0 ∀v ∈ H 1 (Ω).
Γ
By varying the test function v ∈ H 1 (Ω) appropriately it can be seen that this requires
∂n u − g = 0 on Γ.
Remark 1.2 Note that the Neumann boundary condition appears in the variational formulation
(via the linear form on the right-hand side) and is not incorporated in the space V = H 1 (Ω).
It is therefore called natural boundary condition. In contrast, a Dirichlet boundary condition
of the type u = 0 on Γ enters the variational formulation by choosing V appropriately to reflect
this condition, V = H01 (Ω) ⊂ H 1 (Ω) in this case. Therefore, Dirichlet boundary conditions are
also called essential boundary conditions. This difference in incorporating boundary conditions
is inherited by the finite element schemes.
To define a finite element scheme for the approximate solution of (1.19) we choose a finite-
dimensional subspace Vh ⊂ H 1 (Ω). To this end we consider as before a mesh Th consisting of
triangles K. The simplest choice of Vh is
Note that we do not ask v ∈ Vh to vanish on Γ. All the nodes of Th including the ones on Γ are
now being taken into account. The finite element method then is:
Note that uh in general does not satisfy the Neumann boundary condition. One can rather show
that ∂n uh → g (h → 0) in an appropriate norm.
12
Exercise 1.5 Let Ω ⊂ IR2 be a bounded domain with Lipschitz continuous boundary Γ and let
Γ be decomposed into two non-empty curves Γ1 and Γ2 : Γ = Γ̄1 ∪ Γ̄2 and Γ1 ∩ Γ2 = ∅. For
sufficiently smooth functions f and g give a variational formulation of the mixed boundary
value problem
−∆u + u = f in Ω,
u=0 on Γ1 ,
∂n u = g on Γ2 .
13