linear and quadratic finite elements for a moving mesh method · linear and quadratic finite...

62
Linear and Quadratic Finite Elements for a Moving Mesh Method By Muhammad Akram Supervised By Professor Mike Baines A dissertation submitted to the Department of Mathematics, the University of Reading, in partial fulfilment of the requirements for the degree of Masters of Scientific and Industrial Computations (MOSAIC) Dated 18 August, 2008

Upload: others

Post on 15-Mar-2020

3 views

Category:

Documents


1 download

TRANSCRIPT

Page 1: Linear and Quadratic Finite Elements for a Moving Mesh Method · Linear and Quadratic Finite Elements for a Moving Mesh Method By Muhammad Akram Supervised By Professor Mike Baines

Linear and Quadratic Finite Elements for aMoving Mesh Method

By

Muhammad Akram

Supervised By

Professor Mike Baines

A dissertation submitted to the Department of Mathematics, theUniversity of Reading, in partial fulfilment of the requirements for the

degree of Masters of Scientific and Industrial Computations(MOSAIC)

Dated 18 August, 2008

Page 2: Linear and Quadratic Finite Elements for a Moving Mesh Method · Linear and Quadratic Finite Elements for a Moving Mesh Method By Muhammad Akram Supervised By Professor Mike Baines
Page 3: Linear and Quadratic Finite Elements for a Moving Mesh Method · Linear and Quadratic Finite Elements for a Moving Mesh Method By Muhammad Akram Supervised By Professor Mike Baines

Declaration

I hereby declare that this dissertation has not been accepted in substance for any degreeand not being concurrently submitted for any other degree.I confirm that this is my own work and the use of all materials from other sources has beenproperly and fully acknowledged.

Muhammad Akram

Candidate’s Signature

Supervisor’s Signature

3

Page 4: Linear and Quadratic Finite Elements for a Moving Mesh Method · Linear and Quadratic Finite Elements for a Moving Mesh Method By Muhammad Akram Supervised By Professor Mike Baines

Abstract

In this Dissertation linear and quadratic finite elements are used to produce numericalapproximation to the solutions of first order differential equations which arise in a movingmesh finite element method. The behaviour of the moving mesh velocity is investigatedin detail and is compared these results with the existing exact solutions to investigate theeffect of the moving boundaries and provided the error analysis in both linear and quadraticcases.

4

Page 5: Linear and Quadratic Finite Elements for a Moving Mesh Method · Linear and Quadratic Finite Elements for a Moving Mesh Method By Muhammad Akram Supervised By Professor Mike Baines

Acknowledgements

All praise is to almighty Allah, who deserves all praises alone. It is only his blessing, whichenables me to reach this zenith of in the field of Mathematics. I am highly grateful to manyindividuals who contributed in various ways to the completion of this research project. Firstof all I would like to thanks my most competent, knowledgeable and co-operative supervisor,Professor Mike Baines for his remarkable help, valuable suggestions, guidance, engagement,patience and sincere personal involment in my work throughout the course of my study.I would like to express my gratitude to my siblings and friends who helped me at the variousstages of my study. I am also thankful to everybody who turned the little spark into a bigflame.I also give thanks to all my friends in Mathematics department at Reading University forall the help and support during this year throughout the hard times. Special thanks toPeter Sweby for giving me a chance to do my MSc in Mathematics at Reading Universityand his support at all the hard times. Lastly, special thanks to my dad, uncle, aunty andNyla for all thier encouragement, support and love.

5

Page 6: Linear and Quadratic Finite Elements for a Moving Mesh Method · Linear and Quadratic Finite Elements for a Moving Mesh Method By Muhammad Akram Supervised By Professor Mike Baines

Contents

Declaration 3

Abstract 4

Acknowledgements 5

1 Introduction 12

1.1 Moving mesh velocity equation . . . . . . . . . . . . . . . . . . . . . . . . . 12

1.2 Weak Form . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13

1.3 Alternative approach . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14

1.4 Finite elements for a first order Differential Equations . . . . . . . . . . . . 15

1.5 Outline of the Dissertation . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17

2 Finite Elements for Second order Equations 18

2.1 Basic Finite Elements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18

2.1.1 Weak Forms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18

2.1.2 The Finite Element Method (general) . . . . . . . . . . . . . . . . . 20

2.1.3 Evaluation of Stiffness Matrix K and Load Vector f for Linears . . . 21

2.1.4 Evaluation of Stiffness matrix K and Load Vector f for Quadratics . 22

2.2 A More General first order Differential Equation . . . . . . . . . . . . . . . 23

2.2.1 Linear Finite Elements . . . . . . . . . . . . . . . . . . . . . . . . . . 23

6

Page 7: Linear and Quadratic Finite Elements for a Moving Mesh Method · Linear and Quadratic Finite Elements for a Moving Mesh Method By Muhammad Akram Supervised By Professor Mike Baines

CONTENTS 7

2.2.2 Quadratic Finite Elements . . . . . . . . . . . . . . . . . . . . . . . . 24

3 A Test Problem 25

3.1 Linear Finite Elements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26

3.2 Quadratic Finite Element Method . . . . . . . . . . . . . . . . . . . . . . . 31

3.2.1 Solution for Two Elements . . . . . . . . . . . . . . . . . . . . . . . 31

3.2.2 Solution for Four Elements . . . . . . . . . . . . . . . . . . . . . . . 33

3.2.3 Soluiton for Eight and sixteen Elements . . . . . . . . . . . . . . . . 35

3.3 A More General 1-D Differential Equation . . . . . . . . . . . . . . . . . . . 38

3.3.1 Linear Finite Elements . . . . . . . . . . . . . . . . . . . . . . . . . . 38

3.3.2 Quadratic Finite Elements . . . . . . . . . . . . . . . . . . . . . . . . 41

4 Recovery of the Solution to the first order Problem 43

4.1 Discontinuous Solution (by differentiation) . . . . . . . . . . . . . . . . . . . 43

4.2 Continuous Solution . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44

4.2.1 Least Squares for Linears . . . . . . . . . . . . . . . . . . . . . . . . 44

4.2.2 For Quadratics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45

4.3 Linear Elements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45

4.4 Quadratic Elements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48

5 Discussion 53

5.1 Exact solution for y . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 53

5.2 Results . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 55

5.2.1 Linear and Quadratic continuous Solution for y (Problem-1) . . . . . 55

5.2.2 Linear and Quadratic continuous Solution for y (Problem-2) . . . . . 59

5.3 Conclusion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 60

5.4 Future Work . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 61

Bibliography 62

Page 8: Linear and Quadratic Finite Elements for a Moving Mesh Method · Linear and Quadratic Finite Elements for a Moving Mesh Method By Muhammad Akram Supervised By Professor Mike Baines

List of Figures

2.1 Linear finite elements for one element . . . . . . . . . . . . . . . . . . . . . 19

2.2 Quadratic finite elements for one element . . . . . . . . . . . . . . . . . . . 19

3.1 Shows matrices assembly for more elements. . . . . . . . . . . . . . . . . . . 25

3.2 linear finite elements for one element . . . . . . . . . . . . . . . . . . . . . . 27

3.3 Linear finite element for Two elements. . . . . . . . . . . . . . . . . . . . . . 28

3.4 Linear finite element for Four elements. . . . . . . . . . . . . . . . . . . . . 29

3.5 Linear finite element for eight elements. . . . . . . . . . . . . . . . . . . . . 30

3.6 Linear finite element for sixteen elements. . . . . . . . . . . . . . . . . . . . 31

3.7 Quadratic finite element for Two elements. . . . . . . . . . . . . . . . . . . 32

3.8 Quadratic finite element for Four elements. . . . . . . . . . . . . . . . . . . 33

3.9 Quadratic finite element for eight elements. . . . . . . . . . . . . . . . . . . 35

3.10 Quadratic finite element for sixteen elements. . . . . . . . . . . . . . . . . . 36

5.1 Graphs showing the results for linear and quadratic finite elements of firsttest problem for 2 and 4 elemets. . . . . . . . . . . . . . . . . . . . . . . . . 55

5.2 Graphs showing the results for linear and quadratic finite elements of firsttest problem for 8 and 16 elemets. . . . . . . . . . . . . . . . . . . . . . . . 56

5.3 Graphs showing the results for linear and quadratic finite elements of firsttest problem for 2 and 4 elemets. . . . . . . . . . . . . . . . . . . . . . . . . 57

5.4 Graphs showing the results for linear and quadratic finite elements of firsttest problem for 8 and 16 elemets. . . . . . . . . . . . . . . . . . . . . . . . 58

8

Page 9: Linear and Quadratic Finite Elements for a Moving Mesh Method · Linear and Quadratic Finite Elements for a Moving Mesh Method By Muhammad Akram Supervised By Professor Mike Baines

LIST OF FIGURES 9

5.5 Graphs showing the results for linear and quadratic finite elements of secondtest problem for 2 and 4 elemets. . . . . . . . . . . . . . . . . . . . . . . . . 59

5.6 Graphs showing the results for linear and quadratic finite elements of secondtest problem for 8 and 16 elemets. . . . . . . . . . . . . . . . . . . . . . . . 60

Page 10: Linear and Quadratic Finite Elements for a Moving Mesh Method · Linear and Quadratic Finite Elements for a Moving Mesh Method By Muhammad Akram Supervised By Professor Mike Baines

List of Tables

3.1 Results for equation d2udx2 = x and x2 for one Element. . . . . . . . . . . . . . 27

3.2 Results for equation d2udx2 = x and x2 of Two Element. . . . . . . . . . . . . . 28

3.3 Results for equation d2udx2 = x and x2 of Four Element. . . . . . . . . . . . . 30

3.4 Results for equation d2udx2 = x2 of Eight Element. . . . . . . . . . . . . . . . . 30

3.5 Results for equation d2udx2 = x2 of Sixteen Element. . . . . . . . . . . . . . . . 31

3.6 Results for equation d2udx2 = x and x2 for Two Element. . . . . . . . . . . . . 33

3.7 Results for equation d2udx2 = x and x2 for Four Element. . . . . . . . . . . . . 35

3.8 Results for equation d2udx2 = x and x2 for eight Element. . . . . . . . . . . . . 36

3.9 Results for equation d2udx2 = x and x2 for sixteen Element. . . . . . . . . . . . 37

3.10 Results for equation − ddx

((2x + 1)du

dx

)= x2 for One Element. . . . . . . . . 38

3.11 Results for equation − ddx

((2x + 1)du

dx

)= x2 for Two Element. . . . . . . . . 39

3.12 Results for equation − ddx

((2x + 1)du

dx

)= x2 for Four Element. . . . . . . . . 40

3.13 Results for equation − ddx

((2x + 1)du

dx

)= x2 for Two Element. . . . . . . . . 41

3.14 Results for equation − ddx

((2x + 1)du

dx

)= x2 for Four Element. . . . . . . . . 42

4.1 Linear finite elements to solve equation dydx = x and x2 for 2 elements. . . . 46

4.2 Linear finite elements to solve equation dydx = x and x2 for 4 elements. . . . 46

4.3 Linear finite elements to solve equation dydx = x and x2 for 8 elements. . . . 46

4.4 Linear finite elements to solve equation dydx = x and x2 for 16 elements. . . . 46

4.5 Results by solving equation − ddx ((2x + 1)y) = x2 for 2 elements. . . . . . . 47

10

Page 11: Linear and Quadratic Finite Elements for a Moving Mesh Method · Linear and Quadratic Finite Elements for a Moving Mesh Method By Muhammad Akram Supervised By Professor Mike Baines

LIST OF TABLES 11

4.6 Results by solving equation − ddx ((2x + 1)y) = x2 for 4 elements. . . . . . . 47

4.7 Results by solving equation − ddx ((2x + 1)y) = x2 for 8 elements. . . . . . . 47

4.8 Results by solving equation − ddx ((2x + 1)y) = x2 for 16 elements. . . . . . . 48

4.9 Results by solving equation dydx with f(x) = x and f(x) = x2 for 2 elements. 48

4.10 Results by solving equation dydx with f(x) = x and f(x) = x2 for 4 Elements. 49

4.11 Results by solving equation dydxwithf(x)=xandf(x)=x2 for 8 Elements. . . . . 49

4.12 Results by solving equation dydx with f(x) = x and f(x) = x2 for 16 Elements. 50

4.13 Results by solving equation − ddx ((2x + 1)y) = x2 for 2 elements. . . . . . . 51

4.14 Results by solving equation − ddx ((2x + 1)y) = x2 for 4 elements. . . . . . . 51

4.15 Results by solving equation − ddx ((2x + 1)y) = x2 for 8 elements. . . . . . . 52

4.16 Results by solving equation − ddx ((2x + 1)y) = x2 for 16 elements. . . . . . . 52

Page 12: Linear and Quadratic Finite Elements for a Moving Mesh Method · Linear and Quadratic Finite Elements for a Moving Mesh Method By Muhammad Akram Supervised By Professor Mike Baines

Chapter 1

Introduction

This dissertation concerns the finite element solution of first order differential equations. Itis well known that the standard finite element method is not well suited to dy

dx = f(x) in(0, 1) with y(0) = 1, due to the insufficient boundary conditions and difficulty of invertingthe element matrix, leading to various kinds of regularisations in the literature.There are many applications in which first order equations arise, notably in steady statefluid mechanics. The motivation in this dissertation, however comes from a moving meshmethod for time-dependent Partial Differential Equations (PDEs).The strategy is to replace the first order differential equation by a second order one withan artificial boundary condition, giving ( dy

dx = d2udx2 = f(x) with du

dx(0) = 1 and u(1) = 0) aproblem which is well suited to the finite element approach. It then remains to recover thesolution of the first order equation from the finite element solution obtained. In movingmesh applications this has to be a continous function.The moving mesh work is new in this field and therefore, there is a limited amount ofinformation available in existing literature. Due to the nature of this dissertation, themajority of the preliminary work is based on programming.

1.1 Moving mesh velocity equation

A moving mesh approach to solving the Partial Differential Equation (PDE)

∂p

∂t= Lxp

12

Page 13: Linear and Quadratic Finite Elements for a Moving Mesh Method · Linear and Quadratic Finite Elements for a Moving Mesh Method By Muhammad Akram Supervised By Professor Mike Baines

1.2. WEAK FORM 13

where Lx is a partial operator, is to use conservation of the integral of p to move the mesh,

d

dt

∫ x(t)

0pdx = 0

By Leibnitz’ Integral Rule [9]

d

dt

∫ x(t)

0pdx =

∫ x(t)

0

(∂p

∂t+

∂x(py)

)dx = 0

where (y = dxdt ) is the mesh velocity, giving

∫ x(t)

0

(Lxp +

∂x(py)

)dx = 0

Since this is true for all x we get the first order Ordinary Differential Equation (ODE)

− d

dx(py) = Lxp

1.2 Weak Form

We want to solve this equation for y by finite elements. The weak form is

−∫ b(t)

a(t)ω

d

dx(py)dx =

∫ b(t)

a(t)ωLxpdx

giving, after integrating by parts, where ω is a test function

−ωpy|ba +∫ b

apdω

dxydx =

∫ b

aωLxpdx

The finite element form (with ω ≈ φi and y ≈ Y =∑

j Yjφj) is

−φipY |ba +∫ b

apdφi

dx

∑j

Yjφj

dx =∫ b

aφiLxpdx

giving (apart from the boundary term) a matrix equation

BY = f

Page 14: Linear and Quadratic Finite Elements for a Moving Mesh Method · Linear and Quadratic Finite Elements for a Moving Mesh Method By Muhammad Akram Supervised By Professor Mike Baines

14 CHAPTER 1. INTRODUCTION

for the vector of velocities Y, where B is a matrix with entries

Bij =∫ b

apdφi

dxφjdx

This is an unsymmetric matrix, similar to an anti-symmetric matrix, and difficult to invert.

1.3 Alternative approach

An alternative approach is to write y = dudx where u is a velocity potential, giving the second

order equation

− d

dx(p

du

dx) = Lxp

with weak form

−∫ b

d

dx

(pdu

dx

)=∫ b

aωLxpdx

giving, after integration by parts

−φipdU

dx|ba + p

dφi

dx

∑j

Ujdφj

dx

dx =∫ b

aωLxpdx

leading to (apart form the boundary term)

KU = f

where K is the stiffness matrix with entries

Kij =∫ b

apdφi

dx

dφj

dxdx

This is a symmetric matrix, easy to invert after imposing a boundary condition, giving U .The function Y can be found (in principle) from Y = dU

dx . The problem is that Y (beinga velocity) needs to be continuous. We shall investigate this second approach using a testproblem.

Page 15: Linear and Quadratic Finite Elements for a Moving Mesh Method · Linear and Quadratic Finite Elements for a Moving Mesh Method By Muhammad Akram Supervised By Professor Mike Baines

1.4. FINITE ELEMENTS FOR A FIRST ORDER DIFFERENTIAL EQUATIONS 15

1.4 Finite elements for a first order Differential Equations

Consider solving the first order differential equation problem

dy

dx= f(x), y(0) = 1 (1.1)

in (0,1) by the Finite Element method. The weak form is∫ 1

0ωi

dy

dx= f(x)

Replace ωi = φi(x) by piecewise linear or quadratic basis functions and expand

y ≈ Y =∑

Yjφj

which gives us1∑

j=0

Yj

(∫ 1

0φi

dφj

dxdx

)=∫ 1

0φif(x)dx (1.2)

To solve this system of equation, we can write equation (1.2) in the matrix form as follows

BY = f

where

Bij =∫ 1

0φi

dφj

dxdx

and f is the load vector

fi =∫ 1

0φif(x)dx

Yj are unknowns and B is Matrix, which is not a stiffness matrix, it looks like this (on aregular grid)

B =

0 1 0 . . . 0 0−1 0 1 . . . 0 00 −1 0 1 0 0

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

0 0 0 −1 0 10 0 0 0 −1 0.5

Page 16: Linear and Quadratic Finite Elements for a Moving Mesh Method · Linear and Quadratic Finite Elements for a Moving Mesh Method By Muhammad Akram Supervised By Professor Mike Baines

16 CHAPTER 1. INTRODUCTION

B is badly conditioned, anti-symmetric and difficult to invert.In the approach used in this dissertation, put

y =du

dx

and instead of solving (1.1), solve the second order equation

d2u

dx2= f(x) (1.3)

where dudx = 1 at x = 0 and we impose (arbitrarily) the artificial boundary condition u = 0

at x = 1. From the weak form of (1.3), we have

ωidu

dx|10 −

∫ 1

0

dωi

dx

du

dxy =

∫ 1

0ωf(x)dx

Replacing ωi by finite element basis functions φi(x) and approximating u by

U =N−1∑j=0

Ujφj

and applying boundary conditions it leads to the weak form

−e0 −N−1∑j=0

Uj

(∫ 1

0

dφi

dx

dφj

dxdx

)=∫ 1

0φif(x)dx

where e0 = δ0i or

N−1∑j=0

Uj

(∫ 1

0

dφi

dx

dφj

dxdx

)= −

∫ 1

0φif(x)dx− e0 (1.4)

We can write (1.4) in matrix form as follows

KU = −(f + e0)

where K is stiffness matrix, U is a vector of unknowns and f is a load vector and where

e0 =[

1 0 . . . 0]T

.

Page 17: Linear and Quadratic Finite Elements for a Moving Mesh Method · Linear and Quadratic Finite Elements for a Moving Mesh Method By Muhammad Akram Supervised By Professor Mike Baines

1.5. OUTLINE OF THE DISSERTATION 17

1.5 Outline of the Dissertation

Chapter Two, is based on theory of finite elements for second order differential equa-tions. This chapter investigate the method of Linear Finite elements and deficencies in thismethod for our purpose and provides an alternative Quadratic elements method to find thenumerical solution.

Chapter Three, provides the Linear and Quadratic approaches to solve the first orderdifferential equations as well as the Sturn-Liouiville type differential equations. In thischapter we solve test problems to investigate the numerical results.

Chapter Four, introduces the results for moving boundary and discusses the possiblebehaviour that can be arise as the boundary moves. We also discuss the numerical resultsof the test problem and compare them with the exact solutions to investigate the errors.

Chapter Five contains discussion and conclusions.

Page 18: Linear and Quadratic Finite Elements for a Moving Mesh Method · Linear and Quadratic Finite Elements for a Moving Mesh Method By Muhammad Akram Supervised By Professor Mike Baines

Chapter 2

Finite Elements for Second order

Equations

There are many ways to solve Partial Differentail Equations (PDEs) numerically with ad-vantages and disadvantages. The Finite Element Method (FEM) is a good choice for solvingPDEs over complex domains, when a domain changes (as during a solid state reaction witha moving boundary), when the desired precision varies over the entire domain, or when thesolution lacks smoothness. For instance, in simulations of the weather patterns on Earth, itis more important to have accurate predictions over land than over the open sea, a demandthat is achievable using the finite element method.

2.1 Basic Finite Elements

2.1.1 Weak Forms

Because of limited differentiability of discrete solutions when substituting into a PDE,instead of substituting a piecewise linear representation we can substitute it into a ’weak’form. Consider a second order differential equation to illustrate the weak form of PDE.

− d2u

dx2= f(x), (a < x < b) (2.1)

where u ∈ C2(a, b), is at least twice differentiable in domain (a,b).Multiply both sides of 2.1 by ωi(x), where ωi(x) belongs to a set of test functions which are

18

Page 19: Linear and Quadratic Finite Elements for a Moving Mesh Method · Linear and Quadratic Finite Elements for a Moving Mesh Method By Muhammad Akram Supervised By Professor Mike Baines

2.1. BASIC FINITE ELEMENTS 19

-

HHHHHH

HHHHHH

HH

x1 x2Element 1 x

1

Figure 2.1: Linear finite elements for one element

Figure 2.2: Quadratic finite elements for one element

C1 and square integrable in (a,b) and integrate it, giving

−∫ b

aωi(x)

d2u

dx2dx =

∫ b

aωi(x)f(x)dx (2.2)

Now integrate left hand side of (2.2) by parts, giving

− ωi(x)du

dx|ba +

∫ b

a

dωi(x)dx

du

dxdx =

∫ b

aωi(x)f(x)dx (2.3)

This is known as the weak form of the differential equation. In equation (2.3), we onlyrequire that u, ωi ∈ H1(a, b), once differentiable. So linear representation of such functionsis allowed. Also since the integrals can be broken into subintervals, piecewise functions are

Page 20: Linear and Quadratic Finite Elements for a Moving Mesh Method · Linear and Quadratic Finite Elements for a Moving Mesh Method By Muhammad Akram Supervised By Professor Mike Baines

20 CHAPTER 2. FINITE ELEMENTS FOR SECOND ORDER EQUATIONS

allowed.

2.1.2 The Finite Element Method (general)

Leave out the first term of the left hand side of (2.3) for the moment and write the otherterms as a sum over a set of given intervals k such as

N+1∑k=1

∫ xk

xk−1

dωi

dx

du

dxdx (2.4)

By replacing ωi with piecewise test functions φi ∈ H1, (i = 0, 1, . . . , N + 1) and u withU ∈ H1, where

dU

dx=

N+1∑j=0

Ujdφj

dx(2.5)

Equation (2.3) becomes

N+1∑j=0

Uj

∫ b

a

dφi

dx

dφj

dxdx =

∫ b

aφi(x)f(x)dx (2.6)

which is known as finite element equation. There are N+2 equations and N+2 unknowns.We know that basis functions φi(x) are non-zero only on the two intervals either side ofnode i, so the system (2.6) for i = 1, . . . , N + 1 becomes

j=i+1∑j=i−1

Uj

∫ xi+1

xi−1

dφi

dx

φj

dxdx =

∫ b

aφi(x)f(x)dx, (i = 1, 2, . . . , N) (2.7)

This set of equations can be written in matrix form as follows

KU = f (2.8)

where U is a vector of unknowns Uj , K is a stiffness matrix consisting of elements

Kij =∫ xj+1

xj−1

dφi

dx

dφj

dxdx (2.9)

Page 21: Linear and Quadratic Finite Elements for a Moving Mesh Method · Linear and Quadratic Finite Elements for a Moving Mesh Method By Muhammad Akram Supervised By Professor Mike Baines

2.1. BASIC FINITE ELEMENTS 21

j = 0, N + 1 and f is load vector consisting of

fi =∫ xj+1

xj−1

φi(x)f(x)dx (2.10)

The first and last equations are special with basis functions which are ”half hats” and are

1∑j=0

Uj

∫ x1

x0

dφ0

dx

φj

dxdx =

∫ x1

x0

φ0(x)f(x)dx, (i = 0) (2.11)

andN+1∑j=N

Uj

∫ xN+1

xN

dφN

dx

φj

dxdx =

∫ xN+1

xN

φN (x)f(x)dx, (i = N + 1) (2.12)

These are easily incorporated into the stiffness matrix and load vector. Boundary conditionscan easily be applied to (2.8)

2.1.3 Evaluation of Stiffness Matrix K and Load Vector f for Linears

We define φi(x) as follows

φi =

x−xi

xi−xi−1xi−1 ≤ x ≤ xi

xi+1−xxi+1−xi

xi ≤ x ≤ xi+1

0 otherwise

(2.13)

By differentiating equation (2.13), we get

dφi

dx=

1

xi−xi−1xi−1 ≤ x ≤ xi

−1xi+1−xi

xi ≤ x ≤ xi+1

0 otherwise

(2.14)

where (i = 1, . . . , N) are peicewise constant functions, with subsets of (2.14) for the ”halfhats.”The equations (2.7) reduces to

Ui − Ui−1

xi − xi−1− Ui+1 − Ui

xi+1 − xi=∫ xi+1

xi−1

φi(x)f(x)dx, (i = 1, . . . , N) (2.15)

Page 22: Linear and Quadratic Finite Elements for a Moving Mesh Method · Linear and Quadratic Finite Elements for a Moving Mesh Method By Muhammad Akram Supervised By Professor Mike Baines

22 CHAPTER 2. FINITE ELEMENTS FOR SECOND ORDER EQUATIONS

First and last equations reduced to

− U1 − U0

x1 − x0=∫ x1

x0

φ0(x)f(x)dx, (i = 0) (2.16)

andUN+1 − UN

xN+1 − xN=∫ xN+1

xN

φN (x)f(x)dx, (i = N + 1) (2.17)

The right hand side integrals can be evaluated by numerical integration.The stiffness matrix K is singular, which follows from the fact that the φi(x) form a partitionof unity, so

N+1∑i=0

φi(x) = 1 ⇒N+1∑i=0

dφi

dx= 0 (2.18)

It means all column sums of the determinant of Matrix K are zero. By applying boundaryconditions, it is possible to invert this matrix.

2.1.4 Evaluation of Stiffness matrix K and Load Vector f for Quadratics

In this section we explain how can we construct solution by adding an extra node in eachelement as p-refinement.There are deficiencies in linear finite elements formulation in convection-diffusion problems.In such situations to examine the numerical solution of 1D convection-diffusion problemdiscretise with quadratic shape functions as shown in figure (2.2).First of all we establish a matrix equation for the given problem, as for linear finite elements,then the discrete solution of the problem is analysed.As shown in figure (2.2), we consider a generic element with nodes 1, 2 and 3, where node 2is a mid-side. With reference to the condition 0 < x < 1, the shape function of the elementareN1(x) = 2(x− 1

2)(x− 1), N2(x) = −4x(x− 1), and N3(x) = 2x(x− 12).

We can establish an element stiffness matrix Ke of the quadratic elements [1] as follows

Ke =∫

Ω

∂N1∂x

∂N1∂x

∂N1∂x

∂N2∂x

∂N1∂x

∂N3∂x

∂N2∂x

∂N1∂x

∂N2∂x

∂N2∂x

∂N2∂x

∂N2∂x

∂N3∂x

∂N1∂x

∂N3∂x

∂N2∂x

∂N3∂x

∂N3∂x

dx

Page 23: Linear and Quadratic Finite Elements for a Moving Mesh Method · Linear and Quadratic Finite Elements for a Moving Mesh Method By Muhammad Akram Supervised By Professor Mike Baines

2.2. A MORE GENERAL FIRST ORDER DIFFERENTIAL EQUATION 23

and load vector f as follows

fi =∫

Ωf(x)Ni(x)dx

where i = (1, 2, 3).

2.2 A More General first order Differential Equation

Let us consider a more general differential equation of Sturm-Liouiville type

− d

dx(p(x)y) + q(x)u = f(x) (2.19)

in (0, 1) where q(x) = 0, with boundary conditions, at x = 0 and at x = 1.

2.2.1 Linear Finite Elements

To obtain the weak form multiply (2.19) by the test function ω ∈ H10 and integrate from 0

to 1, apply finite elements and finally we get

∫ 1

0p(x)

dφi

dx

N+1∑j=0

Ujdφj

dx

dx =∫ 1

0φi(x)f(x)dx (2.20)

which can be written in the formKU = f

where

Kij =∫ 1

0p(x)

dφi

dx

dφj

dxdx,

Uj is a vector of unknowns and

fi =∫ 1

0φi(x)f(x)dx

is a load vector.

Page 24: Linear and Quadratic Finite Elements for a Moving Mesh Method · Linear and Quadratic Finite Elements for a Moving Mesh Method By Muhammad Akram Supervised By Professor Mike Baines

24 CHAPTER 2. FINITE ELEMENTS FOR SECOND ORDER EQUATIONS

2.2.2 Quadratic Finite Elements

Similarly from (2.19), apply quadratic finite elements and after applying all the calculations,we get the matrix equation

KU = f

where K is the assembly of element matrices

Keij =

∫Ω

p(x)

∂N1∂x

∂N1∂x

∂N1∂x

∂N2∂x

∂N1∂x

∂N3∂x

∂N2∂x

∂N1∂x

∂N2∂x

∂N2∂x

∂N2∂x

∂N2∂x

∂N3∂x

∂N1∂x

∂N3∂x

∂N2∂x

∂N3∂x

∂N3∂x

dx

and

fi =∫ 1

0f(x)Ni(x)dx

is a load vector.

Page 25: Linear and Quadratic Finite Elements for a Moving Mesh Method · Linear and Quadratic Finite Elements for a Moving Mesh Method By Muhammad Akram Supervised By Professor Mike Baines

Chapter 3

A Test Problem

In this chapter we solve some test problems by using the methods discussed in chapter2. First we take a simple example and solve it by linear finite element and then by thequadratic elements method. We assemble element stiffness matrix for all elements as shownin figure (3.1) and by using Gaussian inversion method, we will invert stiffness matrix K tosolve the problem. Consider the problem

Figure 3.1: Shows matrices assembly for more elements.

25

Page 26: Linear and Quadratic Finite Elements for a Moving Mesh Method · Linear and Quadratic Finite Elements for a Moving Mesh Method By Muhammad Akram Supervised By Professor Mike Baines

26 CHAPTER 3. A TEST PROBLEM

dy

dx=

d2u

dx2= f(x) (3.1)

in (0, 1), with dudx = 1 at x = 0 and u = 0 at x = 1.

3.1 Linear Finite Elements

Let us consider finite elements for equation (3.1). We know from chapter 2, matrix equationfor (3.1)is

KU = −(f + e0) (3.2)

where

Kij =∫ 1

0

dφi

dx

dφj

dxdx,

U are unknowns,

fi =∫

φi(x)f(x)dx

and e0 =[

1 0 . . . 0]

We can solve this problem by dividing the interval (0, 1) into 1, 2, 4, 8, and 16 elements.Stiffness matrix entries in each case are (for equal spacing h)

Kij =∫ xi+1

xi−1

dφi

dx

dφj

dxdx =

1h

(1 −1−1 1

)

• Stiffness Matrix and load vector for One element

Consider the following figure (3.2) and apply the method mentioned in section (3.1),we can find the stiffness matirx as follows

Ke =

(1 −1−1 1

)

Page 27: Linear and Quadratic Finite Elements for a Moving Mesh Method · Linear and Quadratic Finite Elements for a Moving Mesh Method By Muhammad Akram Supervised By Professor Mike Baines

3.1. LINEAR FINITE ELEMENTS 27

-

HHHH

HHHHHH

HH

0 1Element 1 x

1

Figure 3.2: linear finite elements for one element

and load vectors for f(x) = x2 are

f0 =∫ 1

0(1− x)x2dx =

112

f1 =∫ 1

0x3dx =

14

By solving the test problem, we get approximate value of velocity potential U shownin table (3.1).

Table 3.1: Results for equation d2udx2 = x and x2 for one Element.

x value Exact f(x)=x LFE f(x)=x Error (u-U) Exact f(x)=x2 LFE f(x)=x2 error (u-U)

0 -1.33333 -1.16667 -0.166667 -1.08333 -1.5 0.4166671 0 0 0 0 0 0

• Stiffness Matrix and load vector for Two element

The stiffness matrix for two elements in figure (3.3) can be found by getting elementstiffness matrix for each element and then assemble them as shown

K =

2 −2 0−2 4 −20 −2 2

and load vectors are

f0 =∫ 1

2

0(1− 2x)x2dx =

196

Page 28: Linear and Quadratic Finite Elements for a Moving Mesh Method · Linear and Quadratic Finite Elements for a Moving Mesh Method By Muhammad Akram Supervised By Professor Mike Baines

28 CHAPTER 3. A TEST PROBLEM

0 12 1

Figure 3.3: Linear finite element for Two elements.

,

f1 =∫ 1

2

0(2x)x2dx +

∫ 1

12

(2− 2x)x2dx =748

and

f2 =∫ 1

12

(2x− 1)x2dx =1796

Similarly if f(x) = x the load vector is

fi =(

124

14

524

)T

The solution for U is shown in table (3.2)

Table 3.2: Results for equation d2udx2 = x and x2 of Two Element.

x value Exact f(x)=x LFE f(x)=x Error (u-U) Exact f(x)=x2 LFE f(x)=x2 error (u-U)

0 -1.33333 -1.16667 -0.166667 -1.08333 -1.08333 2.22045e-0160.5 -0.791667 -0.645833 -0.145833 -0.578125 -0.578125 1.11022e-0161 0 0 0 0 0 0

• Stiffness Matrix and load vector for Four element

The assembled stiffness matrix for four elements is

K =

4 −4 0 0 0−4 8 −4 0 00 −4 8 −4 00 0 −4 8 −40 0 0 −4 4

Page 29: Linear and Quadratic Finite Elements for a Moving Mesh Method · Linear and Quadratic Finite Elements for a Moving Mesh Method By Muhammad Akram Supervised By Professor Mike Baines

3.1. LINEAR FINITE ELEMENTS 29

and the load vector is

f0 =∫ 1

4

0(1− 4x)x2dx =

1768

,

f1 =∫ 1

4

0(4x)x2dx +

∫ 12(2−4x)x2dx= 7

384

14

f2 =∫ 1

2

14

(4x− 1)x2dx +∫ 3

4(3−4x)x2dx= 25

384

12

f3 =∫ 3

4

12

(4x− 2)x2dx +∫ 1

34

(4− 4x)x2dx =55384

and

f4 =∫ 1

34

(4x− 3)x2dx =27256

The load vector f is when f(x) = x is

fi =(

196

116

18

38

1196

)T

0 14

12

34 1

Figure 3.4: Linear finite element for Four elements.

The solution is shown in table (3.3)

Page 30: Linear and Quadratic Finite Elements for a Moving Mesh Method · Linear and Quadratic Finite Elements for a Moving Mesh Method By Muhammad Akram Supervised By Professor Mike Baines

30 CHAPTER 3. A TEST PROBLEM

Table 3.3: Results for equation d2udx2 = x and x2 of Four Element.

x value Exact f(x)=x LFE f(x)=x Error (u-U) Exact f(x)=x2 LFE f(x)=x2 error (u-U)

0 -1.33333 -1.16667 -0.166667 -1.08333 -1.08333 00.25 -1.07813 -0.914063 -0.164063 -0.833008 -0.833008 1.11022e-0160.5 -0.791667 -0.645833 -0.145833 -0.578125 -0.578125 1.11022e-0160.75 -0.442708 -0.346354 -0.0963542 -0.306966 -0.306966 1.11022e-0161 0 0 0 0 0 0

• Solutions for eight and sixteen elements

Similarly we can find the stiffness matrix and load vectors for eight and sixteen andsolve them to get results shown in table (3.4) and (3.5).

0 18

14

38

12

58

34

78 1

Figure 3.5: Linear finite element for eight elements.

Table 3.4: Results for equation d2udx2 = x2 of Eight Element.

x value Exact f(x)=x LFE f(x)=x Error (u-U) Exact f(x)=x2 LFE f(x)=x2 error (u-U)

0 -1.33333 -1.16667 -0.166667 -1.08333 -1.08333 2.22045e-0160.125 -1.20768 -1.04134 -0.166341 -0.958313 -0.958313 1.11022e-0160.25 -1.07813 -0.914063 -0.164063 -0.833008 -0.833008 1.11022e-0160.375 -0.940755 -0.782878 -0.157878 -0.706685 -0.706685 2.22045e-0160.5 -0.791667 -0.645833 -0.145833 -0.578125 -0.578125 0

0.625 -0.626953 -0.500977 -0.125977 -0.445618 -0.445618 5.55112e-0170.75 -0.442708 -0.346354 -0.0963542 -0.306966 -0.306966 00.875 -0.235026 -0.180013 -0.055013 -0.159485 -0.159485 2.77556e-017

1 0 0 0 0 0 0

Solution for sixteen elements

Page 31: Linear and Quadratic Finite Elements for a Moving Mesh Method · Linear and Quadratic Finite Elements for a Moving Mesh Method By Muhammad Akram Supervised By Professor Mike Baines

3.2. QUADRATIC FINITE ELEMENT METHOD 31

0 116

18

316

14

516

38

716

12

916

58

1116

34

1316

78

1516 1

Figure 3.6: Linear finite element for sixteen elements.

Table 3.5: Results for equation d2udx2 = x2 of Sixteen Element.

x value Exact f(x)=x LFE f(x)=x Error (u-U) Exact f(x)=x2 LFE f(x)=x2 error (u-U)

0 -1.33333 -1.16667 -0.166667 -1.08333 -1.08333 00.0625 -1.27075 -1.10413 -0.166626 -1.02083 -1.02083 00.125 -1.20768 -1.04134 -0.166341 -0.958313 -0.958313 1.11022e-0160.1875 -1.14364 -0.978068 -0.165568 -0.89573 -0.89573 -1.11022e-0160.25 -1.07813 -0.914063 -0.164063 -0.833008 -0.833008 1.11022e-016

0.3125 -1.01066 -0.84908 -0.16158 -0.770039 -0.770039 2.22045e-0160.375 -0.940755 -0.782878 -0.157878 -0.706685 -0.706685 -2.22045e-0160.4375 -0.86792 -0.71521 -0.15271 -0.64278 -0.64278 1.11022e-016

0.5 -0.791667 -0.645833 -0.145833 -0.578125 -0.578125 3.33067e-0160.5625 -0.711507 -0.574504 -0.137004 -0.512491 -0.512491 2.22045e-0160.625 -0.626953 -0.500977 -0.125977 -0.445618 -0.445618 5.55112e-0170.6875 -0.537516 -0.425008 -0.112508 -0.377216 -0.377216 -1.66533e-0160.75 -0.442708 -0.346354 -0.0963542 -0.306966 -0.306966 2.77556e-016

0.8125 -0.342041 -0.264771 -0.0772705 -0.234516 -0.234516 8.32667e-0170.875 -0.235026 -0.180013 -0.055013 -0.159485 -0.159485 1.94289e-0160.9375 -0.121175 -0.0918376 -0.0293376 -0.0814603 -0.0814603 1.38778e-016

1 0 0 0 0 0 0

3.2 Quadratic Finite Element Method

In this section we explain, how can we construct solution by adding an extra node in eachelement. So the quadratic solution for (3.1) is as follows

3.2.1 Solution for Two Elements

Let us consider the figure (3.7). First of all we need to find the node values to get stiffnessmatrix and load vector. The node values are as follows for two elements.

1. First ElementN1(x) = 8(x− 1

4)(x− 12),

N2(x) = −16x(x− 12),

N3(x) = 8x(x− 14)

2. Second Element

Page 32: Linear and Quadratic Finite Elements for a Moving Mesh Method · Linear and Quadratic Finite Elements for a Moving Mesh Method By Muhammad Akram Supervised By Professor Mike Baines

32 CHAPTER 3. A TEST PROBLEM

0 14

12

34 1

Figure 3.7: Quadratic finite element for Two elements.

N1(x) = 8(x− 34)(x− 1),

N2(x) = −16(x− 12)(x− 1),

N3(x) = 8(x− 12)(x− 3

4)

For each element, the stiffness matrix is

Ke =

143

−163

23

−163

323

−163

23

−163

143

so we need to assemble this to get stiffness matrix for two elemts.The load vector of function f(x) = x is

f1i =

[0 1

12124

14

112

]Tand for f(x) = x2 is

f2i =

[−1480

140

360

23120

13160

]TThe matrix after assembly is

K =

143

−163

23 0 0

−163

323

−163 0 0

23

−163

283

−163

23

0 0 −163

323

−163

0 0 23

−163

143

Page 33: Linear and Quadratic Finite Elements for a Moving Mesh Method · Linear and Quadratic Finite Elements for a Moving Mesh Method By Muhammad Akram Supervised By Professor Mike Baines

3.2. QUADRATIC FINITE ELEMENT METHOD 33

By solving the above matrix system we get the result as Table (3.6) shows the U values ofequation 3.1.

Table 3.6: Results for equation d2udx2 = x and x2 for Two Element.

x Exact (x) QFE (x) Error (x) Exact (x2) QFE (x2) Error (x2)

0 -1.33333 -1.14583 -0.1875 -1.08333 -1.07396 -0.0093750.25 -1.07813 -0.893229 -0.184896 -0.833008 -0.823698 -0.00930990.5 -0.791667 -0.625 -0.166667 -0.578125 -0.56875 -0.0093750.75 -0.442708 -0.335938 -0.106771 -0.306966 -0.302344 -0.00462241 0 0 0 0 0 0

3.2.2 Solution for Four Elements

Let us consider the figure (3.8) The node values are as follows

0 18

14

38

12

58

34

78 1

Figure 3.8: Quadratic finite element for Four elements.

1. First ElementN1(x) = 32(x− 1

8)(x− 14),

N2(x) = −64x(x− 14),

N3(x) = 32x(x− 18)

2. Second ElementN1(x) = 32(x− 3

8)(x− 12),

N2(x) = −64(x− 14)(x− 1

2),N3(x) = 32(x− 1

4)(x− 38)

3. Third ElementN1(x) = 32(x− 5

8)(x− 34),

Page 34: Linear and Quadratic Finite Elements for a Moving Mesh Method · Linear and Quadratic Finite Elements for a Moving Mesh Method By Muhammad Akram Supervised By Professor Mike Baines

34 CHAPTER 3. A TEST PROBLEM

N2(x) = −64(x− 12)(x− 3

4),N3(x) = 32(x− 1

2)(x− 58)

4. Fourth ElementN1(x) = 32(x− 7

8)(x− 1),N2(x) = −64(x− 3

4)(x− 1),N3(x) = 32(x− 3

4)(x− 78)

For each element, the stiffness matrix is

Ke =

283

−323

43

−323

643

−323

43

−323

283

and load vectors for f(x) = x and f(x) = x2 are

f1i =

[0 1

48196

116

148

548

132

748

124

]Tand

f2i =

[−1

38401

3203

128023960

21320

893540

41320

531280

]TThe matrix after assembly is

K =13

28 −32 4 0 0 0 0 0 0−32 64 −32 0 0 0 0 0 04 −32 56 −32 4 0 0 0 00 0 −32 64 −32 0 0 0 00 0 4 −32 56 −32 4 0 00 0 0 0 −32 64 −32 0 00 0 0 0 4 −32 56 −32 40 0 0 0 0 0 −32 64 −320 0 0 0 0 0 4 −32 28

Table (3.7) gives the solution for four elements

Page 35: Linear and Quadratic Finite Elements for a Moving Mesh Method · Linear and Quadratic Finite Elements for a Moving Mesh Method By Muhammad Akram Supervised By Professor Mike Baines

3.2. QUADRATIC FINITE ELEMENT METHOD 35

Table 3.7: Results for equation d2udx2 = x and x2 for Four Element.

x Exact (x) QFE (x) Error (x) Exact (x2) QFE (x2) Error (x2)

0 -1.33333 -1.15625 -0.177083 -1.08333 -1.06953 -0.01380210.125 -1.20768 -1.03092 -0.176758 -0.958313 -0.944515 -0.0137980.25 -1.07813 -0.903646 -0.174479 -0.833008 -0.819206 -0.01380210.375 -0.940755 -0.773763 -0.166992 -0.706685 -0.693376 -0.01330970.5 -0.791667 -0.638021 -0.153646 -0.578125 -0.565299 -0.0128255

0.625 -0.626953 -0.49707 -0.129883 -0.445618 -0.434554 -0.01106360.75 -0.442708 -0.346354 -0.0963542 -0.306966 -0.297656 -0.00930990.875 -0.235026 -0.17513 -0.0598958 -0.159485 -0.154834 -0.00465088

1 0 0 0 0 0 0

3.2.3 Soluiton for Eight and sixteen Elements

Similarly we can construct solution for eight and sixteen elements. The element stiffnessmatrix is given for each case, assemble it acoordingly, also load vectors are shown. So tosolve these systems, we get the results as shown in table (3.8) and (3.9). For each element,

0 116

18

316

14

516

38

716

12

916

58

1116

34

1316

78

1516 1

Figure 3.9: Quadratic finite element for eight elements.

the stiffness matrix is

Ke =

563

−643

83

−643

1283

−643

83

−643

1283

and load vectors for (5.3) and (5.5) are

f1i =

[0 1

1921

384164

1384

5194

1128

7192

196

364

5384

11192

164

13192

7384

564

148

]T

Page 36: Linear and Quadratic Finite Elements for a Moving Mesh Method · Linear and Quadratic Finite Elements for a Moving Mesh Method By Muhammad Akram Supervised By Professor Mike Baines

36 CHAPTER 3. A TEST PROBLEM

and

f2i =

[−1

307201

25603

1024023

76803

1024021

256089

3072041

256053

102402037680

8310240

1012560

35930720

1412560

16310240

5637680

21310240

]T

Table 3.8: Results for equation d2udx2 = x and x2 for eight Element.

x Exact (x) QFE (x) Error (x) Exact (x2) QFE (x2) Error (x2)

0 -1.33333 -1.13688 -0.196452 -1.08333 -1.06904 -0.01429040.0625 -1.27075 -1.07434 -0.196411 -1.02083 -1.00654 -0.01429010.125 -1.20768 -1.01156 -0.196126 -0.958313 -0.944023 -0.01429040.1875 -1.14364 -0.948446 -0.19519 -0.89573 -0.881459 -0.01427180.25 -1.07813 -0.884603 -0.193522 -0.833008 -0.818754 -0.0142537

0.3125 -1.01066 -0.820109 -0.190552 -0.770039 -0.755944 -0.01409480.375 -0.940755 -0.754395 -0.186361 -0.706685 -0.692749 -0.01393640.4375 -0.86792 -0.687703 -0.180216 -0.64278 -0.629184 -0.0135963

0.5 -0.791667 -0.619303 -0.172363 -0.578125 -0.564868 -0.01325680.5625 -0.711507 -0.549601 -0.161906 -0.512491 -0.499897 -0.01259330.625 -0.626953 -0.477702 -0.149251 -0.445618 -0.433687 -0.01193030.6875 -0.537516 -0.404175 -0.133341 -0.377216 -0.366456 -0.01076020.75 -0.442708 -0.327962 -0.114746 -0.306966 -0.297375 -0.00959066

0.8125 -0.342041 -0.250061 -0.09198 -0.234516 -0.226826 -0.007690180.875 -0.235026 -0.170573 -0.0644531 -0.159485 -0.153695 -0.00579020.9375 -0.121175 -0.0857747 -0.0354004 -0.0814603 -0.0785655 -0.00289485

1 0 0 0 0 0 0

0 132

116

332

18

532

316

732

14

932

516

1132

38

1332

716

1532

12

1732

916

1932

58

2132

1116

2332

34

2532

1316

2732

78

2932

1516

3132 1

Figure 3.10: Quadratic finite element for sixteen elements.

For each element, the stiffness matrix is

Ke =

1123

−1283

163

−1283

2563

−1283

163

−1283

1123

and load vectors for f(x) = x and f(x) = x2 are

f1i =

0 1768

11536

1256

1768

5768

1512

7768

1384

3256

51536

11768

5256

131768

71536

5256

1192

17768

3512

19768

5768

7256

111536

23768

1128

25768

131536

9256

7768

29768

31768

196

T

Page 37: Linear and Quadratic Finite Elements for a Moving Mesh Method · Linear and Quadratic Finite Elements for a Moving Mesh Method By Muhammad Akram Supervised By Professor Mike Baines

3.2. QUADRATIC FINITE ELEMENT METHOD 37

and

f2i =

−1

2457601

204803

8192023

6144013

8192021

2048089

24576041

2048051

81920203

6144083

81920101

20480359

245760141

20480163

81920563

61440213

81920241

20440809

245760301

20480333

81920110361440

40381920

44120480

1439245760

52120480

56381920

182361440

65381920

70120480

2249245760

80120480

85381920

T

Table 3.9: Results for equation d2udx2 = x and x2 for sixteen Element.

x Exact (x) QFE (x) Error (x) Exact (x2) QFE (x2) Error (x2)

0 -1.33333 -1.15159 -0.18174 -1.08333 -1.06953 -0.01380410.03125 -1.30207 -1.12034 -0.181735 -1.05208 -1.03828 -0.01380410.0625 -1.27075 -1.08905 -0.181699 -1.02083 -1.00703 -0.01380410.09375 -1.23931 -1.05773 -0.181582 -0.989577 -0.975774 -0.0138030.125 -1.20768 -1.02631 -0.181373 -0.958313 -0.944511 -0.0138018

0.15625 -1.17581 -0.99481 -0.181002 -0.927034 -0.913238 -0.01379570.1875 -1.14364 -0.963158 -0.180478 -0.89573 -0.881941 -0.01378960.21875 -1.11109 -0.931384 -0.17971 -0.864393 -0.85062 -0.0137722

0.25 -1.07813 -0.899396 -0.178729 -0.833008 -0.819253 -0.01375480.28125 -1.04467 -0.867246 -0.177421 -0.801562 -0.787845 -0.01371710.3125 -1.01066 -0.834821 -0.17584 -0.770039 -0.756359 -0.01367950.34375 -0.976044 -0.802193 -0.173851 -0.73842 -0.72481 -0.01361020.375 -0.940755 -0.769229 -0.171526 -0.706685 -0.693144 -0.0135409

0.40625 -0.904734 -0.735532 -0.169202 -0.674814 -0.661388 -0.01342590.4375 -0.86792 -0.701439 -0.166481 -0.64278 -0.629469 -0.0133110.46875 -0.830251 -0.667061 -0.16319 -0.61056 -0.597426 -0.0131339

0.5 -0.791667 -0.632225 -0.159442 -0.578125 -0.565168 -0.01295670.53125 -0.752106 -0.596887 -0.155219 -0.545446 -0.532747 -0.01269830.5625 -0.711507 -0.56103 -0.150477 -0.512491 -0.500051 -0.012440.59375 -0.66981 -0.524807 -0.145003 -0.479226 -0.467148 -0.01207870.625 -0.626953 -0.488003 -0.13895 -0.445618 -0.4339 -0.0117175

0.65625 -0.582876 -0.450794 -0.132082 -0.411627 -0.400398 -0.01122920.6875 -0.537516 -0.412943 -0.124574 -0.377216 -0.366475 -0.01074090.71875 -0.490814 -0.374644 -0.11617 -0.342344 -0.332245 -0.0100989

0.75 -0.442708 -0.335644 -0.107065 -0.306966 -0.297509 -0.009456890.78125 -0.393138 -0.296155 -0.0969824 -0.271039 -0.262407 -0.008631880.8125 -0.342041 -0.255904 -0.0861374 -0.234516 -0.226709 -0.007806910.84375 -0.289358 -0.215123 -0.0742345 -0.197348 -0.190581 -0.006767130.875 -0.235026 -0.173519 -0.0615075 -0.159485 -0.153757 -0.00572739

0.90625 -0.178986 -0.131344 -0.0476413 -0.120874 -0.116435 -0.004438510.9375 -0.121175 -0.0882851 -0.03289 -0.0814603 -0.0783106 -0.003149670.96875 -0.0615336 -0.0446156 -0.016918 -0.0411885 -0.0396137 -0.00157482

1 0 0 0 0 0 0

Page 38: Linear and Quadratic Finite Elements for a Moving Mesh Method · Linear and Quadratic Finite Elements for a Moving Mesh Method By Muhammad Akram Supervised By Professor Mike Baines

38 CHAPTER 3. A TEST PROBLEM

3.3 A More General 1-D Differential Equation

Now consider the problem

− d

dx

((2x + 1)

du

dx

)= x2 (3.3)

in (0, 1) with artificial boundary conditions dudx = 1 at x = 0 and u = 0 at x = 1. This is

representative of the moving mesh movement equation.

3.3.1 Linear Finite Elements

So by using the approach discussed in chapter 2, we can find stiffness and load vector asshown below.

• Solution for One element

Stiffness matrix for one elemnt with h = 1 and p(x) = 2x + 1 is

K =1h2

∫ 1

0p(x)

dφi

dx

dφj

dxdx =

(2 −2−2 2

)

and load vectors are

f0 =∫ 1

0(1− x)x2dx =

112

f1 =∫ 1

0x3dx =

14

We have element stiffness matrix and load vector, solve this to get the result, whichis shown in table (3.10)

Table 3.10: Results for equation − ddx

((2x + 1)du

dx

)= x2 for One Element.

x values Exact values (u) Linar Finite values (U) Error (u-U)

0 -0.516638 -0.458333 -0.05830471 0 0 0

• Solution for Two elements

We require two stiffness element matrices for two elements, hence h = 2

Ke1 =

1h2

∫ 12

0p(x)

dφi

dx

dφj

dxdx =

(3 −3−3 3

)

Page 39: Linear and Quadratic Finite Elements for a Moving Mesh Method · Linear and Quadratic Finite Elements for a Moving Mesh Method By Muhammad Akram Supervised By Professor Mike Baines

3.3. A MORE GENERAL 1-D DIFFERENTIAL EQUATION 39

Ke2 =

1h2

∫ 1

12

p(x)dφi

dx

dφj

dxdx =

(5 −5−5 5

)

and load vectors are

f0 =∫ 1

2

0(1− 2x)x2dx =

196

f1 =∫ 1

2

02x3dx +

∫ 1

12

(2− 2x)x2dx =748

f2 =∫ 1

12

(2x− 1)x2dx =748

After assemling above stiffness element matrices,we get

K =

3 −3 0−3 8 −50 −5 5

To solve this system we get the result shown in table (3.11)

Table 3.11: Results for equation − ddx

((2x + 1)du

dx

)= x2 for Two Element.

x values Exact values (u) Linar Finite values (U) Error (u-U)

0 -0.516638 -0.498611 -0.01802690.5 -0.172985 -0.16875 -0.004234951 0 0 0

• Solution for Four elements

In this section we need four stiffness element matrices with h = 4

Ke1 =

1h2

∫ 14

0p(x)

dφi

dx

dφj

dxdx =

(5 −5−5 5

)

Ke2 =

1h2

∫ 12

14

p(x)dφi

dx

dφj

dxdx =

(7 −7−7 7

)

Page 40: Linear and Quadratic Finite Elements for a Moving Mesh Method · Linear and Quadratic Finite Elements for a Moving Mesh Method By Muhammad Akram Supervised By Professor Mike Baines

40 CHAPTER 3. A TEST PROBLEM

Ke3 =

1h2

∫ 34

12

p(x)dφi

dx

dφj

dxdx =

(9 −9−9 9

)

Ke4 =

1h2

∫ 1

34

p(x)dφi

dx

dφj

dxdx =

(11 −11−11 11

)

and load vectors are

f0 =∫ 1

4

0(1− 4x)x2dx =

1768

f1 =∫ 1

4

04x3dx +

∫ 12

14

(2− 4x)x2dx =7

384

f2 =∫ 1

2

14

(4x− 1)x2dx +∫ 3

4

12

(3− 4x)x2dx =25384

f3 =∫ 3

4

12

(4x− 2)x2dx +∫ 1

34

(4− 4x)x2dx =55384

f4 =∫ 1

34

(4x− 3)x2dx =27256

The stiffness matrix for four elements is

K =

5 −5 0 0 0−5 12 −7 0 00 −7 16 −9 00 0 −9 20 −110 0 0 −11 11

Table 3.12: Results for equation − ddx

((2x + 1)du

dx

)= x2 for Four Element.

x values Exact values (u) Linar Finite values (U) Error (u-U)

0 -0.516638 -0.511708 -0.004930150.25 -0.314139 -0.311968 -0.002170540.5 -0.172985 -0.171901 -0.001083650.75 -0.0706532 -0.0701941 -0.0004591151 0 0 0

Similarly we can find solutions for eight and sixteen elements.

Page 41: Linear and Quadratic Finite Elements for a Moving Mesh Method · Linear and Quadratic Finite Elements for a Moving Mesh Method By Muhammad Akram Supervised By Professor Mike Baines

3.3. A MORE GENERAL 1-D DIFFERENTIAL EQUATION 41

3.3.2 Quadratic Finite Elements

The solution for equation (3.3) can be found by using the same technique used for first testproblem but for stiffness element matrix, we need to multiply the integral of each entry ofthe stiffness element matrix before integrating.

• Solution for Two Elements

So the stiffness matrix for two elements is

K =

5 −5 0 0 0−5 12 −7 0 00 −7 16 −9 00 0 −9 20 −110 0 0 −11 11

So we use the same load vector for f(x) = x2 in quadratic finite elements as usedbefore in this chapter. The solution is shown in Table (3.13)

Table 3.13: Results for equation − ddx

((2x + 1)du

dx

)= x2 for Two Element.

x values Exact values (u) Linar Finite values (U) Error (u-U)

0 -0.516638 -0.520043 0.003404880.25 -0.314139 -0.31824 0.004101180.5 -0.172985 -0.176774 0.003788690.75 -0.0706532 -0.0723606 0.00170741 0 0 0

• Solution for Four Elements

The stiffness matrix for four elements is

K =

31 −36 5 0 0 0 0 0 0−36 80 −44 0 0 0 0 0 05 −44 84 −52 7 0 0 0 00 0 −52 112 −60 0 0 0 00 0 7 −60 112 −68 9 0 00 0 0 0 −68 144 −76 0 00 0 0 0 9 −76 140 −84 110 0 0 0 0 0 −84 176 −920 0 0 0 0 0 11 −92 81

Page 42: Linear and Quadratic Finite Elements for a Moving Mesh Method · Linear and Quadratic Finite Elements for a Moving Mesh Method By Muhammad Akram Supervised By Professor Mike Baines

42 CHAPTER 3. A TEST PROBLEM

We get the solution as shown in Table (3.14)

Table 3.14: Results for equation − ddx

((2x + 1)du

dx

)= x2 for Four Element.

x values Exact values (u) Linar Finite values (U) Error (u-U)

0 -0.516638 -0.521588 0.004950240.125 -0.405083 -0.410112 0.005029110.25 -0.314139 -0.319118 0.004978990.375 -0.237867 -0.24268 0.004812950.5 -0.172985 -0.177631 0.00464633

0.625 -0.117608 -0.12152 0.003912590.75 -0.0706532 -0.0739058 0.003252570.875 -0.0315377 -0.0330893 0.00155158

1 0 0 0

Similarly we can find the solution for eight and sixteen elements.

Page 43: Linear and Quadratic Finite Elements for a Moving Mesh Method · Linear and Quadratic Finite Elements for a Moving Mesh Method By Muhammad Akram Supervised By Professor Mike Baines

Chapter 4

Recovery of the Solution to the

first order Problem

In this chapter we describe how we can accomplish the solution of first order differentialequation i.e. recovery of velocity. In previous chapter we mentioned the approach thatreplaced the velocity (y) with the velocity potential (u) as y = du

dx and solved it for U . Nowwe describe the approach that gives us Y from U which is an approximation to the exactsolution.

4.1 Discontinuous Solution (by differentiation)

• Linears

We can apply different approaches to find the apprximated velocity vector (Y ). Oneway is to get the Y values from U for each element as follows

Yi =du

dx=

Ui+1 − Ui

xi+1 − xi

Here U is piecewise linear and the Y function is piecewise constant. So Y is notcontinuous. We need to look for another way to go from U to Y (=dUdx) which givesus a continuous function which we also discuss in the next section.

• Quadratics

In this case recovery of Y from U by differentiation also gives us discontinuous func-

43

Page 44: Linear and Quadratic Finite Elements for a Moving Mesh Method · Linear and Quadratic Finite Elements for a Moving Mesh Method By Muhammad Akram Supervised By Professor Mike Baines

44CHAPTER 4. RECOVERY OF THE SOLUTION TO THE FIRST ORDER PROBLEM

tion. So we need to adapt these values for each node to get continuous function whichwe discuss in next section.

4.2 Continuous Solution

Consider the following method to find the continuous solution for linear finite elements,

4.2.1 Least Squares for Linears

Let’s consider the following least square approach∥∥∥∥y − dU

dx

∥∥∥∥2

=∫ 1

0

(Y − dU

dx

)2

dx

Minimise it over Y, where Y =∑

yjφj is continuous, requiring minimization of

∫ 1

0

1∑j=0

yjφj −dU

dx

2

dx

. Minimise over y values,

d

dyi

∫ 1

0

1∑j=0

yjφj −dU

dx

2

dx = 0

and generally, it is ∫ 1

0

∑j

yjφj −dU

dx

φidx = 0

The above equation can be written in the form

∑j

(∫ 1

0φiφjdx

)yj −

∫ 1

0φi

dU

dxdx = 0

and in matrix form asMy = g

Page 45: Linear and Quadratic Finite Elements for a Moving Mesh Method · Linear and Quadratic Finite Elements for a Moving Mesh Method By Muhammad Akram Supervised By Professor Mike Baines

4.3. LINEAR ELEMENTS 45

where M is the element mass matrix. For one element M e = h

(13

16

16

13

), y is a velocity

vector and

gei =

dU

dx

∫ 1

0φidx =

12h

dU

dx=

12(U1−U0

x1−x0)

12(Ui+1−Ui

xi+1−xi)

. . .12(Un−Un−1

xn−xn−1)

We can get an approximation to the velocity vector by applying the approach discussedabove. There are some solutions in section (4.3) for the test problems discussed in chapter3.

4.2.2 For Quadratics

After finding the values of U in chapter 3, we need to find the Y values i.e y ≈ Y for eachelement, see the following

Yi =3∑

j=1

Ui∂Nj(xi)

∂x

where i = (0, 1, 2).Each element gives us three values of Y but after the first element we use only two valuesfor each element till the last element because we already have a value for the first node ineach element. Then we combine together to get the approximate solution for the velocityvector, which is continuous. We give some solutions for the test problems from chapter 3in section (4.4).

4.3 Linear Elements

We show the results for linear finite elements for test problem 1 and 2.

1. Linear Solution for First Test Problem

The tables (4.1), (4.2), (4.3) and (4.4) show the results for velocity y and the numericalsolution for the velocity Y by using linear finite elements for 2, 4, 8 and 16 elements.

Page 46: Linear and Quadratic Finite Elements for a Moving Mesh Method · Linear and Quadratic Finite Elements for a Moving Mesh Method By Muhammad Akram Supervised By Professor Mike Baines

46CHAPTER 4. RECOVERY OF THE SOLUTION TO THE FIRST ORDER PROBLEM

Table 4.1: Linear finite elements to solve equation dydx = x and x2 for 2 elements.

x y=Exact(f(x)=x) Y=LFE(f(x)=x) Error(x) y=Exact (f(x)=x2) Y=LFE(f(x)=x2) Error(x2)

0 1 0.973958 0.0260417 1 0.973958 0.02604170.5 1.125 1.08333 0.0416667 1.04167 1.08333 -0.04166671 1.5 1.19271 0.307292 1.33333 1.19271 0.140625

Table 4.2: Linear finite elements to solve equation dydx = x and x2 for 4 elements.

x y=Exact(f(x)=x) Y=LFE(f(x)=x) Error(x) y=Exact (f(x)=x2) Y=LFE(f(x)=x2) Error(x2)

0 1 0.998512 0.0014881 1 0.998512 0.00148810.25 1.03125 1.00688 0.0243676 1.00521 1.00688 -0.001674110.5 1.125 1.03646 0.0885417 1.04167 1.03646 0.005208330.75 1.28125 1.15978 0.121466 1.14063 1.15978 -0.01915921 1.5 1.2619 0.238095 1.33333 1.2619 0.0714286

Table 4.3: Linear finite elements to solve equation dydx = x and x2 for 8 elements.

x y=Exact(f(x)=x) Y=LFE(f(x)=x) Error(x) y=Exact (f(x)=x2) Y=LFE(f(x)=x2) Error(x2)

0 1 0.999904 9.58824e-005 1 0.999904 9.58824e-0050.125 1.00781 1.00068 0.00713245 1.00065 1.00068 -2.90044e-0050.25 1.03125 1.00519 0.0260618 1.00521 1.00519 2.01353e-0050.375 1.07031 1.01763 0.0526828 1.01758 1.01763 -5.15368e-0050.5 1.125 1.04148 0.0835193 1.04167 1.04148 0.000186012

0.625 1.19531 1.08207 0.11324 1.08138 1.08207 -0.0006925110.75 1.28125 1.13804 0.143209 1.14063 1.13804 0.002584030.875 1.38281 1.23295 0.149862 1.22331 1.23295 -0.00964361

1 1.5 1.29734 0.202657 1.33333 1.29734 0.0359904

Table 4.4: Linear finite elements to solve equation dydx = x and x2 for 16 elements.

x y=Exact(f(x)=x) Y=LFE(f(x)=x) Error(x) y=Exact (f(x)=x2) Y=LFE(f(x)=x2) Error(x2)

0 1 2.366 -1.366 1 2.366 -1.3660.0625 1.00195 0.634063 0.36789 1.00008 0.634063 0.3660180.125 1.00781 1.09873 -0.0909128 1.00065 1.09873 -0.09807420.1875 1.01758 0.975918 0.0416598 1.0022 0.975918 0.02627890.25 1.03125 1.01225 0.0190003 1.00521 1.01225 -0.00704141

0.3125 1.04883 1.00829 0.0405423 1.01017 1.00829 0.001886730.375 1.07031 1.01808 0.0522289 1.01758 1.01808 -0.0005055160.4375 1.0957 1.02778 0.067925 1.02791 1.02778 0.000135334

0.5 1.125 1.0417 0.0832975 1.04167 1.0417 -3.58178e-0050.5625 1.1582 1.05932 0.0988849 1.05933 1.05932 7.9377e-0060.625 1.19531 1.08138 0.113936 1.08138 1.08138 4.067e-0060.6875 1.23633 1.10834 0.127987 1.10832 1.10834 -2.42057e-0050.75 1.28125 1.14053 0.140718 1.14063 1.14053 9.27558e-005

0.8125 1.33008 1.17914 0.150939 1.17879 1.17914 -0.0003468180.875 1.38281 1.22201 0.1608 1.22331 1.22201 0.001294510.9375 1.43945 1.27949 0.159964 1.27466 1.27949 -0.00483124

1 1.5 1.3153 0.184697 1.33333 1.3153 0.0180304

Page 47: Linear and Quadratic Finite Elements for a Moving Mesh Method · Linear and Quadratic Finite Elements for a Moving Mesh Method By Muhammad Akram Supervised By Professor Mike Baines

4.3. LINEAR ELEMENTS 47

2. Linear Solution for Second Test problem

We fixed the error occured in finding the solution of the second test problem byapplying linear finite elements for moving mesh. So the following tables (4.5), (4.6),(4.7) and (4.8) show the results for exact velocity y and approximated velocity Y

recovered from the velocity ptential U . All the tables are self explanatory, showingresults for 2, 4, 8, and 16 elements.

Table 4.5: Results by solving equation − ddx ((2x + 1)y) = x2 for 2 elements.

x values Exact values (y) Linear values (Y) Error(y-Y)

0 1 0.740278 0.2597220.5 0.479167 0.498611 -0.01944441 0.222222 0.256944 -0.0347222

Table 4.6: Results by solving equation − ddx ((2x + 1)y) = x2 for 4 elements.

x values Exact values (y) Linear values (Y) Error(y-Y)

0 1 0.854184 0.1458160.25 0.663194 0.688506 -0.0253120.5 0.479167 0.469468 0.009698170.75 0.34375 0.334909 0.008840751 0.222222 0.25371 -0.0314879

Table 4.7: Results by solving equation − ddx ((2x + 1)y) = x2 for 8 elements.

x values Exact values (y) Linear values (Y) Error(y-Y)

0 1 0.925543 0.0744570.125 0.799479 0.815147 -0.01566740.25 0.663194 0.656595 0.006599660.375 0.561384 0.561588 -0.0002044380.5 0.479167 0.478101 0.00106524

0.625 0.408275 0.407409 0.0008663660.75 0.34375 0.344444 -0.0006938760.875 0.282434 0.277335 0.00509873

1 0.222222 0.239135 -0.0169126

Page 48: Linear and Quadratic Finite Elements for a Moving Mesh Method · Linear and Quadratic Finite Elements for a Moving Mesh Method By Muhammad Akram Supervised By Professor Mike Baines

48CHAPTER 4. RECOVERY OF THE SOLUTION TO THE FIRST ORDER PROBLEM

Table 4.8: Results by solving equation − ddx ((2x + 1)y) = x2 for 16 elements.

x values Exact values (y) Linear values (Y) Error(y-Y)

0 1 0.96295 0.037050.0625 0.888817 0.897572 -0.008755480.125 0.799479 0.796498 0.002980880.1875 0.725675 0.726042 -0.0003671520.25 0.663194 0.662797 0.00039698

0.3125 0.609125 0.609022 0.0001029290.375 0.561384 0.561263 0.0001205060.4375 0.518446 0.518373 7.33262e-005

0.5 0.479167 0.479111 5.58403e-0050.5625 0.44267 0.44263 4.04946e-0050.625 0.408275 0.408249 2.60083e-0050.6875 0.375445 0.375412 3.36574e-0050.75 0.34375 0.343778 -2.81752e-005

0.8125 0.312841 0.312661 0.0001802720.875 0.282434 0.283046 -0.0006122770.9375 0.252293 0.249956 0.00233675

1 0.222222 0.230896 -0.00867367

4.4 Quadratic Elements

In this section we recover velocity Y from U by using the quadratic finite elements. We aretrying to solve by increasing elements each time. Let us consider the the solution as follows

1. Quadratic Solution for First Test Problem

The recovery of velocity from velocity potential is shown by Table (4.9), (4.10), (4.11)and (4.12) for 2, 4, 8 and 16 elements by quadratic approach.

Table 4.9: Results by solving equation dydx with f(x) = x and f(x) = x2 for 2 elements.

x y=Exact(f(x)=x) Y=QFE(f(x)=x) Error(x) y=Exact (f(x)=x2) Y=QFE(f(x)=x2) Error(x2)

0 1 0.979167 0.0208333 1 0.991667 0.008333330.25 1.03125 1.04167 -0.0104167 1.00521 1.01042 -0.005208330.5 1.125 1.10417 0.0208333 1.04167 1.02917 0.01250.75 1.28125 1.25 0.03125 1.14063 1.1375 0.0031251 1.5 1.4375 0.0625 1.33333 1.28125 0.0520833

Page 49: Linear and Quadratic Finite Elements for a Moving Mesh Method · Linear and Quadratic Finite Elements for a Moving Mesh Method By Muhammad Akram Supervised By Professor Mike Baines

4.4. QUADRATIC ELEMENTS 49

Table 4.10: Results by solving equation dydx with f(x) = x and f(x) = x2 for 4 Elements.

x y=Exact (f(x)=x) Y=QFE (f(x)=x) Error (x) y=Exact (f(x)=x2) Y=QFE (f(x)=x2) Error (x2)

0 1 0.994792 0.00520833 1 0.998958 0.001041670.125 1.00781 1.01042 -0.00260417 1.00065 1.0013 -0.0006510420.25 1.03125 1.02604 0.00520833 1.00521 1.00365 0.00156250.375 1.07031 1.0625 0.0078125 1.01758 1.01562 0.001953130.5 1.125 1.10937 0.015625 1.04167 1.03359 0.00807292

0.625 1.19531 1.16667 0.0286458 1.08138 1.07057 0.01080730.75 1.28125 1.24479 0.0364583 1.14063 1.11979 0.02083330.875 1.38281 1.38542 -0.00260417 1.22331 1.19062 0.0326823

1 1.5 1.41667 0.0833333 1.33333 1.28672 0.0466146

Table 4.11: Results by solving equation dydxwithf(x)=xandf(x)=x2 for 8 Elements.

x y=Exact (f(x)=x) Y=QFE (f(x)=x) Error (x) y=Exact (f(x)=x2) Y=QFE (f(x)=x2) Error (x2)

0 1 0.998698 0.00130208 1 0.99987 0.0001302080.0625 1.00195 1.0026 -0.000651042 1.00008 1.00016 -8.13802e-0050.125 1.00781 1.00651 0.00130208 1.00065 1.00046 0.0001953120.1875 1.01758 1.01562 0.00195313 1.0022 1.00215 4.88281e-0050.25 1.03125 1.02734 0.00390625 1.00521 1.00439 0.000813802

0.3125 1.04883 1.04167 0.00716146 1.01017 1.00804 0.002132160.375 1.07031 1.0612 0.00911458 1.01758 1.01419 0.003385420.4375 1.0957 1.08073 0.014974 1.02791 1.02305 0.00486654

0.5 1.125 1.10807 0.0169271 1.04167 1.03506 0.006608070.5625 1.1582 1.13281 0.0253906 1.05933 1.04945 0.009879560.625 1.19531 1.16797 0.0273438 1.08138 1.06927 0.01210940.6875 1.23633 1.19792 0.0384115 1.10832 1.09049 0.01782230.75 1.28125 1.24089 0.0403646 1.14063 1.12008 0.0205404

0.8125 1.33008 1.25911 0.0709635 1.17879 1.14945 0.02934570.875 1.38281 1.28451 0.0983073 1.22331 1.19076 0.03255210.9375 1.43945 1.36458 0.0748698 1.27466 1.22956 0.0451009

1 1.5 1.38021 0.119792 1.33333 1.28454 0.0487956

Page 50: Linear and Quadratic Finite Elements for a Moving Mesh Method · Linear and Quadratic Finite Elements for a Moving Mesh Method By Muhammad Akram Supervised By Professor Mike Baines

50CHAPTER 4. RECOVERY OF THE SOLUTION TO THE FIRST ORDER PROBLEM

Table 4.12: Results by solving equation dydx with f(x) = x and f(x) = x2 for 16 Elements.

x y=Exact (f(x)=x) Y=QFE (f(x)=x) Error (x) y=Exact (f(x)=x2) Y=QFE (f(x)=x2) Error (x2)

0 1 0.999674 0.000325521 1 0.999984 1.6276e-0050.03125 1.00049 1.00065 -0.00016276 1.00001 1.00002 -1.01725e-0050.0625 1.00195 1.00163 0.000325521 1.00008 1.00006 2.44141e-0050.09375 1.00439 1.00391 0.000488281 1.00027 1.00027 6.10352e-0060.125 1.00781 1.00684 0.000976563 1.00065 1.00055 0.000101725

0.15625 1.01221 1.01042 0.00179036 1.00127 1.00113 0.000144450.1875 1.01758 1.0153 0.00227865 1.0022 1.0019 0.0003011070.21875 1.02393 1.02018 0.00374349 1.00349 1.003 0.000486247

0.25 1.03125 1.02702 0.00423177 1.00521 1.0045 0.0007039390.28125 1.03955 1.0332 0.00634766 1.00742 1.0063 0.001112870.3125 1.04883 1.04199 0.00683594 1.01017 1.00878 0.00139160.34375 1.05908 1.04948 0.00960286 1.01354 1.01143 0.002105710.375 1.07031 1.06022 0.0100911 1.01758 1.01513 0.00244548

0.40625 1.08252 1.08464 -0.00211589 1.02235 1.0188 0.003546140.4375 1.0957 1.09733 -0.0016276 1.02791 1.02397 0.003946940.46875 1.10986 1.10742 0.00244141 1.03433 1.02882 0.00551554

0.5 1.125 1.12207 0.00292969 1.04167 1.03569 0.005977380.53125 1.14111 1.13912 0.00198851 1.04998 1.04188 0.00809530.5625 1.1582 1.15573 0.00247679 1.05933 1.05071 0.008618160.59375 1.17627 1.16842 0.00784788 1.06977 1.05841 0.01136680.625 1.19531 1.18698 0.00833616 1.08138 1.06943 0.0119507

0.65625 1.21533 1.20097 0.0143583 1.09421 1.0788 0.01541140.6875 1.23633 1.22148 0.0148466 1.10832 1.09226 0.01605630.71875 1.2583 1.23678 0.0215198 1.12377 1.10346 0.0203105

0.75 1.28125 1.25924 0.022008 1.14063 1.11961 0.02101640.78125 1.30518 1.27584 0.0293323 1.15895 1.1328 0.02614540.8125 1.33008 1.30026 0.0298205 1.17879 1.15188 0.02691240.84375 1.35596 1.31816 0.0377958 1.20023 1.16723 0.03299760.875 1.38281 1.34453 0.0382841 1.22331 1.18948 0.0338257

0.90625 1.41064 1.36373 0.0469104 1.2481 1.20715 0.04094850.9375 1.43945 1.39205 0.0473987 1.27466 1.23282 0.04183760.96875 1.46924 1.41256 0.056676 1.30305 1.25297 0.0500793

1 1.5 1.44284 0.0571643 1.33333 1.2823 0.0510295

Page 51: Linear and Quadratic Finite Elements for a Moving Mesh Method · Linear and Quadratic Finite Elements for a Moving Mesh Method By Muhammad Akram Supervised By Professor Mike Baines

4.4. QUADRATIC ELEMENTS 51

2. Quadratic Solution for Second Test Problem

The following tables (4.13), (4.14), (4.15) and (4.16) give us the results for 2, 4, 8 and16 elements by using quadratic approach.

Table 4.13: Results by solving equation − ddx ((2x + 1)y) = x2 for 2 elements.

x values Exact values (y) Quadratic values (Y) Error(y-Y)

0 1 0.927885 0.07211540.25 0.663194 0.686538 -0.0233440.5 0.479167 0.445192 0.03397440.75 0.34375 0.353547 -0.00979731 0.222222 0.225338 -0.00311562

Table 4.14: Results by solving equation − ddx ((2x + 1)y) = x2 for 4 elements.

x values Exact values (y) Quadratic values (Y) Error(y-Y)

0 1 0.973733 0.02626690.125 0.799479 0.809882 -0.01040260.25 0.663194 0.64603 0.0171640.375 0.561384 0.565946 -0.004562130.5 0.479167 0.474829 0.0043379

0.625 0.408275 0.414902 -0.00662640.75 0.34375 0.346927 -0.003176650.875 0.282434 0.295623 -0.0131896

1 0.222222 0.233805 -0.011583

Page 52: Linear and Quadratic Finite Elements for a Moving Mesh Method · Linear and Quadratic Finite Elements for a Moving Mesh Method By Muhammad Akram Supervised By Professor Mike Baines

52CHAPTER 4. RECOVERY OF THE SOLUTION TO THE FIRST ORDER PROBLEM

Table 4.15: Results by solving equation − ddx ((2x + 1)y) = x2 for 8 elements.

x values Exact values (y) Quadratic values (Y) Error(y-Y)

0 1 0.991845 0.00815470.0625 0.888817 0.892426 -0.003609840.125 0.799479 0.793007 0.006471680.1875 0.725675 0.727765 -0.002089870.25 0.663194 0.659971 0.0032238

0.3125 0.609125 0.61174 -0.002615770.375 0.561384 0.560897 0.0004865720.4375 0.518446 0.521957 -0.00351112

0.5 0.479167 0.480754 -0.001587230.5625 0.44267 0.448019 -0.005348870.625 0.408275 0.412336 -0.004060350.6875 0.375445 0.383522 -0.008076820.75 0.34375 0.350878 -0.007128

0.8125 0.312841 0.324515 -0.01167440.875 0.282434 0.293326 -0.0108920.9375 0.252293 0.268426 -0.0161336

1 0.222222 0.237632 -0.0154098

Table 4.16: Results by solving equation − ddx ((2x + 1)y) = x2 for 16 elements.

x values Exact values (y) Quadratic values (Y) Error(y-Y)

0 1 0.997705 0.002294580.03125 0.941167 0.942245 -0.001077890.0625 0.888817 0.886784 0.00203240.09375 0.841874 0.842661 -0.0007873680.125 0.799479 0.798074 0.00140485

0.15625 0.760936 0.761631 -0.0006950420.1875 0.725675 0.724777 0.0008978040.21875 0.693225 0.694016 -0.000790709

0.25 0.663194 0.662797 0.0003979040.28125 0.635254 0.636327 -0.001072760.3125 0.609125 0.609288 -0.0001630620.34375 0.584569 0.586112 -0.001542890.375 0.561384 0.562212 -0.000828374

0.40625 0.539394 0.541598 -0.00220390.4375 0.518446 0.520073 -0.001626710.46875 0.498409 0.501468 -0.00305881

0.5 0.479167 0.481744 -0.002577780.53125 0.460617 0.464727 -0.004110460.5625 0.44267 0.446366 -0.003695570.59375 0.425246 0.430608 -0.005361410.625 0.408275 0.413266 -0.00499026

0.65625 0.391694 0.398508 -0.006813860.6875 0.375445 0.381915 -0.006469450.71875 0.359479 0.367949 -0.00846977

0.75 0.34375 0.351889 -0.008138910.78125 0.328216 0.338547 -0.01033080.8125 0.312841 0.322844 -0.01000310.84375 0.29759 0.309989 -0.01239830.875 0.282434 0.294499 -0.0120656

0.90625 0.267343 0.282017 -0.01467350.9375 0.252293 0.266622 -0.01432910.96875 0.23726 0.254417 -0.0171575

1 0.222222 0.239018 -0.0167959

Page 53: Linear and Quadratic Finite Elements for a Moving Mesh Method · Linear and Quadratic Finite Elements for a Moving Mesh Method By Muhammad Akram Supervised By Professor Mike Baines

Chapter 5

Discussion

Comparison of the results.

5.1 Exact solution for y

• First Problem

To find the exact solution ofdy

dx= f(x) (5.1)

in (0, 1), with y = 1 at x = 0. Let us consider f(x) = x and integrate (5.1),giving

y =x2

2+ A

by applying boundary conditions, giving

y =x2

2+ 1 (5.2)

the exact solution for y.Now let us consider y = du

dx and dudx = 1 at x = 0 and u = 0 at x = 1, giving

du2

dx2= x (5.3)

By integrating (5.3) twice and applying boundary conditions, giving

53

Page 54: Linear and Quadratic Finite Elements for a Moving Mesh Method · Linear and Quadratic Finite Elements for a Moving Mesh Method By Muhammad Akram Supervised By Professor Mike Baines

54 CHAPTER 5. DISCUSSION

u =x3

3+ x− 4

3(5.4)

the exact solution for u.

Let us consider f(x) = x2, givingdu2

dx2= x2 (5.5)

Now by integrating (5.5), the exact solution for y is

y =x3

3+ 1 (5.6)

and for u is

u =x4

12+ x− 13

12(5.7)

• Second Example

To solve the following equation

− d

dx((2x + 1)y) = x2 (5.8)

in (0, 1) with y = 1 at x = 0 and integrating (5.8), giving

− (2x + 1)y =x3

3+ B (5.9)

by applying boundary condition, we get

y =3− x3

6x + 3(5.10)

Consider y = dudx in equation (5.8), giving

− d

dx

((2x + 1)

du

dx

)= x2 (5.11)

integrating (5.11) twice and applying boundary conditions, we get

u = −x3

18+

x2

24+− x

24+

2548

ln(2x + 1)− 0.516638 (5.12)

Page 55: Linear and Quadratic Finite Elements for a Moving Mesh Method · Linear and Quadratic Finite Elements for a Moving Mesh Method By Muhammad Akram Supervised By Professor Mike Baines

5.2. RESULTS 55

5.2 Results

5.2.1 Linear and Quadratic continuous Solution for y (Problem-1)

All the graphs shown below give us enough information to understand about the results.By comparison of linear and quadratic results it is clear that linear approach is not goodas compared to quadratic in case of first test problem. Quadratic finite elements gives usbetter results.

(a) Linear finite Elements for f(x) = x. (b) Quadratic finite Elements for f(x) =x.

(c) Linear finite Elements for f(x) = x. (d) Quadratic finite Elements for f(x) =x.

Figure 5.1: Graphs showing the results for linear and quadratic finite elements of first testproblem for 2 and 4 elemets.

Page 56: Linear and Quadratic Finite Elements for a Moving Mesh Method · Linear and Quadratic Finite Elements for a Moving Mesh Method By Muhammad Akram Supervised By Professor Mike Baines

56 CHAPTER 5. DISCUSSION

(a) Linear finite Elements for f(x) = x. (b) Quadratic finite Elements for f(x) =x.

(c) Linear finite Elements for f(x) = x. (d) Quadratic finite Elements for f(x) =x.

Figure 5.2: Graphs showing the results for linear and quadratic finite elements of first testproblem for 8 and 16 elemets.

Page 57: Linear and Quadratic Finite Elements for a Moving Mesh Method · Linear and Quadratic Finite Elements for a Moving Mesh Method By Muhammad Akram Supervised By Professor Mike Baines

5.2. RESULTS 57

(a) Linear finite Elements for f(x) = x2. (b) Quadratic finite Elements for f(x) =x2.

(c) Linear finite Elements for f(x) = x2. (d) Quadratic finite Elements for f(x) =x2.

Figure 5.3: Graphs showing the results for linear and quadratic finite elements of first testproblem for 2 and 4 elemets.

Page 58: Linear and Quadratic Finite Elements for a Moving Mesh Method · Linear and Quadratic Finite Elements for a Moving Mesh Method By Muhammad Akram Supervised By Professor Mike Baines

58 CHAPTER 5. DISCUSSION

(a) Linear finite Elements for f(x) = x2. (b) Quadratic finite Elements for f(x) =x2.

(c) Linear finite Elements for f(x) = x2. (d) Quadratic finite Elements for f(x) =x2.

Figure 5.4: Graphs showing the results for linear and quadratic finite elements of first testproblem for 8 and 16 elemets.

Page 59: Linear and Quadratic Finite Elements for a Moving Mesh Method · Linear and Quadratic Finite Elements for a Moving Mesh Method By Muhammad Akram Supervised By Professor Mike Baines

5.2. RESULTS 59

5.2.2 Linear and Quadratic continuous Solution for y (Problem-2)

The comparison of the results for linear and quadratic finite elements of second test problemtells us

• Graphs show that numerical values for Y get better as we increase the number ofelements.

• Linear results are really good except for end values for 16 elements.

• Quadratic results are better at the start of any number of elements.

(a) Linear finite Elements. (b) Quadratic finite Elements.

(c) Linear finite Elements. (d) Quadratic finite Elements.

Figure 5.5: Graphs showing the results for linear and quadratic finite elements of secondtest problem for 2 and 4 elemets.

Page 60: Linear and Quadratic Finite Elements for a Moving Mesh Method · Linear and Quadratic Finite Elements for a Moving Mesh Method By Muhammad Akram Supervised By Professor Mike Baines

60 CHAPTER 5. DISCUSSION

(a) Linear finite Elements. (b) Quadratic finite Elements.

(c) Linear finite Elements. (d) Quadratic finite Elements.

Figure 5.6: Graphs showing the results for linear and quadratic finite elements of secondtest problem for 8 and 16 elemets.

5.3 Conclusion

We have showed that when linear elements approach does not work very well to recover thevalues of velocity (Y ) from potential velocity (U), then we need to apply quadratic finiteelements approach to get better accuracy.

Chapter two gave the theory of finite elements for second order differential equations.This chapter investigated the method of Linear Finite elements and deficencies in thismethod for our purpose and provided an alternative Quadratic elements method to find thenumerical solution.

Chapter Three provided the Linear and Quadratic approaches to solve the first order differ-

Page 61: Linear and Quadratic Finite Elements for a Moving Mesh Method · Linear and Quadratic Finite Elements for a Moving Mesh Method By Muhammad Akram Supervised By Professor Mike Baines

5.4. FUTURE WORK 61

ential equations as well as the Sturn-Liouiville type differential equations. In this chapterwe solved test problems to investigate the numerical results.

Chapter Four introduced the results for moving boundary and discussed the possible be-haviour that can arise as the boundary moves. We also discussed the numerical results ofthe test problem and compared them with the exact solutions to investigate the errors.

5.4 Future Work

Our next target is to find the solutions for higher order differential equations.

Page 62: Linear and Quadratic Finite Elements for a Moving Mesh Method · Linear and Quadratic Finite Elements for a Moving Mesh Method By Muhammad Akram Supervised By Professor Mike Baines

Bibliography

[1] Finite Element Methods for flow problems by Jean Donea, Antonio, 2003.

[2] J. C. HEINRICH, University of Arizona, Department of Aerospace and MechenicalEngineering, Tucson, Arizona 85721,U.S.A.

[3] A Moving Mesh Finite Element algorithm for the adaptive solution of time-dependentpartial differential equations with moving boundaries, by M.J. Baines, M.E. Hubbard,and P.K. Jimack, Applied Numerical Mathematics, 54, 450-469 (2005).

[4] Clough, Ray W.; Edward L. Wilson. Early Finite Element Research at Berkeley (PDF).Retrieved on 2007-10-25.

[5] The Finite Element Method by Douglas H. Norrie, Gerard de Vries, Academic Press,New York San Francisco London, 1973.

[6] Eric B. Becker, Graham F. Carey, and J. Tinsley Oden: Finite Elements,

An Introduction, volume I.

[7] Harold C. Martin, Graham F. Carey: Introduction to Finite Element Analysis,Theory and Application, McGraw-Hill Book Company, 1973.

[8] O.C.Zienkiewicz, K. Morgan:, Finite Elements and Approximation, A Wiley-International Publication, 1983.

[9] K. Eriksson, D. Estep, C. Johnson Introduction to Adaptive Methods for differ-ential Equations, Acta Numerica, (1995), 001-054.

62