2 FEM Basics: Discretization 2.4 The Galerkin Basis...

3

Click here to load reader

Transcript of 2 FEM Basics: Discretization 2.4 The Galerkin Basis...

Page 1: 2 FEM Basics: Discretization 2.4 The Galerkin Basis …maths.nuigalway.ie/~niall/teaching/Archive/1112/MathsOfFEM/Lecture... · 2 FEM Basics: Discretization 2.1 The weak form, again

Lecture 2 4 Wed, 18/01/12

2 FEM Basics: Discretization

2.1 The weak form, again

Recall... we are interested in the following differential

equation: find u ∈ C[0, 1] ∪ C2(Ω) such that

−u ′′(x) + r(x)u(x) = f(x) for 0 < x < 1,

with u(0) = u(1) = 1. Here r and f are given functions.

We then derived the variational formulation: Define

• the inner product (u, v) :=∫

1

0u(x)v(x)dx;

• the bilinear form B(u, v) := (u ′, v ′) + (ru, v), and

• the linear form l(v) = (f, v).

Then, the weak/variational formulation of the differen-

tial equation is: Find u ∈ H1

0(0, 1) such that

B(u, v) = l(v) for all v ∈ H1

0(0, 1).

2.2 The minimisation problem

In some case, its very useful to rephrase problem (1.5)

as a minimisation problem. This can be done as follows:

Let F(v) = A(v, v)/2 − L(v). Then solving the prob-

lem:

find u ∈ V such that F(u) 6 F(v) for all v ∈ V,

is equivalent to solving the weak problem (1.5). We’ll

give a careful explanation of why this is true in a future

lecture.

2.3 On Infinite- and Finite-Dimensional

Spaces

We are familiar with finite dimensional spaces, such as

the space of vectors in R2, or R

n. And with much larger

spaces, such as the space of all continuous functions on

[0, 1]. This is an infinite dimensional space: we would

have to write down an infinite number of values to de-

scribe a member uniquely. The space H1

0(0, 1) that we

met earlier is even larger.

Example 2.1. The space of functions that are of the

form g(x) = γ(x − a)(x − b) for any γ ∈ R is finite-

dimensional (because it has dimension 1). But every

member of this space also belongs to the infinite dimen-

sional space H1

0(0, 1); it is a finite-dimensional subspace

of H1

0(0, 1).

2.4 The Galerkin Basis Functions

Example 2.2. To get another very important exam-

ple of a finite dimensional subspace of H1

0(0, 1), first fix

a “mesh” on [0, 1]. This is just a set of points a = x0 <

x1 < x2 < · · · < xn = b. Then consider the space of

all functions that are piecewise linear on this mesh and

that vanish at x = a and x = b.

This is a a finite-dimensional sub-space of H1

0(0, 1).

A reasonable basis for this space would be the hat func-

tions ψ1,ψ2, . . . ,ψn−1 given by

ψi(x) =

(x − xi−1)/h xi−1 6 x < xi

(xi+1 − x)/h xi 6 x 6 xi+1

0 otherwise.

where h = (b − a)/n is the distance between adjacent

points. Then we can write any function uh as

uh(x) = λ1ψ1(x) + λ2ψ2(x) + · · · + λn−1ψn−1(x).

This basis set, shown below, are often called hat

functions or Galerkin Basis functions.

x2x1a = x0

ψ2

x3

ψn−2

xn−3 xn−2 xn−1 xn = b

ψn−1ψ1

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

2.5 The Discrete Variational Form

Recall that we reformulated our boundary value prob-

lem as: Find u ∈ H1

0(0, 1) such that

B(u, v) = l(v) for all v ∈ H1

0(0, 1).

Now imagine we were trying to solve it by taking a func-

tion from H1

0(0, 1) and checking if this integral equation

is true for all functions v in H1

0(0, 1). This would take

forever because there are an infinite number of candi-

dates. So instead we restrict our attention to a finite-

dimensional subspace S of H1

0(0, 1). Now we can select

a function uh from S and “put it on trial” by testing

it against (all) the functions vh in S. This leads to the

terminology of calling uh a trial function and vh a test

function.

Early methods due to Ritz, Galerkin and others use

specially chosen functions which could yield rather accu-

rate solutions, but typically where difficult to compute

with, and to generalise. Richard Currant proposed the

much simpler approach of using piecewise polynomials;

Page 2: 2 FEM Basics: Discretization 2.4 The Galerkin Basis …maths.nuigalway.ie/~niall/teaching/Archive/1112/MathsOfFEM/Lecture... · 2 FEM Basics: Discretization 2.1 The weak form, again

Lecture 2 5 Wed, 25/01/12

this led to the “finite element method” (a term coined

by Ray W. Clough in 1961).

Let S be the space of piecewise linear functions on

the mesh xi = ih, where h = 1/n. As above, uh can be

written as

uh(x) = λ1ψ1(x) + λ2ψ2(x) + · · · + λn−1ψn−1(x).

So uh has n − 1 unknowns: λ1, λ2, . . . , λn. To generate

n − 1 equations, we’ll test uh against the n − 1 hat

functions ψ1,ψ2, . . . ,ψn. Thus we have n−1 equations

in n − 1 unknowns to solve.

Definition 2.1 (The Finite Element Method). Let S be

the finite dimensional subspace of H1

0(0, 1) made up of

the piecewise linear functions on a fixed mesh 0 = x0 <

x1 < · · · < xn = 1. Then the Galerkin Finite Element

method is Find uh ∈ S such that

B(uh, vh) = (f, vh) for all vh(x) ∈ S. (2.6)

2.6 An example of the FEM

Use the FEM on the mesh 0, 1, 2, 3 to find an approx-

imate solution to

−u ′′ + 3u = x on (0, 3), u(0) = u(3) = 0.

Solution: The FEM is: Find uh(x) ∈ S such that

B(uh,vh) := (u ′

h,v ′

h) + 3(uh,vh) = (x,uh)

for all vh(x) ∈ S.

We have that h = 1 so let

ψ1(x) =

x 0 6 x < 1

2 − x 1 6 x 6 2

0 otherwise,

ψ2(x) =

x − 1 1 6 x < 2

3 − x 2 6 x 6 3

0 otherwise,

and

uh(x) = λ1ψ1(x) + λ2ψ2(x).

Our two equations are:

(λ1ψ ′

1 + λ2ψ ′

2,ψ ′

1) + 3(λ1ψ1 + λ2ψ2,ψ1) = (x,ψ1),

(λ1ψ ′

1 + λ2ψ ′

2,ψ ′

2) + 3(λ1ψ1 + λ2ψ2,ψ2) = (x,ψ2).

giving

λ1

(∫

3

0

ψ ′

1ψ ′

1dx + 3

3

0

ψ1ψ1dx

)

+

λ2

(∫

3

0

ψ ′

2ψ ′

1dx + 3

3

0

ψ2ψ1dx

)

=

3

0

xψ1dx

λ1

(∫

3

0

ψ ′

1ψ ′

2dx + 3

3

0

ψ1ψ2dx

)

+

λ2

(∫

3

0

ψ ′

2ψ ′

2dx + 3

3

0

ψ2ψ2dx

)

=

3

0

xψ1dx.

We now need to evaluate these integrals. For example, from the

1st equation:∫

3

0

ψ ′

1ψ ′

1dx =

1

0

(1)2dx +

2

1

(−1)2dx = 2,

3

0

ψ1ψ1dx =

1

0

x2dx +

2

1

(2 − x)2dx = 2/3,

so the coefficient of λ1 is 2 + 3(2/3) = 4. Also,

3

0

ψ ′

2ψ ′

1dx =

2

1

ψ ′

2ψ ′

1dx =

2

1

(1)(−1)dx = −1,

3

0

ψ2ψ1dx =

2

1

ψ2ψ1dx =

2

1

(x − 1)(2 − x)dx = 1/6.

So the coefficient of λ2 is −1+3(1/6) = −1/2. For the right-hand

side:∫

3

0

xψ1dx =

1

0

(x)(x)dx +

2

1

(x)(2 − x)dx = 1/3 + 2/3 = 1.

And so on. The final system is

4λ1 −1

2λ2 = 1, −

1

2λ1 + 4λ2 = 2.

Solving, we get λ1 = 20/63 and λ2 = 34/63. The solution is

uh(x) = (20/63)φ1(x)+(34/63)φ2(x). Note: in general

when r is not constant a quadrature rule is used

to estimate the integrals. The Gaussian Quadrature

methods are the most popular for this.

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

Obviously these methods are usually implemented

by computer. Also, they involve many more unknowns

than in the example above. However, it is important to

note that

• Any given “hat” function φi is only non-zero on

the region [xi−1, xi+1].

• We have to compute

A(ψi,ψj) =

∫b

a

ψ ′

i(x)ψ ′

j(x) + r(x)ψi(x)ψj(x).

But this will be non-zero only if there is overlap

between [xi−1, xi+1] and [xj−1, xj+1].

• This gives that A(ψi,ψj) = 0 if |i − j| > 1, and

otherwise

A(ψi,ψj) =

∫xi+1

xi−1

ψ ′

i(x)ψ ′

j(x) + r(x)ψi(x)ψj(x).

There are two consequences to this:

(i) It takes less effort to set up the linear systems of

equations than one might have thought.

(ii) The system is tridiagonal, and so relatively easy to

solve. The left-hand side looks like this:

1 0 0 0 · · · 0A(ψ2,ψ1) A(ψ2,ψ2) A(ψ2,ψ3) 0 · · · 0

0 A(ψ3,ψ2) A(ψ3,ψ3) A(2psi3,ψ4) · · · 0

.

.

.. . .

. . .. . . · · ·

.

.

.0 0 0 0 · · · 1

Page 3: 2 FEM Basics: Discretization 2.4 The Galerkin Basis …maths.nuigalway.ie/~niall/teaching/Archive/1112/MathsOfFEM/Lecture... · 2 FEM Basics: Discretization 2.1 The weak form, again

Lecture 3: 6 Wed, 25/01/12

3 FEM Basics: Error Analysis

We discussed some terminology needed to derive an er-

ror analysis for our model problem.

This included:

• Definition of a semi-norm;

• The various notations used to denote the energy

norm. We will opt for

‖u‖B :=√

B(u,u),

where B(·, ·) is the bilinear form defined above. We

will also use the usual norm on L2(Ω):

‖u‖2 :=

Ω

u2.

We proved the Cauchy Schwarz inequality:

|B(u, v)| 6 ‖u‖B‖v‖b.

Exercise 3.1. Use this to prove that ‖ · ‖B is indeed a

norm.

Exercise 3.2. Show that the functional

W(u) :=∫

1

0

(

u ′(x))2

dx is a semi-norm on H1(Ω), and a

norm on H1

0(Ω).

Let’s designate u to be the solution to (1.5), let uh

be the solution to (2.6).

We proved the Galerkin Orthogonality result: Since

S is a subspace of H1

0(0, 1), we have from (1.5) that

A(u, vh) = (f, vh) for all vh. Subtract this from (2.6) to

get that:

A(u − uh, vh) = 0 for all vh ∈ S,

(i.e., the difference between the true and approximate

solutions is orthogonal to S).

Next we used Cauchy-Schwarz to prove that opti-

mality result:

|||u − uh||| 6 |||u − vh||| for all vh ∈ S.

Here is a different proof: Let vh be any function in

S(0, 1). Then

B(u − vh,u − vh) = B(u − uh + uh − vh,u − uh + uh − vh)

= B(u − uh,u − uh)+

B(uh − vh,uh − vh)+

2B(u − uh,uh − vh)

= B(u − uh,u − uh)+

B(uh − vh,uh − vh)

> B(u − uh,u − uh),

because B(uh − vh,uh − vh) > 0.

This again gives

B(u − uh,u − uh) = minvh∈S

B(u − vh,u − vh),

(i.e., there is no element of S that is closer to u than

uh).