28
Finite Elements Colin Cotter January 15, 2018 Colin Cotter FEM

Finite Elements - GitHub Pages · Towards the nite element discretisation Proceeding with the nite element discretisation, we assume that we have a solution u to Equation (1) that

Embed Size (px)

Citation preview

Page 1: Finite Elements - GitHub Pages · Towards the nite element discretisation Proceeding with the nite element discretisation, we assume that we have a solution u to Equation (1) that

Finite Elements

Colin Cotter

January 15, 2018

Colin CotterFEM

Page 2: Finite Elements - GitHub Pages · Towards the nite element discretisation Proceeding with the nite element discretisation, we assume that we have a solution u to Equation (1) that

Why FEM

I Can solve PDEs on complicated domains.

I Have flexibility to increase order of accuracy and match thenumerics to the physics.

I FEM has an elegant mathematical formulation that lends itselfto mathematical analysis and flexible code implementation.

Colin CotterFEM

Page 3: Finite Elements - GitHub Pages · Towards the nite element discretisation Proceeding with the nite element discretisation, we assume that we have a solution u to Equation (1) that

This course

I In this course we blend theoretical analysis with computerimplementation.

I 14 lectures + 3 tutorials (Dr Cotter) - assessed byexamination (50%).

I 15 computer labs (Dr Ham) - assessed by coursework (50%)

I Dr Cotter Office Hour (Huxley 755): 5-6pm Tuesdays.

Colin CotterFEM

Page 4: Finite Elements - GitHub Pages · Towards the nite element discretisation Proceeding with the nite element discretisation, we assume that we have a solution u to Equation (1) that

Introduction

Definition (Poisson’s equation in the unit square)

Let Ω = [0, 1]× [0, 1] be the unit square. For a given function f ,we seek u such that

−(∂2

∂x2+

∂2

∂y2

)u := −∇2u = f ,

u(0, y) = u(1, y) = 0,∂u

∂y(x , 0) =

∂u

∂y(x , 1) = 0. (1)

Colin CotterFEM

Page 5: Finite Elements - GitHub Pages · Towards the nite element discretisation Proceeding with the nite element discretisation, we assume that we have a solution u to Equation (1) that

Triangulation

The finite element space that we shall use is defined on atriangulation.

Definition

Triangulation Let Ω be a polygonal subdomain of R2. Atriangulation T of Ω is a set of triangles KiNi=1, such that:

1. intKi ∩Kj = ∅, i 6= j , where int denotes the interior of a set.

2. ∪Ki = Ω, the closure of Ω.

3. No vertex of the interior of any triangle is located in theinterior of any other triangle in T .

Colin CotterFEM

Page 6: Finite Elements - GitHub Pages · Towards the nite element discretisation Proceeding with the nite element discretisation, we assume that we have a solution u to Equation (1) that

P1

Definition (P1 finite element space)

Let T be a triangulation of Ω. Then the P1 finite element space isa space Vh containing all functions v such that

1. v ∈ C 0(Ω),

2. v |Kiis a linear function for each Ki ∈ T .

We also define the following subspace,

Vh = v ∈ Vh : v(0, y) = v(1, y) = 0 . (2)

Colin CotterFEM

Page 7: Finite Elements - GitHub Pages · Towards the nite element discretisation Proceeding with the nite element discretisation, we assume that we have a solution u to Equation (1) that

Definition (L2 norm)

For a real-valued function f on a domain Ω, with Lebesgue integral∫Ωf (x) dx , (3)

we define the L2 norm of f ,

‖f ‖L2(Ω) =

(∫Ω|f (x)|2 dx

)1/2

. (4)

Colin CotterFEM

Page 8: Finite Elements - GitHub Pages · Towards the nite element discretisation Proceeding with the nite element discretisation, we assume that we have a solution u to Equation (1) that

Definition (L2)

We define L2(Ω) as the set of functions

L2(Ω) = f : ‖f ‖L2(Ω) <∞ , (5)

and identify two functions f and g if ‖f − g‖L2(Ω) = 0.

Colin CotterFEM

Page 9: Finite Elements - GitHub Pages · Towards the nite element discretisation Proceeding with the nite element discretisation, we assume that we have a solution u to Equation (1) that

Example

Consider the two functions f and g defined on Ω = [0, 1]× [0, 1]with

f (x , y) =

1 x ≥ 0.5,0 x < 0.5,

, g(x , y) =

1 x > 0.5,0 x ≤ 0.5,

. (6)

Since f and g only differ on the line x = 0.5 which has zero area,then ‖f − g‖L2(Ω) = 0, and so f ≡ g in L2.

Colin CotterFEM

Page 10: Finite Elements - GitHub Pages · Towards the nite element discretisation Proceeding with the nite element discretisation, we assume that we have a solution u to Equation (1) that

Definition (Finite element derivative)

The finite element partial derivative ∂FE

∂xiu of u is defined in L2(Ω)

such that restricted to Ki , we have

∂FEu

∂xi|Ki

=∂u

∂xi. (7)

Colin CotterFEM

Page 11: Finite Elements - GitHub Pages · Towards the nite element discretisation Proceeding with the nite element discretisation, we assume that we have a solution u to Equation (1) that

Exercise

Let Vh be a P1 finite element space for a triangulation T of Ω.For all u ∈ Vh, show that the definition above uniquely defines∂FEu∂xi

in L2(Ω).

Exercise

Let u ∈ C 1(Ω). Show that the finite element partial derivative andthe usual derivative are equal in L2(Ω).

Colin CotterFEM

Page 12: Finite Elements - GitHub Pages · Towards the nite element discretisation Proceeding with the nite element discretisation, we assume that we have a solution u to Equation (1) that

Remark

In view of this, in this section we will consider all derivatives to befinite element derivatives. In later sections we shall consider aneven more general definition of the derivative which contains bothof these definitions.

Colin CotterFEM

Page 13: Finite Elements - GitHub Pages · Towards the nite element discretisation Proceeding with the nite element discretisation, we assume that we have a solution u to Equation (1) that

Towards the finite element discretisation

Proceeding with the finite element discretisation, we assume thatwe have a solution u to Equation (1) that is smooth (i.e. u ∈ C 1).We take v ∈ Vh, multiply by Equation (1), and integrate over thedomain. Integration by parts in each triangle then gives∑

i

(∫Ki

∇v · ∇u dx −∫∂Ki

vn · ∇u dS

)=

∫Ωvf dx , (8)

where n is the unit outward pointing normal to Ki .

Colin CotterFEM

Page 14: Finite Elements - GitHub Pages · Towards the nite element discretisation Proceeding with the nite element discretisation, we assume that we have a solution u to Equation (1) that

Next, we consider each interior edge f in the triangulation, formedas the intersection between two neighbouring triangles Ki ∩ Kj . Ifi > j , then we label the Ki side of f with a +, and the Kj side witha −. Then, denoting Γ as the union of all such interior edges, wecan rewrite our equation as∫

Ω∇v ·∇u dx−

∫Γvn+·∇u+vn−·∇u dS−

∫∂Ω

vn·∇u dS =

∫Ωvf dx ,

(9)where n± is the unit normal to f pointing from the ± side into the∓ side. Since n− = −n+, the interior edge integrals vanish.

Colin CotterFEM

Page 15: Finite Elements - GitHub Pages · Towards the nite element discretisation Proceeding with the nite element discretisation, we assume that we have a solution u to Equation (1) that

Further, on the boundary, either v vanishes (at x = 0 and x = 1)or n · ∇u vanishes (at y = 0 and y = 1), and we obtain∫

Ω∇v · ∇u dx =

∫Ωvf dx . (10)

The finite element approximation is then defined by requiring thatthis equation holds for all v ∈ Vh and when we restrict u ∈ Vh.

Colin CotterFEM

Page 16: Finite Elements - GitHub Pages · Towards the nite element discretisation Proceeding with the nite element discretisation, we assume that we have a solution u to Equation (1) that

Definition (Finite element approximation)

The finite element approximation uh ∈ Vh to the solution u ofPoisson’s equation is defined by∫

Ω∇v · ∇uh dx =

∫Ωvf dx , ∀v ∈ Vh. (11)

Colin CotterFEM

Page 17: Finite Elements - GitHub Pages · Towards the nite element discretisation Proceeding with the nite element discretisation, we assume that we have a solution u to Equation (1) that

Some plots

Colin CotterFEM

Page 18: Finite Elements - GitHub Pages · Towards the nite element discretisation Proceeding with the nite element discretisation, we assume that we have a solution u to Equation (1) that

Some plots

Colin CotterFEM

Page 19: Finite Elements - GitHub Pages · Towards the nite element discretisation Proceeding with the nite element discretisation, we assume that we have a solution u to Equation (1) that

Some plots

Colin CotterFEM

Page 20: Finite Elements - GitHub Pages · Towards the nite element discretisation Proceeding with the nite element discretisation, we assume that we have a solution u to Equation (1) that

Convergence of error

Colin CotterFEM

Page 21: Finite Elements - GitHub Pages · Towards the nite element discretisation Proceeding with the nite element discretisation, we assume that we have a solution u to Equation (1) that

Several questions arise at this point.

1. Is uh unique?

2. What is the size of the error u − uh?

3. Does this error go to zero as the mesh is refined?

4. For what types of functions f can these questions beanswered?

5. What other kinds of finite element spaces are there?

6. How do we extend this approach to other PDEs?

7. How can we calculate uh using a computer?

We shall aim to address these questions, at least partially, throughthe rest of this course. For now, we concentrate on the finalquestion.

Colin CotterFEM

Page 22: Finite Elements - GitHub Pages · Towards the nite element discretisation Proceeding with the nite element discretisation, we assume that we have a solution u to Equation (1) that

In this course we shall mostly concentrate on finite elementmethods for elliptic PDEs, of which Poisson’s equation is anexample, using continuous finite element spaces, of which P1 is anexample. The design, analysis and implementation of finitemethods for PDEs is a huge field of current research, and includesparabolic and elliptic PDEs and other PDEs from elasticity, fluiddynamics, electromagnetism, mathematical biology, mathematicalfinance, astrophysics and cosmology, etc. This course is intendedas a starting point to introduce the general concepts that can beapplied in all of these areas.

Colin CotterFEM

Page 23: Finite Elements - GitHub Pages · Towards the nite element discretisation Proceeding with the nite element discretisation, we assume that we have a solution u to Equation (1) that

Definition (Nodal basis for P1)

Let ziMi=1 indicate the vertices in the triangulation T . For eachvertex zi , we define a basis function φi ∈ Vh by

φi (zj) = δij :=

1 i = j ,0 i 6= j .

(12)

We can define a similar basis for Vh by removing the basisfunctions φi corresponding to vertices zi on the Dirichletboundaries x = 0 and x = 1.

Colin CotterFEM

Page 24: Finite Elements - GitHub Pages · Towards the nite element discretisation Proceeding with the nite element discretisation, we assume that we have a solution u to Equation (1) that

If we expand uh and v in the basis for Vh,

uh(x) =∑i

uiφi (x), v(x) =∑i

viφi (x), (13)

into Equation (11), then we obtain

∑i

vi

∑j

∫Ω∇φi · ∇φj dxvj −

∫Ωφi f dx

= 0. (14)

Colin CotterFEM

Page 25: Finite Elements - GitHub Pages · Towards the nite element discretisation Proceeding with the nite element discretisation, we assume that we have a solution u to Equation (1) that

Since this equation must hold for all v ∈ Vh, then it must hold forall basis coefficients vi , and we obtain the matrix-vector system

Ku = f, (15)

where

Kij =

∫Ω∇φi · ∇φj dx , (16)

u = (u1, u2, . . . , uM)T , (17)

f = (f1, f2, . . . , fM)T , fi =

∫Ωφi f dx . (18)

The system is square, but we do not currently know that K isinvertible. This is equivalent to the finite element approximationhaving a unique solution uh, which we shall establish in latersections.

Colin CotterFEM

Page 26: Finite Elements - GitHub Pages · Towards the nite element discretisation Proceeding with the nite element discretisation, we assume that we have a solution u to Equation (1) that

Putting solvability aside for the moment, the goal of theimplementation sections of this course is to explain how toefficiently form K and f, and solve this system. For now we note afew following aspects that suggest that this might be possible.First, the matrix K and vector f can be written as sums overelements,

Kij =∑K∈T

∫K∇φi · ∇φj dx , fi =

∑K∈T

∫Kφi f dx . (19)

For each entry in the sum for Kij , the integrand is composedentirely of polynomials (actually constants in this particular case,but we shall shortly consider finite element spaces usingpolynomials of higher degree).

Colin CotterFEM

Page 27: Finite Elements - GitHub Pages · Towards the nite element discretisation Proceeding with the nite element discretisation, we assume that we have a solution u to Equation (1) that

I This motivates our starting point in exposing the computerimplementation, namely the integration of polynomials overtriangles using quadrature rules. T

I This will also motivate an efficient way to constructderivatives of polynomials evaluated at quadrature points.

I Further, we shall shortly develop an interpolation operator Isuch that If ∈ Vh. If we replace f by If in theapproximations above, then the evaluation of fi can also beperformed via quadrature rules.

Colin CotterFEM

Page 28: Finite Elements - GitHub Pages · Towards the nite element discretisation Proceeding with the nite element discretisation, we assume that we have a solution u to Equation (1) that

I Further, the matrix K is very sparse, since in most triangles,both φi and φj are zero. Any efficient implementation mustmake use of this and avoid computing integrals that returnzero.

I This motivates the concept of global assembly, the process oflooping over elements, computing only the contributions to Kthat are non-zero from that element.

I Finally, the sparsity of K means that the system should besolved using numerical linear algebra algorithms that canexploit this sparsity.

Colin CotterFEM