0% found this document useful (0 votes)
162 views154 pages

Lecture Notes CFD 2014-2015

Lectures on Computational Fluid Dynamics

Uploaded by

showbhut
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
162 views154 pages

Lecture Notes CFD 2014-2015

Lectures on Computational Fluid Dynamics

Uploaded by

showbhut
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 154

P.

Wesseling
updated by D.R. van der Heul

ELEMENTS OF
COMPUTATIONAL FLUID
DYNAMICS

Lecture notes WI 4011 Numerieke Stromingsleer


Copyright 2001
c by P. Wesseling

Faculty ITS
Applied Mathematics
Preface

The technological value of computational fluid dynamics has become undis-


puted. A capability has been established to compute flows that can be investi-
gated experimentally only at reduced Reynolds numbers, or at greater cost, or
not at all, such as the flow around a space vehicle at re-entry, or a loss-of-coolant
accident in a nuclear reactor. Large commercial computational fluid dynamics
computer codes have arisen, and found widespread use in industry. Users of
these codes need to be familiar with the basic principles. It has been observed
on numerous occasions, that even simple flows are not correctly predicted by
advanced computational fluid dynamics codes, if used without sufficient insight
in both the numerics and the physics involved. This course aims to elucidate
some basic principles of computational fluid dynamics.

Because the subject is vast we have to confine ourselves here to just a few as-
pects. A more complete introduction is given in Wesseling (2001), and other
sources quoted there. Occasionally, we will refer to the literature for further
information. But the student will be examined only about material presented
in these lecture notes.

Fluid dynamics is governed by partial differential equations. These may be


solved numerically by finite difference, finite volume, finite element and spectral
methods. In engineering applications, finite difference and finite volume meth-
ods are predominant. We will confine ourselves here to finite difference and finite
volume methods.

Although most practical flows are turbulent, we restrict ourselves here to lam-
inar flow, because this book is on numerics only. The numerical principles un-
covered for the laminar case carry over to the turbulent case. Furthermore,
we will discuss only incompressible flow. Considerable attention is given to the
convection-diffusion equation, because much can be learned from this simple
model about numerical aspects of the Navier-Stokes equations. One chapter is
devoted to direct and iterative solution methods.
II

Errata and MATLAB software related to a number of examples discussed in


these course notes may be obtained via the authors website, to be found at
ta.twi.tudelft.nl/nw/users/wesseling
(see under Information for students / College WI4 011 Numerieke Stro-
mingsleer)

Delft, September 2001 P. Wesseling


Preface to the updated edition

The content of the course Numerieke Stromingsleer have been adapted to


eliminate the overlap with concurring courses on computational fluid dynamics
and with the content of the course WI 4201 Scientific Computing. In particular
the subject of the earlier Chapter 6, iterative solution methods, is extensively
discussed in the latter course. To be able to understand the fundamentals of
structured grid generation same basic tensor analysis is discussed. However,
students that want to pursue in the field of computational fluid dynamics are
advised to take the course WI 4037 Tensor Analysis
The course is (still) meant as an in depth mathematical discussion of the mere
basics of the field of computational fluid dynamics, as opposed to other courses
that will offer a more shallow discussion of many more aspects of the field.
The original lecture notes have been augmented with additional remarks and
in some cases additional steps in the derivations have been added to assist
the reader in understanding the concepts, without being discouraged by the
mathematical analysis, which is straightforward but is regarded by some as
tedious.
The original content is extended with a discussion of grid generation techniques.
It is important to understand, that apart from analysis of the computed results,
the main workload for the computational fluid dynamics practitioner is in the
generation of the grid. Therefore, there is a continuing interest in industry to
reduce the workload (=cost) in grid generation by automating the process. This
can be achieved for both structured and unstructured computational grids,
using advanced numerical techniques. Again, an indepth discussion of the basics
is given, as opposed to briefly touching on the many different flavours that exist.

Delft, October 2009 D.R. van der Heul


Contents

Preface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . I

Preface to the updated edition . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . III

1. The basic equations of fluid dynamics . . . . . . . . . . . . . . . . . . . . . . . 1


1.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
1.2 Vector analysis . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
1.3 The total derivative and the transport theorem . . . . . . . . . . . . . . . 4
1.4 Conservation of mass . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
1.5 Conservation of momentum . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
1.6 The convection-diffusion equation . . . . . . . . . . . . . . . . . . . . . . . . . . 11
1.7 Summary of this chapter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13

2. The stationary convection-diffusion equation in one dimension 15


2.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
2.2 Analytic aspects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
2.3 Finite volume method . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20

3. The stationary convection-diffusion equation in two dimen-


sions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41
3.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41
3.2 Singular perturbation theory . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42
3.3 Finite volume method . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 50

4. The nonstationary convection-diffusion equation . . . . . . . . . . . . 59


4.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 59
4.2 A numerical example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 60
4.3 Convergence, consistency and stability . . . . . . . . . . . . . . . . . . . . . . 62
4.4 Fourier stability analysis . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 66
4.5 Numerical experiments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 77

5. The incompressible Navier-Stokes equations . . . . . . . . . . . . . . . . 81


5.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 81
5.2 Equations of motion and boundary conditions . . . . . . . . . . . . . . . . 82
5.3 Spatial discretization on staggered grid . . . . . . . . . . . . . . . . . . . . . . 84
5.4 Spatial discretization on colocated grid . . . . . . . . . . . . . . . . . . . . . . 89
5.5 Temporal discretization on staggered grid . . . . . . . . . . . . . . . . . . . . 94
5.6 Numerical experiments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 99
VI Contents

6. Discretisation on an unstructured grid. . . . . . . . . . . . . . . . . . . . . . 107


6.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 107
6.2 Discretisation of the incompressible Navier-Stokes equations on
an unstructured grid . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 107
6.2.1 Structure in an unstructured grid . . . . . . . . . . . . . . . . . . . . . 108
6.2.2 The rotational form of the incompressible Navier-Stokes
equations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 108
6.2.3 The divergence form of the Navier-Stokes equations . . . . . 111

7. Discretisation on a boundary conforming grid. . . . . . . . . . . . . . . 113


7.1 The basic idea . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 113
7.2 Some tensor calculus . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 113
7.3 The coordinate mapping . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 114
7.3.1 Definition of the basis vectors . . . . . . . . . . . . . . . . . . . . . . . . 114
7.3.2 Construction of the basis vectors . . . . . . . . . . . . . . . . . . . . . 114
7.3.3 Covariant and contravariant vectors . . . . . . . . . . . . . . . . . . 116
7.3.4 Representation of u . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 117
7.3.5 The permutation symbol . . . . . . . . . . . . . . . . . . . . . . . . 118
7.3.6 The metric tensor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 119
7.3.7 Contraction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 120
7.3.8 The inner product . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 120
7.3.9 Physical component . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 120
7.3.10 Christoffel symbols . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 121
7.3.11 Differentiating the metric tensor . . . . . . . . . . . . . . . . . . . . . . 123
7.3.12 Differentiating a vector field . . . . . . . . . . . . . . . . . . . . . . . . . 124
7.3.13 Formulating equations in coordinate invariant form . . . . . 125
7.3.14 Divergence operator . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 125
7.3.15 Laplace operator . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 126
7.3.16 An example computation . . . . . . . . . . . . . . . . . . . . . . . . . . . . 127
7.3.17 Navier-Stokes equations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 127

8. Introduction to classical grid generation . . . . . . . . . . . . . . . . . . . . 129


8.1 Starting point . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 129
8.2 Structured grid generation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 130
8.2.1 Algebraic grid generation techniques . . . . . . . . . . . . . . . . . . 131
8.3 Differential models for grid generation . . . . . . . . . . . . . . . . . . . . . . . 134
8.3.1 The Winslow equations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 134
8.3.2 The Thompson-Thames-Mastin (TTM) equations . . . . . . 136
8.3.3 Source function for control of grid density . . . . . . . . . . . . . 137
8.3.4 Source function for control of direction of the grid lines . 137

References . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 142
1. The basic equations of fluid dynamics

1.1 Introduction

Fluid dynamics is a classic discipline. The physical principles governing the flow
of simple fluids and gases, such as water and air, have been understood since
the times of Newton. Since about 1950 classic fluid dynamics finds itself in the
company of computational fluid dynamics. This newer discipline still lacks the
elegance and unification of its classic counterpart, and is in a state of rapid
development.

Good starting points for exploration of the Internet for material related to com-
putational fluid dynamics is the following website:
www.cfd-online.com/

The site contains a lot of information on available textbooks and discussion


boards related to different topics and packages to post your questions and share
your ideas.
Readers well-versed in theoretical fluid dynamics may skip the remainder of
this chapter, perhaps after taking note of the notation introduced in the next
section. But those less familiar with this discipline will find it useful to continue
with the present chapter.

The purpose of this chapter is:

To introduce some notation that will be useful later;


To recall some basic facts of vector analysis;
To introduce the governing equations of laminar incompressible fluid dynam-
ics;
To explain that the Reynolds number is usually very large. In later chapters
this will be seen to have a large impact on numerical methods.

1.2 Vector analysis

Cartesian tensor notation

We assume a right-handed Cartesian coordinate system (x1 , x2 , ..., xd ) with d


the number of space dimensions. Bold-faced lower case Latin letters denote vec-
tors, for example, x = (x1 , x2 , ..., xd ). Greek letters denote scalars. In Cartesian
tensor notation, which we shall often use, differentiation is denoted as follows:
2 1. The basic equations of fluid dynamics


, = . (1.1)
x
Greek subscripts refer to coordinate directions, and the summation convention
is used: summation takes place over Greek indices that occur twice in a term or
product. The reason for our preference for this compact notation will become
clear in the discussion of formulation in general coordinates. In the latter case
the standard notation becomes totally impractical.

Examples
d
P
Inner product: u v = u v = u v
=1
d
2
Laplace operator: 2 = , =
P
x2
=1

d
2
P
Note that u + v does not mean (u + v ) (why?)
=1

We will also use vector notation, instead of the subscript notation just explained,
and may write u, if this is more elegant or convenient than the tensor equiv-
alent u, ; and sometimes we write grad or for the vector (,1 , ,2 , ,3 ).

The Kronecker delta is defined by:

11 = 22 = = dd = 1, = 0, 6= ,

where d is the number of space dimensions.

Divergence theorem

We will need the following fundamental theorem:


Theorem 1.2.1. For any volume V Rd bounded by a piecewise smooth closed
surface S and any differentiable scalar field we have
Z Z
, dV = n dS ,
V S

where n is the outward unit normal on S (and n the component of n in the


direction.
For a proof, see for example Aris (1962). The proof is given for a simple solid
region (a cylindrical region with the cylinder axis aligned with one of the coor-
dinate directions) and is generalized to a general region by merging simple solid
regions.

A direct consequence of this theorem is:


1.2 Vector analysis 3

Theorem 1.2.2. (Divergence theorem).


For any volume V Rd with piecewise smooth closed surface S and any differ-
entiable vector field u we have
Z Z
u, dV = n u dS ,
V S

where n is the outward unit normal on S.


Proof. Apply Theorem 1.2.1 with , = u , = 1, 2, ..., d successively and add.
2

A vector field satisfying u, = 0 is called solenoidal.

The streamfunction

In two dimensions, if for a given velocity field u there exists a function such
that
,1 = u2 , ,2 = u1 ,
then such a function is called the streamfunction. For the streamfunction to exist
it is obviously necessary that ,12 = ,21 ; therefore we must have u1,1 = u2,2 ,
or div u = 0. Hence, two-dimensional solenoidal vector fields have a streamfunc-
tion. The normal to an isoline (x) = constant is parallel to = (,1 , ,2 );
therefore the vector u = (,2 , ,1 ) is tangential to this isoline. Streamlines
are curves that are everywhere tangential to u. We see that in two dimensions
the streamfunction is constant along streamlines. Later, this fact will provide
us with a convenient way to compute streamline patterns numerically.

Potential flow

The curl of a vector field is defined by



u3,2 u2,3
u = u1,3 u3,1 .
u2,1 u1,2

That is, the x1 -component of the vector curlu is u3,2 u2,3 , etc. Often, the curl
is called rotation, and a vector field satisfying u = 0 is called irrotational.
In two dimensions, the curl is obtained by putting the third component and
/x3 equal to zero. This gives

u = u2,1 u1,2 .

It can be shown (cf. Aris (1962)) that if a vector field u satisfies u = 0


there exists a scalar field such that

u = , or u = , (1.2)
4 1. The basic equations of fluid dynamics

(or u = , ). The scalar is called the potential, and flows with velocity field u
satisfying (1.2) are called potential flows or irrotational flows (since = 0,
cf. Exercise 1.2.3). The potential flow model assumes the flow to be inviscid and
solenoidal. Because of the simplicity of the model numerical solutions can be
obtained very quickly. In those cases where viscous effects are not important,
the potential flow model can be relatively accurate, e.g. in the computation of
the lift of thin airfoils at small angle of attack.

Exercise 1.2.1. Prove Theorem 1.2.1 for the special case that V is the unit
cube.
Exercise 1.2.2. Show that u is solenoidal.
Exercise 1.2.3. Show that curl grad = 0.
Exercise 1.2.4. Show that = d.

1.3 The total derivative and the transport theorem


Streamlines

We repeat: a streamline is a curve that is everywhere tangent to the velocity


vector u(t, x) at a given time t. Hence, a streamline may be parameterized with
a parameter s such that a streamline is a curve x = x(s) defined by
dx/ds = u(t, x) .

The total derivative

Let x(t, y) be the position of a material particle at time t > 0, that at time t = 0
had initial position y. Obviously, the velocity field u(t, x) of the flow satisfies
x(t, y)
u(t, x) = . (1.3)
t
The time-derivative of a property of a material particle, called a material
property (for example its temperature), is denoted by D/Dt. This is called the
total derivative. All material particles have some , so is defined everywhere
in the flow, and is a scalar field (t, x). We have
D
[t, x(t, y)] , (1.4)
Dt t
where the partial derivative has to be taken with y constant, since the total
derivative tracks variation for a particular material particle. We obtain
D x (t, y)
= + , .
Dt t t
By using (1.3) we get
D
= + u , .
Dt t
1.4 Conservation of mass 5

The transport theorem

A material volume V (t) is a volume of fluid that moves with the flow and consists
permanently of the same material particles.
Theorem 1.3.1. (Reynoldss transport theorem)
For any material volume V (t) and differentiable scalar field we have
Z Z  
d
dV = + (u ), dV . (1.5)
dt t
V (t) V (t)

Not the fact that the integration volume is time-dependent. For a proof, see
Sect. 1.3 of Wesseling (2001).

We are now ready to formulate the governing equations of fluid dynamics, which
consist of the conservation laws for mass, momentum and energy.

1.4 Conservation of mass


Continuum hypothesis

The dynamics of fluids is governed by the conservation laws of classical physics,


namely conservation of mass, momentum and energy. From these laws partial
differential equations are derived and, under appropriate circumstances, simpli-
fied. It is customary to formulate the conservation laws under the assumption
that the fluid is a continuous medium (continuum hypothesis). Physical prop-
erties of the flow, such as density and velocity can then be described as time-
dependent scalar or vector fields on R2 or R3 , for example (t, x) and u(t, x).

The mass conservation equation

The mass conservation law says that the rate of change of mass in an arbitrary
material volume V (t) equals the rate of mass production in V (t). This can be
expressed as Z Z
d
dV = dV , (1.6)
dt
V (t) V (t)

where (t, x) is the density of the material particle at time t and position x,
and (t, x) is the rate of mass production per volume. In practice, 6= 0 only in
multiphase flows, in which case (1.6) holds for each phase separately. We take
= 0, and use the transport theorem to obtain
Z  

+ (u) dV = 0 .
t
V (t)

Since this holds for every V (t) the integrand must be zero:

+ (u) = 0 . (1.7)
t
This is the mass conservation law, also called the continuity equation.
6 1. The basic equations of fluid dynamics

Incompressible flow

An incompressible flow is a flow in which the density of each material particle


remains the same during the motion:

[t, x(t, y)] = (0, y) . (1.8)

Hence
D
= 0. (1.9)
Dt
Because
(u) = u + u ,
it follows from the mass conservation law (1.7) that

u=0. (1.10)

This is the form that the mass conservation law takes for incompressible flow.

Sometimes incompressibility is erroneously taken to be a property of the fluid


rather than of the flow. But it may be shown that compressibility depends only
on the speed of the flow, see Sect. 1.12 of Wesseling (2001). If the magnitude of
the velocity of the flow is of the order of the speed of sound in the fluid ( 340
m/s in air at sea level at 15 C, 1.4 km/s in water at 15 C, depending on the
amount of dissolved air) the flow is compressible; if the velocity is much smaller
than the speed of sound, incompressibility is a good approximation. In liquids,
flow velocities anywhere near the speed of sound cannot normally be reached,
due to the enormous pressures involved and the phenomenon of cavitation.

1.5 Conservation of momentum


Body forces and surface forces

Newtons law of conservation of momentum implies that the rate of change of


momentum of a material volume equals the total force on the volume. There are
body forces and surface forces. A body force acts on a material particle, and is
proportional to its mass. Let the volume of the material particle be dV (t) and
let its density be . Then we can write

body force = f b dV (t) . (1.11)

A surface force works on the surface of V (t) and is proportional to area. The
surface force working on a surface element dS(t) of V (t) can be written as

surface force = f s dS(t) . (1.12)

Conservation of momentum

The law of conservation of momentum applied to a material volume gives


1.5 Conservation of momentum 7

Z Z Z
d
u dV = fb dV + fs dS . (1.13)
dt
V (t) V (t) S(t)

By substituting = u in the transport theorem (1.5), this can be written as


Z h Z Z
u i
+ (u u ), dV = fb dV + fs dS . (1.14)
t
V (t) V (t) S(t)

It may be shown (see Aris (1962)) there exist nine quantities such that

fs = n , (1.15)

where is the stress tensor and n is the outward unit normal on dS. By
applying Theorem 1.2.1 with replaced by and n by n , equation (1.14)
can be rewritten as
Z h Z
u i
+ (u u ), dV = (fb + , )dV .
t
V (t) V (t)

Since this holds for every V (t), we must have

u
+ (u u ), = , + fb , (1.16)
t
which is the momentum conservation law . The left-hand side is called the inertia
term, because it comes from the inertia of the mass of fluid contained in V (t)
in equation (1.13).

An example where f b 6= 0 is stratified flow under the influence of gravity.

Constitutive relation

In order to complete the system of equations it is necessary to relate the stress


tensor to the local motion of the fluid. Such a relation is called a constitutive
relation. A full discussion of constitutive relations would lead us too far. The
simplest constitutive relation is (see Batchelor (1967))
1
= p + 2(e ) , (1.17)
3
where p is the pressure, is the Kronecker delta, is the dynamic viscosity,
e is the rate of strain tensor, defined by

1
e = (u, + u, ) ,
2
and
= e = u, .
The quantity = / is called the kinematic viscosity.. This relation is based
on:
8 1. The basic equations of fluid dynamics

The experimentally confirmed assumption that there is a linear relation be-


tween the stress tensor and gradient of the velocity.
The fact that the stress tensor should be symmetric
The fact that the deviatoric stress tensor by definition does not contribute to
the mean normal stress, which should be equal to the pressure.
The relation (1.17) was derived by Saint-Venant (1842!) and Stokes (1845).
In many fluids and gases depends on temperature, but not on pressure. Fluids
satisfying (1.17) are called Newtonian fluids. Examples are gases and liquids
such as water and mercury. Examples of non-Newtonian fluids are polymers
and blood.

The Navier-Stokes equations

Substitution of (1.17) in (1.16) gives


u 1
+ (u u ), = p, + 2[(e )], + fb . (1.18)
t 3
These are the Navier-Stokes equations. The terms in the left-hand side are due to
the inertia of the fluid particles, and are called the inertia terms. The first term
on the right represents the pressure force that works on the fluid particles, and
is called the pressure term. The second term on the right represents the friction
force, and is called the viscous term. The third term on the right is the body force.

Because of the continuity equation (1.7), one may also write


Du 1
= p, + 2[(e )], + fb . (1.19)
Dt 3
In incompressible flows = 0, and we get
Du
= p, + 2(e ), + fb . (1.20)
Dt
These are the incompressible Navier-Stokes equations. If, furthermore, = con-
stant then we can use u, = (u, ) = 0 to obtain
Du
= p, + u, + fb . (1.21)
Dt
This equation was first derived by Navier (1823), Poisson (1831), de Saint-
Venant (1843) and Stokes (1845). Its vector form is
Du
= p + 2 u + f b ,
Dt
where 2 is the Laplace operator. The quantity
Du u
= + u u,
Dt t
is sometimes written as
Du u
= + u u .
Dt t
1.5 Conservation of momentum 9

Making the equations dimensionless

In fluid dynamics there are exactly four independent physical units: those of
length, velocity, mass and temperature, to be denoted by L, U, M and Tr , re-
spectively. From these all other units can be and should be derived in order to
avoid the introduction of superfluous coefficients in the equations. For instance,
the appropriate unit of time is L/U ; the unit of force F follows from Newtons
law as M U 2 /L. Often it is useful not to choose these units arbitrarily, but to
derive them from the problem at hand, and to make the equations dimension-
less. This leads to the identification of the dimensionless parameters that govern
a flow problem. An example follows.

The Reynolds number

Let L and U be typical length and velocity scales for a given flow problem,
and take these as units of length and velocity. The unit of mass is chosen as
M = r L3 with r a suitable value for the density, for example the density in
the flow at upstream infinity, or the density of the fluid at rest. Dimensionless
variables are denoted by a prime:
0 0 0
x = x/L, u = u/U, = /r . (1.22)

In dimensionless variables, equation (1.18) takes the following form:


0 0
L u 0 0 0 1 2 0 1 0 L 0
+ ( u u ), = 2
p, + {(e )}, + 2 fb ,
U t r U r U L 3 U
(1.23)
0 0 0 0
where now the subscript , stands for /x , and e = 21 (u, + u, ),
0 0
= e . We introduce further dimensionless quantities as follows:
0 0 0 L b
t = U t/L, p = p/r U 2 , (f b ) = f . (1.24)
U2
By substitution in (1.23) we obtain the following dimensionless form of the
Navier-Stokes equations, deleting the primes:
u 1
+ (u u ), = p, + 2{Re1 (e )}, + fb ,
t 3
where the Reynolds number Re is defined by
r U L
Re = .

The dimensionless form of (1.21) is, if = constant = r ,
Du
= p, + Re1 u, + fb . (1.25)
Dt
The transformation (1.22) shows that the inertia term is of order r U 2 /L and
the viscous term is of order U/L2 . Hence, Re is a measure of the ratio of in-
ertial and viscous forces in the flow. This can also be seen immediately from
10 1. The basic equations of fluid dynamics

equation (1.25). For Re  1 inertia dominates, for Re  1 friction (the viscous


term) dominates. Both are balanced by the pressure gradient.

In the case of constant density, equations (1.25) and (1.10) form a com-
plete system of four equations with four unknowns. The solution depends
on the single dimensionless parameter Re only. What values does Re have
in nature? At a temperature of 150 C and atmospheric pressure, for air we
have for the kinematic viscosity / = 1.5 105 m2 /s, whereas for water
/ = 1.1 106 m2 /s. In the International Civil Aviation Organization Stan-
dard Atmosphere, / = 4.9 105 m2 /s at an altitude of 12.5 km. This gives
for the flow over an aircraft wing in cruise condition at 12.5 km altitude with
wing cord L = 3 m and U = 900 km/h: Re = 1.5 107 . In a windtunnel exper-
iment at sea-level with L = 0.5 m and U = 25 m/s we obtain Re = 8.3 105 .
For landing aircraft at sea-level with L = 3 m and U = 220 km/h we obtain
Re = 1.2 107 . For a house in a light wind with L = 10 m and U = 0.5 m/s we
have Re = 3.3 105 . Air circulation in a room with L = 4 m and U = 0.1 m/s
gives Re = 2.7 104 . A large ship with L = 200 m and U = 7 m/s gives
Re = 1.3 108 , whereas a yacht with L = 7 m and U = 3 m/s has Re = 1.9 107 .
A small fish with L = 0.1 m and U = 0.2 m/s has Re = 1.8 104 .

All these very different examples have in common that Re  1, which is indeed
almost the rule in flows of industrial and environmental interest. One might
think that flows around a given shape will be quite similar for different values of
Re, as long as Re  1, but nothing is farther from the truth. At Re = 107 a flow
may be significantly different from the flow at Re = 105 , in the same geometry.
This strong dependence on Re complicates predictions based on scaled down
experiments. Modern cryogenic wind tunnels allow testing of scaled models at
the correct Mach number and Reynolds number, by cooling the wind tunnel
medium to cryogenic temperatures. Performing wind tunnel tests is expensive,
whereas cryogenic wind tunnel testing is really, really expensive. Therefore com-
putational fluid dynamics plays an important role in extrapolation to full scale.
The rich variety of solutions of (1.25) that evolves as Re is one of the
most surprising and interesting features of fluid dynamics, with important con-
sequences for technological applications. A route to chaos develops as Re ,
resulting in turbulence. Intricate and intriguing flow patterns occur, accurately
rendered in masterful drawings by Leonardo da Vinci, and photographically
recorded in Hinze (1975), Nakayama and Woods (1988), Van Dyke (1982) and
Hirsch (1988).

Turbulent flows are characterized by small rapid fluctuations of a seemingly


random nature. Smooth flows are called laminar. The transition form laminar
to turbulent flow depends on the Reynolds number and the flow geometry. Very
roughly speaking (!), for Re > 10000 flows may be assumed to be turbulent.

The complexity of flows used to be thought surprising, since the physics under-
lying the governing equations is simply conservation of mass and momentum.
Since about 1960, however, it is known that the sweeping generalizations about
determinism of Newtonian mechanics made by many scientists (notably Laplace)
in the nineteenth century were wrong. Even simple classic nonlinear dynamical
systems often exhibit a complicated seemingly random behavior, with such a
1.6 The convection-diffusion equation 11

sensitivity to initial conditions, that their long-term behavior cannot be pre-


dicted in detail. For a discussion of the modern view on (un-)predictability in
Newtonian mechanics, see Lighthill (1986).

The Stokes equations

Very viscous flows are flows with Re  1. For Re 0 the system (1.25) simplifies
to the Stokes equations. If we multiply (1.25) by Re and let Re 0, the pressure
drops out, which cannot be correct, since we would have four equations (Stokes
and mass conservation) for three unknowns u . It follows that p = O(Re1 ).
We therefore substitute 0
p = Re1 p . (1.26)
From (1.26) and (1.24) it follows that the dimensional (physical) pressure is
0
U p /L. Substitution of (1.26) in (1.25), multiplying by Re and letting Re 0
gives the Stokes equations:

u, p, = 0 . (1.27)

These linear equations together with (1.10) were solved by Stokes (1851) for
flow around a sphere. Surprisingly, the Stokes equations do not describe low
Reynolds flow in two dimensions. This is called the Stokes paradox. See Sect.
1.6 of Wesseling (2001) for the equations that govern low Reynolds flows in two
dimensions.

The governing equations of incompressible fluid dynamics are given by, if the
density is constant, equations (1.25) and (1.10). This is the only situation to be
considered in these lecture notes.

Exercise 1.5.1. Derive equation (1.19) from equation (1.18).


Exercise 1.5.2. What is the speed of sound and the kinematic viscosity in the
air around you? You ride your bike at 18 km/h. Compute your Reynolds number
based on a characteristic length (average of body length and width, say) of 1
m. Do you think the flow around you will be laminar or turbulent?

1.6 The convection-diffusion equation


Conservation law for material properties

Let be a material property, i.e. a scalar that corresponds to a physical prop-


erty of material particles, such as heat or concentration of a solute in a fluid,
for example salt in water. Assume that is conserved and can change only
through exchange between material particles or through external sources. Let
be defined per unit of mass. Then the conservation law for is:
Z Z Z
d
dV = f n dS + qdV .
dt
V (t) S(t) V (t)
12 1. The basic equations of fluid dynamics

Here f is the flux vector, governing the rate of transfer through the surface, and
q is the source term. For f we assume Ficks law (called Fouriers law if is
temperature):
f = k , or f = k,
with k the diffusion coefficient. By arguments that are now familiar it follows
that

+ (u ), = (k, ), + q . (1.28)
t
This is the convection-diffusion equation. The left-hand side represents trans-
port of by convection with the flow, the first term at the right represents
transport by diffusion.

By using the mass conservation law, equation (1.28) can be written as

D
= (k, ), + q . (1.29)
Dt
If we add a term r to the left-hand side of (1.28) we obtain the convection-
diffusion-reaction equation:

+ (u ), + r = (k, ), + q .
t
This equation occurs in flows in which chemical reactions take place. The Black-
Scholes equation, famous for modeling option prices in mathematical finance, is
also a convection-diffusion-reaction equation:

+ (1 k),x + k = ,xx .
t
We will not discuss the convection-diffusion-reaction equation, but only the
convection-diffusion equation.

Note that the momentum equation (1.21) comes close to being a convection-
diffusion equation. Many aspects of numerical approximation in computational
fluid dynamics already show up in the numerical analysis of the relatively simple
convection-diffusion equation, which is why we will devote two special chapters
to this equation.

Dimensionless form

We can make the convection-diffusion equation dimensionless in the same way


as the Navier-Stokes equations. The unit for may be called r . It is left as an
exercise to derive the following dimensionless form for the convection-diffusion
equation (1.28):

+ (u ), = (Pe1 , ), + q , (1.30)
t
where the Peclet number Pe is defined as

Pe = 0 U L/k0 .
1.7 Summary of this chapter 13

We see that the Peclet number characterizes the balance between convection
and diffusion. For Pe  1 we have dominating convection, for Pe  1 diffusion
dominates. If equation (1.30) stands for the heat transfer equation with the
temperature, then for air we have k /0.73. Therefore, for the same reasons
as put forward in Sect. 1.5 for the Reynolds number, in computational fluid
dynamics Pe  1 is the rule rather than the exception.

Exercise 1.6.1. Derive equation (1.30).

1.7 Summary of this chapter

We have introduced Cartesian tensor notation, and have recalled some basic
facts from vector analysis. The transport theorem helps to express the con-
servation laws for mass and momentum of a fluid particle in terms of partial
differential equations. This leads to the incompressible Navier-Stokes equations.
Nondimensionalization leads to the identification of the dimensionless param-
eter governing incompressible viscous flows, called the Reynolds number. We
have seen that the value of the Reynolds number is usually very high in flows
of industrial and environmental interest. We have briefly touched upon the phe-
nomenon of turbulence, which occurs if the Reynolds number is large enough.
The convection-diffusion equation, which is the conservation law for material
properties that are transported by convection and diffusion, has been derived.
Its dimensionless form gives rise to the dimensionless Peclet number, that de-
scribes the balance between convection and diffusion..

Some self-test questions

Write down the divergence theorem.

What is the total derivative?

Write down the transport theorem.

Write down the governing equations of incompressible viscous flow.

Define the Reynolds number.

Write down the convection-diffusion-reaction equation.


2. The stationary convection-diffusion equation
in one dimension

2.1 Introduction
Although the one-dimensional case is of no practical use, we will devote a special
chapter to it, because important general principles of CFD can be easily ana-
lyzed and explained thoroughly in one dimension. We will pay special attention
to difficulties caused by a large Peclet number Pe, which is generally the case
in CFD, as noted in Sect. 1.6.

In this chapter we consider the one-dimensional stationary version of the dimen-


sionless convection-diffusion equation (1.30) with = 1:
(u),x = (,x ),x + q(x) , x (0, 1) , (2.1)
where the domain has been chosen to be the unit interval, and = 1/Pe. For
the physical meaning of this equation, see Sect. 1.6

The purpose of this chapter is:

To explain that a boundary value problem can be well-posed or ill-posed, and


to identify boundary conditions that give a well-posed problem for Pe  1;

To discuss the choice of outflow boundary conditions;

To explain how the maximum principle can tell us whether the exact solution
is monotone;

To explain the finite volume discretization method;

To explain the discrete maximum principle that may be satisfied by the nu-
merical scheme;

To study the local truncation error on nonuniform grids;

To show by means of the discrete maximum principle that although the local
truncation error is relatively large at the boundaries and in the interior of a
nonuniform grid, nevertheless the global truncation error can be about as small
as on a uniform grid;

To show how by means of local grid refinement accuracy and computing work
can be made independent of the Peclet number;
16 2. The stationary convection-diffusion equation in one dimension

To illustrate the above points by numerical experiments;

To give a few hints about programming in MATLAB.

2.2 Analytic aspects


Conservation form

The time-dependent version of (2.1) can be written as



= L + q , L (u),1 (,1 ),1 .
t
Let us integrate over :
Z Z Z
d
d = Ld + qd.
dt

Since Z
1
Ld = (u ,1 )|0 , (2.2)

(where we define f (x)|ba f (b) f (a)), we see that


Z Z
d 1
d = (u ,1 )|0 + qd.
dt

Hence, if there is no transport through the boundaries x = 0, 1, and if the source


term q = 0, then Z
d
d = 0 .
dt
R R
Therefore d is conserved. The total amount of , i.e. d, can change
only in time by transport through the boundaries x = 0, 1, and by the action
of a source term q. Therefore a differential operator such as L, whose integral
over the domain reduces to an integral over the boundary, is said to be in
conservation form.

A famous example of a nonlinear convection equation (no diffusion) is the Burg-


ers equation (named after the TUD professor J.M. Burgers, 18951981):
1 2 
+ ,1 = 0 . (2.3)
t 2
This equation is in conservation form. But the following version is not in con-
servation form:

+ ,1 = 0 . (2.4)
t
It is not necessarily wrong to use the nonconservative form of the equation,
and many methods are based on this approach. However, when the equation
is discretised in nonconservative integral form , a sequence of weak solutions is
not guaranteed to converge to the exact weak solution. Weak solutions of gen-
eral hyperbolic conservation laws are discussed in the course Wi4212 Advanced
Numerical Methods.
2.2 Analytic aspects 17

An exact solution

Let u 1, = constant and q = 0. Then equation (2.1) becomes

,1 = ,11 , x (0, 1) , (2.5)

which can be solved analytically by postulating = Cex . Substitution in (2.5)


shows this is a solution if
2 = 0 ,
hence 1 = 0 and 2 = 1/. Therefore the general solution is

(x) = C1 + C2 ex/ , (2.6)

with C1,2 free constants, that must follow from the boundary conditions, in order
to determine a unique solution. We see that precisely two boundary conditions
are needed, corresponding to the order of the differential equation.

Boundary conditions

For a second order differential equation, such as (2.1), two boundary conditions
are required, to make the solution unique. A differential equation together with
its boundary conditions is called a boundary value problem.
We start with the following two boundary conditions, both at x = 0:

(0) = a, ,1 (0) = b. (2.7)

The first condition, which prescribes a value for , is called a Dirichlet condition;
the second, which prescribes a value for the derivative of , is called a Neumann
condition. The boundary conditions (2.7) are satisfied if the constants in (2.6)
are given by C1 = a b, C2 = b, so that the exact solution is given by

(x) = a b + bex/ . (2.8)

Ill-posed and well-posed

We now show there is something wrong with boundary conditions (2.7) if  1.


Suppose b is perturbed by an amount b. The resulting perturbation in (1) is

(1) = be1/ .

We see that
|(1)|
1 if  1 .
|b|
Hence, a small change in a boundary condition causes a large change in the
solution if  1. We assume indeed  1, for reasons set forth in Sect. 1.6.
Problems which have large sensitivity to perturbations of the boundary data (or
other input, such as coefficients and right-hand side) are called ill-posed. Usually,
but not always, ill-posedness of a problem indicates a fault in the formulation of
the mathematical model. The opposite of ill-posed is well-posed. Since numerical
18 2. The stationary convection-diffusion equation in one dimension

approximations always involve perturbations, ill-posed problems can in general


not be solved numerically with satisfactory accuracy, especially in more than one
dimension (although there are special numerical methods for solving ill-posed
problems with reasonable accuracy; this is a special field). In the present case
ill-posedness is caused by wrong boundary conditions.

It is left to the reader to show in Exercise 2.2.2 that the following boundary
conditions:
(0) = a, ,1 (1) = b. (2.9)
lead to a well-posed problem. The exact solution is now given by (verify this):

(x) = a + b(e(x1)/ e1/ ). (2.10)

Note that equation (2.5) corresponds to a velocity u = 1, so that x = 0 is an


inflow boundary. Hence in (2.9) we have a Dirichlet boundary condition at the
inflow boundary and a Neumann boundary condition at the outflow boundary.
If we assume u = 1, so that this is the other way around, then the problem is
ill-posed as  1 with boundary conditions (2.9). This follows from the result
of Exercise 2.2.3. We conclude that it is wrong to give a Neumann condition at
an inflow boundary.

Finally, let a Dirichlet condition is given at both boundaries:

(0) = a, (1) = b. (2.11)

The exact solution is


ex/ 1
(x) = a + (b a) (2.12)
e1/ 1
The result of Exercise 2.2.4 shows that boundary conditions (2.11) give a well-
posed problem.

To summarize: To obtain a well-posed problem, the boundary conditions must be


correct.

Maximum principle

We rewrite equation (2.1) as

(u),1 (,1 ),1 = q(x) , x. (2.13)

Let q(x) < 0, x . In an interior extremum of the solution in a point x0 we


have ,1 (x0 ) = 0, so that

(x0 )u,1 (x0 ) ,11 (x0 ) < 0.

Now suppose that u,1 = 0 (in more dimensions it suffices that u, = 0, which
is satisfied in incompressible flows). Then ,11 (x0 ) > 0, so that the extremum
cannot be a maximum. This result can be strengthened easily to the case q(x)
0, x : Rewrite (2.13) in the following way and assume = [a, b]:
2.2 Analytic aspects 19

u 1
L[] = ,1 ,11 = q(x) 0 , x. (2.14)

with u bounded on If we assume (x) M in ha, bi and if the maximum
M is attained at an interior point c ha, bi and there is a d > c, (d) < M
Define z(x) as
z(x) = e(xc) 1 (2.15)
with > 0, a constant to be determined later on. Clearly z(x) has the following
properties:

<0 ; ax<c
z(x) = 0 ; x=c (2.16)
>0 ; c<xb

Substituting z(x) in (2.14) gives:


u u 
L[z] = z,1 z,11 = e(xc) (2.17)

u
Because we assume that u is bounded, we can choose such that > and
this will make L[z] < 0. Define

M (d)
w(x) = (x) + z(x), R+ : < (2.18)
z(d)

Since (d) < M and z(d) > 0, it is possible to find such a . Using the fact that
z(x) < 0, x ha, ci and > 0 it will hold that:

x < c w(x) = (x) + z(x) < (x)< M , (2.19)


x = c w(x) = (x) + z(x) = (x)= M , (2.20)
x = d w(x) = (x) + z(x) < (x) + M (d)< M . (2.21)

This means that w(x) attains a maximum M M in ha, bi. But L[z] = L[] +
L[z] < 0. We started our discussion with the proof that when L[z] < 0, z can
not attain a maximum at an interior point, so we have a contradiction and the
only possibility is that M ; x ha, bi. For the case that d < c we can redefine
z(x) as
z(x) = e(xc) 1, (2.22)
and complete the proof in the same way as for the case c < d. Additionally the
occurrence of stationary points on the boundary of the interval can be excluded.
Hence, if
u,1 ,11 0, x ,
local maxima can occur only at the boundaries. This is called the maximum prin-
ciple. By reversing signs we see that if q(x) 0, x there cannot be an
interior minimum. If q(x) 0 there cannot be an interior extremum, so that
the solution is monotone (in one dimension). The maximum principle gives us
important information about the solution, without having to determine the so-
lution. Such information is called a priori information and can help us in the
design of numerical methods. Furthermore, take note of the fact that not all
PDEs have solutions that conform to the maximum principle. For instance hy-
perbolic (systems of) equations do not confirm to the maximum principle (wave
20 2. The stationary convection-diffusion equation in one dimension

equation, instationary Euler equations

If the exact solution has no local maximum or minimum, then wiggles (oscilla-
tions) in a numerical solution are nor physical, but must be a numerical artifact.

This concludes our discussion of analytic aspects (especially for  1) of the


convection-diffusion equation. We now turn to numerical solution methods.

Exercise 2.2.1. Show that equation (2.3) is in conservation form, and that
(2.4) is not.
Exercise 2.2.2. Show that the solution (2.10) satisfies

|(x)| |(x)|
= 1, < (1 + e1/ ).
|a| |b|
Hence, the solution is relatively insensitive to the boundary data a and b for all
> 0.
Exercise 2.2.3. Show that with u = 1, = constant and q = 0 the solution
of equation (2.1) is given by

(x) = a + be1/ (1 ex/ ) ,

so that
(1)
= (e1/ 1) .
b
Why does this mean that the problem is ill-posed for  1?
Exercise 2.2.4. Show that it follows from the exact solution (2.12) that

|(x)| |(x)|
<2, <1.
|a| |b|
2

2.3 Finite volume method


We now describe how equation (2.1) is discretized with the finite volume method.
We rewrite (2.1) as

L (u),1 (,1 ),1 = q, x (0, 1) . (2.23)

Let x = 0 be an inflow boundary, i.e. u(0) > 0. As seen before, it would be


wrong to prescribe a Neumann condition (if  1), so we assume a Dirichlet
condition:
(0) = a . (2.24)
Let x = 1 be an outflow boundary, i.e. u(1) > 0. We prescribe either a Neumann
condition:
,1 (1) = b , (2.25)
2.3 Finite volume method 21

or a Dirichlet condition:
(1) = b . (2.26)
The finite volume method works as follows. The domain is subdivided in
segments j , j = 1, , J, as shown in the upper part of Fig. 2.1. The segments
are called cells or finite volumes or control volumes , and the segment length,
denoted by hj , is called the mesh size. The coordinates of the centers of the

1111
0000
0
1 1
0000
1111
0
0000
1111
0
1
0000
1111
0
1 0000
1111
0
1
0000
1111
0
1
0000
1111
0
1
0000
1111
0
1 1 j J 0000
1111
0
1
0000
1111
0
1
0000
1111
0
1 1
0
0
1 1
0
0
1 1
0
0
1 0000
1111
0
1
0000
1111
0
1
0000
1111
0
1 0
1 0
1 0
1 0000
1111
0
1
0000
1111
0
1
0000
1111
0
1 0
1 0
1 0
1 0000
1111
0
1
0000
1111
0
1
0000
1111
0
1 0000
1111
0
1
0000
1111
0
1

1111
0000
0
1 0000
1111
0
1
0000
1111
0
1 0000
1111
0
1
0000
1111
0
1
0000
1111
0
1 1 j 0000
1111
0
1
0000
1111
0
1
0000
1111
0
1 J
0000
1111
0
1
1111111111111111111111111111111111
0000000000000000000000000000000000
0000
1111
0
1 0000
1111
0
1
0000
1111
0
1 0000
1111
0
1
0000
1111
0
1
0000
1111
0
1 0000
1111
0
1
0000
1111
0
1
0000
1111
0
1 0000
1111
0
1
Figure 2.1. Non-uniform cell-centered grid (above) and vertex-centered grid (below).

cells are called xj , the size of j is called hj and the coordinate of the interface
between j and j+1 is called xj+1/2 . The cell centers are frequently called grid
points or nodes. This is called a cell-centered grid; the nodes are in the centers of
the cells and there are no nodes on the boundaries. In a vertex-centered grid one
first distributes the nodes over the domain and puts nodes on the boundary; the
boundaries of the control volumes are centered between the nodes; see the lower
part of Fig. 2.1. We continue with a cell-centered grid. We integrate equation
(2.23) over j and obtain:
Z Z
Ld = F |j1/2 = qd
j+1/2
= hj qj ,
j j

j+1/2
with F |j1/2 Fj+1/2 Fj1/2 , Fj+1/2 = F (xj+1/2 ), F (x) u d/dx.
Often, F (x) is called the flux. The following scheme is obtained:
Lh j Fj+1/2 Fj1/2 = hj qj , j = 1, , J . (2.27)
We will call u the convective flux and d/dx the diffusive flux.

Conservative scheme

Summation of equation (2.27) over all cells gives


J
X
Lh j = FJ+1/2 F1/2 . (2.28)
j=1

We see that only boundary fluxes remain, to that equation (2.28) mimics the
conservation property (2.2) of the differential equation. Therefore the scheme
(2.27) is called conservative. This property is generally beneficial for accuracy
and physical realism.
22 2. The stationary convection-diffusion equation in one dimension

Discretization of the flux

To complete the discretization, the flux Fj+1/2 has to be approximated in terms


of neighboring grid function values; the result is called the numerical flux. Cen-
tral discretization of the convection term is done by approximating the convec-
tive flux as follows:
1
(u)j+1/2
= uj+1/2 j+1/2 , j+1/2 = (j + j+1 ) . (2.29)
2
Since u(x) is a known coefficient, uj+1/2 is known. One might think that better
accuracy on nonuniform grids is obtained by linear interpolation:
hj j+1 + hj+1 j
j+1/2 = . (2.30)
hj + hj+1

Surprisingly, the scheme (2.27) is less accurate with (2.30) than with (2.29), as

we will see. This is one of the important lessons that can be learned from the
present simple one-dimensional example.

Upwind discretization is given by


1 1
(u)j+1/2
= (uj+1/2 + |uj+1/2 |)j + (uj+1/2 |uj+1/2 |)j+1 . (2.31)
2 2
This means that u is biased in upstream direction (to the left for u > 0, to the
right for u < 0), which is why this is called upwind discretization. A complete
family of approximations can be defined based on a single parameter , the
so-called -scheme:

(u)j+1/2
= (2.32)
 
(j + j+1 ) 1
uj+1/2 + (j1 + 2j j+1 ) , uj+1/2 0
2 4
(u)j+1/2
=
 
(j + j+1 ) 1
uj+1/2 + (j + 2j+1 j+2 ) , uj+1/2 0
2 4

A very similar definition is that of the scheme:

(u)j+1/2
= (2.33)
 
(j + j+1 )
uj+1/2 (j+1 2j + j1 ) , uj+1/2 0(u)j+1/2
=
2
 
(j + j+1 )
uj+1/2 (j 2j+1 + j+2 ) , uj+1/2 0
2
Important values of these parameters are given in Table
The diffusive part of the flux is approximated by

1
(),1 j+1/2 = j+1/2 (j+1 j )/hj+1/2 , hj+1/2 = (hj + hj+1 ) . (2.34)
2
2.3 Finite volume method 23

Scheme
Central 1 0
1 1
QUICK 2 8
1
Second order upwind -1 2
1 1
Third order upwind 3 6

Table 2.1. Important values of the parameters / for the convection schemes (2.32)
and (2.33).

Boundary conditions

At x = 0 we cannot approximate the diffusive flux by (2.34), since the node x0


is missing. We use the Dirichlet boundary condition, and write:

(),1 1/2

= 21/2 (1 a)/h1 . (2.35)

This is a one-sided approximation of (,1 )1/2 , which might impair the accuracy
of the scheme. We will investigate later whether this is the case or not. The
convective flux becomes simply

(u)1/2
= u1/2 a . (2.36)

Next, consider the boundary x = 1 . Assume we have the Neumann condition


(2.25). The diffusive flux is given directly by the Neumann condition:

(),1 J+1/2

= J+1/2 b. (2.37)

Since x = 1 is assumed to be an outflow boundary, we have uJ+1/2 > 0, so that


for the upwind convective flux (2.31) an approximation for J+1/2 is not re-
quired. For the central convective fluxes (2.29) or (2.30) we approximate J+1/2
with extrapolation, using the Neumann condition:

J+1/2
= J + hJ b/2 . (2.38)

The Dirichlet condition (2.26) is handled in the same way as at x = 0.

The numerical scheme

The numerical flux as specified above can be written as

Fj+1/2 = j0 j + j+1
1
j+1 , j = 1, , J 1 ,
(2.39)
F1/2 = 11 1 + 0 , FJ+1/2 = J0 J + 1 ,

where 0,1 are known terms arising from the boundary conditions. For example,
for the upwind scheme we obtain the results specified in Exercise 2.3.2.

For future reference, we also give the coefficients for the central schemes. For
the central scheme (2.29) we find:
24 2. The stationary convection-diffusion equation in one dimension

1
j0 = uj+1/2 + (/h)j+1/2 , j = 1, , J 1 ,
2
1 1
j+1 = uj+1/2 (/h)j+1/2 , j = 1, , J 1 , 11 = 21/2 /h1 ,
2 (2.40)
0 = (u1/2 + 21/2 /h1 )a ,
J0 = uJ+1/2 , 1 = uJ+1/2 hJ b/2 J+1/2 b (Neumann),
J0 = 2J+1/2 /hJ , 1 = (uJ+1/2 2J+1/2 /hJ )b (Dirichlet).

For the central scheme (2.30) we find:


hj+1
j0 = uj+1/2 + (/h)j+1/2 , j = 1, , J 1 ,
2hj+1/2
(2.41)
1 hj
j+1 = uj+1/2 (/h)j+1/2 , j = 1, , J 1 .
2hj+1/2

The other coefficients (at the boundaries) are the same as in equation (2.40).
On a uniform grid the central schemes (2.40) and (2.41) are identical.

Substitution of equations (2.39)(2.41) in equation (2.27) gives the following


linear algebraic system:

Lh j = j1 j1 + j0 j + j1 j+1 = qj , j = 1, , J , (2.42)

with 11 = J1 = 0. This is called the numerical scheme or the finite volume


scheme. Its coefficients are related to those of the numerical flux (2.80) (2.41)
by
j1 = j1
0
, j = 2, , J ,
j0 = j0 j1 , j = 1, , J , (2.43)
j1 = 1
j+1 , j = 1, , J 1 .

The right-hand side is found to be


qj = hj qj , j = 2, , J 1 ,
(2.44)
q1 = h1 q1 + 0 , qJ = hJ qJ 1 .

Stencil notation

The general form of a linear scheme is


X
Lh j = jk j+k = qj , (2.45)
kK

with K some index set. For example, in the case of (2.45), K = {1, 0, 1}.
The stencil [Lh ] of the operator Lh is a tableau of the coefficients of the scheme
of the following form:
[Lh ]j = [ j1 j0 j1 ] . (2.46)
We will see later that this is often a convenient way to specify the coefficients.
Equation (2.45) is the stencil notation of the scheme.
2.3 Finite volume method 25

The matrix of the scheme

In matrix notation the scheme can be denoted as



1 q1
Ay = b , y = ... , b = .. , (2.47)

.
J qJ

where A is the following tridiagonal matrix:


0
1 11

0 0
1 0 ..
2 2 21

.

A= 0
. .. . .. . .. .

(2.48)
0
.
. 1

. 0 1
J1 J1 J1
0 0 J1 J0

Vertex-centered grid

In the interior of a vertex-centered grid the finite volume method works just as
in the cell-centered case, so that further explanation is not necessary. But at the
boundaries the procedure is a little different. If we have a Dirichlet condition,
for example at x = 0, then an equation for 1 is not needed, because 1 is
prescribed (x1 is at the boundary, see Fig. 2.1). Suppose we have a Neumann
condition at x = 1. Finite volume integration over the last control volume (which
has xJ as the right end point, see Fig. 2.1) gives:

Lh J FJ FJ1/2 = hJ qJ ,

where we approximate FJ as follows, in the case of the central scheme for con-
vection, for example:
FJ = uJ J J b ,
where b is given in (2.25).

Symmetry

When the velocity u 0, the convection-diffusion equation reduces to the diffu-


sion equation, also called heat equation. According to equations (2.39)(2.41)
1
we have in this case j1 = j1
0
, so that (2.43) gives j1 = j+1 , which makes
the matrix A symmetric. This holds also in the vertex-centered case. Symme-
try can be exploited to save computer memory and to make solution methods
more efficient. Sometimes the equations are scaled to make the coefficients of
size O(1); but this destroys symmetry, unless the same scaling factor is used for
every equation.
26 2. The stationary convection-diffusion equation in one dimension

Two important questions

The two big questions asked in the numerical analysis of differential equations
are:
How well does the numerical solution approximate the exact solution of equa-
tion (2.23)?
How accurately and efficiently can we solve the linear algebraic system (2.47)?
These questions will come up frequently in what follows. In the ideal case one
shows theoretically that the numerical solution converges to the exact solution
as the mesh size hj 0. In the present simple case, where we have the exact
solution (2.6), we can check convergence by numerical experiment.

Numerical experiments on uniform grid

We take u = 1, constant, q = 0 and the grid cell-centered and uniform,


with hj = h = 1/12. We choose Dirichlet boundary conditions (2.11) with
a = 0.2, b = 1. The exact solution is given by (2.12). The numerical results in
this section have been obtained with the MATLAB code cd1 . Fig. 2.2 gives
results for two values of the Peclet number (remember that = 1/Pe). We see

Pe=10, 12 cells Pe=40, 12 cells


1 1

0.9 0.8

0.8
0.6
0.7
0.4
0.6
0.2
0.5
0
0.4

0.3 0.2

0.2 0.4
0 0.2 0.4 0.6 0.8 1 0 0.2 0.4 0.6 0.8 1
Figure 2.2. Exact solution () and numerical solution (*).

a marked difference between the cases Pe = 10 and Pe = 40. The numerical


solution for Pe = 40 is completely unacceptable. We will now analyze why this
is so and look for remedies.

The maximum principle

In Sect. 2.2 we saw that according to the maximum principle, with q = 0


the solution of equation (2.23) cannot have local extrema in the interior. This
is confirmed of course in Fig. 2.2. However, the numerical solution for Pe =
40 shows local extrema. These undesirable numerical artifacts are often called
wiggles. It is desirable that the numerical scheme satisfies a similar maximum
principle as the differential equation, so that artificial wiggles are excluded.
This is the case for positive schemes, defined below. Let the scheme be written
2.3 Finite volume method 27

in stencil notation:
X
Lh j = jk j+k = qj , j = 1, , J .
kK

Definition 2.3.1. The operator Lh is of positive type if


X
jk = 0, j = 2, , J 1 (2.49)
kK

and
jk < 0, k 6= 0, j = 2, , J 1 . (2.50)
Note that a condition is put on the coefficients only in the interior. The following
theorem says that schemes of positive type satisfy a similar maximum principle
as the differential equation.

Theorem 2.3.1. Discrete maximum principle.


If Lh is of positive type and

Lh j 0, j = 2, , J 2 ,

then j max{1 , J }.
Corollary Let conditions (2.49) and (2.50) also hold for j = J. Then j 1 .

A formal proof is given in Sect. 4.4 of Wesseling (2001), but it is easy to see
that the theorem is true. Let K = {1, 0, 1}. We have for every interior grid
point xj :
j w1 j1 + w1 j+1 , w1 j1 /j0 .
Since w1 + w1 = 1 and w1 > 0, j is a weighted average of its neighbors j1
and j+1 . Hence, either j < max{j1 , j+1 } or j = j1 = j+1 .

Let us now see whether the scheme used for Fig. 2.2 is of positive type. Its
stencil is given by equation (2.81) in the exercises at the end of the chapter:
 
1 1
[Lh ] = u 2 u . (2.51)
2 h h 2 h
We see that this scheme is of positive type if and only if
|u|h
p<2, p . (2.52)

The dimensionless number p is called the mesh Peclet number.

For the left half of Fig. 2.2 we have p = 10/12 < 2, whereas for the right
half p = 40/12 > 2, which explains the wiggles. In general, Pe = U L/ and
p = U h/, so that p = Peh/L, with L the length of the domain and U
representative of the size of u, for example U = max[u(x) : x ]. and for p < 2
we must choose h small enough: h/L < 2/Pe. Since in practice Pe is usually very
large, as shown in Sect. 1.6, this is not feasible (certainly not in more than one
dimension), due to computer time and memory limitations. Therefore a scheme
28 2. The stationary convection-diffusion equation in one dimension

is required that is of positive type for all values of Pe. Such a scheme is obtained
if we approximate the convective flux u such that a non-positive contribution
is made to j1 . This is precisely what the upwind scheme (2.31) is about. For
the problem computed in Fig. 2.2 its stencil is, since u > 0:
h i
[Lh ] = u u+2 . (2.53)
h h h
It is easy to see that this scheme is of positive type for all Pe. Results are given in
Fig. 2.3. We see that wiggles are absent, and that the numerical solution satisfies

Pe=10, 12 cells, Upwind scheme Pe=40, 12 cells, Upwind scheme


1 1

0.9 0.9

0.8 0.8

0.7 0.7

0.6 0.6

0.5 0.5

0.4 0.4

0.3 0.3

0.2 0.2
0 0.2 0.4 0.6 0.8 1 0 0.2 0.4 0.6 0.8 1
Figure 2.3. Exact solution () and numerical solution (*).

the maximum principle. But the solution is smeared near the outflow boundary.
It is as if the numerical solution has a smaller Peclet number than the exact
solution. This is because the upwind scheme introduces numerical diffusion; the
viscosity is increased with an artificial viscosity coefficient a = uh/2. To see
this, just replace by +a in the stencil of the central scheme (2.51): it becomes
identical to the stencil of the upwind scheme (2.53).

Local grid refinement

The preceding figures show for Pe = 40 a rapid variation of the exact solution in
a narrow zone near the outflow boundary x = 1. This zone is called a boundary
layer. From the exact solution (2.13) it follows that the boundary layer thickness
satisfies
= O() = O(Pe1 ). (2.54)
(Landaus order symbol O is defined later in this section). We will see later
how to estimate the boundary layer thickness when an exact solution is not
available. It is clear that to have reasonable accuracy in the boundary layer, the
local mesh size must satisfy h < , in order to have sufficient resolution (i.e.
enough grid points) in the boundary layer. This is not the case in the right parts
of the preceding figures. To improve the accuracy we refine the grid locally in
the boundary layer. We define 6; the factor 6 is somewhat arbitrary and
has been determined by trial and error. We put 6 equal cells in (0, 1 ) and 6
equal cells in (1 , 1). The result is shown in Fig. 2.4. Although the total num-
ber of cells remains the same, the accuracy of the upwind scheme has improved
2.3 Finite volume method 29

Pe=40, 12 cells, Upwind scheme Pe=400, 12 cells, Upwind scheme


1 1

0.9 0.9

0.8 0.8

0.7 0.7

0.6 0.6

0.5 0.5

0.4 0.4

0.3 0.3

0.2 0.2
0 0.2 0.4 0.6 0.8 1 0 0.2 0.4 0.6 0.8 1
Figure 2.4. Exact solution () and numerical solution (*) with local grid refinement;
upwind scheme

significantly. Even for Pe = 400, in which case the boundary layer is very thin,
the accuracy is good.

Fig. 2.5 gives results for the central scheme (2.29). Surprisingly, the wiggles

Pe=40, 12 cells, Central scheme (2.20) Pe=400, 12 cells, Central scheme (2.20)
1 1

0.9 0.9

0.8 0.8

0.7 0.7

0.6 0.6

0.5 0.5

0.4 0.4

0.3 0.3

0.2 0.2

0.1 0.1
0 0.2 0.4 0.6 0.8 1 0 0.2 0.4 0.6 0.8 1

Figure 2.5. Exact solution () and numerical solution (*) with local grid refinement;
central scheme (2.29)

which destroyed the accuracy in Fig. 2.2 have become invisible. In the refine-
ment zone the local mesh Peclet number satisfies p = 1, which is less than 2, so
that according to the maximum principle there can be no wiggles in the refine-
ment zone (see equation (2.52) and the discussion preceding (2.52)). However,
inspection of the numbers shows that small wiggles remain outside the refine-
ment zone.

Fig. 2.6 gives results for the central scheme (2.30). This scheme might be ex-
pected to be more accurate than central scheme (2.29), because linear interpo-
lation to approximate j+1/2 is more accurate than averaging on a nonuniform
grid. However, we see that for Pe = 400 the opposite is true! Clearly, we are
in need of theoretical error analysis. This subject will be touched upon later.
A preliminary explanation is as follows. Let the boundary of the refinement
zone be located between the nodes xj and xj+1 . Call the mesh size inside and
outside the refinement zone h and H, respectively. The stencil of the central
30 2. The stationary convection-diffusion equation in one dimension

Pe=40, 12 cells, Central scheme (2.21) Pe=400, 12 cells, Central scheme (2.21)
1 1

0.9 0.9

0.8 0.8

0.7 0.7

0.6 0.6

0.5 0.5

0.4 0.4

0.3 0.3

0.2 0.2

0.1 0.1
0 0.2 0.4 0.6 0.8 1 0 0.2 0.4 0.6 0.8 1

Figure 2.6. Exact solution () and numerical solution (*) with local grid refinement;
central scheme (2.30)

scheme scheme (2.29) at xj follows from equation (2.40) as:


 
1 2 1 2
[Lh ] = + . (2.55)
2 H H h+H 2 h+H
For the central scheme (2.30) we find from equation (2.41):
 
1 1 h 2 H 2
[Lh ] = + + + .
2 H 2 h+H H h+H h+H h+H
(2.56)
According to definition 2.3.1, one of the necessary conditions for a positive
scheme scheme is that the third element in the above stencils is non-positive.
For  1 (and consequently h/H  1) this element is about 1/2 in (2.55)
and 1 in (2.56), which is worse. Furthermore, in (2.56) the central element is
negative. We see that (2.56) deviates more from the conditions for a positive
scheme than (2.55), so that it is more prone to wiggles.

Peclet-uniform accuracy and efficiency

The maximum norm of the error ej (xj ) j is defined as


kek max{|ej |, j = 1, , J},
where (x) is the exact solution. Table 2.2 gives results. The number of cells is
the same as in the preceding figures. For Pe = 10 a uniform grid is used, for the
other cases the grid is locally refined, as before. We see that our doubts about

Scheme Pe=10 Pe=40 Pe=400 Pe=4000


Upwind .0785 .0882 .0882 .0882
Central (2.20) .0607 .0852 .0852 .0852
Central (2.21) .0607 .0852 .0856 .3657

Table 2.2. Maximum error norm; 12 cells.

the central scheme (2.30) are confirmed. For the other schemes we see that kek
2.3 Finite volume method 31

is almost independent of Pe. This is due to the adaptive (i.e. Pe-dependent) lo-
cal grid refinement in the boundary layer. Of course, since the number of cells
J required for a given accuracy does not depend on Pe, computing work and
storage are also independent of Pe. We may conclude that computing cost and
accuracy are uniform in Pe.

This is an important observation. A not uncommon misunderstanding is that


numerical predictions of high Reynolds (or Peclet in the present case) num-
ber flows are inherently untrustworthy, because numerical discretization errors
(numerical viscosity) dominate the small viscous forces. This is not true, pro-
vided appropriate measures are taken, as was just shown. Local grid refinement
in boundary layers enables us to obtain accuracy independent of the Reynolds
number. Because in practice Re (or its equivalent such as the Peclet number) is
often very large (see Sect. 1.5) it is an important (but not impossible) challenge
to realize this also in more difficult multi-dimensional situations. An analysis of
Pe-uniform accuracy for a two-dimensional singular perturbation problem will
be given in Sect. 3.3.

Global and local truncation error

By using Taylors formula (see below) it is easy to see that the numerical flux
as specified above (equations(2.292.34)) approaches the exact flux as the grid
is refined, i.e. as

0, max{hj , j = 1, , J} . (2.57)

But does this mean that the difference between the numerical and exact solution
goes to zero? Surprisingly, this is no simple matter, but one of the deepest
questions in numerical analysis. We will present only some basic considerations.
We define
Definition 2.3.2. Global truncation error
The global truncation error is defined as

ej (xj ) j , j = 1, , J ,

with (x) the exact solution.


Truncation errors are errors that are caused by truncation (to truncate means
to shorten by cutting off) of an infinite process. The process we have in mind
here is the limit 0; we stop at a finite value of . Rounding errors are
the errors that are caused by the finite precision approximation of real numbers
in computer memories. In the numerical approximation of differential equations
these are usually much smaller than truncation errors. Here we just assume zero
rounding error.

Obviously, the global truncation error is what we are after, but it cannot be esti-
mated directly, because the exact solution is not available. Therefore a quantity
is introduced that can be estimated, namely
Definition 2.3.3. Local truncation error
The local truncation error of the discrete operator Lh is defined as
32 2. The stationary convection-diffusion equation in one dimension

j Lh ej , j = 1, , J . (2.58)

The exact solution to the differential equation is not a solution of the discrete
differential operator: this mismatch is the local truncation error:

j = Lh [(xj ) j ] = Lh [(xj )] L[j ] = Lh [(xj )] , j = 1, , J . (2.59)

It follows that e = L1
h , with e and algebraic vectors with elements ej , j .
Hence
kek kL1
h kk k .

This suggests that a scheme with smaller k k will have a smaller kek than a
scheme with a larger k k. But this need not be so, because Lh is different for
the two schemes, so that kL1
h k is different. To improve our insight in accuracy,
we will now dive into a somewhat complicated but elementary analysis.

Estimate of local truncation error in the interior

The purpose of the following elementary but laborious analysis is to eliminate


two common misunderstandings. The first is that the meshwidth of grids should
vary smoothly for accuracy; this is not true in general, at least not for positive
schemes (Definition 2.3.1). The second is that a large local truncation error at
a boundary causes a large global truncation error ; this is also not true in general.

We begin with estimating the local truncation error. For simplicity u and
are assumed constant. We select the central scheme for convection. The scheme
(2.51) with a Dirichlet condition at x = 0 and a Neumann condition at x = 1
(cf. equation (2.40)) and defining hj+1/2 = 12 (hj + hj+1 ) (Figure 2.7) can be
written as
     
u 2 u 2
Lh 1 + + 1 + 2 = h1 q1 + u + a,
2 h3/2 h1 2 h3/2 h1
   
u 1 1
Lh j + j1 + + j
2 hj1/2 hj1/2 hj+1/2
 
u
+ j+1 = hj qj , j = 2, , J 1 ,
2 hj+1/2
   
u u
Lh J + J1 + + J
2 hJ1/2 2 hJ1/2
u 
=hJ qJ hJ b .
2
(2.60)

Here we made use of the following approximations for the fluxes at the boundary
points:
2 (1 a)
F0 = ua + (2.61)
h1
 
bhJ
FJ+ 21 = J + u + b (2.62)
2
2.3 Finite volume method 33

hj hj+1
111
000 111
000
000
111
000
111 000
111
000
111
000
111 000
111
000
111
000
111 000
111
000
111
000
111 j j+1 000
111
000
111 000
111
hj+1/2

1
Figure 2.7. Definition of hj+1/2 = 2
(hj + hj+1 )

Taylors formula

To estimate the local truncation error we need Taylors formula:


n1
X 1 dk f (x0 ) k 1 dn f ()
f (x) = f (x0 ) + (x x 0 ) + (x x0 )n (2.63)
k! dxk n! dxn
k=1

for some between x and x0 . Of course, f must be sufficiently differentiable.


This gives for the exact solution, writing (k) for dk (x)/dxk ,
1 1
(xj1 ) = (xj ) hj1/2 (1) (xj ) + h2j1/2 (2) (xj ) h3j1/2 (3) (xj )
2 6
1 4 (4) 5
+ hj1/2 (xj ) + O(hj1/2 ) ,
24
(2.64)

where O is Landaus order symbol, defined as follows:


Definition 2.3.4. Landaus order symbol
A function f (h) = O(hp ) if there exist a constant M independent of h and a
constant h0 > 0 such that
|f (h)|
< M, h (0, h0 ) .
hp
The relation f (h) = O(hp ) is pronounced as f is of order hp . It is a common
misconception in some engineering communities that of the order of gives an
indication of the magnitude, whereas it only concerns the asymptotic behavior
in the limit h 0.

Estimate of local truncation error, continued

We will now see that although we do not know the exact solution, we can
nevertheless determine the dependence of j on hj . We substitute (2.64) in
Lh ((xj ), and obtain, after some tedious work that cannot be avoided, for j =
2, , J 1:
34 2. The stationary convection-diffusion equation in one dimension

Lh (xj ) = Lh (xj ) + O(4 ) ,


1
Lh (xj ) qj (hj1/2 + hj+1/2 )
2 
1 (2) 1 (3) (2.65)
+ u (h2j+1/2 h2j1/2 )
4 6
 
1 (3) 1 (4)
+ u (h3j+1/2 + h3j1/2 ) ,
12 24

where (n) = dn (xj )/dxn . We have

j = Lh ej = Lh [(xj ) j ] = Lh (xj ) hj qj + O(4 ) ,

so that we obtain:

1
j = qj ( hj1/2 2hj + hj+1/2 )
2
 
1 (2) 1 (3)
+ u (h2j+1/2 h2j1/2 ) (2.66)
4 6
 
1 1
+ u(3) (4) (h3j+1/2 + h3j1/2 ) + O(4 ) .
12 24
The grid is called smooth if the mesh size hj varies slowly, or more precisely, if

|hj+1/2 hj1/2 | = O(2 ) and |hj1/2 2hj + hj+1/2 | = O(3 ) .

The grid is called rough if the mesh size hj varies abruptly, or more precisely, if

|hj+1/2 hj1/2 | = O() and |hj1/2 2hj + hj+1/2 | = O() .

Therefore on smooth grids j = O(3 ), but on rough grids j = O(). There-


fore it is often thought that one should always work with smooth grids for better
accuracy, but, surprisingly, this is not necessary in general. We will show why
later. Note that the locally refined grid used in the preceding numerical experi-
ments is rough, but nevertheless the accuracy was found to be satisfactory.

Estimate of local truncation error at the boundaries

For simplicity we now assume the grid uniform, with hj h. Let the scheme be
cell-centered. We start with the Dirichlet boundary x = 0. Proceeding as before,
we find using Taylors formula for (x2 ) in the first equation of (2.60),

Lh (x1 ) = Lh (x1 ) + O(h2 ) ,


1
Lh (x1 ) (u + 2/h)(x1 ) (1) + q1 h ,
2
where (1) = d(x1 )/dx, and (x) is the exact solution. We write

1 = Lh [(x1 ) 1 ] = Lh (x1 ) hq1 (u + 2/h)a + O(h2 )


1
= (u + 2/h)[(x1 ) a] (1) hq1 + O(h2 ) .
2
2.3 Finite volume method 35

We use Taylors formula for a = (0):


1 1
a = (0) = (x1 ) h(1) + h2 (2) + O(h3 )
2 8
and find
h (2)
1 = + O(h2 ) . (2.67)
4
In the interior we have j = O(h3 ) on a uniform grid, as seen from equation
(2.66). Hence, because in the cell centered case the unknowns do not coincide
with the boundary, we have a nonzero local truncation error at the boundary,
that is even larger than the local truncation error in the interior domain....
However, it is not necessary to improve the local accuracy near a Dirichlet
boundary, which is one of the important messages of this section; we will show
this below. But first we will estimate the local truncation error at the Neumann
boundary x = 1. By using Taylors formula for (xJ1 ) in the third equation of
(2.60) we get

Lh (xJ ) = Lh (xJ ) + O(h3 ) ,


1 u 
Lh (xJ ) (1) + qJ h (2) (3) h2 + O(h3 ) ,
2 4 6
where (n) = dn (xJ )/dxn . We write

J = Lh [(xJ ) J ] = Lh (xJ ) hJ qJ + (uhJ /2 )b + O(h3 )


= (1) qJ h/2 (u(2) /4 (3) /6)h2 + (uh/2 )b + O(h3 ) .

We use Taylors formula for b = d(1)/dx:


1 1
b = (1) + h(2) + h2 (3) + O(h3 )
2 8
and find
1 (3) 2
J = h + O(h3 ) . (2.68)
24

Error estimation with the maximum principle

The student is not expected to be able to carry out the following error analysis
independently. This analysis is presented merely to make our assertions about
accuracy on rough grids and at boundaries really convincing. We will use the
maximum principle to derive estimates of the global truncation error from esti-
mates of the local truncation error.

By e < E we mean ej < Ej , j = 1, , J and by |e| we mean the grid function


with values |ej |. We recall that the global and local truncation error are related
by
Lh ej = j , j = 1, , J . (2.69)
Suppose we have a grid function Ej , which will be called a barrier function,
such that
Lh Ej |j |, j = 1, , J . (2.70)
36 2. The stationary convection-diffusion equation in one dimension

We are going to show: |e| E. From (2.69) and (2.70) it follows that

Lh (ej Ej ) 0, j = 1, , J .

Let the numerical scheme (2.60) satisfy the conditions of the corollary of The-
orem 2.3.1; this is the case if
|u|hj+1/2
< 2, j = 1, , J 1 . (2.71)

Then the corollary says

ej Ej e1 E1 , j = 2, , J . (2.72)

Next we show that |e1 | E1 . From Lh (e1 E1 ) 0 it follows (with the use
of (2.72) for j = 2) that

a(e1 E1 ) b(e2 E2 ) b(e1 E1 ) ,


a = u/2 + 3/h1 , b = /h1 u/2 ,

where we assume h2 = h1 . Note that 0 < b < a. Therefore e1 E1 0 , hence


|e1 | E1 . Substitution in (2.72) results in

|ej | Ej , j = 1, , J . (2.73)

which we wanted to show. It remains to construct a suitable barrier function


Ej . Finding a suitable Ej is an art.

Global error estimate on uniform grid

First, assume the grid is uniform: hj = h. We choose the barrier function as


follows:
Ej = M (xj ), (x) 1 + 3x x2 , (2.74)
with M a constant still to be chosen. We find (note that u > 0; otherwise the
boundary conditions would be ill-posed for  1, as seen in Sect. 2.2):

Lh (x1 ) = u(1 + 3h 5h2 /4) + (2 + 3h2 /2) > 2/h for h small enough ,
h
Lh (xj ) = uh(3 2xj ) + 2h > 2h, j = 2, , J 1 ,
Lh (xJ ) = (1 + 2h) + uh(1/2 + h) > .

According to equations (2.66)(2.68) there exist constants M1 , M2 , M3 such


that for h small enough

1 < M1 h ,
j < M2 h3 , j = 2, , J 1 ,
2
J < M3 h .

Hence, with
h2
M= max{M1 /2, M2 /2, M3 }

2.3 Finite volume method 37

condition (2.70) is satisfied, so that

|e| < E = O(h2 ) .

This shows that the fact that the local truncation errors at the boundaries are
of lower order than in the interior does not have a bad effect on the global
truncation error.

Global error estimate on nonuniform grid

Next, we consider the effect of grid roughness. From equation (2.66) we see that
in the interior
j = O(), = max{hj , j = 1, J} .
We will show that nevertheless e = O(2 ), as for a uniform grid. The barrier
function used before does not dominate sufficiently. Therefore we use the
following stratagem. Define the following grid functions:
j
X j
X
1j h2j , 2j h3k1/2 , 3j (h2k + h2k1 )hk1/2 ,
k=1 k=1

where h0 0. We find with Lh defined by (2.60) and k (x), k = 1, 2, 3 smooth


functions to be chosen later:

Lh (1 (xj )1j ) = 1 (xj )(2hj+1 + 4hj 2hj1 ) + (2.75)


d1 (xj ) 1
+ { u1 (xj )}(h2j1 h2j+1 ) + O(3 ) ,
dx 2
Lh (2 (xj )2j ) = 2 (xj )(h2j1/2 h2j+1/2 ) + O(3 ) , (2.76)
Lh (3 (xj )3j ) = 3 (xj )(h2j1 h2j+1 ) + O(3 ) . (2.77)

We choose
q(x) 1 u
1 = , 2 = (3) (2) ,
8 6 4
d1 u
3 = + 1
dx 2
and define
ekj k (xj )kj , k = 1, 2, 3 .
Remembering (2.69), comparison of (2.75)(2.77) with (2.66) shows that

Lh (ej e1j e2j e3j ) = O(3 ) . (2.78)

The right-hand side is of the same order as the local truncation error in the
uniform grid case, and can be dominated by the barrier function (2.74) with
M = C2 , with C a constant that we will not bother to specify further. For
simplicity we assume that h2 = h1 and hJ1 = hJ , so that the situation at the
boundaries is the same as in the case of the uniform grid. Hence

|ej e1j e2j e3j | < C2 (1 + 3xj x2j )


38 2. The stationary convection-diffusion equation in one dimension

Since ekj = O(2 ) , k = 1, 2, 3 we find

ej = O(2 ) . (2.79)

which is what we wanted to show. Hence, the scheme defined by (2.60) has sec-
ond order convergence on arbitrary grids, so that its widespread application is
justified. However, recall that the whole proof depends on the numerical scheme
being of positive type, and the continuous equation obeying the maximum prin-
ciple.

Vertex-centered grid

On a vertex-centered grid we have grid points on the boundary. Therefore the


Dirichlet boundary condition at x = 0 gives zero local truncation error, which
is markedly better than (2.67). Furthermore, because the cell boundaries are
now midway between the nodes, the cell face approximation (2.29) is much
more accurate. Indeed, the local truncation error is an order smaller on rough
grids for vertex-centered schemes; we will not show this. Therefore it is some-
times thought that vertex-centered schemes are more accurate than cell-centered
schemes. But this is not so. In both cases, e = O(2 ). Because this is most
surprising for cell-centered schemes, we have chosen to elaborate this case. In
practice, both types of grid are widely used.

Exercise 2.3.1. Derive equation (2.30). (Remember that linear interpolation


is exact for functions of type f (x) = a + bx).
Exercise 2.3.2. Assume u > 0. Show that for the upwind scheme the coeffi-
cients in the numerical flux are:
j0 = uj+1/2 + (/h)j+1/2 , j = 1, , J 1 ,
1
j+1 = (/h)j+1/2 , j = 1, , J 1 , 11 = 21/2 /h1 ,
0 = (u1/2 + 21/2 /h1 )a , (2.80)
J0 = uJ+1/2 , 1 = J+1/2 b (Neumann),
J0 = uJ+1/2 + 2J+1/2 /hJ , 1 = 2J+1/2 b/hJ (Dirichlet).

Exercise 2.3.3. Show that with and u constant on a uniform grid the stencil
for the central scheme with Dirichlet boundary conditions is given by
 
1 1
[Lh ]1 = 0 3 + u u ,
h 2 2 h
 
1 1
[Lh ]j = u 2 u , j = 2, , J 1 , (2.81)
2 h h 2 h
 
1 1
[Lh ]J = u 3 u 0 .
2 h h 2

Exercise 2.3.4. Show that in the refinement zone the local mesh Peclet number
satisfies p = 1.
39

Exercise 2.3.5. Derive equations (2.55) and (2.56).


Exercise 2.3.6. Implement a Neumann boundary condition at x = 1 in the
MATLAB program cd1. Derive and implement the corresponding exact solu-
tion. Study the error by numerical experiments. Implement wrong boundary
conditions: Neumann at inflow, Dirichlet at outflow. See what happens.
Exercise 2.3.7. In the program cd1 the size of the refinement zone is del = 6/pe .
Find out how sensitive the results are to changes in the factor 6.
Exercise 2.3.8. Let xj = jh (uniform grid) and denote (xj ) by j . Show:

h
(j j1 )/h = ,1 (xj )
,11 () , (2.82)
2
h2
(j+1 j1 )/(2h) = ,1 (xj ) + ,111 () , (2.83)
6
h2
(j1 2j + j+1 )/h2 = ,11 (xj ) + ,1111 () , (2.84)
12
(2.85)

with [xj1 , xj+1 ].

Exercise 2.3.9. Show that


sin x
= O( x).
x

Some self-test questions

When is the convection-diffusion equation in conservation form?

Write down the Burgers equation.

When do we call a problem ill-posed?

Formulate the maximum principle.

When is a finite volume scheme in conservation form?

What are cell-centered and vertex-centered grids?

What are the conditions for a scheme to be of positive type? Which desirable property do positive
schemes have?

Define the mesh-Peclet number.

Why is it important to have Peclet-uniform accuracy and efficiency?

Derive a finite volume scheme for the convection-diffusion equation.

Derive the condition to be satisfied by the step size h for the central scheme to be of positive type
on a uniform grid.

Define the global and local truncation error.

Derive the exact solution of the convection-diffusion equation.

Write down Taylors formula.


3. The stationary convection-diffusion equation
in two dimensions

3.1 Introduction

We will discuss only new aspects that did not come up in the one-dimensional
case. The equation to be studied is the two-dimensional stationary convection-
diffusion equation:

(u ), (, ), = q(x1 , x2 ) , (x1 , x2 ) (0, 1) (0, 1) . (3.1)

Note that the convection-diffusion equation is a model equation for us that helps
us understand the many mathematical properties it shares with the Navier-
Stokes equations. We solve for the unknown , while the velocity field u is given.
Think of as the local temperature, or the local concentration of a soluble salt
in a fluid.
Suitable boundary conditions are:

= f (x1 , x2 ) on i (Dirichlet), (3.2)


= f (x1 , x2 ) on o (Dirichlet) or (3.3)
n , = g(x1 , x2 ) on o (Neumann), (3.4)

where n is the outward unit normal on the boundary , i is the inflow


boundary (where n , < 0) and o is the remainder of , to be called the
outflow boundary.

We recall that = 1/Pe, with the Peclet number Pe  1. In the same way as
in Sect. 2.2 it can be shown that equation (3.1) is in conservation form.

As in one dimension, we have a maximum principle. We write (3.1) in the


following non-conservative form:

u , (, ), = q q u, . (3.5)

If q 0 then local maxima can only occur on the boundary . We will not
show this here; the interested reader may consult Sect. 2.4 of Wesseling (2001).

Purpose of this chapter

The purpose of this chapter is:


42 3. The stationary convection-diffusion equation in two dimensions

To explain how singular perturbation theory can be used to predict where for
Pe  1 thin layers (boundary layers) will occur, and to determine the order of
their thickness, without knowing the exact solution;

To explain the difference between ordinary and parabolic boundary layers;

To show which boundary conditions are suitable for Pe  1;

To introduce the finite volume method in two dimensions;

To show how by means of local grid refinement accuracy and computing work
can be made independent of the Peclet number;

To introduce the stencil of the scheme and to show how to generate its coef-
ficient matrix;

To explain the discrete maximum principle in two dimensions;

To illustrate the above points by numerical experiments.

Exercise 3.1.1. Show that equation (3.1) is in conservation form by using The-
orem 1.2.1.

3.2 Singular perturbation theory

Before discussing numerical schemes, we will consider singular perturbation the-


ory for the stationary convection-diffusion equation in two dimensions. In view
of our experience in the one-dimensional case, we expect when  1 the occur-
rence of thin layers in which the solution varies rapidly. Such layers are called
boundary layers. As seen in Chapt. 2, local grid refinement is required in bound-
ary layers for accuracy. Therefore it is necessary to know where boundary layers
occur and the dependence of their thickness on . In Chapt. 2 this information
was deduced from the exact solution; however, in general the exact solution
is not available, of course. But the required information is provided by singu-
lar perturbation theory, also called boundary layer theory. The boundary layer
concept was first introduced by Ludwig Prandtl in 1904, but the mathematical
foundation was developed in the middle of the last century.

Subcharacteristics

When  1 it is natural to approximate (3.1) by putting = 0, so that we


obtain, switching to nonconservative form:

u , = q , q = q u, . (3.6)

This is the convection equation. Let us define curves called characteristics in


space by relations x = x (s), satisfying
3.2 Singular perturbation theory 43

x,s = u . (3.7)

For the derivative along the curve we have

,s = , x,s = u , .

Therefore equation (3.6) reduces to

,s = q . (3.8)

We see that in the homogeneous case q = 0 the solution is constant along


the characteristics, which is why these curves are important. When > 0 we
do not have constant on the characteristics, but as we will see, these curves
still play an important role when  1. To avoid confusion, when > 0 the
characteristics are called subcharacteristics.

A paradox

Let the pattern of streamlines (i.e. (sub)characteristics) be qualitatively as in


Fig. 3.1. The characteristic C1 intersects the boundary in points P1 and P2 .

x2

P4
C2

P3
P2
C1

x1
P1 1
Figure 3.1. Streamline pattern.

Here a boundary condition is given, according to equations (3.2)(3.4). On C1


we have = constant = (C1 ). It is clear that in general (C1 ) cannot sat-
isfy simultaneously the boundary conditions in P1 and in P2 . For example, let
(P1 ) 6= (P2 ) be prescribed by a Dirichlet condition at y = 0 and at x = 1.
Do we have (C1 ) = (P1 ) or (C1 ) = (P2 ) or (C1 ) = ((P1 ) + (P2 ))/2
or something else? What value to take for (C1 )? The difficulty has to do with
the change of type that the partial differential equation (3.1) undergoes when
= 0: for > 0 it is elliptic, for = 0 it is regarded as hyperbolic, because
characteristics can be defined in the same way as for second order hyperbolic
partial differential equations. It is clear that we cannot get a good approxima-
tion to equation (3.1) for 0 by simply deleting the small diffusion term. This
44 3. The stationary convection-diffusion equation in two dimensions

paradoxical situation has baffled mathematicians in the nineteenth century, who


found the drag of a body in an ideal fluid (zero viscosity) to be zero, whereas in
physical experiments the drag around bluff bodies was found to be appreciable,
even at very high Reynolds numbers. This was called the paradox of dAlembert.
The problem remains in the nonhomogeneous case q 6= 0, because the first order
equation (3.6) can satisfy only one boundary condition.

Problems that contain a small parameter are called perturbation problems. The
terms that are multiplied by the small parameter are regarded as perturbations.
If a good approximation can be obtained by simply neglecting the perturbations,
we speak of a regular perturbation problem. If a good first approximation cannot
be obtained in this way the perturbation problem is called singular. An example
of a regular perturbation problem is the sun-earth-moon system. If we neglect
the attraction of the moon we still get a good approximation of the orbit and
the period of the earth. The above paradox shows that the convection-diffusion
equation at large Peclet number is a singular perturbation problem.
We will see that in most cases the flow field is nearly completely described by
the inviscid equation, but for very thin regions in the vicinity of the boundary:
The boundary layers. We will shortly see there are two types of boundary lay-
ers:One that corresponds to the boundary layer concept familiar for those with
a background in fluid dynamics, but also a second type of boundary layer that
results from the specific behavior of the singular perturbation problem.

Singular perturbation theory

The above paradox is resolved by singular perturbation theory. If we assume flow


is from the right to the left in Fig. 3.1, so that x1 = 1 is an inflow boundary and
x2 = 0 is an outflow boundary, then = (C1 ) = (P2 ) is a good approximation
for  1 to the solution of (3.1)(3.4) in 1 x2 > = O() (assuming q = 0),
whereas (3.6) has to be replaced by a so-called boundary layer equation to obtain
an approximation in > x2 0. This can be seen as follows. First, assume that
we indeed have (C1 ) = (P2 ) in 1 y > with  1. In > x2 0 we
expect a rapid change of from (P2 ) to (P1 ). For derivatives of we expect
m
= O( m ) , (3.9)
xm
2

so that perhaps the diffusion term in (3.1) cannot be neglected in the boundary
layer; this will depend on the size of . Assume
= O( ) , (3.10)
with to be determined. In order to exhibit the dependence of the magnitude
of derivatives on we introduce a stretched coordinate x2 :
x2 = x2 , (3.11)
which is chosen such that x2 = O(1) in the boundary layer. We take constant
for simplicity. It follows from (3.9)(3.11) that
m
= O(1) (3.12)
xm
2
3.2 Singular perturbation theory 45

in the boundary layer. In the stretched coordinate, equation (3.1) becomes

(u1 ),1 + (u2 ),2 ,11 12 ,22 = 0 . (3.13)

Letting 0 and using (3.12), equation (3.13) takes various forms, depending
on . The correct value of follows from the requirement, that the solution of
the 0 limit of equation (3.13) satisfies the boundary condition at x2 = 0,
and the so-called matching principle.

Matching principle

As x2 increases, the solution of (the 0 limit of) equation (3.13) has to


somehow join up with the solution of (3.6), i.e. approach the value (C1 ). In
singular perturbation theory this condition is formulated precisely, and is known
as the matching principle:

lim inner (x1 , x2 ) = lim outer (x1 , x2 ) .


x2 x2 0

Here inner , also called the inner solution, is the solution of the inner equation
or boundary layer equation, which is the limit as 0 of equation (3.13) for the
correct value of , which we are trying to determine. Furthermore, outer , also
called the outer solution, is the solution of the outer equation, which is the limit
as 0 of the original equation, i.e. equation (3.6). The matching principle
becomes
inner (x1 , ) = g(x1 ) lim outer (x1 , x2 ) . (3.14)
x2 0

As already mentioned, the other condition to be satisfied is the boundary con-


dition at x2 = 0:
(x1 , 0) = f (x1 ) . (3.15)
For < 0 (corresponding to compression rather than stretching) the limit as
0 of (3.13) is, taking u constant for simplicity,

u,1 = 0 , (3.16)

so that = (x2 ) , which obviously cannot satisfy (3.14), so that the case < 0
has to be rejected. With = 0 equation (3.6) is obtained, which cannot satisfy
both conditions at x1 = 0 and x2 = x2 = 0, as we saw.

For 0 < < 1 the limit of (3.13) is, taking u2 constant for simplicity,

u2 ,2 = 0 ,

so that the inner solution is independent of x2 , hence, in general equations (3.14)


and (3.15) cannot be satisfied simultaneously. This rules out the case 0 < < 1.

For = 1 equation (3.13) becomes as 0:

u2 (x1 , 0),2 ,22 = 0 , (3.17)

where we have used that u2 (x1 , x2 ) = u2 (x1 , x2 ) u2 (x1 , 0) as 0. The


general solution of (3.16) is
46 3. The stationary convection-diffusion equation in two dimensions

= A(x1 ) + B(x1 )eu2 x2 , (3.18)

with u2 = u2 (x1 , 0). We can satisfy both (3.14) and (3.15), remembering that
we had assumed that y = 0 is an outflow boundary, so that v < 0. From (3.14)
and (3.15) we find

A(x1 ) = g(x1 ), B(x1 ) = f (x1 ) g(x1 ) .

This gives us the inner solution. In terms of the unstretched variable x2 the
inner solution is given by

= g(x1 ) + [f (x1 ) g(x1 )]eu2 x2 / .

We see a rapid exponential variation from g(x1 ) to f (x1 ) in a thin layer of


thickness = O(), confirming our earlier statement about the behavior of
the solution. Fig. 3.2(left) gives a sketch of the inner and outer solutions as a
function of x2 for some given x1 . An asymptotic approximation for 0 that is
valid everywhere is given by inner + outer g(x1 ) (not shown in the figure).
Additionally, Fig. 3.2(right) shows the familiar boundary layer profile we know
from fluid dynamics.
x2

f(x1 )

inner

outer

g(x1 )

outer

x2
inner

f(x1 ) g(x1 )

Figure 3.2. Sketch of inner and outer solutions. The left figure shows the solution as
function of the unstretched coordinate x2 , while the left figure shows the solution in
the form of a boundary layer profile

The distinguished limit

The limit as 0 of the stretched equation (3.13) for the special value = 1 for
which the solution of the resulting inner equation can satisfy both the boundary
condition and the matching principle is called the distinguished limit. In order
to show that this limit is unique we will also investigate the remaining values
of that we did not yet consider, namely > 1. Now equation (3.13) gives the
following inner equation:
,22 = 0 ,
with the general solution

= A(x1 ) + B(x1 ) x2 .
3.2 Singular perturbation theory 47

The limit of as x2 does not exist, so that the matching principle cannot
be satisfied. Hence, = 1 is the only value that gives a distinguished limit.

The only element of arbitrariness that remains in this analysis is the assumption
that we have a boundary layer at x2 = 0. Why no boundary layer at x1 = 1, and
(C1 ) = (P1 ) (cf. Fig. 3.1)?This can be investigated by assuming a boundary
layer at x1 = 1, and determining whether a distinguished limit exists or not.
This is left as an exercise. It turns out that boundary layers cannot arise at
inflow boundaries.

The role of boundary conditions

The occurrence of boundary layers is strongly influenced by the type of boundary


condition. Let (3.15) be replaced by a Neumann condition:

,2 (x1 , 0) = f (x1 ) . (3.19)

As before, a boundary layer of thickness O() is found at x2 = 0, and the


boundary layer equation is given by (3.16), with general solution (3.18). Taking
boundary condition (3.19) into account we find

B(x1 ) = f (x1 )/u2 ,

so that B(x1 ) 0 as 0. Hence, to first order, there is no boundary layer,


and the outer solution (solution of (3.6)) is uniformly valid in .

Parabolic and ordinary boundary layers

Those familiar with fluid dynamics may wonder at the boundary layer thickness
O() = O(1/Pe), since in fluid dynamics laminar boundary layers have thickness
O(1/ Re), so that one would have expected = O(1/ Pe). We will now see
that the convection-diffusion equation gives rise to two types of boundary layers.

Consider the case that x2 = 0 is a solid wall, so that u2 (x1 , 0) = 0. The shape
of the characteristics of the outer equation (3.6) might be as in Fig. 3.3, where
also x2 = 1 is assumed to be a solid wall, so that we have a channel flow. Since
u2 (x1 , 0) = 0, the wall x2 = 0 is a characteristic of the outer equation (3.6)
according to (3.7), so that the solution along this characteristic is given by

(x1 , 0) = f1 (0) , (3.20)

assuming x1 = 0 is a inflow boundary with Dirichlet condition

(0, x2 ) = f1 (x2 ) . (3.21)

Let there also be a Dirichlet condition at the wall y = 0:

(x1 , 0) = f2 (x1 ) . (3.22)


48 3. The stationary convection-diffusion equation in two dimensions

x2

x1
1
Figure 3.3. Characteristics of equation (3.6) in a channel flow.

This condition cannot in general be satisfied by the outer solution, because it is


constant along the wall, which is a characteristic. Hence, we expect a boundary
layer at x2 = 0. Obviously, this boundary layer will be of different type than
obtained before, because the boundary layer solution cannot be given by (3.18),
since now we have u2 = 0. In order to derive the boundary layer equation,
the same procedure is followed as before. Again, we introduce the stretched
coordinate (3.11). Keeping in mind that u2 = 0, equation (3.1) goes over in

(u),1 ,11 12 ,22 = 0 . (3.23)

The boundary condition is

(x1 , 0) = f2 (x1 ) , (3.24)

and the matching principle gives

lim (x1 , x2 ) = outer (x1 , 0) . (3.25)


x2

Now we take the limit of (3.23) as 0. For < 1/2 the outer equation at
x2 = 0 is recovered with solution (3.20), which cannot satisfy (3.25). For = 1/2
the limit of (3.23) is
(u),1 ,yy = 0 , (3.26)
This is a parabolic partial differential equation, which in general cannot be
solved explicitly, but for which it is known that boundary conditions at y = 0
and y = give a well-posed problem. Hence, = 1/2 gives the distinguished
limit, and (3.26) is the
boundary layer equation. The thickness of this type of
boundary layer is O( ), which is much larger than for the preceding type,
and of the
same order as laminar boundary layers in fluid dynamics, for which
= O(1/ Re).

In order to specify a unique solution for (3.26), in addition a boundary condition


has to be specified at x = 0 (assuming u > 0). From (3.21) we obtain the
following boundary condition for the boundary layer solution:

(0, x2 ) = f1 (x2 ) ,
3.2 Singular perturbation theory 49

which to the present asymptotic order of approximation (we will not go into
higher order boundary layer theory) may be replaced by

(0, x2 ) = f1 (0) .

It is left to the reader to verify that > 1/2 does not give a distinguished limit.

The cause of the difference between the two boundary layer equations (3.17)
(an ordinary differential equation) and (3.26) (a partial differential equation) is
the angle which the characteristics of the outer equation (3.6) make with the
boundary layer. In the first case this angle is nonzero (cf. Fig. 3.1),in the second
case the characteristics do not intersect the boundary layer. The first type is
called an ordinary boundary layer (the boundary layer equation is an ordinary
differential equation), whereas the second type is called a parabolic boundary
layer (parabolic boundary layer equation).

Summarizing, in the case of the channel flow depicted


in Fig. 3.3, for  1 there
are parabolic boundary layers of thickness O( ) at x2 = 0 and x2 = 1, and
an ordinary boundary layer of thickness O() at the outflow boundary, unless a
Neumann boundary condition is prescribed there.

On outflow boundary conditions

It frequently happens that physically no outflow boundary condition is known,


but that this is required mathematically. Singular perturbation theory helps to
resolve this difficulty. If = O(1) such a physical model is incomplete, but for
 1 an artificial (invented) outflow condition may safely be used to complete
the mathematical model, because this does not affect the solution to any sig-
nificant extent. Furthermore, an artificial condition of Neumann type is to be
preferred above one of Dirichlet type. This may be seen by means of singular
perturbation theory, as follows.

Consider the following physical situation: an incompressible flow with given


velocity field u through a channel, the walls of which are kept at a known tem-
perature. We want to know the temperature of the fluid, especially at the outlet.
This leads to the following mathematical model. The governing equation is (3.1),
with the temperature. Assume  1, and u1 > 0. We have prescribed at
x1 = 0 and at x2 = 0, 1, but at x1 = 1 we know nothing. Hence, we cannot
proceed with solving (3.1), either analytically or numerically. Now let us just
postulate some temperature profile at x1 = 1:

(1, x2 ) = f3 (x2 ).

An ordinary boundary layer will occur at x1 = 1, with solution, derived in the


way discussed earlier (cf. equation 3.18), given by

(x1 , x2 ) = outer (1, x2 ) + {f3 (x2 ) outer (1, x2 )}eu1 (x1 1) , (3.27)

where u1 u1 (1, x2 ). This shows that the invented temperature profile f3 (x2 )
influences the solution only in the thin (artificially generated) boundary layer at
x1 = 1. This means that the computed temperature outside this boundary layer
50 3. The stationary convection-diffusion equation in two dimensions

will be correct, regardless what we take for f3 (x2 ). When = O(1) this is no
longer true, and more information from physics is required, in order to specify
f3 (x2 ) correctly. In physical reality there will not be a boundary layer at all
at x1 = 1, of course. Therefore a more satisfactory artificial outflow boundary
condition is
(1, x2 ),1 = 0 ,
since with this Neumann boundary condition there will be no boundary layer
at x1 = 1 in the mathematical model.

Exercise 3.2.1. Show that there is no boundary layer at x1 = 1, if this is an


inflow boundary. Hint: choose as stretched coordinate x1 = (x1 1)/ .
Exercise 3.2.2. Consider equation (2.5). Show that with Dirichlet boundary
conditions for  1 there is a boundary layer of thickness O() at x1 = 1 and
not at x1 = 0.
Exercise 3.2.3. Derive equation (3.27).

3.3 Finite volume method

Problem statement

In this section we study the numerical approximation of the two-dimensional


stationary convection-diffusion equation, for convenience written in Cartesian
tensor notation:

L (u ), (, ), = q , = 1, 2 , (x1 , x2 ) (0, 1) (1, 1) . (3.28)

We assume that we have solid walls at x2 = 1, 1, so that u2 (x1 , 1) = u2 (x1 , 1)


= 0. Let u1 < 0, so that x1 = 0 is an outflow boundary. In view of what we
learned in Sect. 3.2 we choose a Neumann boundary condition at x1 = 0, and
Dirichlet boundary conditions at the other parts of the boundary:

,1 (0, x2 ) = g 3 (x2 ) , (x1 , 1) = g 1 (x1 ) ,


(x1 , 1) = g 1 (x1 ) , (1, x2 ) = g 2 (x2 ) .

This corresponds to the channel flow problem studied before. We assume sym-
metry with respect to the centerline of the channel, so that we have to solve only
in half the domain, i.e. in (0, 1) (1, 0). At the centerline our boundary
condition is the symmetry condition ,2 = 0, so that the boundary conditions
are:
,1 (0, x2 ) = g 3 (x2 ) , (x1 , 1) = g 1 (x1 ) ,
(3.29)
,2 (x1 , 0) = 0 , (1, x2 ) = g 2 (x2 ) .
The computational domain is illustrated in Fig. 3.4.
As discussed before, it is best to choose at the outflow boundary a homogeneous
Neumann condition, i.e. g 3 0, but for the purpose of numerical experimenta-
tion we leave the possibility of choosing a nonhomogeneous Neumann condition
3.3 Finite volume method 51

Full domain Reduced domain,


x2 x2 exploiting symmetry
= g1(x1)
11111111111111111111
00000000000000000000
00000000000000000000
11111111111111111111
00000000000000000000
11111111111111111111
00000000000000000000
11111111111111111111
00000000000000000000
11111111111111111111
00000000000000000000
11111111111111111111
00000000000000000000
11111111111111111111
00000000000000000000
11111111111111111111
00000000000000000000
11111111111111111111
,1 = g3(x2 )

00000000000000000000
11111111111111111111

= g2(x2)
00000000000000000000
11111111111111111111
00000000000000000000
11111111111111111111
00000000000000000000
11111111111111111111
00000000000000000000
11111111111111111111
00000000000000000000
11111111111111111111
00000000000000000000
11111111111111111111
00000000000000000000
11111111111111111111
00000000000000000000
11111111111111111111
00000000000000000000
11111111111111111111
00000000000000000000
11111111111111111111
00000000000000000000
11111111111111111111
00000000000000000000
11111111111111111111
00000000000000000000
11111111111111111111
00000000000000000000
11111111111111111111
00000000000000000000
11111111111111111111
00000000000000000000
11111111111111111111
,2 = 0
00000000000000000000
11111111111111111111
00000000000000000000
11111111111111111111 11111111111111111111
00000000000000000000
00000000000000000000
11111111111111111111
00000000000000000000
11111111111111111111
x1 00000000000000000000
11111111111111111111
00000000000000000000
11111111111111111111
x1
00000000000000000000
11111111111111111111 00000000000000000000
11111111111111111111
00000000000000000000
11111111111111111111
00000000000000000000
11111111111111111111
00000000000000000000
11111111111111111111 00000000000000000000
11111111111111111111
00000000000000000000
11111111111111111111 00000000000000000000
11111111111111111111
00000000000000000000
11111111111111111111 00000000000000000000
11111111111111111111
00000000000000000000
11111111111111111111 00000000000000000000
11111111111111111111
00000000000000000000
11111111111111111111
00000000000000000000
11111111111111111111

= g2(x2 )
,1 = g3(x2 )

,1 = g3(x2 )

= g2(x2 )
00000000000000000000
11111111111111111111 00000000000000000000
11111111111111111111
00000000000000000000
11111111111111111111
00000000000000000000
11111111111111111111 00000000000000000000
11111111111111111111
00000000000000000000
11111111111111111111
00000000000000000000
11111111111111111111 00000000000000000000
11111111111111111111
00000000000000000000
11111111111111111111 00000000000000000000
11111111111111111111
00000000000000000000
11111111111111111111
00000000000000000000
11111111111111111111
00000000000000000000
11111111111111111111 00000000000000000000
11111111111111111111
00000000000000000000
11111111111111111111 00000000000000000000
11111111111111111111
00000000000000000000
11111111111111111111
00000000000000000000
11111111111111111111
00000000000000000000
11111111111111111111 00000000000000000000
11111111111111111111
00000000000000000000
11111111111111111111 00000000000000000000
11111111111111111111
00000000000000000000
11111111111111111111 00000000000000000000
11111111111111111111
00000000000000000000
11111111111111111111
00000000000000000000
11111111111111111111
00000000000000000000
11111111111111111111 00000000000000000000
11111111111111111111
00000000000000000000
11111111111111111111 00000000000000000000
11111111111111111111
00000000000000000000
11111111111111111111 00000000000000000000
11111111111111111111
00000000000000000000
11111111111111111111
00000000000000000000
11111111111111111111
00000000000000000000
11111111111111111111 00000000000000000000
11111111111111111111
00000000000000000000
11111111111111111111 00000000000000000000
11111111111111111111

= g1(x1) = g1(x1)
Figure 3.4. The computational domain can be reduced by exploiting symmetry in
the geometry and the boundary conditions.

open. We will not discuss the three-dimensional case, because this does not pro-
vide new insights.

Our purpose in this section is to show, as in Sect. 2.3, but this time in two
dimensions, that (3.28) can be solved numerically such that accuracy and com-
puting cost are uniform in Pe. Therefore, fear that it is impossible to compute
high Peclet (Reynolds) number flow accurately is unfounded, as argued before.
For simplicity we assume horizontal flow: u2 0, and we will simply write u
instead of u1 .

Choice of grid

In view of what we learned in Sect. 3.2, we expect a parabolic (because u2 =


0) boundary layer at x2 = 1 with thickness O( ). If g 3 0 we have a
homogeneous Neumann condition at the outflow boundary, and there is no
boundary layer at x1 = 0. Just as in Sect. 2.3, in order to make accuracy and
computing work uniform in , we choose a grid with local refinement in the
boundary layer, as sketched in Fig. 3.5. We will apply grid refinement nearthe
outflow boundary later. The region of refinement has thickness = O( ),
i.e. the boundary layer thickness scales asymptotically with the inverse of the
Peclet number. The precise choice of will be discussed later, and is such that
the boundary layer falls inside the refinement region. The refined part of the
grid is called Gf , the interface between the refined and unrefined parts is called
and the remainder of the grid is called Gc . The mesh sizes in Gf and Gc are
uniform, as indicated in Fig. 3.5. Note that the location of the horizontal grid
lines depends on .
52 3. The stationary convection-diffusion equation in two dimensions

Gc
H2


Gf
h2
H1

Figure 3.5. Computational grid

Finite volume discretization

We choose a cell-centered scheme. The cell centers are labeled by integer two-
tuples (i, j) in the usual way: ij is the cell with center at (xi , yj ). Hence, for
example, (i + 1/2, j) refers to the center of a vertical cell edge. Cell-centered
finite volume discretization is used as described in Sect. 2.3. For completeness
the discretization is summarized below. The finite volume method gives by in-
tegration over ij and by using the divergence theorem:
Z hR
xi+1/2,j+1/2 R xi1/2,j+1/2 i
Ld = xi+1/2,j1/2
xi1/2,j1/2
(u ,1 )dx2
ij
hR R xi+1/2,j1/2 i
xi+1/2,j+1/2
+ xi1/2,j+1/2
xi1/2,j1/2
(,2 )dx1
i+1/2,j i,j+1/2
= F 1 |i1/2,j + F 2 |i,j1/2 .

The approximation of the numerical fluxes F 1,2 is given below. The right-hand
side of equation (3.28) is numerically integrated over ij as follows:
Z
qd = qij H1 Kj q(xij ) , (3.30)
ij

where Kj is the vertical dimension of ij : Kj = h2 in Gf and Kj = H2 in Gc .


The cells are numbered i = 1, ..., I and j = 1, ..., J in the x1 - and x2 -directions,
respectively. The following scheme is obtained:
i+1/2,j i,j+1/2
Lh ij F 1 |i1/2,j + F 2 |i,j1/2 = qij . (3.31)

If we sum (3.31) over all cells only boundary fluxes remain, so that the scheme
is conservative (cf. Sect. 2.3).

The numerical flux

How to approximate the numerical fluxes F 1,2 in terms of neighboring grid


function values follows directly from the one-dimensional case discussed in the
3.3 Finite volume method 53

preceding chapter. With upwind discretization for the first derivative (taking
into account that u < 0), the numerical fluxes F 1,2 are approximated as follows:
1
Fi+1/2,j
= Kj [ui+1/2,j i+1,j (i+1,j ij )/H1 ] ,
F 2
= 2H1 (i,j+1 ij )/(Kj + Kj+1 ) , (3.32)
i,j+1/2

With the central scheme for the first derivative F 1 becomes:


1
Fi+1/2,j
= Kj [ui+1/2,j (i,j + i+1,j )/2 (i+1,j ij )/H1 ] . (3.33)
The boundary conditions are implemented as in Sect. 2.3. This gives both for
the upwind and central schemes:
1
F1/2,j
= Kj [u1/2,j (1j H1 g 4 (yj )/2) g 4 (yj )] ,
FI+1/2,j
1
= Kj [uI+1/2,j I+1/2,j 2(I+1/2,j Ij )/H1 ] ,
(3.34)
F2 i,1/2 = 2H1 (i,1 i,1/2 )/h2 ,
2
Fi,J+1/2 = 0,
where I+1/2,j and i,1/2 are given by the boundary conditions (3.29).

The stencil of the scheme

Although this is tedious, we will spell out more details of the scheme, as prepa-
ration for a MATLAB program. The numerical fluxes as specified above can be
written as
1 0 1
Fi+1/2,j = ij ij + i+1,j i+1,j , i = 1, , I 1 , j = 1, , J ,
1 1
F1/2,j = 1j 1,j + j0 , j = 1, , J ,
1 0
FI+1/2,j = Ij Ij + j1 , j = 1, , J ,
2 2 3
(3.35)
Fi,j+1/2 = ij ij + i,j+1 i,j+1 , i = 1, , I , j = 1, , J 1 ,
2 3
Fi,1/2 = i1 i,1 + i2 , i = 1, , I ,
2
Fi,J+1/2 =0, i = 1, , I ,
where 0 , 1 , 2 are known terms arising from the boundary conditions. The
and coefficients follow easily from (3.34), and will not be written down. The
scheme consists of a linear system of equations of the form
1
X 1
X
kl
Lh ij = ij i+k,j+l , (3.36)
k=1 l=1

where the only nonzero coefficients are


1,0 0 1,0 1
ij = i1,j , ij = ij
0,1 2 0,1 3
ij = i,j1 , ij = ij (3.37)
0,0 0 1 2 3
ij = ( + )ij .
The scheme has a five-point stencil:
0,1

[Lh ] = 1,0 0,0 1,0 .


0,1
54 3. The stationary convection-diffusion equation in two dimensions

The maximum principle

Just as in the one-dimensional case, we have a discrete maximum principle. We


generalize Definition 2.3.1 to the two-dimensional case as follows:

Definition 3.3.1. The operator Lh is of positive type if for i = 2, , I 1 and


j = 2, , J 1 X
kl
ij =0 (3.38)
kl

and
kl
ij < 0, (k, l) 6= (0, 0) . (3.39)
The following theorem says that schemes of positive type satisfy a similar max-
imum principle as the differential equation.

Theorem 3.3.1. Discrete maximum principle.


If Lh is of positive type and

Lh ij 0, i = 2, , I 1, j = 2, , J 2 ,

then ij maxij {1j , Ij , i1 , iJ }.


In other words, local maxima can only occur in cells adjacent to the boundaries.

It is left to the reader to show that with the upwind scheme Lh is of positive
type, and with the central scheme this is the case if (taking u constant for
simplicity) the mesh Peclet number satisfies

|u|h
p<2, p ,

just as in the one-dimensional case (cf. equation (2.52)).

The matrix of the scheme

In matrix notation the scheme (3.31) can be denoted as

Ay = b .

Let the algebraic vector y contain the unknowns in lexicographic order:

ym = ij , m = i + (j 1)I . (3.40)

Vice-versa, i and j follow from m as follows:

j = floor[(m 1)/I], i = m (j 1)I , (3.41)

where floor(a/b) is the largest integer a/b. The right-hand side b contains
qij in lexicographic order. The relation between the grid indices i, j and the
lexicographic index m is illustrated in Fig. 3.6 With lexicographic ordering, A
is an IJ IJ matrix with the following block-tridiagonal structure:
3.3 Finite volume method 55

9 10 11 12 1,3 2,3 3,3 4,3


5 6 7 8 1,2 2,2 3,2 4,2
1 2 3 4 1,1 2,1 3,1 4,1
Figure 3.6. Relation between lexicographic and grid indices



B1 D1 0 0
..
C2 B2 D2 .

A = 0 ... ... .. ,

. 0
.
..

CJ1 BJ1 DJ1
0 0 CJ BJ
where Bj are I I tridiagonal matrices, given by
0,0 1,0

1j 1j 0 0

1,0 0,0 1,0 ..
2j 2j 2j .
Bj =
.. .. ..
0 . . . 0 ,

.
. 1,0 0,0 1,0
. I1,j I1,j I1,j


1,0 0,0
0 0 I,j Ij

and Cj and Dj are I I diagonal matrices, given by


0,1 0,1
Cj = diag{ij }, Dj = diag{ij }.

Remarks on the MATLAB program cd2

The numerical scheme described above has been implemented in the MATLAB
program cd2, available at the authors website; see the Preface.

The student is not expected to fully understand this program, because use is
made of somewhat advanced features, such as meshgrid and reshape, in order
to avoid for loops. Avoiding for loops is essential for efficiency in MATLAB,
as can be seen in the code cd2 by comparing computing time (using tic toc)
for generating the matrices A1 and A3. Generation of A1 is done in a simple
way with for loops, and requires 1.22 time units on a 32 72 grid, whereas
the more sophisticated program for A3 takes 0.067 time units; this discrepancy
grows rapidly with increasing grid size. The time used for solving the system
Ay = b is 0.32.

In MATLAB, A is generated as a sparse matrix by


d = [-I; -1; 0; 1; I];
A = spdiags([a1 a2 -a1-a2-a4-a5 a4 a5], d, n, n);
with suitable definition of the diagonals a1 a5. Exploiting sparsity is essential
for saving memory and computing time. The solution of the system Ay = b is
obtained in MATLAB by
56 3. The stationary convection-diffusion equation in two dimensions

y = A\b;
This means that we solve with a direct method using sparse LU factorization.
For large systems, that occur particularly when partial differential equations are
solved in three-dimensional domains, direct methods frequently demand intol-
erable amounts of computer time and memory, even when sparsity is exploited.
Efficient solution methods for solving the algebraic systems arising from numer-
ical schemes for partial differential equations will be discussed in Chapt. 6.

Numerical experiments

The purpose of the numerical experiments with the program cd2 that we will
now describe is to demonstrate, as we did in Sect. 2.3 for the one-dimensional
case, that we can achieve Peclet-uniform accuracy and efficiency, and that ac-
curate results can be obtained on grids with large jumps in mesh size. This is
shown theoretically in Sect. 4.7 of Wesseling (2001), but here we confine our-
selves to numerical illustration.

In order to be able to assess the error, we choose an exact solution. Of course,


this solution has to exhibit the boundary layer behavior occurring in practice.
We choose the following solution of the boundary layer (inner) equation (3.26):

x22 (2 x2 )2
 
1
= exp( ) + exp( .
2 x1 4(2 x1 ) 4(2 x1 )

The right-hand side and boundary conditions in (3.29) are chosen accordingly.
The exact solution is symmetric with respect to x2 = 1, as assumed by the
boundary conditions (3.29).

Because the solution is extremely smooth in c , it turns out that in Gc the


number of cells in the vertical direction can be fixed at 4; the maximum of the
error is found to always occur in Gf . We take

=8 . (3.42)

Table 3.1 gives results for the cell-centered upwind case. Exactly the same re-
sults (not shown) are obtained for = 105 and = 107 , showing -uniform
accuracy. Of course, computing time and memory are also independent of ,
because they depend only on nx1 and nx2 . The maximum error is found to
occur in the interior of the boundary layer. Because we use the upwind scheme

nx1 nx2 error 104


8 32 54
32 64 14
128 128 3.6

Table 3.1. Maximum error as function of number of grid-cells for = 103 ; cell-
centered upwind discretization. nx1 : horizontal number of cells; nx2 : vertical number
of cells in Gf .
3.3 Finite volume method 57

in the x1 -direction and the central scheme in the x2 -direction, we expect for the
error e = O(H1 + h22 ), so that the error should decrease by a factor 4 at each
refinement in Table 3.1; this expectation is confirmed. Table 3.2 gives results
for central discretization of the convection term. Visual inspection of graphical
output (not shown) shows no visible wiggles. But very small wiggles are present.

nx ny error 104
8 16 92
16 32 28
32 64 7.8
64 128 2.1

Table 3.2. Cell-centered central discretization; = 103 .

These are the cause that the rate of convergence is somewhat worse than the
hoped for O(H12 +h22 ), but here again the same results are obtained for = 107 ,
showing uniformity in .

We may conclude that in practice work and accuracy can be made to be uniform
in , by suitable local mesh refinement according to Fig. 3.5 and equation (3.42).
Hence, in principle, high Reynolds number flows are amenable to computation.

As before, having come to the end of this chapter, looking again at the list of
items that we wanted to cover given in Sect. 3.1 will help the reader to remind
himself of what the main points were that we wanted to emphasize.

Exercise 3.3.1. Derive equations (3.32) and (3.33).


Exercise 3.3.2. Take u1 , u2 and constant, and the grid uniform. Discretize
the convection-diffusion equation (3.28) with the finite volume method, using
the central scheme. Show that the resulting stencil is

1 h1
2 p2 h2
[Lh ] = 12 p1 hh21 2( hh21 + hh21 ) 1 h2
2 p1 h1 ,

21 p2 hh12

where p1 u1 h1 / and p2 u2 h2 / are the signed (i.e., they can be positive or


negative) mesh Peclet numbers.
Exercise 3.3.3. Run cd2 with a homogeneous Neumann condition at the out-
flow boundary, and compare with the case in which the x1 -derivative at the
outflow boundary is prescribed in accordance with the exact solution. This ex-
ercise illustrates once again that Pe  1 it is safe to prescribe a homogeneous
Neumann condition at outflow.
Exercise 3.3.4. Run cd2 with the central scheme for the convection term.
Observe that this does not give better results than the upwind scheme if the
mesh Peclet number is larger than 2. The cause is the occurrence of (very small)
wiggles. How small should dx1 be to bring the mesh Peclet number p below 2?
Would p < 2 make the computing work nonuniform in ?
58

Some self-test questions

What is your favorite outflow boundary condition? Why?

Define the subcharacteristics of the convection-diffusion equation.

What is the difference between a regular and a singular perturbation problem?


Formulate the matching principle.

What is the essential feature that makes it possible to have accuracy and efficiency Peclet-uniform?
Why do we want this property?

When is a scheme of positive type? Why is this nice?

Under what conditions is the scheme with stencil of Exercise 3.3.2 of positive type?
4. The nonstationary convection-diffusion
equation

4.1 Introduction
In the nonstationary case, time is included. The equation to be studied is the
two-dimensional nonstationary convection-diffusion equation:

+(u ), (, ), = q(t, x1 , x2 ) , 0 < t T, (x1 , x2 ) (0, 1)(0, 1) .


t
(4.1)
The following initial condition is required:

(0, x1 , x2 ) = 0 (x1 , x2 ) . (4.2)

Suitable boundary conditions are:

(t, x1 , x2 ) = f (t, x1 , x2 ) on i (Dirichlet), (4.3)


(t, x1 , x2 ) = f (t, x1 , x2 ) on o (Dirichlet) or (4.4)
(t, x1 , x2 )
= g(t, x1 , x2 ) on o (Neumann), (4.5)
n
where n is the outward unit normal on the boundary , i is the inflow
boundary (where u n < 0) and o is the remainder of , to be called the
outflow boundary.

When = 1/Pe  1, boundary layers may occur at the same location and
with the same thickness as in the stationary case, as may be seen by means of
singular perturbation theory, which is easily extended to the nonstationary case.

As in the stationary case, we have a maximum principle. The non-conservative


form of (4.1) is:

+ u , (, ), = q q u , . (4.6)
t
The maximum principle for the nonstationary case says that if q 0 and if
there is a local maximum in the interior of for t = t > 0, then = constant,
0 t t . In effect this says that local maxima can occur only at t = 0 and
at the boundaries. If q 0 the same applies to local minima, so that in the
homogeneous case q = 0 there can be no local extrema (in space and time)
in the interior; any numerical wiggles must be regarded as numerical artifacts.
See Sect. 2.4 of Wesseling (2001) for a more precise version of the maximum
principle. We will not prove this maximum principle here. But a simple physical
analogy will convince the reader that it must be true. Think of a copper plate
60 4. The nonstationary convection-diffusion equation

with a nonuniform temperature distribution at t = 0. The evolution of the tem-


perature is governed by the heat equation, i.e. equation (4.6) with u = v = 0.
If no heat sources or sinks are present (i.e. q = 0) then the temperature distri-
bution evolves to a uniform state, and a local hot spot must have been hotter
at earlier times.

Purpose of this chapter

The purpose of this chapter is:

To introduce methods for discretization in time;


To explain the concepts of consistency, stability and convergence and their
relation;
To show that numerical schemes must be stable to be convergent;
To show how stability conditions can be derived by Fourier analysis for one-
step schemes.
How Fourier analysis can be used to derive stability conditions for general
time-integration schemes by fitting the stability region.

4.2 A numerical example


Consider the one-dimensional heat equation, which is a special case of equation
(4.1):

,11 = 0 , 0 < t T , x (0, 1) , (4.7)
t
with initial condition and homogeneous Neumann boundary conditions given by
(0, x) = 0 (x) , ,1 (t, 0)x = ,1 (t, 1)x = 0 . (4.8)
This is a mathematical model for the evolution of the temperature in a thin
insulated bar with initial temperature distribution 0 (x). We have
Z 1
lim (t, x) = constant = 0 (x)dx . (4.9)
t 0

Discretization in space

For discretization in space we use the finite volume method on the vertex-
centered grid of Fig. 2.1 with uniform mesh size h. The following details have
been covered in the preceding chapters and we leave the derivation of (4.10) as
an exercise. Integration over the control volumes gives, with constant:
h d1
+ F1 F3/2 = 0 ,
2 dt
dj
h + Fj1/2 Fj+1/2 = 0 , j = 2, , J 1 , (4.10)
dt
h dJ
+ FJ1/2 FJ = 0 ,
2 dt
4.2 A numerical example 61

where F is an approximation of /x, naturally chosen as follows:

Fj+1/2 = (j+1 j )/h , j = 1, , J 1 .

From the boundary conditions it follows that F1 = FJ = 0.

Discretization in time

Equation (4.10) is rewritten as


dj
+ Lh j = 0 , j = 1, , J . (4.11)
dt
For discretization in time we choose the forward Euler scheme:

(n+1
j nj )/ + Lh nj = 0 , n = 0, , N , N T / , (4.12)

with the time step, taken constant; nj is the numerical approximation of


(n, xj ) with (t, x) the exact solution. From Fig. 2.1 it follows that xj =
(j 1)h, h = 1/(J 1). Equation (4.12) is equivalent to

n+1
1 = (1 2d)n1 + 2dn2 ,
n+1
j = dnj1 + (1 2d)nj + dnj+1 , j = 2, , J 1 , (4.13)
n+1
J = 2dnJ1 + (1 2d)nJ ,

where d /h2 is a dimensionless number, that we will call the diffusion


number. Note that this scheme is an approximation of times the differential
equation.

The matrix of the scheme

If we define (1 , , J )T then (4.13) can be rewritten as

n+1 = An ,

with A the following tridiagonal matrix:

1 2d 2d

0 0
..
d
1 2d d .

A= 0
.. .. ..
. (4.14)
. . . 0
..
. d 1 2d d
0 0 2d 1 2d

Numerical results

The following numerical results have been obtained with the MATLAB code
heq . As initial solution we choose
62 4. The nonstationary convection-diffusion equation

0 (x) = 0 , 0 < x < 0.4 ,


0 (x) = 1 , 0.4 < x < 0.6 , (4.15)
0 (x) = 0 , 0.6 < x < 1 .
Numerical results are shown in Fig. 4.1 for two values of the diffusion number d.
The result at the left looks as expected: the temperature distribution is tending

d=0.48, 50 cells, T=0.1 d=0.52, 50 cells, T=0.1


0.7 2.5

0.6 2

1.5
0.5
1
0.4
0.5
0.3
0
0.2
0.5

0.1 1

0 1.5
0 0.2 0.4 0.6 0.8 1 0 0.2 0.4 0.6 0.8 1
Figure 4.1. Numerical solution of heat equation for two values of d.

to uniformity, and the maximum principle is satisfied: no new maxima in space,


and the maximum at x = 1/2 was larger at earlier times. But the result in
the right part of the figure is wrong. Clearly, the value of the diffusion number
has a crucial influence, and something strange happens between d = 0.48 and
d = 0.52! This will be investigated in what follows.
Exercise 4.2.1. Prove equation (4.9).
R1
Hints: Show that if d
t = 0 the solution is constant. Show that dt 0 dx = 0.
(This shows that with these boundary conditions the bar is insulated: the heat
content is conserved).
Exercise 4.2.2. Derive equations (4.10).

4.3 Convergence, consistency and stability


One-step schemes

Schemes in which only two time levels are involved are called one-step schemes;
the forward Euler method (4.12) is an example. The general form of linear one-
step schemes is:
B1 n+1 = B0 n + B2 qn + B3 qn+1 , (4.16)
where B0 , , B3 are linear operators, and where q arises from the right-hand
side of the differential equation and the boundary conditions. Initially, we will
restrict ourselves here to one-step schemes. Note that the 4 operators are the
result of two different weighting operators.
4.3 Convergence, consistency and stability 63

Local and global truncation error

Let us denote the algebraic vector with elements equal to the exact solution
evaluated at the grid points and at time tn by ne . Let us define the local
truncation error jn , gathered in an algebraic vector n (not to be confused
with the time step ) by the following equation:

B1 n+1
e = B0 ne + B2 qn + B3 qn+1 + n . (4.17)

The global truncation error is defined as

en ne n . (4.18)

By subtracting (4.17) and (4.16) we get the following relation between the global
and the local truncation error:

B1 en+1 = B0 en + n . (4.19)

This is very similar to equation (2.58), so that the above definitions are consis-
tent with the truncation error definitions for the stationary case given in Sect.
2.3.

Convergence

Of course, we want ken k 0, n = 1, , T / as the grid is refined and 0


(while keeping T / integer, obviously). This is not the case for our previous
numerical example when d > 1/2. No matter how small h and are chosen,
the numerical solution will always look like the right part of Fig. 4.1, since it
depends only on the parameter d, cf. (4.13).
Clearly, we have to do some analysis to find conditions that guarantee that a
numerical scheme is good. The fact that we made an O(h2 ) approximation of
the spatial derivative and a O(h) approximation to the temporal derivative is
not enough to have the solution approach the exact solution.

Let the number of space dimensions be m and let us have an m-dimensional


spatial grid G with grid points

xj = (x1j1 , , xm
jm ) .

Hence, now j is a multi-index (j1 , , jm ) (Fig. 4.2). Let the spatial mesh sizes
and the time step be decreasing functions of a parameter h, that belongs to a
sequence that decreases to zero. To emphasize the dependence of G on h we
write Gh . We want that at a fixed time T and a fixed location x in space the
error to tend to 0 as h 0. This implies that the number of time steps n = T /
changes, and the multi-index j changes to keep xj fixed. To emphasize this we
write jh . Of course, we assume that Gh is such that the fixed point xjh remains
a grid point when the grid is refined. For example, in the preceding numerical
example we could choose

xjh = 1/2 , h {1/2, 1/4, 1/6, }.

so that jh {1, 2, 3, }. We are now ready for the definition of convergence.


64 4. The nonstationary convection-diffusion equation

x2

xj
x2j
2

x1
x1j
1

Figure 4.2. Example of use of the multi-index for m = 2.

Definition 4.3.1. Convergence


A scheme is called convergent if the global truncation error satisfies
T /
lim ejh = 0, xjh fixed.
h0

Clearly, scheme (4.13) is not convergent for d > 1/2.

Consistency

It seems likely that for convergence it is necessary that the local truncation
error is small enough. We therefore formulate a condition. Let the scheme (4.16)
in a given grid point xj approximate the differential equation times |j |
with |j | the volume of some cell around xj (For example, the scheme (4.13)
obviously approximates equation (4.7) times , so that in this case = 1, =
0). This is necessary because the local truncation error changes when the whole
scheme is premultiplied by |j | . We define
Definition 4.3.2. Consistency
The scheme (4.16) is called consistent if

lim jnh /( |jh | ) = 0, j Gh , 1 n T / .


h0

In Exercise 4.3.1 the reader is asked to show that scheme (2.60) is not consistent
on rough grids. This seems disturbing, because we are going to show that con-
sistency is necessary for convergence, but in Sect. 2.3 it was shown that scheme
(2.60) converges on rough grids. This apparent paradox arises from the fact that
Def. 4.3.2 implies that the local truncation error is measured in the maximum
norm. On rough grids we have consistency of scheme (2.60) in a more sophis-
ticated norm, but not in the maximum norm; we will not go into this further.
In this chapter only uniform grids are considered; on these grids the various
appropriate norms are the same.
4.3 Convergence, consistency and stability 65

Stability

As illustrated by the numerical example in the preceding section, consistency


does not imply convergence. It turns out the scheme requires another property
to be convergent. In addition, stability is required. This concept will now be
explained. Let 0 be a hypothetical arbitrary perturbation of 0 . The resulting
perturbation of n is called n . It is left for the reader to derive from equation
(4.16) that
B1 n+1 = B0 n . (4.20)
Let k kh be some norm for functions Gh R. Stability means that n remains
bounded as n , for all 0 . Two useful definitions are:
Definition 4.3.3. Zero-stability
A scheme is called zero-stable if there exists a bounded function C(T ) and a
function 0 (h) such that for arbitrary 0
k T / kh C(T )k 0 kh (4.21)
for all 0 (h) and all h h0 for some fixed h0 .
The appellation zero-stability refers to the fact that the limit h 0 is consid-
ered. Note that is allowed to grow slowly in each time step as long as the grow
factor in each time step scales appropriately with .
Definition 4.3.4. Absolute stability
A scheme is called absolutely stable if there exists a constant C and a function
0 (h) such that for arbitrary 0
k n kh Ck 0 kh (4.22)
for h fixed, all n > 0 and all 0 (h).
The difference with zero-stability is that here h is fixed; k n kh can not grow in
a time step, but any growth would jeopardize the bound on lim k n kh
n

Laxs equivalence theorem

Definition 4.3.3 considers the perturbation at a fixed time T as h 0, which is


the same limit as in the definition of convergence. It can be shown that con-
vergence implies zero-stability, and zero-stability plus consistency imply con-
vergence. This is known as Laxs equivalence theorem. As a consequence, zero-
stability is necessary for convergence. But absolute stability is also good to
have, because it allows n to grow indefinitely, making it possible to continue
time stepping until a steady state is reached. Absolute and zero-stability are
not completely equivalent.

A remark on stability analysis

The purpose of stability analysis is to find a suitable function 0 (h) such that
(4.21) and/or (4.22) hold(s). This is the case if the linear operators in (4.20)
satisfy
66 4. The nonstationary convection-diffusion equation

k(B11 B0 )n kh C .
In the case of absolute stability, h and hence the dimensions of the matrices B0
and B1 are fixed, and linear algebra can be used to find conditions under which
k(B11 B0 )n k is bounded as n . But in the case of zero-stability, n
and h 0 simultaneously, and we have to study not just the behavior of the
nth power of a matrix, but of a family of matrices of increasing size. This is
not a familiar situation in linear algebra. We will see that Fourier analysis is
well-suited to the study of both kinds of stability, if the boundary conditions
are periodic.

Exercise 4.3.1. Show that for scheme(2.60) we have = 1. Because this


scheme is for the stationary case, time can be disregarded. Show that, using
(2.66), scheme (2.60) is consistent on smooth grids (as defined below equation
(2.66)), but not on rough grids.

4.4 Fourier stability analysis

Applicability of Fourier analysis

In general it is difficult to derive estimates like (4.21) and (4.22). But if the co-
efficients in the scheme are constant, the mesh uniform, the grid a rectangular
block and the boundary conditions periodic, then Fourier analysis applies and
the required estimates are often not difficult to obtain.

In practice, of course, the coefficients are usually not constant. The scheme is
called locally stable if we have stability for the constant coefficients scheme that
results from taking local values of the coefficients, and to assign these values to
the coefficients in the whole domain (frozen coefficients method). Local stability
in the whole domain is necessary for stability in the variable coefficients case.
We will discuss stability only for constant coefficients.

Stability theory for non-periodic boundary conditions is complicated. But for


explicit time stepping schemes it takes a while before the influence of the bound-
ary conditions makes itself felt in the interior, so that Fourier stability theory
applies during a certain initial time span. As a consequence, stability with pe-
riodic boundary conditions is desirable, even if the boundary conditions are of
different type.

Example of frozen coefficients method

Consider the Burgers equation:


1 2 
+ ,1 = 0 .
t 2
4.4 Fourier stability analysis 67

Discretization with the forward Euler method in time and the upwind scheme
in space gives:

n+1 nj + [(n )2 (nj1 )2 ] = 0 ,
j
2h j
assuming > 0 and a uniform grid. For stability analysis we postulate a per-
turbation 0 of the initial solution. The perturbed solution satisfies

( + )n+1
j ( + )nj + {[( + )nj ]2 [( + )nj1 ]2 } = 0 .
2h
Subtraction of the preceding two equations and linearization (i.e. deletion of
terms quadratic in ) gives:

n+1
j nj + [()nj ()nj1 ] = 0 .
h
Freezing of the coefficients results in
c
n+1
j nj + (nj nj1 ) = 0 ,
h
where c is the frozen value of . This scheme allows Fourier stability analysis.
Usually, a stability condition of the type
c
<C (4.23)
h
results for some value of C. This condition is to be satisfied for the frozen coef-
ficient c equal to all values that the variable coefficient nj takes. We see from
(4.23) that it suffices to take c = max(|nj |). Frequently an informed guess for
max(|nj |) can be made by looking at the boundary conditions.

In the remainder of this section we present the basic principles of Fourier sta-
bility analysis.

Fourier series

Let Gh be a uniform grid on the unit interval with nodes

xj = jh , j = 0, 1, , J 1 1/h .

It can be shown that every grid function : Gh R can be represented by


what is called a Fourier series Wesseling (1992):
m+p
X
j = ck eij2k/J , j = 0, 1, , J 1 , (4.24)
k=m

where p = 0, m = (J 1)/2 for J odd and p = 1, m = (J 2)/2 for J even. In


turn the coefficients ck of the expansion are given as:
J1
X
ck = J 1 j eij2k/J (4.25)
j=0
68 4. The nonstationary convection-diffusion equation

We first need to show that the different discrete Fourier modes are orthogonal:
J1
X
eij2k/J eij2l/J = Jkl (4.26)
j=0

When l = k we have
J1
X J1
X
eij2k/J eij2k/J = e0 = J (4.27)
j=0 j=0

when l 6= k we have a geometric series. Recall that


n
X a (1 rn )
sn = arj1 = (4.28)
j=1
1r

in our case:
J1
X J1
X
eij2k/J eij2l/J = (ei2(kl)/J )j = (4.29)
j=0 j=0

1 eiJ2(kl)/J
=0
1 ei2(kl)/J
We can now prove (4.24) given that (4.25), holds:

m+p
X m+p
X J1
X
ck eij2k/J = J 1 l eil2k/J eij2k/J = (4.30)
k=m k=m l=0
J1
X J1
X
J 1 l ei2(km)(jl)/J =
l=0 k=0
J1
X J1
X
J 1 l ei2m(lj)/J eik2jk/J eik2lk/J
l=0 k=0

Next we follow the reverse course and show that given (4.25) we can prove
(4.24):

J1
X l=m+p
X J1
X
J 1 j eij2k/J = J 1 cl eij2k/J eij2l/J = (4.31)
j=0 l=m j=0
l=m+p
X
cl kl = ck
l=m

It is convenient to rewrite this as


X
j = c eij , { = 2k/J , k = m, m + 1, , m + p} . (4.32)

We note that eij = cos j + i sin j is complex, so that c is also complex, such
that j is real. We can regard c as the amplitude of the harmonic wave eij .
4.4 Fourier stability analysis 69

In (4.32) ranges approximately between and if J  1. For = we


have the shortest wave that can be resolved on Gh : eij = (1)j , and for
= 0 the wavelength is infinite: e0 = 1. Note that is periodic: j = j+J .
The functions eij , are called Fourier modes. The parameter is called
the wavenumber. The function f (x) eij has period or wavelength 2/, since
f (x + 2/) = f (x).

The Fourier series (4.32) is easily extended to more dimensions. We restrict


ourselves to the two-dimensional case. Let Gh be a uniform grid on the unit
square with nodes

xj = (j1 h1 , j2 h2 ) , j = 0, , J 1 1/h , = 1, 2 .

Define the set of wavenumbers as


{ = (1 , 2 ) : = 2k /J ,
k = m , m + 1, , m + p , = 1, 2} ,

where p = 0, m = (J 1)/2 for J odd and p = 1, m = J /2 1 for J


even. Define
X2
j = j . (4.33)
=1

It can be shown that every grid function : Gh R can be written as


X
j = c eij . (4.34)

with the amplitudes c given by


X
c = N 1 j eij , N = J1 J2 .
jGh

As a consequence we have
X
c eij = 0, j Gh c = 0, . (4.35)

Let us define the l2 -norm by


1 1
X X
kk = N 2 { (j )2 }1/2 , kck = N 2 { |c |2 }1/2
jGh

We will need
Theorem 4.4.1. Parseval.
If and c are related by (4.34), then in the l2 -norm

kk = N 1/2 kck .
70 4. The nonstationary convection-diffusion equation

An example

Consider the example of Sect. 4.2. The perturbation n in the numerical solution
n satisfies the same equation as n , i.e. equation (4.13) (show this!). But now
we assume periodic boundary conditions (to make Fourier analysis applicable),
so that the boundary conditions are replaced by the condition j = j+J . We
have
jn+1 = dj1
n
+ (1 2d)jn + dj+1
n
.
Substitution of (4.32) gives:
X
eij cn+1 cn (dei + 1 2d + dei ) = 0 .
 

Because and h are constant, d is constant; therefore the term between [ ]


does not depend on j; if this were not the case the following step could not be
taken and Fourier analysis falls through. But since the term between [ ] does
not depend on j, it follows from (4.35) that the term between [ ] is zero, and we
get rid of the sum in the preceding equation. Using ei + ei = 2 cos we get

cn+1
= g()cn , g() 1 2d(1 cos ) , (4.36)

where g() is called the amplification factor: it measures the amplification (or
damping) of the amplitude c of the Fourier mode eij . Before continuing with
this example, we go to the general case.

The general case

Whenever Fourier stability analysis is applicable, we get relation (4.36) with


some function g() (that is complex in general). It follows that

cn = g()n c0 ,

so that
kcn k g n kc0 k , g = max{|g()| : } , (4.37)
with equality for the for which the maximum is attained. According to Parse-
vals theorem (Theorem 4.4.1) we have kck = N 1/2 kk, so that the preceding
equation gives
k n k g n k 0 k . (4.38)
From Definition 4.3.4 it follows that for absolute stability we must have

g n < C, n

for some C; hence


g < 1. (4.39)
This is sufficient, but also necessary, because equality can occur in (4.37), since
all Fourier modes can be present, because 0 is arbitrary (cf. Def. 4.3.4).

A sufficient condition for zero-stability is that there exists a constant C such


that
4.4 Fourier stability analysis 71

g (T / ) C (4.40)
for 0 0 (h). Since

C /T = exp( ln C) = 1 + O( ) , (4.41)
T
we may write
g 1 + O( ) . (4.42)
This is the von Neumann condition for zero-stability (after John von Neumann,
who introduced the Fourier method for stability analysis around 1944 in Los
Alamos; not to be confused with the nineteenth century mathematician Neu-
mann of the boundary condition). The von Neumann condition is also necessary,
because if g 1 + , > 0, then there is a with |g()| = 1 + . Choosing
j0 = eij gives k n k/kk = (1 + )n , n = T / , which is unbounded as 0.
Note that the O( ) term (4.42) is not allowed to depend on h; this follows from
(4.40)(4.42).

We will neglect the O( ) term in (4.42), because this makes hardly any differ-
ence. For simplicity, we will also extend the set of wave numbers to

= (, ] (one dimension), = (, ] (, ] (two dimensions).

This also makes hardly any difference, since in practice J  1. We end up with
the following condition for absolute and zero-stability:

g 1 , g max{|g()| : }. (4.43)

(Note that g() is complex in general, so that |g| is the modulus of a complex
number).

An example, continued

In our example g() is given by (4.36), so that g() happens to be real, and
equation (4.43) gives:

1 1 2d(1 cos ) 1 , .

Th right inequality is always satisfied, since d 0. The left inequality gives

d(1 cos ) 1 , ,

so that we must have


d 1/2 .
This beautifully explains the numerical results obtained in Fig. 4.1. It follows
that the time step must satisfy

h2
. (4.44)
2
Here we encounter an example of the function 0 (h) in the definition of zero-
stability:
72 4. The nonstationary convection-diffusion equation

h2
0 (h) = .
2
Condition (4.44) is rather restrictive, because must be reduced much more
than h, when h is decreased for better accuracy. It may be inefficient to use
such small time steps. Therefore we will consider another scheme below. But
first we give another example.

Second example

Consider the one-dimensional convection equation:



+ u,1 = 0. (4.45)
t
We discretize in space with the upwind scheme and in time with the forward
Euler scheme, and obtain (assuming u > 0):

n+1
j = nj c(nj nj1 ) , c u /h . (4.46)

The dimensionless number c is called the Courant-Friedrichs-Lewy number or


CFL number, after the authors of the 1928 paper in which the importance of
numerical stability was first brought to light; c is also called the Courant number.
The quick way to get the amplification factor is to take just one Fourier mode,
and to substitute nj = cn eij ; the amplification factor is g() = cn+1
/cn . This
gives
g() = 1 c(1 ei ) . (4.47)
To study stability we must consider |g()|, which, however, takes a somewhat
unpleasant form, so that we prefer the following more elegant geometrical ap-
proach. We note that the complex number g(), when varies between and
, traces out a circle with center at 1 c and radius c. From Fig. 4.4 it is clear
that for |g()| not to leave the unit circle we must have 0 c 1, resulting in
the following stability condition on the time step:

h/u , (4.48)

which provides another example of the function 0 (h) in Def. 4.3.3.

The -scheme

The backward Euler scheme for equation (4.11) is given by

(n+1
j nj )/ + Lh n+1
j =0. (4.49)

Now we have to solve a system of equations for n+1 , which is why this is
called an implicit scheme; the forward Euler scheme (4.12) is of explicit type.
Therefore a time step with an implicit scheme requires much more computing
work than an explicit scheme, but this may be compensated by better stability
properties, allowing a larger time step. The global truncation error of the Euler
time stepping schemes (4.12) and (4.49) satisfies
4.4 Fourier stability analysis 73

1.5

0.5
Im(g())

0.5

1
c=0.2
c=0.4
c=0.6
c=0.8
1.5
c=1.0
Stability region

2
2 1.5 1 0.5 0 0.5 1 1.5 2
Re(g())

Figure 4.3. Locus of g() in complex plane for different values of parameter c in
(4.47).

e = O( + hm ) ,

where m depends on the accuracy of the spatial discretization Lh . We can


improve this by taking a linear combination of the forward and backward Euler
schemes, as follows:

(n+1 n n n+1 n+1 n


jk jk )/ + (1 )Lh jk + Lh jk = qjk + (1 )qjk , (4.50)

where we now assume the right-hand side q in (4.1) to be nonzero, and where we
have gone to the two-dimensional case. This is called the -scheme. For = 1/2
this is called the Crank-Nicolson scheme, which is second order in time:

e = O( 2 + hm ) .

With the central scheme for convection, the space discretization of equation
(4.1) is, with u, v, constant and uniform mesh sizes h1 and h2 in the x and
ydirections, respectively,:
u v
Lh jk = (j+1,k j1,k ) + (j,k+1 j,k1 )
2h1 2h2

+ 2 (j1,k + 2jk j+1,k ) + 2 (j,k1 + 2jk j,k+1 ) .
h1 h2
(4.51)
74 4. The nonstationary convection-diffusion equation

n
The equation for the perturbation jk is identical to the homogeneous version
(i.e. q = 0) of equation (4.51). For 1/2 < < 1 the stability analysis of the
-scheme is easy. As said before, the quick way to determine the amplification
factor is to substitute jn = cn eij , where now j stands for {j, k}, and where
j = j1 + k2 , cf. equation (4.33). Substitution gives

cn+1
cn + (1 ) Lh ()cn + Lh ()cn+1
=0,

where
Lh () eij Lh eij . (4.52)
commonly referred to as the Fourier transform, or the symbol, of Lh . It follows
that
cn+1 1 (1 ) Lh ()
g() = n = .
c 1 + Lh ()
Let the real and imaginary part of the complex variable Lh be w1 and w2 ,
respectively: Lh = w1 + iw2 . Noting that for two complex numbers z1,2 we
have |z1 /z2 | = |z1 |/|z2 | and noting that |Lh |2 = w12 + w22 , we get

[1 (1 )w1 ]2 + (1 )2 w22
|g()|2 .
(1 + w1 )2 + 2 w22

Assume that w1 0. Then for 1/2 1 the denominator is not smaller


than the numerator, so that |g()| 1, and we have stability. To check whether
w1 0, we have to determine Lh . We find that

Lh = i(c1 sin 1 + c2 sin 2 ) + 2d1 (1 cos 1 ) + 2d2 (1 cos 2 ) , (4.53)

where
u v
c1 , c2 , d1 2 , d2 2 ,
h1 h2 h1 h2
from which it is obvious that w1 = Re( Lh ) 0, . Similarly, with the upwind
scheme for convection we obtain, assuming u, v 0,

Lh = c1 (1 ei1 ) + c2 (1 ei2 ) + 2d1 (1 cos 1 ) + 2d2 (1 cos 2 ) , (4.54)

We have w1 = (c1 +2d1 )(1cos 1 )+(c2 +2d2 )(1cos 2 ) 0 , , since c1,2 0.

Hence, we have established unconditional stability of the -scheme for the


convection-diffusion equation, for 1/2 1. The only interesting values
of are 0, 1/2 + O( ), 1. The value = 0 is of interest because this gives an
explicit scheme, for which a time step is cheap. A value = 1/2 + O( ) is of
interest because this gives O( 2 ) accuracy. Finally, = 1 is of interest because
this is necessary for the discrete maximum principle in the nonstationary case;
we will not go into this. Therefore we will not give stability conditions for the
-scheme for 0 < 1/2, but only for = 0.
In this case the analysis proceeds as follows (Wesseling (2001)). Using the Fourier
transform of the solution and (4.52) we can write (4.1) as

dc
= Lh ()cn (4.55)
dt
4.4 Fourier stability analysis 75

The stability domain of numerical methods for the differential equation


dy
= y, C, (4.56)
dt
is defined as
S = C; |y n+1 | |y n |

(4.57)
Comparing (4.55) and (4.56) shows that for zero stability it is necessary and
sufficient that tL h() S, . To simplify the analysis this requirement
is strengthened to hold for all (as opposed to the discrete values of in . As
a foundation for formulating stability conditions we require
n o
SL S, SL Lh () : (4.58)

In words: For stability the symbol should be scaled with the time step to fit inside
the stability region.
For the -scheme defined in Chapter 3, the symbol is given by

Lh () = Ch () + Dh (), (4.59)
Ch () = 1 () + i2 (), Dh () = (),

where
X X
1 () = 2(1 ) (c s2 ) = 2 c s2 , c = (1 )c (4.60)
=1,2 =1,2
X
2 () = {(1 )s + 1} sin , s = sin2 21 (4.61)
=1,2
X
() = 2 d s (4.62)
=1,2

c and d are the Courant-Friedrichs-Lewy (CFL) number and the diffusion


number, respectively, defined as

c = |u | /h , d = 2 /h2 (4.63)

In (Wesseling (2001)) a number of conditions can be derived on the coefficients


of the discretised convection diffusion equation, i.e. , c , d , to have the symbol
fit in the following different geometric shapes.
Rectangle, Theorem (5.7.1) of (Wesseling (2001))
Ellipse, Theorem (5.7.2) of (Wesseling (2001))
Oval, Theorem (5.7.3) of (Wesseling (2001))
Half ellipse, Theorem (5.7.4) of (Wesseling (2001))
Parabola, Theorem (5.7.5) of (Wesseling (2001))
As an example we will use the conditions on the symbol derived in (Wesseling
(2001)), to derive conditions on the time-step to have a stable time integration
with the explicit Euler method and a central discretization for the convective
terms. Any textbook on time-integration methods will show how to derive the
stability region of this method: A unit circle in the complex plane, centered at
(1, 0):
76 4. The nonstationary convection-diffusion equation

(v + 1)2 + w2 = 1, v + iw = z. (4.64)

We can now use Theorem (5.7.2) to define conditions on the coefficients in the
discretised equation, such that the symbol will fit in this region.
Theorem 4.4.2. (Ellipse).
If X X
d = d a and c2 /d (2 )2 b2 /a (4.65)
=1,2 =1,2

then SL is contained in the ellipse

(v/a + 1)2 + (w/b)2 = 1, v + iw = z, a > 0. (4.66)

The first condition is necessary.


The proof is given in (Wesseling (2001)).
To fit in the stability region we have to choose a = b = 1. This means that the
following restrictions on the time-step should hold.

c21 c2
d1 + d2 1 and + 2 (2 )2 . (4.67)
d1 d2
For the central scheme = 1 and the resulting conditions are
1 1 u u
2 ( 2 + 2 ) 1 and 1. (4.68)
h1 h2 2

Exercise 4.4.1. Suppose we have a numerical scheme for the convection equa-
tion

+c = 0 , c constant ,
t x
that has a stability condition c /h < C. What is the stability condition for this
scheme for the nonlinear case /t + m /x = 0?
Exercise 4.4.2. Derive equations (4.46) and (4.47).
Exercise 4.4.3. Show that scheme (4.46) is unconditionally unstable when u <
0. (This is one way to see why the downwind scheme is bad).

Exercise 4.4.4. Discretize (4.45) with the central scheme in space and the
forward Euler scheme in time. Show that the scheme is unconditionally unstable.
Exercise 4.4.5. This exercise is meant to demonstrate the attractiveness of
the geometric approach illustrated in Fig. 4.4. Determine |g()|, with g() given
by equation (4.47). Use analysis instead of geometry to find conditions on c such
that |g()| 1, .
Exercise 4.4.6. Derive equations (4.51)(4.54).
Exercise 4.4.7. Write down the upwind version of scheme (4.51).
4.5 Numerical experiments 77

4.5 Numerical experiments

Problem statement

Some numerical experiments will be presented for the following one-dimensional


test problem:

+ u,1 ,11 = q, 0 < x < 1, 0 < t T ,
t (4.69)
q(t, x) = 2 cos (x ut) ,

with and u > 0 constant, and a parameter. An exact solution is given by


2
(t, x) = cos (x ut) + e t
cos (x ut) , (4.70)

with arbitrary. Spatial discretization is done with the second order central
or with the first order upwind scheme on the vertex-centered grid of Fig. 2.1
with uniform mesh size h. For temporal discretization the -scheme is used. The
resulting scheme can be written as
hj n+1
( nj ) + Lh n+1 + (1 )Lh nj = hj [qjn+1 + (1 )qjn ] , (4.71)
j j

where hj is the volume of the cell over which is integrated. We choose a Neumann
condition at x = 1, so that hj = h, j 6= J, hJ = h/2. In the interior we get for
the central scheme:
Lh j =Fj+1/2 Fj1/2 ,
1 (4.72)
Fj+1/2 = u(j+1 + j ) (j+1 j ) , j = 2, , J 1 .
2 h
At the Neumann boundary we integrate over a half cell, and obtain

FJ+1/2 = uJ b(t) ,

assuming a Neumann condition (t, 1)/x = b(t).

Choice of time step, mesh size and time scale

The length scale L and time scale T of the exact solution are given by

L = / max(, ), T = min{L/u, (2 )1 } ,

where we take for the length scale of a harmonic function half its wavelength. We
may expect accuracy to be sufficient if  T , h  L. For efficiency, we would
like to avoid more stringent restrictions on and h, such as might arise from
stability. In the numerical experiments to be described we take = 4, = 2,
so that L = 1/4. We take mostly h = 1/30, giving h/L = 0.13.
78 4. The nonstationary convection-diffusion equation

d=1.2 c=1.1 p=1.8 30 cells =1 T=1 d=1.2 c=1.1 p=1.8 30 cells =0.5 T=1
1.5 1.5

1 1

0.5 0.5

0 0

0.5 0.5

1 1
0 0.2 0.4 0.6 0.8 1 0 0.2 0.4 0.6 0.8 1
Figure 4.4. Exact () and numerical solution (*) of (4.69). Central scheme; u =
1.1, = 0.02, h = = 1/30, t = 1, = 4, = 2. Left: = 1, right: = 1/2.

Numerical results

The numerical experiments described below have been carried out with the code
cdns. We prescribe a Dirichlet condition at x = 0 and a Neumann condition at
x = 1. Initial and boundary conditions are chosen conforming with the exact
solution (4.70). The left half of Fig. 4.4 shows a result. In this case we have
T = 0.23,
= 0.15T . The accuracy with = 1 is disappointing. The cause is
that the scheme is only first order accurate in time. With = 1/2 the scheme
is second order accurate in time, and the accuracy is much better. In this case
we have d 2 /h2 = 1.2, u2 /(2) = 1.0, so that the explicit ( = 0) scheme
is instable according to the one-dimensional version (v = 0, h2 = ) of the sta-
bility conditions To get comparable accuracy as in the right part of the figure
with = 0 we find that we need to decrease (in order to compensate for first
order accuracy in time) to 1/300 (results not shown). This gives an elapsed
time (with tic...toc) of 0.287, whereas for the right part of the figure we find
an elapsed time of 0.027. The stability of the explicit ( = 0) scheme constrains
the time step much more than accuracy. This is inefficient, so that it pays of to
use a more complicated scheme with more work per time step, but with a less
severe stability restriction on the time step.

Exercise 4.5.1. Verify the stability conditions by numerical experiments with


the MATLAB program used in this section.
Exercise 4.5.2. Make a cell-centered version of the code cdns .

Some self-test questions

Write down the instationary convection-diffusion equation.

Formulate the maximum principle for the instationary convection-diffusion equation.

Write down the one-dimensional heat equation, discretize it with the forward Euler scheme and
write down the matrix of the scheme.

Define the global and local truncation error for the instationary convection-diffusion equation.
79

Formulate Laxs equivalence theorem.

Define zero-stability and absolute stability.

Write down the Fourier series for a grid function j in d dimensions.

Write down the -scheme.

Which are the interesting values of for the -scheme? Why?

Show that the -scheme is unconditionally stable for 1/2.


5. The incompressible Navier-Stokes equations

5.1 Introduction

In this chapter, the incompressible Navier-Stokes equations in Cartesian coordi-


nates discretized on Cartesian nonuniform grids will be considered, discussing
most of the basic numerical principles in a simple setting. In practical applica-
tions, of course, nonuniform grids and general coordinate systems are prevalent;
Discretisation on nonuniform and unstructured grids will be discussed in later
chapters.

We can be relatively brief in discussing discretization of the Navier-Stokes


equations, because we prepared the ground in our extensive discussion of the
convection-diffusion equation in Chapters 24. Therefore it wil not be necessary
to discuss again the various possibilities for discretizing convection, or stability
conditions.

Only the primitive variable formulation will be discussed. This means that the
velocity components and the pressure will be used as unknowns.

Purpose of this chapter

The purpose of this chapter is to present a numerical method for the incom-
pressible Navier-Stokes equations. In particular, we will:

Present suitable boundary conditions;


Describe spatial discretization on a staggered grid;
Describe spatial discretization on a colocated grid using the Pressure Weighted
Interpolation Method Describe the -scheme, the Adams-Bashforth scheme
and the Adams-Bashforth- scheme for discretization in time;
Show how to linearize with the Picard or Newton method;
Describe the pressure-correction method to solve the discretized nonstationary
Navier-Stokes equations;
Describe the SIMPLE method to solve the discretized stationary Navier-Stokes
equations;
Discuss stability conditions;
Present some numerical experiments with the MATLAB codes ns1 and ns2;
Discuss outflow boundary conditions;
Discuss efficiency.
82 5. The incompressible Navier-Stokes equations

5.2 Equations of motion and boundary conditions

Equations of motion

We restrict ourselves to the two-dimensional case. The equations of motion have


been discussed in Chap. 1. For ease of reference, the equations to be considered
are repeated here. We assume incompressible flow, i.e. D/Dt = 0, so that (cf.
(1.10))
u, = 0 , (5.1)
where we denote partial differentiation by a subscript. The density and viscosity
are taken constant. The dimensionless incompressible Navier-Stokes equations
are given by equation (1.25):

u1,t + u1 u1,1 + u2 u1,2 = p,1 + Re1 u1, ,


(5.2)
u2,t + u1 u2,1 + u2 u2,2 = p,2 + Re1 u2, .

By adding u1 u, and u2 u, (both zero according to (5.1)), respectively, this


can be put in conservation form:

u1,t + (u1 u1 ),1 + (u2 u1 ),2 = p,1 + Re1 u1, ,


(5.3)
u2,t + (u1 u2 ),1 + (u2 u2 ),2 = p,2 + Re1 u2, .

The following units are chosen: velocity: U ; length: L; density: 0 ; pressure:


0 U 2 . Then the Reynolds number is given by

Re = 0 U L/ ,

with the dynamic viscosity coefficient,.

The deviatoric stress tensor (i.e. the viscous part of the stress tensor) is denoted
by . From equation (1.17) it follows that

11 = 2Re1 u1,1 12 = 21 = Re1 (u1,2 + u2,1 ), 22 = 2Re1 u2,2 . (5.4)

The governing equations (5.1) and (5.2) need to be accompanied by initial and
boundary conditions.

Initial conditions

For the momentum equations (5.2) the following initial conditions are required:

u(0, x) = u0 (x) , v(0, x) = v0 (x) ,

with the prescribed initial velocity field u0 satisfying the continuity equation
(5.1). Note that there is no initial condition for the pressure, since pt does not
occur.
5.2 Equations of motion and boundary conditions 83

No-slip condition

Viscous fluids cling to solid surfaces. This is called the no-slip condition. At a
solid surface we have
u(t, x) = v(t, x) , (5.5)
with v(t, x) the local wall velocity. The Dirichlet condition (5.5) holds also at
open parts of the boundary where the velocity is prescribed, which may be the
case at an inflow boundary. But at an inflow boundary one may also prescribe
condition (5.6) given below.

Free surface conditions

At a free surface the tangential stress components are zero. We consider only
the very special case where the free surface is fixed at x2 = a = constant. For
the general case, see Sect. 6.2 of Wesseling (2001). At a fixed free surface, the
normal velocity and the tangential stress are zero:

u2 (t, x1 , a) = 0, u1,2 (t, x1 , a) = 0 , (5.6)

where we have used

12 (t, x1 , a) = Re1 (u1,2 + u2,1 )(t, x1 , a) = Re1 u1,2 (t, x1 , a) .

We see that we have a Dirichlet condition for the normal velocity and a Neumann
condition for the tangential velocity. A truly free surface moves, its shape must
be determined and follows from the condition that the normal stress equals the
ambient pressure. This case will not be considered. Conditions (5.6) may also
arise at a plane of symmetry. In special cases one may wish to prescribe non-zero
tangential stress in (5.6), for example, when one wishes to take the influence of
wind shear on a water surface into account.

Inflow conditions

The momentum equations resemble convection-diffusion equations for u1 and u2 ,


so that the insights gained in the convection-diffusion equation in Chapt. 24
provide guidelines for numerical approximation. Based on what we learned about
the convection-diffusion equation, we prescribe Dirichlet conditions at an inflow
boundary. If, for example, x1 = 0 is an inflow boundary, we prescribe

u1 (t, 0, x2 ) = U1 (t, x2 ) , u2 (t, 0, x2 ) = U2 (t, x2 ) . (5.7)

Outflow conditions

At an outflow boundary, often not enough physical information is available on


which to base a sufficient number of boundary conditions. Usually only the
pressure is known. This is not as serious as it may seem, because when Re  1
wrong information generated by an artificial boundary condition propagates
84 5. The incompressible Navier-Stokes equations

upstream only over a distance of O(Re1 ). This is plausible because of the


resemblance of (5.2) to the convection-diffusion equation, and may in fact be
shown directly by applying singular perturbation analysis to (5.2) in a similar
manner as in Sect. 3.2. In order to avoid spurious numerical wiggles it is advis-
able to choose as artificial outflow condition a homogeneous Neumann condition
for the tangential velocity. For an outflow boundary at x1 = a this gives:
p(t, a, x2 ) = p , u2,1 (t, a, x2 ) = 0 . (5.8)

Compatibility condition

At every part of the boundary exactly one of the boundary conditions (5.5),
(5.6) or (5.8) needs to be prescribed. If it is the case that along the whole of
the boundary the normal velocity u (t, x)n is prescribed, then it follows
from (5.1) and the divergence theorem that the following compatibility condition
must be satisfied: Z
ua lpha(t, x)na lphadS = 0 . (5.9)

It can be shown theoretically (for further information, see Sect. 6.2 of Wesseling
(2001)) that in order for (5.1), (5.2) to be well-posed, the normal component
of the prescribed initial velocity field u0 (x) and a prescribed normal velocity
component must match at t = 0:
u0 (x)n = u (0, x)n
on parts of where the normal velocity is prescribed. But the tangential
components of the initial and boundary velocity fields need not match at t = 0.
Therefore, for example, a sliding wall may be set in motion instantaneously
at t = 0 in a fluid originally at rest, but one should not let the speed of an
arbitrarily shaped body or of an inlet flow change discontinuously.

5.3 Spatial discretization on staggered grid


Let the domain be rectangular and be covered with a nonuniform grid consisting
of rectangular cells as sketched in Fig. 5.1. The oldest and most straightforward

Figure 5.1. Rectangular nonuniform grid

approach to discretizing the Navier-Stokes equations in space is the method


proposed in 1965 by Harlow and Welch (see Sect 6.4 of Wesseling (2001) for ref-
erences to the literature). On orthogonal grids it remains the method of choice.
5.3 Spatial discretization on staggered grid 85

Staggered grid

Grid points for different unknowns are staggered with respect to each other.
The pressure resides in the cell centers, whereas the cell face centers contain
the normal velocity components, cf. Fig. 5.2. The grid nodes are numbered as

j,k+1/2

jk j+1/2,k

Figure 5.2. Staggered placement of unknowns; , : velocity components; : pressure.

follows. The cell with center at xjk is called

jk , j = 1, , J, k = 1, , K .

The horizontal and vertical sides of jk have length h1j and h2k , respectively.
The center of the east side of jk is called xj+1/2k , etc., see Fig. 5.2. Hence,
jk contains the following unknowns: pjk , u1 j1/2k , u2 jk1/2 . Note that with
a staggered grid we always have a mixture of vertex-centered and cell-centered
discretization. Unavoidably, at a boundary, some unknowns will have nodes upon
it, whereas other unknowns have no nodes on this boundary, but half a mesh
size removed. Therefore it is fortunate, as seen in Chapt. 2, that vertex-centered
and cell-centered discretization are on equal footing as far as global accuracy
and ease of implementation of boundary conditions are concerned.

Discretization of continuity equation

The continuity equation (5.1) is integrated over jk , resulting in


j+1/2,k j,k+1/2
h2k u1 |j1/2,k + h1j u2 |j,k1/2 = 0 . (5.10)

The advantage of the staggered placement of the unknowns is that no further


approximation is necessary in this equation.

Discretization of momentum equations

Finite volume integration takes place over control volumes surrounding u1 and
u2 grid points, with sides through neighboring pressure points. For example,
the control volume for u1 j+1/2k consists of the union of half of j,k and half of
j+1k , as illustrated in Fig. 5.3. This control volume is called j+1/2,k . Finite
volume integration gives
86 5. The incompressible Navier-Stokes equations

Figure 5.3. Control volume j+1/2,k for u1 j+1/2k .

Z
u1,t + (u1 u1 + p Re1 u1.1 ),1 + (u1 u2 Re1 u1,2 ),2 d
 
=
j+1/2,k

du1 j+1/2,k j+1,k (5.11)


h1j+1/2 h2k + h2k u1 u1 + p Re1 u1,1 jk
dt
j+1/2,k+1/2
+h1j+1/2 u1 u2 Re1 u1,2 j+1/2,k1/2 = 0 .

Here p occurs only in its own nodal points, and further approximation is not
necessary. But the derivatives and u1 and u2 need to be approximated in terms
of surrounding nodes.

The derivatives are approximated as follows:

u1,1 |jk
= (u1 j+1/2,k u1 1
j1/2k )/hj ,

u1,2 |j+1/2k+1/2 = (u1 j+1/2k+1 u1 2
j+1/2k )/hk+1/2 .

The central scheme for the inertia term is obtained with the following approxi-
mations:

u21
= (u21 + u21
jk j1/2,k j+1/2,k )/2 ,
(u1 u2 )j+1/2,k+1/2
= (u1 j+1/2,k + u1 j+1/2,k+1 )(u2 j,k+1/2 + u2 j+1,k+1/2 )/4 .

The resulting stencil for u1 j+1/2,k is given in Fig. 5.4.

Figure 5.4. Stencil for u1 j+1/2,k .

The upwind scheme for the inertia term is obtained as follows. We do not wish
to test on the sign of u , because if statements in for loops are very computer
time consuming, cf. Sect. 4.3. We note that upwind approximation of a term
u, can be implemented as follows, without an if statement:
5.3 Spatial discretization on staggered grid 87

1
u1 (xj+1/2 )

= (u1 + |u1 |)j + (u1 |u1 |)j1 .
2
By using this idea we obtain the following upwind approximation of the inertia
terms:
1
u21 jk (u1 + |u1 |)2j1/2,k + (u1 |u1 |)2j+1/2,k ,

=
4
1
(u1 u2 )j+1/2,k+1/2 = (u2 + |u2 |)j+1/2,k+1/2 u1 j+1/2,k (5.12)
2 
+(u2 |u2 |)j+1/2,k+1/2 u1 j+1/2,k+1 ,
where
u2 j+1/2,k+1/2 (u2 j,k+1/2 + u2 j+1,k+1/2 )/2 .
The momentum equation for u2 is discretized similarly. This completes finite
volume discretization in the interior. We continue with the boundary condi-
tions. On the staggered grid the implementation of the boundary conditions
(5.5)(5.8) is just as simple and done in the same way as for the convection-
diffusion equation in Chapters 2 and 3.

The no-slip condition

Let x2 = 0 be a wall moving horizontally with velocity U1 (t). Then the lower
side of j,1 is at the boundary. We have u2 j1/2 = 0, so that no discretization for
u2 j,1/2 is required. In the finite volume scheme for u1 j+1/21 we need, according
to the stencil presented in Fig. 5.4, u1 j+1/2,0 , which is not available, because
x1 j+1/2,0 is outside the domain. Values outside the domain are called virtual
values. We write u1 j+1/2,0 + u1 j+1/2,1 = 2U (t), so that
u1 j+1/2,0 = 2U1 (t) u1 j+1/2,1 , (5.13)
which is used to eliminate the virtual value u1 j+1/2,0 .

Free surface conditions

Let x2 = a be a free surface boundary or a symmetry boundary, so that we have


conditions (5.6). Let jk be at the boundary. We have u2 j,K+1/2 = 0, so that
no discrete equation is required for u2 j,K+1/2 . In the stencil for u1 j+1/2,K we
have u1 j+1/2,K+1 , according to Fig. 5.4, which is outside the domain and has
to be eliminated. We put 0 = u1,2 = (u1 j+1/2,K+1 u1 j+1/2,K )/h2K , so that
u1 j+1/2,K+1 = u1 j+1/2,K . (5.14)

Inflow conditions

Let x1 = 0 be an inflow boundary, so that 1k is at the boundary. According to


(5.7) we have Dirichlet conditions for u1 and u2 , so that the situation is almost
the same as for the no-slip condition. We put
u1 1/2,k = U1 (t, x2 k ) , u2 0,k+1/2 = 2U2 (t, x2 k+1/2 ) u2 1,k+1/2 . (5.15)
88 5. The incompressible Navier-Stokes equations

Outflow conditions

Let Jk be at an outflow boundary x1 = a. We need discrete equations for


u1 J+1/2,k and u2 J,k+1/2 . The control volume for uJ+1/2,k consists of half of
Jk , as illustrated in Fig. 5.5. Finite volume integration gives, similar to (5.11),

11
00
00
11 111
000 11
00 111
000
11
00
000
111
00
11 00
11 000
111
00
11
00
11 000
111
000
111
00
11
00
11 000
111
000
111
00
11
00
11 000
111
000
111
00
11
00
11 000
111
000
111
00
11 000
111
00
11
00
11 000
111
000
111
00
11
00
11 000
111
000
111
00
11
00
11 000
111
000
111
00
11
00
11 000
111
000
111
00
11
00
11 000
111
000
111
00
11
00
11 000
111
000
111
00
11
00
11 000
111
000
111
111
000 11
00
11
00 11
00

Figure 5.5. Control volumes for u1 J+1/2,k and u2 J,k+1/2 at outflow boundary.

Z
u1,t +(u1 u1 + p Re1 u1,1 ),1 + (u1 u2 Re1 u1,2 ),2 d
 
=
J+1/2,k
J+1/2,k
1 1 2
2 hJ hk (u1 J+1/2,k ),t + h2k u1 u1 + p Re1 u1,1 Jk
J+1/2,k+1/2
+ 12 h1J u1 u2 Re1 u1,2 J+1/2,k1/2 = 0 .

Compared to the interior case, we have to change only terms at or near the
outflow boundary. We put the normal stress at x1 J+1/2,k equal to the prescribed
pressure (cf. (5.8)):
(p Re1 u1,1 )J+1/2,k = p .
Furthermore,

(u1 u2 )J+1/2,k+1/2 = u2 J,k+1/2 u1 J+1/2,k+1/2 ,

where u1 J+1/2,k+1/2 is approximated with the upwind scheme or the central


scheme. Finally,

Re1 (u1,2 )J+1/2,k+1/2


= (u1 J+1/2,k+1 u1 2
J+1/2,k )/hJ+1/2,k+1/2 .

The scheme for u2 J,k+1/2 brings nothing new. A virtual value u2 J+1,k+1/2
occurs as may be seen form the stencil of the u2 -momentum equation, which is
obtained from Fig. 5.4 by rotation over 90o . This virtual value is eliminated by
using u2,1 = 0 (cf. (5.8)), which results in

u2 J+1,k+1/2 = u2 J,k+1/2

(cf. (5.14)).

Summary of equations

We put all unknown velocity components in some order in an algebraic vec-


tor u and all pressure unknowns in an algebraic vector p, and we divide by
5.4 Spatial discretization on colocated grid 89

the coefficients of the time derivatives. Then the scheme can be written as a
differential-algebraic system of the following structure:
u,t + N (u) + Gp = f (t) , Du = g(t) . (5.16)
Here N is a nonlinear algebraic operator arising from the discretization of the
inertia and viscous terms, G is a linear algebraic operator representing the dis-
cretization of the pressure gradient, D is a linear algebraic operator representing
the discretization of divergence operator in the continuity equation, and f and
g are known source terms, arising from the boundary conditions. This is called
a differential-algebraic system because it is a mixture of a system of ordinary
differential equations (the first member of (5.16)), and algebraic equations (the
second member of (5.16)). This completes our description of spatial discretiza-
tion on the staggered grid.

5.4 Spatial discretization on colocated grid


By staggering the unknowns to different positions in the computational cells, a
straightforward and accurate discretization on Cartesian grids can be achieved.
However, the use of a colocated grid is still popular for a number of different
reasons:
The extension of a colocated scheme to a structured curvilinear grid can be
done easily in a formulation in a Cartesian frame of reference. This is not
(that) easily done for a staggered arrangement of unknowns. The latter has
certainly been done.
The compressible Navier-Stokes equations are nearly always discretized on a
colocated grid. An algorithm to solve the compressible Navier-Stokes equa-
tions can be modified to solve the incompressible equations by including pre-
conditioning on the continuous equations. So the use of a modified algorithm
for the compressible Navier-Stokes equations almost automatically leads to a
colocated discretization.
The most efficient solution algorithms for the linear systems resulting from
discretization of the momentum and pressure correction equation are based
on or make use of hierarchical algorithms like e.g. multigrid. The staggered
grid arrangement requires different inter-level operators for each unknown,
adding to the complexity of the algorithm.

Colocated grid

Grid points for different unknowns are colocated with respect to each other. We
will discuss the case, where the pressure and both velocity components reside in
the cell centers, cf. Fig. 5.6. The grid nodes are numbered as follows. The cell
with center at xjk is called
jk , j = 1, , J, k = 1, , K .
As in the staggered case the horizontal and vertical sides of jk have length h1j
and h2k , respectively. The center of the east side of jk is called xj+1/2,k , etc.,
see Fig. 5.6. Hence, jk contains the following unknowns: pjk , u1 jk , u2 jk .
90 5. The incompressible Navier-Stokes equations

jk

Figure 5.6. Colocated placement of unknowns; , : velocity components;


: pressure.

Discretization of continuity equation

The continuity equation (5.1) is integrated over jk , resulting in


j+1/2,k j,k+1/2
h2k u1 |j1/2,k + h1j u2 |j,k1/2 = 0 . (5.17)

where we use central approximations of u1 |j+1/2,k and u2 |j,k+1/2 in the following


way:
u1 j+1/2,k = (u1 jk + u1 j+1,k ) /2, (5.18)
u2 j,k+1/2 = (u2 jk + u2 j,k+1 ) /2.

Discretization of momentum equations

Finite volume integration for the momentum equation for the u components
takes place over the same control volume as used for the discretization of the
continuity equation, as illustrated in Fig. 5.7.

Figure 5.7. Control volume jk for u1 jk .

Finite volume integration gives


Z
u,t + (u u + p Re1 u, ), d
 
=
jk

j+ 21 k (5.19)
h1j h2k u jk,t + h2k u1 u + 1 p Re1 u,1 1
j 2 k

jk+ 12
+h1j u2 u + 2 p Re1 u,2 1 =0.
jk 2
5.4 Spatial discretization on colocated grid 91

As opposed to the staggered discretization we need to interpolate the velocities


and the pressure for the fluxes.
The derivatives are approximated as follows:

u,1 |j+1/2,k
= (u j+1k u 1
jk )/hj ,

u,2 |j,k+1/2
= (u jk+1 u 2
jk )/hk+1/2 .

The central scheme for the inertia term is obtained with the following approxi-
mations:

u21
= (u21 + u21
j+1/2,k jk j+1k )/2 ,
(u1 u2 )jk+1/2
= (u1 jk u2 jk + u1 j+1k+1 u2 j+1,k+1 )/2 .

The resulting stencil for u1 jk is given in Fig. 5.8.

Figure 5.8. Stencil for ujk .

The first order upwind scheme is obtained as follows:

u21 j+1/2k = u21 jk , u1 jk + u1 j+1k 0 (5.20)


u21 j+1/2k = u21 j+1k , u1 jk + u1 j+1k <0 (5.21)
(u1 u2 )jk+1/2 = (u1 u2 )jk , u1 jk + u1 j+1k 0 (5.22)
(u1 u2 )jk+1/2 = (u1 u2 )jk+1 , u1 jk + u1 jk+1 <0 (5.23)

The pressure is interpolated to the cell faces using a central approximation:

pj+1/2k
= 1
2 (pjk + pj+1k ) . (5.24)

The momentum equation for u2 is discretized similarly. This completes finite


volume discretization in the interior. We continue with the boundary conditions.
On the colocated grid the implementation of the boundary conditions (5.5)(5.8)
is just as simple and done in the same way as for the convection-diffusion equa-
tion in Chapters 2 and 3.

The no-slip condition

Let x2 = 0 be a wall moving horizontally with velocity U (t). Then the lower side
of j,1 is at the boundary. We have u2 j,1/2 = 0. In the finite volume scheme for
u1 j,1 we need, according to the stencil presented in Fig. 5.8, u1 j,0 , which is not
92 5. The incompressible Navier-Stokes equations

available, because xj,1 is outside the domain.We write u1 j0 + u1 j1 = 2U1 (t),


so that
u1 j0 = 2U1 (t) u1 j1 , (5.25)
which is used to eliminate the virtual value u1 j0 . Similarly, we need u2 j0 for
the stencil of u2 j1 . The former can be approximated as:

u2 j0 = u2 j1 , (5.26)

Free surface conditions

Let x2 = a be a free surface boundary or a symmetry boundary, so that we


have conditions (5.6). Let jk be at the boundary. We have u2 jK+1/2 = 0,
that will be used to eliminate the need for u2 jK+1 in the same way as is done
for the no-slip condition. In the stencil for u1 jK we have u1 jK+1 , according
to Fig. 5.8, which is outside the domain and has to be eliminated. We put
0 = u1,2
= (u1 jK+1 u1 jK )/h2K , so that

u1 jK+1 = u1 jK , (5.27)
u2 jK+1 = u2 jK (5.28)

Inflow conditions

Let x1 = 0 be an inflow boundary, so that 1k is at the boundary. According to


(5.7) we have Dirichlet conditions for u1 and u2 , so that the situation is almost
the same as for the no-slip condition. We put

u1 0k = 2U1 (t, x2 k ) u1 1k , u2 0k = 2U2 (t, x2 k ) u2 1k . (5.29)

Outflow conditions

Let Jk be at an outflow boundary x1 = a. We need discrete equations for


u1 J+1,k . Finite volume integration gives, similar to (5.11),
Z
u1,t +(u1 u1 + p Re1 u1,1 ),1 + (u1 u2 Re1 u1,2 ),2 d
 
=
Jk
J+1/2,k
h1J h2k u1,t J,k + h2k u1 u1 + p Re1 u1,1 J1/2,k
J,k+1/2
+ 12 h1J u1 u2 Re1 u1,2 J,k1/2 = 0 .

Compared to the interior case, we have to change only terms at or near the
outflow boundary. We put the normal stress at xJ+1/2,k equal to the prescribed
pressure (cf. (5.8)):
(p Re1 u1,1 )J+1/2,k = p .
Finally, we have to specify the value of u1 J+1,k , by linear (5.30) or constant
(5.31) extrapolation from the interior.
5.4 Spatial discretization on colocated grid 93

u1 J+1k = 2u1 Jk u1 J1k (5.30)


u1 J+1k = u1 Jk (5.31)

This concludes our description of the discretization of the incompressible Navier-


Stokes equations. However, the discretization just presented is completely use-
less. We will now show why, by verifying that the following ansatz leads to a
solution of the discretized equations (Wesseling (2001)) :

u jk = (1)j+k g(t), (5.32)


j+k
p = (1) , (5.33)

where g(t) remains a function to be defined. If we substitute (5.32) and (5.33)


in the momentum equation (5.19), the contribution of the inertial terms and
the pressure gradient clearly vanish. What remains is the contribution of the
diffusive fluxes:
h2k 1 h1j 1
h1j h2k (1)j+k gt (t) + 4 Re g(t) + 4 Re g(t) = 0
h1j h2k
!
1 1
gt (t) + 4Re1 + 2 2 g(t) = 0, (5.34)
(h1j )2 (hk )

The ordinary differential equation (5.34) can be solved for g(t)


 
1
4Re 1
+ 1
t
(h1 )2 (h2 )2
g(t) = e j k (5.35)

Apparently, our ansatz presents a solution that allows so-called checkerboard


oscillations for both velocity and pressure, where the former are only slowly
dampened for large values of Re and the latter are not dampened at all.
In the early eighties a specific fix was proposed by Rhie and Chow. This fix
is commonly referred to as Using Rhie and Chow or the Pressure Weighted
Interpolation method, or PWI-method. Although its use is questionable, it is
important to be familiar with this approach and the implications it has for
the accuracy of the solution. Other approaches to circumvent the checkerboard
modes are discussed in (Wesseling (2001)).
The idea of the PWI method is to replace the linear interpolation of the face
velocities in the continuity equation with the following expressions:
 2 
1 hk 1
u1 j+1/2,k = (u1 jk + u1 j+1,k ) + p |j+1,k
jk , (5.36)
2 4a1
1 pjk = pj+1,k 2pjk + pj1,k ,
 1 
1 hk 2
u2 j,k+1/2 = (u2 jk + u2 j,k+1 ) + p |j,k+1
jk , (5.37)
2 4a2
2 pjk = pj,k+1 2pjk + pj,k1 ,

where a is the sum of all the coefficients of u lm , (lm) 6= (jk) (all the off
diagonal elements in the discretized momentum equation operator). Because for
smooth p, 1/2 p = O(h2 ), the pressure dependent terms in (5.36) and (5.37) do
not influence the order of the interpolation. The discretized continuity equation
will now read:
94 5. The incompressible Navier-Stokes equations

j+1/2,k j,k+1/2
h2k u1 |j1/2,k + h1j u2 |j,k1/2 + (5.38)
(      )
1 1 1 1 1 1
(h2 )2 1
p 1
p + p +
2a j+1,k a jk 2a1 j1,k
(      )
1 2 1 2 1 2 1 2
(h ) p p + p =0
2a2 j,k+1 a2 jk 2a2 j,k1

This corresponds approximately to:

u, = Ch4 (p,1111 + p,2222 ) (5.39)

To have a consistent discretization it is important to use the expressions (5.36)


and (5.37) for the convection velocities in the momentum equation and addi-
tional convection diffusion equations in the model. We will not discuss the math-
ematical background of the PWI-method, because there isnt any. The method
aims to achieve a coupling between adjacent degrees of freedom in the pressure
and this is achieved without affecting the order of accuracy of the discretization.

Summary of equations

We put all unknown velocity components in some order in an algebraic vec-


tor u and all pressure unknowns in an algebraic vector p, and we divide by
the coefficients of the time derivatives. Then the scheme can be written as a
differential-algebraic system of the following structure:

u,t + N (u) + Gp = f (t) , Du + Bp = g(t) . (5.40)

Here N is a nonlinear algebraic operator arising from the discretization of the


inertia and viscous terms, G is a linear algebraic operator representing the dis-
cretization of the pressure gradient, D is a linear algebraic operator representing
the discretization of divergence operator in the continuity equation, B is the
discretization of the fourth order operator arising form the Pressure Weighted
Interpolation method and f and g are known source terms, arising from the
boundary conditions. This is called a differential-algebraic system because it is
a mixture of a system of ordinary differential equations (the first member of
(5.40)), and algebraic equations (the second member of (5.40)). This completes
our description of spatial discretization on the colocated grid.

5.5 Temporal discretization on staggered grid


We now discretize also in time. Equation (5.16) is our point of departure. With
the forward Euler scheme we obtain:
1 n
(u un1 ) + N (un1 ) + Gpn1/2 = f (tn1 ) , Dun = g(tn ) . (5.41)

Note that we have to take the pressure term at the new time tn , or for better
accuracy in time, at tn1/2 , in order to have degrees of freedom to satisfy the
algebraic solenoidality constraint (second equation of (5.41)). In other words,
5.5 Temporal discretization on staggered grid 95

the pressure always has to be taken implicitly; this is a consequence of the


differential-algebraic nature of (5.40). In incompressible flows, the pressure acts
as a Lagrange multiplier, that makes it possible to satisfy the continuity equa-
tion.

With the -scheme we obtain:


1 n
(u un1 )+N (un ) + (1 )N (un1 ) + Gpn1/2
(5.42)
=f (tn ) + (1 )f (tn1 ) , Dun = g(tn ) .

Linearization

Equation (5.42) is a nonlinear system, because the nonlinear inertia term makes
the operator N nonlinear. To make the system more easily solvable we linearize
the operator N . Newton linearization works as follows, writing u = un un1 :

N (un ) = N (un1 + u)
= N (un1 ) + C(un1 )u ,

where C(u) is the Jacobian of N evaluated at u. We clarify this by taking as


an example one term of the inertia term (cf. (5.11)):

(un+1 2 n 2
= (un1 jk )2 + 2un1 jk u1
1 jk ) = (u1 jk + u1 jk ) jk .

We eliminate u and obtain:


2
(un+1 n n+1 n 2
1 jk ) = 2u1 jk ujk (u1 jk ) ,

which is linear in the unknown un+1


1 jk . Picard linearization works as follows:

2 n
(un+1 n+1
1 jk ) = u1 jk u1 jk .

This is simpler, but temporal accuracy decreases to O( ). A second order accu-


rate approximation is obtained if one replaces un by an extrapolation to tn+1 :
2
(un+1 n n1 n+1
1 jk ) = (2u1 jk u1 jk )u1 jk . (5.43)

We will call this extrapolated Picard linearization.

After linearization, the matrix C that one obtains changes every time step,
because C depends on un1 . Matrix generation is computer time consuming.
Therefore a time step will be cheaper if the inertia term is discretized explicitly.
This gives us a so-called IMEX (implicit-explicit) scheme. The resulting scheme
is cheaper, because the implicit operator is now linear and independent of time,
so that the corresponding matrix has to be generated only once, and other
ingredients necessary for solving, such as an LU factorization, need also to be
prepared only once. To maintain second order accuracy in time, it is attractive
to use for the explicit part not the forward Euler scheme, but a second order
explicit scheme, such as the Adams-Bashforth scheme. For a system of ordinary
differential equations w,t = f (w, t) this scheme is given by
96 5. The incompressible Navier-Stokes equations

1 n 3 1
(w wn1 ) = f (wn1 , tn1 ) f (wn2 , tn2 ) . (5.44)
2 2
This is called a two-step method, because two time steps are involved. At the
initial time t = 0 one may define w1 = w0 . Application to the Navier-Stokes
equations takes place as follows. Let N (u) in (5.42) be split in a nonlinear inertia
part C and a linear viscous part B, as follows:
N (u) = C(u) + Bu .
Then the Adams-Bashforth-Crank-Nicolson scheme is obtained by using (5.42)
for Bu and (5.44) for C(u), so that we obtain:
1 n
(u un1 )+ 3
2 C(u
n1
) 21 C(un2 ) + 12 B(un + un1 ) + Gpn1/2

= f (tn+1/2 ) , Dun = g(tn ) .

General formulation on staggered grid

As seen from these examples, time stepping methods applied to equation (5.11)
can generally be written as

A(un ) + Gpn1/2 = r n ,
(5.45)
Dun = g(tn ) ,
where r n is known from previous time steps and the boundary conditions. For
explicit methods, A is the identity I. The system (5.45) is a coupled system
for un and pn1/2 . Computing time is reduced if pn1/2 and un can be solved
for separately. To this end the following method has been devised, which is the
method of choice for nonstationary problems.

Pressure-correction method

Equation (5.45) is not solved as it stands, but first a prediction u of un is made


that does not satisfy the continuity equation. Then a correction is computed
involving the pressure, such that the continuity equation is satisfied. The method
is given by:
A(u ) + Gpn3/2 = r n , (5.46)
un u + G(pn1/2 pn3/2 ) = 0 , (5.47)
Dun = g(tn ) . (5.48)
Equation (5.46) more or less amounts to solving discretized convection-diffusion
equations for the predicted velocity components. We use the best available guess
for the pressure, namely pn3/2 . Equation (5.47) is motivated by the fact, that
if in the explicit case, where A is the identity, we eliminate u from (5.46)
and (5.47), then the original system (5.45) is recovered. The pressure can be
computed by applying the operator D to (5.47) and using (5.48), resulting in
1
DGp = {Du g(tn )}, pn1/2 = pn3/2 + p . (5.49)

5.5 Temporal discretization on staggered grid 97

After pn1/2 has been computed, un follows from (5.47).

Equation (5.47) can be regarded as a correction of u for the change in pressure.


Therefore (5.46)(5.49) is called the pressure-correction method. It is an exam-
ple of a fractional step method, in which a time step is split up in sub-steps,
and different physical effects are accounted for separately in the sub-steps. Here
pressure forces are accounted for in the second sub-step, and inertia and friction
in the first sub-step. Confusingly, the term pressure-correction method is often
also applied to various iterative methods to solve the stationary Navier-Stokes
equations, in which velocity and pressure updates are carried out not simulta-
neously but successively. Such methods will be encountered in Chap. 6, where
they will be called distributive iteration methods. These should not be confused
with the pressure-correction method used in time accurate schemes as formu-
lated above. This method may also be called a projection method, because in
(5.47) the new velocity un is the projection of the intermediate velocity field u
on the space of velocity fields with discretized divergence equal to zero.

Remembering that divgrad equals the Laplacian, we see that (5.49) looks very
much like a discrete Poisson equation; it is frequently called the pressure Poisson
equation. Note that no boundary condition needs to be invoked for p (fortu-
nately, for no such condition is given with the original equations, at least not
on the complete boundary), because the boundary conditions have already been
taken into account in the construction of D, G and g; the operator DG works
exclusively on pressure values at grid points in the interior of the domain.

Even if the method is explicit (A is a diagonal matrix), we still have to solve an


implicit system for p. This is an unavoidable consequence of the differential-
algebraic nature of (5.16).

As we remarked before, by elimination of u it is easily seen that in the explicit


case the pressure-correction method (5.46)(5.49) is equivalent to (5.45), and
that this remains true if pn3/2 is neglected in (5.46) and (5.47). But in the
implicit case this does not hold, and inclusion of a sufficiently accurate first
guess, such as pn3/2 , for the pressure in (5.46) seems to be necessary to obtain
full, i.e. O( 2 ), temporal accuracy. This may make it necessary to compute the
initial pressure field at the starting step (n = 1), to be used instead of p1/2 .
This may be done as follows. Application of D to (5.16) at t = 0 gives
dg(0)/dt + DN (u(0)) + DGp(0) = Df (0) . (5.50)
1/2
After solving p(0) from (5.50), we put p = p(0).

Discrete compatibility condition

In case the pressure is not involved in any of the boundary conditions, it follows
from the incompressible Navier-Stokes equations that the pressure is determined
up to a constant. The system (5.49) for p is singular in this case, and (5.49)
has a solution only if the right-hand side satisfies a compatibility condition. The
boundary conditions discussed in Sect. 5.2 are such that if the pressure is not
involved in any of the boundary conditions, then the normal velocity component
is prescribed all along the boundary, and the compatibility condition (5.9) is
98 5. The incompressible Navier-Stokes equations

satisfied. Summing the discrete continuity equation (5.10) over all cells reduces,
due to cancellation in the interior, to the following sum over boundary points:
K
X (J+1/2,k) J
X (j,K+1/2)
h2k u1 + h1j u2 =0, (5.51)

(1/2,k) (j,1/2)
k=1 j=1

where u1 and u2 are the prescribed velocity components at the boundary. If


(5.51) is not satisfied exactly one should adjust u1 and u2 at the boundaries,
which should not be difficult, because of the compatibility condition (5.9). If
(5.51) holds, then it turns out that the elements of the right-hand side vector of
(5.49) sum to zero, which is precisely the compatibility condition required for
existence of solutions of (5.49). If one desires to make the solution unique one
can fix p in some point, but iterative methods usually converge faster if one
lets p float.

Temporal accuracy

For literature on the accuracy of the pressure-correction method, see Wesseling


(2001), Sect. 6.6 and references quoted there. Indications are that the temporal
accuracy of un is of the same order as the order of accuracy of the under-
lying time stepping method (for example, O( 2 ) for Adams-Bashforth-Crank-
Nicolson), but that the accuracy of pn1/2 is only O( ), irrespective of the
time stepping method used. If one desires, a pressure field with improved accu-
racy can be obtained after un has been computed (with the pressure-correction
method) by proceeding in the same way as in the derivation of (5.50), leading
to the following equation for pn1/2 :

dg(tn )/dt + DN (un ) + DGpn1/2 = Df (tn ) ,

which very likely results in a pressure field pn1/2 with the same order of tem-
poral accuracy as the velocity field.

Stability

For stability of (5.46)(5.49), it seems necessary that (5.46) is stable. It is


conjectured that this is sufficient for the stability of (5.46)(5.49); numerical
evidence supports this conjecture. We restrict ourselves to Fourier stability anal-
ysis of (5.46). To this end (5.46) is linearized, the coefficients are taken constant
(frozen), the boundary conditions are assumed to be periodic, and the known
source terms Gpn3/2 and r n are neglected. Hence, carrying out Fourier stabil-
ity analysis for (5.46) implies that the discretization of the following simplified
and linearized version of (5.2) is considered:

u,t + U u, Re1 u, = 0, = 1, 2 . (5.52)

Equation (5.52) consists of decoupled and identical convection-diffusion equa-


tions, for which Fourier stability analysis is presented in Chap. 4. The stability
analysis of the Adams-Bashforth-Crank-Nicolson scheme is a bit involved and
is not presented in Chap. 4. In Sect. 6.6 of Wesseling (2001) stability conditions
5.6 Numerical experiments 99

for the Adams-Bashforth-Crank-Nicolson scheme are derived. With the central


scheme for the inertia terms we have:
max[1 , min{2 , 3 }] ,
4  1
1 U U ,
3Re
Re  1 1 (5.53)
2 ,
4 h h
3 1/3  2 1 2/3 1
3 (U1 /h ) + (U22 /h2 )2/3 .
Re
For the upwind scheme:

max[1 , min{2 , 3 }] ,
2 h U12 U22 i1
1 + ,
3Re 2 + U1 h1 Re 2 + U2 h2 Re
Re h 1 + U1 h1 Re/2 1 + U2 h2 Re/2 i1
2 + ,
4 (h1 )2 (h2 )2
3 1/3 h U14 1/3  U24 1/3 i1
3 + .
Re (h1 )2 + U1 (h1 )3 Re/2 (h2 )2 + U2 (h2 )3 Re/2
(5.54)

The computing cost of checking in every grid point whether the stability con-
dition is satisfied is often not negligible, so in practice this is often done only
every 5 or 10 time steps or so, or only once, if one has a reasonable a priori
estimate of U1 (= 2 max(u1 )) and U2 (= 2 max(u2 )). Here the factor 2 arises
from the nonlinearity of the inertia terms, in the same way as for the Burgers
equation in Sect. 4.4.

Exercise 5.5.1. What is the Newton linearization of u1 u2 ?

5.6 Numerical experiments


The schemes just described have been implemented in the MATLAB codes ns1
(-scheme) and ns2 (Adams-Bashforth--scheme), on a nonuniform Cartesian
grid of the type shown in Fig. 5.1. For ns1, Picard linearization or extrapolated
Picard linearization is used for the inertia terms. Three types of boundary condi-
tions have been implemented: inflow, outflow and no-slip. The boundaries can be
divided in segments, on which one can choose different boundary conditions and
numbers of grid cells. For instance, we can do the so-called backward-facing step
problem, illustrated in Fig. 5.9. Because the domain is assumed to be rectangu-
lar, we cannot handle the narrow inflow part at the left, and use the rectangular
domain shown at the right. We choose |AB| = |BC| = 1, |CD| = L, with L
to be chosen. It turns out that a recirculation zone is present attached to BC,
with length dependent on the Reynolds number Re. The length of the domain L
must be larger than the length of the recirculation zone, in order to have u1 > 0
at DE, so that the outflow boundary condition (5.8) is appropriate. Let the
Reynolds number be based on the length of AB and the average inflow velocity.
100 5. The incompressible Navier-Stokes equations

A E

C D
Figure 5.9. The backward-facing step problem.

On the segment AB we prescribe inflow: u2 = 0, u1 = f (x2 ), f parabolic, such


that the average inflow velocity is 1. On DE we prescribe outflow, and on the
remaining boundary segments no-slip. The grid is uniform with n1 n2 cells,
where n is the grid dimension in the x direction.

Wrong outflow conditions

First, we prescribe Dirichlet conditions, namely a parabolic outflow profile:

u1 = g(x2 ), u2 = 0 (5.55)

on the outflow boundary DE. This is against the advice given concerning outflow
boundary conditions in Sect. 5.2. Let us see what goes wrong. Fig. 5.10 shows
a result, using Picard linearization. Note that the horizontal and vertical scales
are different in the left part of the figure. The relative change per time step is

Streamlines Relative change per time step


2
2 10

1
10
1.5

0
10
1
1
10

0.5 2
10

3
0 10
0 2 4 6 8 10 12 0 200 400 600 800 1000
Figure 5.10. Streamlines and convergence history for backward-facing step problem,
code ns1, Dirichlet outflow conditions. Re = 100, = 0.2, t = 190, n1 = 30, n2 =
20, = 1, central scheme.

defined as
k un+1 un1 k k un+1 un2 k k pn+1 pn k
 
1 1 2
max , , ,
dt q n+1 q n+1 k pn k + 21 (q n+1 )2

where q = max(k u1 k, k u2 k), and the maximum norm is used. Remember


that u and p are algebraic vectors containing the (discrete) solution. In the
5.6 Numerical experiments 101

left part of the figure, we observe unphysical wiggles near the outflow boundary,
and the convergence history shows that the solution hesitates to become really
stationary. The cause of the wiggles and the remedy have been discussed in
Sect. 5.2. For Re = 200 a stationary solution was not obtained. Furthermore, it
was found that with extrapolated Picard linearization, convergence to a steady
solution did not take place.

Further results on the backward facing step problem

From now on, we use extrapolated Picard linearization. With the correct out-
flow boundary conditions (5.8) the result shown in Fig. 5.11 is obtained. This

Streamlines Relative change per time step


0
2 10

1
10
1.5

2
10
1
3
10

0.5 4
10

5
0 10
0 2 4 6 8 10 12 0 20 40 60 80 100
Figure 5.11. Streamlines and convergence history for backward-facing step problem,
code ns1, outflow conditions(5.8) . Re = 100, = 0.6, t = 60, n1 = 30, n2 = 20, = 1,
central scheme.

result looks more satisfactory. The length of the recirculation region agrees with
results reported in the literature, and the solution seems to evolve to steady
state. Due to the use of Picard linearization, ns1 it is not unconditionally sta-
ble; we know no guidelines for choosing the time step . For linear problems,
the -scheme with = 1 is unconditionally stable, as seen in Sect. 4.4.

Fig. 5.12 shows what happens when the Reynolds number is increased. The
length of the recirculation region increases; it is thought to be proportional
to the Reynolds number. This flow we have also computed with the Adams-
Bashforth- scheme (code ns2). The flow pattern obtained is the same as in
Fig. 5.12. To determine the time step we have used the stability criterion
for the Adams-Bashforth-Crank-Nicolson scheme (hence, = 1/2) presented
in Sect. 4.4, taking for safety 20% smaller than allowed, giving = 0.021.
The convergence history is shown in Fig. 5.13. Although the time required to
execute a time step with ns1 is seven times larger than for ns2 (why is it larger,
you think?), ns1 is faster because its time step is much larger. The recirculation
length in Fig. 5.12 agrees with reports in the literature. With the upwind scheme
the recirculation length is found to 7, which is too small. This is because the
upwind scheme adds artificial viscosity, and the recirculation length is known
102 5. The incompressible Navier-Stokes equations

Streamlines Relative change per time step


0
2 10

1.5
1
10

2
10
0.5

3
0 10
0 2 4 6 8 10 12 0 20 40 60 80 100
Figure 5.12. Streamlines and convergence history for backward-facing step problem,
code ns1. Re = 200, = 0.6, t = 60, n1 = 30, n2 = 20, = 1, central scheme.

Relative change per time step


0
10

1
10

2
10

3
10
0 500 1000 1500 2000 2500

Figure 5.13. Convergence history for backward-facing step problem, code ns2.

to increase with decreasing viscosity.

The case Re = 400, shown in Fig. 5.14 is found to be more difficult. By trial
and error we found that several changes have to be made in order to have the
solution converge to steady state:

1) The length L has to be increased to make room for the (larger) separation
zone and the secondary separation zone that appears at the top wall.
2) The vertical number of cells ny has to be increased. But it is found that
for stability of ns1 the mesh size ratio x/y should not become too large.
Therefore nx also had to be increased.
3) The time step has to be decreased.
4) The flow takes much longer to settle down to steady state.

As a consequence, Fig. 5.14 takes much more computing time than Fig. 5.12.
Again, the recirculation length agrees with the literature.

Several other flow problems have been implemented in the programs ns1 and
ns2, and the reader is invited to experiment with these codes.
5.6 Numerical experiments 103

Streamlines Relative change per time step


0
2 10

1.5
1
10

2
10
0.5

3
0 10
0 5 10 15 20 25 0 100 200 300 400 500
Figure 5.14. Streamlines and convergence history for backward-facing step problem,
code ns1. Re = 400, = 0.3, t = 150, n1 = 70, n2 = 40, = 1, central scheme.

Efficiency

All numerical results in these course notes have been obtained with MATLAB
version 5.3 on a Pentium III 550 Mhz processor with 512 MB internal memory.
The computation of Fig. 5.14 is the first time that the wall-clock time becomes
long enough (10 min) to be annoying. So now we start to get interested in the
subject of numerical efficiency. In programming ns1 and ns1 we have followed
the MATLAB efficiency guidelines discussed in Sect. 4.2. In order to see where
the computational bottlenecks are, we make an inventory of the time spent in
various parts of the program.

In ns1 and ns2 all linear systems (of type Ay = b) are solved by MATLABs
direct solver, with the statement
y = A\b
This means that the LU-decomposition of A is computed, and y is found from
y = U\(L\b)
The pressure-correction matrix does not change during time-stepping, so its
LU-decomposition is computed once and stored. The viscous matrix also does
not change, because the viscosity is constant. This fact is exploited in code ns2
by means of the IMEX method, in which we have to solve systems with the
viscous matrix; so its LU-decomposition is pre-stored as well in ns2. Of course,
we store the matrices as sparse matrices, so that MATLAB exploits sparsity in
the execution of y = A\b. What consumes most time is the work that has to
be done every time step. This time is dominated by the time for solving the
linear systems for the velocity components tv and the pressure tp , by the time
for matrix generation (inertia_matrix in ns1) tm , and by the time for right-
hand side generation (right_hand_side in ns2) tr . The total time is called tt .
Table 5.1 gives some runtime statistics for the two cases presented in Figs. 5.12,
5.13 (called case 1 in the table) and 5.14 (case 2).
Let us analyze these figures a bit. The number of unknowns (u1 , u2 or p) in x1 -
direction is n1 + m and in x2 -direction n2 + m with m = 1, 0 or 1, depending
on the type of unknown and the type of boundary conditions; of course, for
104 5. The incompressible Navier-Stokes equations

ns1 ns1 ns2


case 1 case 2 case 1
tm 0.039 0.184
tv 0.113 0.896 0.009
tp 0.007 0.060 0.007
tr 0.006
tt 19.2 600 60.1

Table 5.1. Runtime statistics (seconds).

estimating computing work, m can be neglected. This gives us matrices of size


n n, n = n1 n2 , with bandwidth, with lexicographic ordering, equal to 2n1 1.
It is known that the work to compute the LU-decomposition WLU and the work
to solve a system WS with this type of bandmatrix, using standard methods,
are given by:
WLU = 2n31 n2 flops, WS = 2n21 n2 flops. (5.56)
(A flop is a floating point operation). We therefore expect

tv n31 n2 , tp n21 n2 , tm n1 n2 .

Between cases 1 and 2 this equation predicts ratios of 25, 11 and 4.7 for tv , tp
and tm , respectively. Obviously, this prediction is much too pessimistic for tv ,
but is not far off the mark for tp and tm . The reason MATLAB has a WLU that
in our case is much less than given by (5.56) is, that in execution of the com-
mand y = A\b, if A has been declared to be sparse, the equations are reordered
in a clever way, before the triangular factors L and U are computed, in order to
reduce computing work. That WLU may be diminished by reordering is obvious
from equation (5.56): by a different numbering of the cells we can interchange
the roles of n1 and n2 (cf. exercise 5.6.2), which in the present case changes
the ratio just predicted for tv from 25 to 19. We see that MATLAB does an
even better job. Much numerical expertise is hidden behind the \ command in
MATLAB.

The table shows that for an increase of n n1 n2 by a factor 4.7, the time
required by ns1 for a time step increases by a factor 6.8. The total time tt in-
creases by a factor 31. This is mainly due to the much larger number of time
steps required. We conclude that for high Reynolds number flows, time stepping
is an inefficient way to compute a stationary solution.

Table 5.1 shows that for case 1 the computing time for a time step with ns2 is a
factor 7 smaller than with ns1. But because for stability reasons the time step
is much smaller, the total computing time tt is much larger.

In the next chapter we study other methods to compute stationary solutions,


that are hopefully more efficient.

The reader is invited to consult the introduction of this chapter for the topics
that we wanted to discuss.
105

Exercise 5.6.1. In Sect. 3.3 we saw that a Dirichlet outflow condition generates
an artificial boundary layer at the outflow boundary. How does the thickness
of the boundary layer caused by the wrong outflow condition (5.55) depend on
the Reynolds number Re? In Sect. 2.3 we saw that outflow wiggles caused by
an outflow Dirichlet condition go away when we apply mesh refinement near
the outflow boundary, such the the mesh Peclet number p < 2. Try this for the
problem of Fig. 5.10. Define and estimate the mesh Reynolds number, based on
the maximum u1 , which occurs at the inflow boundary. How small should the
local mesh size x be in the refinement zone? Implement a refinement zone in
ns1 by dividing the horizontal domain boundaries in two segments, similar to
what is done in ns1 for the vertical boundaries. See what happens.
Exercise 5.6.2. In the computation of Fig. 5.14, n1 > n2 . Equation (5.56)
shows that it would be better if this were the other way around. Specify a
vertical backward facing step problem in code ns1, and compare run times with
the horizontal version.

Some self-test questions

Write down the free surface conditions.

What are your preferred outflow conditions, and why?

Discretize the x1 -momentum equation on a uniform Cartesian grid.

Describe the Adams-Bashforth-Crank-Nicolson scheme.

Write down the general formulation of the discretized nonstationary incompressible Navier-Stokes
equations.

Formulate the pressure-correction method.

What is the backward-facing step problem?

Why is the computing time for a time step with the code ns2 smaller than with ns1?
6. Discretisation on an unstructured grid.

6.1 Introduction
Up till now we have only discussed methods that can solve the Navier-Stokes
equations on a Cartesian, structured grid. A structured grid has the property
that interior vertices belong to the same number of cells (four in the case of
quadrilaterals but other element types would lead to another number). The
inherent structure of the structured grid makes the connectivity of cells trivial,
and therefore the connectivity does not have to be stored or accessed during the
discretisation saving memory and time.
Of course a numerical method that can solve the Navier-Stokes on the unit
square or even on a Cartesian geometry is of very limited practical use. We
are interested in analyzing the external flow around ships, aircraft, cars or in
the internal flow through a pipe with a circular cross section. In all theses
cases a Cartesian mesh can not be used because it will not conform to the
boundary of the domain of interest. Although it is theoretically possible to use
an interpolation scheme to locally adapt the Cartesian mesh to a curvilinear
boundary (see for instance the discussion in Vermolen, Verbeek, Vuik, and van
Kan (2007), this is seldom done in practice.
Basically, two approaches can be followed, without a specific reference to the
discretisation of the equations:
The use of an unstructured grid consisting of polyhedral control volumes.
The use of a a body conforming curvilinear grid
In this chapter the first will be briefly discussed, merely to show what is in
involved in the generalization from the structured to the unstructured case,
while the second approach is introduced in the next chapter. We will limit the
discussion to the 2-dimensional case.

6.2 Discretisation of the incompressible Navier-Stokes


equations on an unstructured grid
We will discuss two examples of the discretisation of the incompressible Navier-
Stokes on unstructured grids comprising a set of non-overlapping triangles.
Many such approaches exist, but the methods discussed are based on the classic
Harlow and Welch staggered grid approach, of which these share many favorable
properties, specifically:
Conservation of mass and momentum
Conservation of kinetic energy
108 6. Discretisation on an unstructured grid.

The absence of spurious checkerboard modes in the pressure without regular-


ization.
The spatial discretisation will be derived for a staggered discretisation based
on the divergence and the rotational form of the Navier-Stokes equations. The
latter form is commonly referred to as the Lamb-Gromeka form.

Figure 6.1. A Delaunay triangulation is based on an initial tessellation of Voronoi


tiles (colored red).

6.2.1 Structure in an unstructured grid


For the two discretisation schemes we will discuss, the triangulation is not
completely arbitrary: the triangulation is a so-called Delaunay triangulation.
This triangulation has a number of special properties. The triangulation is con-
structed from a set of non-overlapping convex polygonal tiles (Voronoi Tessella-
tion). The boundary of the Voronoi Tiles consists of line segments, equidistant
to all vertices of the triangles. The vertices of the polygonal tiles are the circum-
centers of the triangles. The circumcircle of each triangle does not contain any
other nodes, than the three nodes comprising the triangle. A line connecting the
circumcenters of two neighboring triangles intersects the edges of the triangles
orthogonally and in the center of the edge. Figure 6.1 shows the Voronoi tiles
and the resulting triangulation. The properties of the triangulation significantly
simplify the discretisation of the equations. The construction of a Delaunay
triangulation is discussed in Chapter**.

6.2.2 The rotational form of the incompressible Navier-Stokes


equations
6.2 Discretisation of the incompressible Navier-Stokes equations on an unstructured grid 109

(a) (b)
Figure 6.2. For a true Delaunay triangulation, the circumcircle of each triangle does
not contain any other nodes than the three nodes of the triangle itself. This is clearly
the case for the left (a) but not for the right (b) picture.

u,t + (uu) = p + Re1 2 u (6.1)

The expression aa is called a dyad, a rank 2 tensor of the following form:



a1 b1 a1 b2 a1 b3
ab = a2 b1 a2 b2 a2 b3 (6.2)
a3 b1 a3 b2 a3 b3

We can replace the inertia term in the following way:

(uu) = ( u)u + (u )u = (u )u, (6.3)

where the first term in the expansion vanishes because of incompressibility.


Using another vector identity the inertia term can be brought in rotational
form:

(u u) = 2(u )u + 2u ( u) (6.4)
(u )u = u ( u) + ( 21 u u) (6.5)

The diffusive term can also be brought in rotational form:

2 u = u + ( u) = u (6.6)

Introduce the vorticity and the total pressure p defined as:

=u p = 12 u u + p (6.7)

And we end up with the rotational form of the Navier-Stokes equations:

u,t u = p (6.8)

In two dimensions the vorticity vector will be :

= e3 (6.9)
110 6. Discretisation on an unstructured grid.

hi
hi 1
1
hi
1

Figure 6.3. The control volume used for the discretisation of the Lamb-Gromeka form
of the incompressible Navier-Stokes equations.

The equation is projected in the direction of the normal ni of face i:

(uni ),t u (e3 ) ni = (p ),ni (e3 ) ni (6.10)

Define the unit vector tangent si to face i as:

si = ez n (6.11)

Substitution of this expression leads to the following (scalar) equation:

(uni ),t usi = (p ),ni ,si (6.12)

We want to discretize (6.12) either by a finite difference or finite volume formu-


lation, using an arrangement of the variables that corresponds to the Arakawa-C
arrangement used by Harlow and Amsden, but now on a unstructured triangular
grid. A finite difference formulation will be based on the following information:
The vorticity in the edge centers ( the location of the velocities.
The vorticity at the nodes of the grid
The total pressure (= pressure and velocity vector) in the cell circumcenters
The tangential velocity us at the edge centers.
The vorticity in the nodes is computed using Stokes theorem:
Z Z
dS = u dl (6.13)
S S
6.2 Discretisation of the incompressible Navier-Stokes equations on an unstructured grid 111

or discretely:
1 X
i = usj kxcTj xcTj1 k (6.14)
Adual
Tj Conni

The normal derivative of the pressure gradient on edge i can be approximated


to second order accuracy by

p|xc +
p|xc
T T
p,n |xcedge = i i
(6.15)
i kxcT + xcT + k
i i

 
1
|xcedge = 2 |xedgei + |xedgei (6.16)
i node1 node2

6.2.3 The divergence form of the Navier-Stokes equations

Alternatively, the divergence form of the Navier-Stokes equations can be discre-


tised on an unstructured triangular grid. Start from the Navier-Stokes equations
vector form (6.1) and multiply with the local normal vector ni :

ni (u,t + (uu)) = p + Re1 2 u ni



(6.17)

The equation (6.17) is integrated over the controlvolume depicted in Fig. 6.4.
Note that the boundary of the controlvolume does not coincide with the cell in-
terfaces, and that the control volumes are actually overlapping. However, neither
of these properties will adversely affect the accuracy of the discretisation.
Z Z
p + Re1 2 u ni

(ui ),t + n ( (uu)) dS = (6.18)
E E

The inertial term can be expressed in the following way:


Z
(uu)dS = h1 le c1 + h2 le c2 , (6.19)
E

where c1 is defined as:


Z
1
ci = (uu)dS. (6.20)
AT i Ti

Apply the divergence theorem to formulate (6.20) as a boundary integral:


Z Z
1 1
(uu)dS = (uu) nd (6.21)
ATi Ti ATi Ti
Z
1 1 X
= uun d = (uun )|edge k
ATi Ti AT i
edgesTi

The velocity vector u in the center of the edge is approximated as:


 
uedge k = 21 uT + + uT , (6.22)
edge k edge k
112

where uT denotes the velocity vector in the circumcenter of triangle T . Because


of the Delaunay triangulation we can approximate the integral over the pressure
gradient term in the following way:
Z
xc
(p) ni dS = li p|xcT +

(6.23)
T
E

The diffusion term is expressed very similarly to the inertial term:


Z
Re1 2 udS = li h1 d1 + li h2 d2 , (6.24)
E

where
Z Z
1 1
di = Re1 2 udS = Re1 (u)dS = (6.25)
AT i Ti ATi Ti
Z 1X u+ u
1 u Re
Re1 d =
ATi Ti n AT i hi
edges

Combining the expressions for ci , di and the discrete pressure gradient, the
discrete momentum equation reads:
xc
hli (ui ),t + ni le (h1 c1 + h2 c2 ) = li p|xcT +

+ ni li (h1 d1 + h2 d2 ) (6.26)
T

h1
hi
h2

li
1

Figure 6.4.

Some self-test questions

What is the reason for choosing an unstructured discretisation?

The controlvolumes for the discretisation of the momentum equations are overlapping. Does this
violate global momentum conservation?
7. Discretisation on a boundary conforming grid.

7.1 The basic idea

The basic idea of the approach is the following. The previous chapters describe
the discretisation of the Navier-Stokes equations (or the convection-diffusion
equation for that matter) on a uniform Cartesian grid: a grid that consists of
rectangular cells of uniform width and height. Of course the applicability of a
method that can solve the before mentioned equations on a geometry that can
be subdivided into such cells is very limited. We will now define a one-to-one
mapping x() that transforms a rectangular region in the Computational do-
main to an arbitrarily shaped region in the Physical domain. This very mapping
is used to transform the equations we intended to solve such that the dependent
variables will be in the computational domain: they are no longer expressed in
Cartesian coordinates but in so-called general coordinates. You might expect
that it would be more helpful to have the inverse mapping (x), but it turns
out it will generally not be easy to construct this inverse mapping. Fortunately,
it turns out is sufficient to know that this inverse mapping exists (the original
mapping is one-to-one and onto), and its use can be completely avoided.
This approach will allow us to discretize the transformed equations on a Carte-
sian grid, using the techniques discussed in the previous chapters. The mapping
itself will generally not be available as x(), but as a grid function ij xij ,
for which the derivatives (required for the formulation in general coordinates)
can be accurately approximated using finite differences as long as the grid is suf-
ficiently smooth. The key idea is therefore that our transformation makes the
equations more complicated in exchange for a less complicated computational
domain and discretisation.

7.2 Some tensor calculus

To be able to formulate the equations in general coordinates, we need to un-


derstand some basic tensor algebra. Only the very basics will be discussed here.
If you are interested in continuum mechanics or electromagnetics, a full course
in tensor calculus (WI4037TU, second semester, Daalderop) is indispensable.
Note that in the current context, the summation convention applies to combi-
nations of matched super and subscripts. Why this is not in contradiction with
the Cartesian case, where we applied to summation convention to matching sets
of two matching super or subscripts will become clear shortly.
114 7. Discretisation on a boundary conforming grid.

7.3 The coordinate mapping

7.3.1 Definition of the basis vectors

We will use a coordinate system based on a covariant and contravariant basis.


The meaning of these names will be explained shortly.
The vectors a() comprising the covariant basis and the vectors a() that com-
prise the contravariant basis are defined as, respectively:
x
a() , a() (7.1)

x
(a() ) = , (a() ) = (7.2)
x
In words: the covariant base vectors are the partial derivatives of the coordi-
nate mapping with respect to the respective curvilinear coordinates, while the
contravariant basis vectors are the gradient vectors of the inverse coordinate
mapping (x) Note that the vectors that comprise the covariant basis are easily
approximated from discrete values of the mapping x() using finite differences,
but that direct approximation of the elements of the contravariant basis would
require evaluation of the inverse mapping (x). The covariant vectors are de-
noted with subscripts (co rhymes with low, but this might not be the reason).
Neither the contravariant nor the covariant basis is (necessarily) orthogonal.
Furthermore, the vectors that comprise the basis do not have unit length, as is
the case in the Cartesian standard basis:

|a() | =
6 1, |a() | =
6 1 (7.3)

However it is easy to show that:



() 0, 6=
a() a = (7.4)
1, =

Because:
x
a() a() = = = (7.5)
x

Relation (7.4) will be used later to compute the vectors in the contravariant
basis from the vectors in the covariant basis.

7.3.2 Construction of the basis vectors

In practice we will construct a mapping x(), either numerically or analytically.


This means the covariant base vectors are easily computed, using (finite) dif-
ferencing of the mapping. However, the contravariant base vectors are not that
easily found, because their direct computation would require the inverse map-
ping (x), which will generally not be available. Fortunately, we can use relation
(7.4). The following should obviously hold:

a(1) a() = 1 , = 1, 2, 3. (7.6)


7.3 The coordinate mapping 115

As an example we will show how the compute a(1) from a known covariant basis.
This relation (7.6) can be cast in matrix form to read:

aT(1)
aT (1)
(2) a = e(1) , (7.7)
aT(3)

where the superscript T denotes the transpose of the vector it is applied to.
The system (7.7) can be solved for the contravariant base vector a(1) using
Cramers Rule. This requires evaluation of the determinants of four matrices:

aT(1)

det aT(2) = det(a(1) a(2) a(3) ) = a(1) a(2) a(3) = J = g

(7.8)

T
a(3)

eT(1)
det aT(2) = det(e(1) a(2) a(3) ) = e(1) a(2) a(3)

(7.9)

aT(3)

eT(2)
det aT(2) = det(e(2) a(2) a(3) ) = e(2) a(2) a(3)

(7.10)

aT(3)

eT(3)
det aT(2) = det(e(3) a(2) a(3) ) = e(3) a(2) a(3)

(7.11)

aT(3)

These relations can be derived when the expressions for the determinants are
expanded, they are not (completely) obvious. The reason why we denote the

Jacobian of the mapping J by g will become clear shortly.
In resume the first vector of the contravariant basis can be expressed as:
1
a(1) = a(2) a(3)

(7.12)
g

Of course, a similar relation can be derived for the other contravariant base
vectors. It can be shown that the following general expression holds for all three
contravariant base vectors:

1
a() = a() a() ,

, , cyclic even permutation of 1,2,3 (7.13)
g

There is an alternative way to come to this expression. Note that (7.4) makes
a() orthogonal to both a() and a() . Therefore, a() will be in the direction
of a() a() , but with length to be determined:
 
a() = C a() a() , (7.14)

where C denotes the appropriate, scaling factor that still has to be determined.
Now pre-multiply (7.14) on both sides with a() and solve for C:
116 7. Discretisation on a boundary conforming grid.

1 1 1
C= = = (7.15)
a() a() a() J g

As an example, the cylindrical coordinate system is used to demonstrate the


computation of the vectors in the covariant and contravariant basis. This coor-
dinate mapping x(); x = (x1 , x2 , x3 ), = (r, , z) is given by:

x1 = r cos (7.16)
x2 = r sin
x3 = z

The vectors in the covariant basis are given by:


 
x1 x2 x3
a(r) = , , = (cos , sin , 0) (7.17)
r r r
 
x1 x2 x3
a() = , , = (r sin , r cos , 0) (7.18)

 
x1 x2 x3
a(z) = , , = (0, 0, 1) (7.19)
z z z

Next we compute the vectors in the contravariant basis:



e(1) e(2) e(3)
1 1
a(r) = a() a(z) = r sin r cos 0 = (cos , sin , 0) (7.20)

g r
0 0 1

 1 e(1) e(2) e(3) 1

() 1
a = a(z) a(r) = 0 0 1 = ( sin , cos , 0) (7.21)
g r r
cos sin 0

e(1) e(2) e(3)
1 1
a(z) = a(r) a() = cos

sin 0 = (0, 0, 1) (7.22)
g r
r sin r cos 0

It is straightforward to verify that (7.6) holds for the vectors in the contravariant
and covariant basis. Note that these vectors have different length.

Exercise 7.3.1. Derive the covariant and contravariant basis for the spherical
coordinate system: x(); x = (x1 , x2 , x3 ), = (r, , ) is given by:

x1 = r cos sin , (7.23)


x2 = r sin sin ,
x3 = r cos .

7.3.3 Covariant and contravariant vectors

What do the terms covariant and contravariant mean? It has to do with the way
a vector field transforms when you are changing to a different coordinate system.
Assume you have two different curvilinear coordinate systems, eta = (1 , 2 , 3 )
7.3 The coordinate mapping 117

and = (1 , 2 , 3 ). Assume a given vector field is expressed in its components,


and changing from the coordinate system to the eta coordinate system, these
components transform in the following way:


U () = U (). (7.24)

Then the vector field is a contravariant vector field, as indicated by the compo-
nents being written down as superscripts. On the other hand, if the components
transform according to the following transformation rule:

U () = U (). (7.25)

Then the vector field is a covariant vector field, as indicated by the components
being written down as subscripts. For the Cartesian case, there is no distinction
between the covariant and contravariant components. Therefore, we can use
either notation. To distinguish between a Cartesian and a curvilinear vector the
former is written down as a lower case letter, as opposed to an upper case letter.

7.3.4 Representation of u

Starting from the Cartesian basis, we can express the velocity using a con-
travariant basis. Recall that a contravariant entity transforms in the following
way:


U () = U () (7.26)

We apply this transformation rule to transform a vector expressed in its Carte-
sian components to a vector in curvilinear, contravariant components:


U = ()
u = a u = a() u (7.27)
x
These U are the contravariant components of the velocity vector u. Conversely,
we apply the transformation rule to transform a vector expressed in curvilinear,
contravariant components to a vector in its Cartesian components:

x
u = U = (a() ) U (7.28)

The full vector u is then given by:

u = a() U . (7.29)

This is a representation of the vector u in the co-variant basis vectors and contra-
variant components. On the other hand the same vector u can be expressed using
a set of contra-variant basis vectors and co-variant components. Recall that a
covariant entity transforms in the following way:

U () = U () (7.30)

118 7. Discretisation on a boundary conforming grid.

We apply this transformation rule to transform a vector expressed in its Carte-


sian components to a vector in curvilinear, covariant components:
x
U = u = a
() u = a() u (7.31)

These are the covariant components of the velocity vector u. Conversely, we
apply the transformation rule to transform a vector expressed in curvilinear,
covariant components to a vector in its Cartesian components:

u = U = (a() ) U (7.32)
x
The full vector u is then given by:
u = a() U . (7.33)
This is a representation of the vector u in the contra-variant basis vectors and
co-variant components.

7.3.5 The permutation symbol


One way to define the vector product is by use of the permutation symbol .
The permutation symbol is defined in the following way:

0 , if any of , , are equal
1 , , , even permutation of 1, 2, 3 (7.34)
1 , , , odd permutation of 1, 2, 3

Some examples:
122 = 0 (7.35)
231 = 1, 231 321 123 (double permutation) (7.36)
213 = 1 213 123 (single permutation) (7.37)
The vector product can now be defined as (check that this holds indeed):
c = a b, c = a b (7.38)
And the vector triple product can be defined as:
a() a() a() = (a() ) (a() ) (a() )

(7.39)
Like vectors, tensors are also classified by the way they transform from one to

another coordinate system. A tensor T () is a tensor of covariant order three,
contravariant order two and weight w, if it transforms according to the following
transformation rule:

T () = ( g)w T () (7.40)

The permutation symbol is a tensor of covariant order three and weight 1.
This is easy to verify:
w
x x x x
= = (7.41)

w  w+1
( g) a() a() a() = ( g)
This means that the permutation symbol is a relative tensor of weight 1
7.3 The coordinate mapping 119

7.3.6 The metric tensor

The metric tensor relates increments of distance to increments in the coor-


dinates. The square of an increment of distance ds can be expressed in the
displacement dx as:

ds2 = dx dx (7.42)

The displacement vector can be expressed using the chain rule as:
x
dx = d (7.43)

3
X x x
ds2 = d d = (7.44)
=1

3
X x x
g d d , g =
=1

Close inspection of g reveals that it corresponds with the scalar product of


the two covariant base vectors: a() a() . It is easily shown that the metric
tensor is indeed an absolute covariant tensor or order two:
3 3 3
X x x X x x X x x
g = = = (7.45)
=1
=1
=1

Obviously this tensor is symmetric, because the order of the terms is irrelevant:

g = g (7.46)

Completely analogously a contravariant version and a mixed version of the met-


ric tensor can be formed:

g = a() a() (7.47)


g =a ()
a() =

For the Cartesian case x = we have


x
= , (7.48)

and this means that the metric tensor corresponds to the identity matrix:

g = 1 = g (no summation), g = g (7.49)

Without specification of the index, g refers to the following determinant:


T 
g = a(1) a(2) a(3) a(1) a(2) a(3) = (7.50)

2
a(1) a(2) a(3)

That is why we refer to a(1) a(2) a(3) as g.
120 7. Discretisation on a boundary conforming grid.

7.3.7 Contraction

Contraction refers to the summation over a set of indices (a single super and
subscript of course) to lower the order of a tensor by 2:

T = V (7.51)

g T = S (7.52)

We can use contraction to raise and lower indices. The process is simple, the
outcome is simple, but it is important to understand and keep in mind what
you are actually doing: expressing the entities in a different coordinate system.
Recall that the contravariant components of the velocity vector are given by:
 
U = a() u = a() a() U = g U , (7.53)

where we used an expansion in the contravariant base vectors to express the vec-
tor u. Apparently, we can express the contravariant components of the velocity
in the covariant components using the contravariant metric tensor Similarly we
can express the covariant components in the contravariant components using
the covariant metric tensor.

U = a() u = a() a() U = g U



(7.54)

The general rule to raise indices of a general tensor is given as follows:

g 1 1 T1121...
2 ...

= T21...
1 2 ...

(7.55)

Dummy indices can be lowered or raised as well:

T N = T N , (7.56)

but of course T 6= T .

7.3.8 The inner product

Depending on the basis of a pair of vectors the inner product can take a more
or less compact form:
  
u v = a() U a() V = U V (summation over 3 terms) (7.57)
u v = a() U a() V = g U V (summation over 9 terms) (7.58)
 

7.3.9 Physical component

If n is some unit vector (length one, direction arbitrary) then the projection of
a vector u on n (i.e. u n) is called the physical component of u in the direction
n, and denoted by up (n). We have

up (n) = U N = U N (7.59)

In a Cartesian system u is the physical component in the x -direction, but in


general U is not the physical component in the -direction. The unit vector
parallel to a() for some is
7.3 The coordinate mapping 121


n = a() /|a() | = a() / g (no summation) (7.60)

so that

N = g / g (no summation) (7.61)
which gives

up (n) = U / g (no summation). (7.62)
Similarly, the covariant representation of the unit vector parallel to a() for
some is
N = / g (no summation) (7.63)
so that
up (n) = U / g (no summation) (7.64)
We will also need physical components of second order tensors, in order to
evaluate the shear stress at a wall, for example. In Cartesian coordinates, in a
fluid the stress component in the x -direction on a surface element with unit
normal n is given by
f = t n (7.65)
with t the (symmetric) stress tensor. The physical stress component in the
direction of a unit vector m is given by

f m = m t n (7.66)

Because this is a tensor equation it holds in every coordinate system:

f m = M T N (7.67)

Suppose we want to determine the physical shear stress at a wall along which
3 = constant. The unit normal to the surface is given by (7.61) with = 3.
This gives p
f m = M T 3 / g 33 (7.68)
For the component perpendicular to the wall M is given by (7.63) with = 3,
resulting in p
f m = T 33 / g 33 (7.69)

7.3.10 Christoffel symbols

The distinguishing property of a curvilinear mapping is that the base vectors, as


opposed to the Cartesian case are not constant, but depend on the local coordi-
nates. Both their direction and magnitude are coordinate dependent, and spatial
derivatives are nonzero. Taking the derivative of the covariant base vectors leads
to:
2x
 
a() x a()

=
=
= (7.70)

The derivative is a vector quantity and can be expressed in either the covariant or
contravariant base vectors in the following way, using coefficients to be defined:
122 7. Discretisation on a boundary conforming grid.

a()
= [, ]a() (expressed in the contravariant basis vectors) (7.71)

a()
= a() (expressed in the covariant basis vectors) (7.72)

Taking the inner product with the base vector a() of (7.71) gives:

a()
a() = [, ], (7.73)

where [, ] denotes the Christoffel symbol of the first kind. Taking the inner
product with the base vector a() of (7.72) gives:

a()
a() = , (7.74)


where denotes the Christoffel symbol of the second kind. Obviously, the two
kinds of Christoffel symbols are closely related. We can contract the contravari-
ant base vectors with the metric tensor to express these in the covariant base
vectors.

a() a()
= a()
= g a() = g [, ] = g [, ]. (7.75)

Reversely we can contract the covariant base vectors with the metric tensor to
express these in the contravariant base vectors:
a() a()
[, ] = a() = g a() = g

(7.76)

Similarly, we can express the derivatives of the contravariant base vectors using
Christoffel symbols. Taking derivatives of the relation (7.4) on the left and right
hand side gives:
 () 
a a() = (7.77)


a() a() + a() a()

a()
a() = a() a() =


a() ()
= a

Of course, this derivative can be expressed in the covariant base vectors using
the metric tensor. Important facts concerning the Christoffel symbols are:
There are 18 Christoffel symbols in 3D and 6 in 2D (per kind that is).
The Christoffel symbols contain second derivatives of the coordinate mapping
x():

a() 2x
= a()
= a() (7.78)

7.3 The coordinate mapping 123

This means that these Christoffel symbols are only defined if the mapping
x() C 2 . If the coordinate mapping is defined discretely and the Christoffel
symbols are approximated using finite differences, we can run into problems
if the mapping is not sufficiently smooth. For this reason a discretisation can
be formulated that avoids the use of the Christoffel symbols all together, see
van Beek, van Nooyen, and Wesseling (1995).
The Christoffel symbols are not tensors. This follows if we expand the
Christoffel symbols in a different coordinate system:
 
a() ()
= a = a() a() = (7.79)

2 () a() ()
a() a + a =

2
+

2
+

Apparently, transformation to the tilded system introduces an additional term,
next to the expected mixed third order transformation if the Christoffel symbol
would have been a tensor.

7.3.11 Differentiating the metric tensor

Because the components of the metric tensor are just the inner products of
the vectors in the covariant or contravariant bases we can use the Christoffel
symbols to express the derivative of the metric tensor:

g  a() a()

= a() a() = a() + a() (7.80)

= a() [, ]a() + a() [, ]a()
= [, ] + [, ]
= [, ] + [, ]

We can use (7.80) to express the Christoffel symbols of the first and second kind
in derivatives of the metric tensor:
 
1 g g g
[, ] = 2 + (7.81)

 
g g g
= 21 g
+
(7.82)

We can now contract over 1 subscript and one superscript:

g
= 21 g (7.83)

124 7. Discretisation on a boundary conforming grid.

g
= G = gg (7.84)
g

g g g g

=
= gg (7.85)
g

1 1 g 1 1
= 2 = 2 (ln g) = ( g) (7.86)
g g
This expression will be used shortly to formulate the divergence operator in
general coordinates.

7.3.12 Differentiating a vector field


Taking the derivative of a vector field in the Cartesian case, means taking the
derivatives of the field components, because of the fact that the base vectors are
independent of the spatial coordinates. We have just seen that in the curvilinear
case the base vectors do depend on the spatial coordinates, and we have to apply
the product rule in the following way:

 a() U
u = a () U = U + a() (7.87)

U
= U

a() + a()

U
= U

a() + a()

U
 
= U
+ a()


= U, a() ,
where
U
 

U, := U + (7.88)

is the covariant derivative of the contravariant vector U . We can also start from
a representation of the vector u in the contravariant basis. This leads similarly
to:
u
= U, a() , (7.89)

where
U
U, := U (7.90)

So we have the following representations for the covariant derivative
u
= U, a() = U, a() = U, g a() = U, g a() (7.91)

The covariant derivative is the coordinate-invariant form of the derivative. Note
that in the Cartesian case, where all Christoffel symbols vanish, it corresponds
to the regular derivative. Also note that the complexity of the term is actually
hidden.
7.3 The coordinate mapping 125

7.3.13 Formulating equations in coordinate invariant form

With all building blocks defined, we are now able to formulate equations in
coordinate invariant form. The basic rule is that if an equation is a proper
tensor equation, it can be brought in coordinate invariant form. What defines a
proper tensor equation? Well, first all entries in the equations should of course be
tensors (regarding vectors as tensors of order 1, and scalars as tensors of order 0),
and transform according to either the covariant or contravariant transformation
rules. Then it should hold that any free index in the equation should occur in a
similar way in each term of the equation. So if in one of the terms occurs as
a free subscript, it can not occur in other terms as a free superscript. Finally,
recurring indices (indicating contraction) should occur as a matched set of super
and subscript.
If an equation qualifies as a proper tensor equation, then by Riccis Lemma it
holds in any coordinate system, when all derivatives in the equation are indeed
regarded as covariant derivatives. We will now show how to formulate a number
of operators and equations in coordinate invariant form.

7.3.14 Divergence operator

In Cartesian coordinates (remember, base vectors are constant) in 2D, the di-
vergence operator is given by

u = u, (7.92)

This is not a proper tensor equation, because the repeated index does not occur
as a matched pair of a subscript and superscript. Because in the Cartesian case
there is no difference between the covariant and the contravariant components,
we can rewrite (7.92) as:

u = u
, (7.93)

Now (7.93) does qualify as a proper tensor equation and according to Riccis
lemma it holds in any coordinate system, if we regard the derivatives as covariant
derivatives. So, in general coordinates the divergence operator is given by:

u = U, (7.94)

We will now derive a compact expression for the divergence operator in general
coordinates that can be used in the finite volume discretisation of the Navier-
Stokes equations.
u
= U, a() (7.95)

If we multiply (7.95) by a() . This gives:

u ()
a = U, a() a() = U,

= U, =u (7.96)

126 7. Discretisation on a boundary conforming grid.

u
a() = a() U a() ,


(7.97)

 
U a()
= a() a() + U ,

 
U
= a() a() + U () ,
a

U
= + U ,

U
= + U

,

U 1
=
+ U ( g),
g
U 1
=
+ U ( g),
g
1
= ( gU ) .
g
So, in brief:
1
u= ( gU ) . (7.98)
g

7.3.15 Laplace operator


The Laplace operator applied to a scalar field in the Cartesian case is given
by:
2 = = (, ), . (7.99)
Again, this equation (7.99) does not qualify as a tensor equation, because the
repeated subscript does not occur as a matched pair of one subscript and one
superscript. The problem is that the gradient operator is covariant:
x
= . (7.100)
x
To make (7.99) a proper tensor equation we need to express the gradient vector
in its contravariant components, so we contract with the contravariant metric
tensor:

() = g , . (7.101)
So the proper tensor form of the Cartesian Laplace operator is given by:
2 = g , , .

(7.102)
According to Riccis lemma this tensor equation holds in any coordinate system
if we regard all derivatives of vector quantities (like in the divergence operator)
as covariant derivatives. Combining (7.98) and (7.101) leads to a very elegant
expression for the Laplacian:
 
1
2 = gg (7.103)
g x
7.3 The coordinate mapping 127

7.3.16 An example computation

As an illustration we will compute all the Christoffel symbols of the second kind
for a cylindrical coordinate system x (r, , z):

x1 = r cos (7.104)
x2 = r sin (7.105)
x3 = z (7.106)

It turns out that are are only three nonzero (two unique) Christoffel symbols of
r
the second kind: r , r and
The covariant base vectors are straightforward to find. (Check this!)

a(r) = (cos , sin , 0) (7.107)


a() = (r sin , r cos , 0) (7.108)
a(z) = (0, 0, 1) (7.109)
(7.110)

We also need the contravariant base vectors a(r) and a() :



i j k
(r) 1  1
a = a() a(z) = r sin r cos 0 (7.111)
g r
0 0 1

i j k
1  1
a() = a(z) a(r) = 0

0 1 (7.112)
g r
cos sin 0

The two unique Christoffel symbols are then given by:

a() 1
r = a() = 21 ( sin , cos , 0) ( sin , cos , 0) = (7.113)
r r
r a()
= a(r) = (cos , sin , 0) (r cos , r sin , 0) = r (7.114)

7.3.17 Navier-Stokes equations

We will now formulate the incompressible Navier-Stokes equations in coordinate


invariant form, starting from the Navier-Stokes equations in Cartesian coordi-
nates.

u
, = 0 (7.115)

u
+ u u , = p, + ,

(7.116)
t
= Re1 u

, + u, (7.117)

To be able to cast this system of equations in coordinate invariant form, we


need to verify if it qualifies as a proper set of tensor equations. Close inspection
shows that the only problem occurs in the pressure gradient in the momentum
conservation equation. In this term the free index appears as a subscript,
while the other terms include this free index as a superscript.
128

This can be easily fixed by raising the subscript in the pressure gradient by mul-
tiplication with the contravariant metric tensor g . This leads to the following
coordinate invariant form of the Navier-Stokes equations:

u
, = 0 (7.118)

u
+ u u , = g p , + ,
 
(7.119)
t
= Re1 u

, + u, (7.120)

Now we can transform (7.118) to coordinate invariant form, by simply replacing


the Cartesian velocity components by the contravariant components and all
derivatives of vector quantities by covariant derivatives:

U, =0 (7.121)

U
+ U U , = g p , + ,
 
(7.122)
t
= Re1 U,

+ U, (7.123)

Exercise 7.3.2. If the mapping is not available in closed form, but only as a
grid function xij (ij ) the contravariant basis vectors have to be approximated
numerically. Derive a second order accurate approximation to the first and sec-
ond contravariant basis vectors.
Exercise 7.3.3. Express the boundary condition:

(x) n = g(x), x , (7.124)

where corresponds to a 1 = c curve in (), its derivatives with respect to


and the geometrical quantities a() , a() and the contra- and covariant metric
tensors.

Some self-test questions

How many grid points are in the stencil for the discretisation of (7.103)?
8. Introduction to classical grid generation

In this course we will touch upon the subject of grid generation, to construct
structured and the unstructured grids in 2D. Both algebraic and differential
methods for the generation of structured grids will be discussed, as well as
two different approaches for the generation of unstructured triangulations. The
techniques do certainly not reflect the state-of-the-art, but have proven their
value and are still used today. The material is heavily based on Farrashkhalvat
and Miles (2003), which should be consulted for a more elaborate discussion of
the techniques presented. Knupp and Steinberg (1993) provides a mathemati-
cal background for structured grid generation techniques, and contains sample
programs.
Do not waste your time on building grid generation software for your own
project. Many excellent grid generation programs are freely available. However,
it is essential to understand the basics of these methods to appreciate their
capabilities and computational cost.

8.1 Starting point


The starting point for grid generation is a description of the boundary of the
domain as a set of parameterized curves. The generation of these curves is the
field of Computer Aided Design, and outside the scope of this discussion. The
standard parameterization is done in the normalized arc length. For structured
grid generation the domain has to have the topology of a square: It should have
four vertices and four edges.
Because we plan to map this region to a unit square, the parameterization of the
two opposing pairs of edges is already performed in the appropriate parameters,
as illustrated in Fig. 8.1.
Complex regions that do not have the topology of a unit square can be decom-
posed into a set of non overlapping subdomains (so-called blocks, irrespective of
the dimensionality of the geometry) that do have the right topology, this leads
to multi-block discretisation. Furthermore, we require that the geometry is not
degenerate. This means that a pair of vertices should not coincide, and neither
should one of the included angles of the four corners approach . The grid will
consists of the intersections of two sets of coordinate lines in the following
way:
i1
0 i = 1, i = 1, 2, . . . , n , (8.1)
n 1
and explicitly formulating an onto (bijective) C 1 mapping with a positive Ja-
cobian:
130 8. Introduction to classical grid generation

1
r t ( )

2 2
r l ( ) r r ( )

1
r b( )

Figure 8.1. The starting point for the grid generation is a description of the boundary
of the domain in four parameterized curves.

(x1 , x2 ) = r( 1 , 2 ) (8.2)

8.2 Structured grid generation

The aim of structured grid generation is the construction of an ordered set of


boundary conforming rectilinear quadrilateral elements. A hierarchy of methods
Algebraic methods
Coordinate transformation
Transfinite interpolation
Differential methods
non-elliptic methods
elliptic methods
The properties of algebraic methods in a nutshell are
Algebraic methods are fast and cheap to apply.
Algebraic methods work fine for convex regions,
Algebraic methods can be used to generate a starting grid for differential
methods, to further improve grid smoothness or (local) orthogonality.
Algebraic methods allow direct control of the grid density.
Algebraic methods propagate geometric singularities/non-smoothness (e.g. a
kink) of the boundary into the interior of the computational domain.
On the other hand,
Differential methods are relatively time-consuming/expensive to apply.
Differential methods require the inversion of a linear system,
Differential methods produce intrinsically smooth grids, even for non-smooth
boundaries.
Differential methods can control local grid density (and orthogonality) but
not necessarily in a transparent way.
8.2 Structured grid generation 131

8.2.1 Algebraic grid generation techniques

Naturally boundary fitting coordinate systems. The most straightfor-


ward, but least broadly applicable approach to generation of a boundary con-
forming grid is the use of analytic coordinate transformations, e.g. polar coor-
dinates in 2D and cylindrical and spherical coordinates in 3D. In the rare case
the computational domain corresponds to a circle segment polar coordinates can
transform a circular wedge bounded by the curves to a rectangular region: Next,
and additional scaling can be applied that maps the unit square : {( 1 , 2 )
[0, 1] [0, 1]} to the rectangular region S : {(, r)|1 2 , R1 r R2 }

( 1 , 2 ) = (1 1 )1 + 1 2 , 0 1, 2 1 (8.3)
1 2 2 1 2 2
r( , ) = (1 )R + R , 0 1, 2 1

The combined transformation now reads:

x1 ( 1 , 2 ) = (1 2 )R1 + 2 R2 cos((1 1 )1 + 1 2 )
 
(8.4)
x2 ( 1 , 2 ) = (1 2 )R1 + 2 R2 sin((1 1 )1 + 1 2 )
 

r2

r2
2
1

Figure 8.2. In the (rare) case the computational domain coincides with a circular
wedge, a transformation based on scaled polar coordinates can be defined to define
the mapping r0 ( 1 , 2 ).

Unidirectional interpolation. If the domain has the topology of a square,


with one pair of opposing straight sides (Fig. 8.3) and one pair of opposing
curved sides, we can generate a grid using linear interpolation between the op-
posing curves. First the two curves r1 and r2 are parameterized in the following
way:

r1 = r1 ( 2 ), 0 2 1, (8.5)
2 2
r2 = r2 ( ), 0 1.

To allow for more control in the shape and distribution of the grid lines, ad-
ditional control curves can be added in the interior. These control curves are
132 8. Introduction to classical grid generation

parameterized in the same parameters as the boundary curves. The interpola-


tion connects points on the curves (boundary and control) with equal values of
2 , linearly interpolating across the interior of the domain. The most straight-
forward choice for the interpolation polynomials are the Lagrange interpolation
polynomials. When interpolating between a set of points (x1i , x2i ), the inter-
polants are defined as:
n
Y x1 x1j
Li (x1 ) = (8.6)
x1i x1j
j=0, j6=i

which have the property:

Li (x1j ) = ij (8.7)

The polynomial that interpolates between the points (x1i , x2i ) is given by:
n
X
p(x1 ) = Li (x1 )x2i (8.8)
i=0

The most simple interpolation uses only first order interpolation:

x1 x11 x1 x10
L0 (x1 ) = L1 (x1 ) = (8.9)
x10 x11 x11 x10

We will use a normalized variable 1 such that:

x1 = (x11 x10 ) 1 , 0 1 1 (8.10)

The interpolation polynomials now take the simple form:

1 11 1 1
L0 ( 1 ) = 1 1 = = 1 1 (8.11)
0 1 01
1 10 1 0
L1 ( 1 ) = 1 = = 1
1 01 10
p( 1 ) = x20 (1 1 ) + x21 1

Application of this interpolation polynomial to interpolate between two points


on the boundary curves that have the same value of the parameter 2 defines a
mapping in the whole domain in the following way:

r( 1 , 2 ) = (1 1 )r0 ( 2 ) + 1 r1 ( 2 ), 0 1, 2 1 (8.12)

With the geometry of the two curves fixed, the only way to control the cluster-
ing of grid cells is by re-parameterization of the curves. To be able to allow for
clustering of grid cells, such as is required to have efficiency and accuracy uni-
form in the Peclet or Reynolds number, as was demonstrated in the Cartesian
case in Section **.

r( 1 , 2 ) = r0 ( 2 )L0 ( 1 ) + r 21 ( 2 )L 21 ( 2 ) + r1 ( 2 )L1 ( 1 ) (8.13)


8.2 Structured grid generation 133

r2(2)

r1(2)

1 2 1 2
(1 )r1( )+ r2( )
Figure 8.3. When the domain has the topology of a square with one set of opposing
straight sides, and a set of opposing curved sides, unidirectional interpolation can be
used to define a mapping r0 ( 1 , 2 ).

( 1 11 )( 1 11 ) 1
1
L0 ( ) 2
= 2( 1 )( 1 1) (8.14)
(01 11 )(01 11 ) 2
2

( 1 01 )( 1 11 )
L 21 ( 1 ) = 4 1 (1 1 ) (8.15)
(f1rac12 01 )( 11 11 )
2

( 1 01 )( 1 11 )
L1 ( 1 ) 2
= 1 (2 1 1) (8.16)
(11 01 )(11 11 )
2

This approach allows us to control grid density in the interior of the domain,
but not the orthogonality of the grid in the vicinity of the boundary. Making
the grid lines orthogonal to the boundary will improve the local accuracy of
the discretisation and is also needed in a multi-block environment to guarantee
smoothness of the grid across the block boundaries. Controlling the direction of
the grid lines is accomplished by switching to Hermite interpolation polynomials:
n
X n
X
p(x1 ) = x2i Hi (x1 ) + (x2 )0i Hi (x1 ) (8.17)
i=0 i=0

Transfinite interpolation. Suppose our domain is bounded by four curves,


and we have a mapping available that maps the unit square in the curvilinear
coordinate onto our domain in the way depicted in Figure.** Define the following
projection P1 defined by the unidirectional interpolation between the left and
right curve of the domain:
r0 ( 1 , 2 ) = P1 (r0 ( 1 , 2 )) = (1 1 )r0 (0, 2 ) + 1 r0 (1, 2 ) (8.18)
1 2
This projection is an approximation of the original map r0 ( , ): it leaves
the right and left boundary intact, but replaces the original lower and upper
boundary of the domain by straight lines. Similarly, a projection P2 can be
defined that leaves the upper and lower boundary intact, but replaces the left
and right hand side by straight lines:
134 8. Introduction to classical grid generation

r0 ( 1 , 2 ) = P2 (r0 ( 1 , 2 )) = (1 2 )r0 ( 1 , 0) + 1 r0 ( 1 , 1) (8.19)

It is easily shown that both P1 and P2 are projections (idempotent operations),


because repeated application of for example P1 gives:

r0 ( 1 , 2 ) = P1 (P1 (r0 ( 1 , 2 ))) = (8.20)


(1 1 ) (1 0)r0 (0, 2 ) + 0 r0 (1, 2 ) +
 

1 (1 1)r0 (0, 2 ) + 1 r0 (1, 2 ) =


 

(1 1 )r0 (0, 2 ) + 1 r0 (1, 2 ) = P1 (r0 ( 1 , 2 ))

Combining the two projections leads to a mapping that replaces all four sides
by straight lines, leaving only the four vertices of the patch unaffected:

r0 ( 1 , 2 ) = P1 (P2 (r0 ( 1 , 2 ))) = (8.21)


1 2 1 2
(1 )(1 )r0 (0, 0) + (1 ) r0 (0, 1)+
1 (1 2 )r0 (1, 0) + 1 2 r0 (1, 1)

However, what we want to do is somehow use the projection operators to extend


the mapping from the boundary to the interior of the domain, but in such a
way it leaves all four boundary curves unaffected. This disqualifies the use of
unidirectional interpolation, because this replaced opposite edges by straight
lines. However, it turns out that when the two projection operators are applied
in the following way to the mapping:

P1 + P1 P1 P1 (r0 ( 1 , 2 )) P1 P2 (r0 ),
 
(8.22)

where P1 P2 denotes the Boolean sum of the two projections P1 and P2 .
This mapping is given by:

r0 ( 1 , 2 ) = P1 P2 (r0 ( 1 , 2 )) = (1 2 )r0 ( 1 , 0) + 1 r0 ( 1 , 1)+ (8.23)




(1 2 )r0 ( 1 , 0) + 1 r0 ( 1 , 1)
(1 1 )(1 2 )r0 (0, 0) + (1 1 ) 2 r0 (0, 1)
1 (1 2 )r0 (1, 0) 1 2 r0 (1, 1)

The mapping P1 P2 is the basis for Trans Finite Interpolation (TFI) and
is used both to generate grids, and also to generate an initial condition for
differential grid generation methods.

8.3 Differential models for grid generation

8.3.1 The Winslow equations

The derivation of the Winslow equations follows directly from the transforma-
tion rules for the Christoffel symbol of the second kind:

2
= + (8.24)

8.3 Differential models for grid generation 135

Take the Cartesian coordinates x as the new coordinate system. This means
that the Christoffel symbol of the new system vanishes.

2 x x
0= + (8.25)
x
x x

Next multiply (8.25) with /xy and contract over :

2 x x
0= + = (8.26)

x x x x x x
2
+ =

x x x x
2
+

x x x x
Or rearranging:

2

= (8.27)
x x x x
Contract over (multiple subscripts, allowed because the coordinate system is
Cartesian!).

2 2
= = = a() a()

= g

= (8.28)
x x x x

a() () 2 x
g
a =
x

Multiply () by x /x . We end up with:

x 2 x
2
= g (8.29)

For the curvilinear coordinates the following should hold:

2 = 0, = 1, 2, 2 (8.30)

or using (8.29):

2 x
g = 0, = 1, 2, (8.31)

Transforming () to () changed the set of uncoupled linear equations to a set of


nonlinear, coupled equations. For solution of () it is advantageous to express
the contravariant metric tensor in the covariant metric tensor, as the latter can
be calculated directly from the derivatives of the curvilinear coordinates. Using
the dummy covariant base vector a(3) = (0, 0, 1), the contravariant metric tensor
can be expressed as:
11 12 13
g g g g22 g12 0
1
g 21 g 22 g 23 = g12 g11 0 (8.32)
g
g 31 g 32 g 33 0 0 g
136 8. Introduction to classical grid generation

Using these expressions for the contravariant metric tensor, the Winslow equa-
tions are given by:
2 x1 2 x1 2 x1
g22 1 1
2g12 1 2 + g11 2 2 = 0 (8.33)

2 2 2 2
x x 2 x2
g22 1 1 2g12 1 2 + g11 2 2 = 0

Both equations for x1 and x2 are identical, but of course the solutions are dif-
ferent because of the boundary conditions. The nonlinear system of equations
(8.33) can be solved iteratively, by lagging the metric coefficients in each iter-
ation. The coefficients gij can be computed from the computed grid functions
r0 ( 1 , 2 ) using second order central differencing. As an example consider the
computation of g12 in grid point (i1 , j2 ).
 1 1  2 2
x x x x
(g12 )ij = + = (8.34)
1 2 ij 1 2 ij
   
x1i+1j x1i1j x1ij+1 x1ij1 x2i+1j x2i1j x2ij+1 x2ij1
+ + O(()2 )
4 1 2 4 1 2

8.3.2 The Thompson-Thames-Mastin (TTM) equations


With the Winslow equations no control over grid density is possible beyond
changing the parameterization of the boundary curves. To cluster grid lines in
the vicinity of the boundary to accurately capture boundary layers, e.g. in high
Reynolds number flow we introduce source terms. Additionally, source terms
can be defined to control the direction of the grid lines in the vicinity of the
boundary, either to improve the accuracy of the discretisation or to enable C 1
continuity of the grid lines across block-interfaces in a multi-block grids. The
inhomogeneous form of the Winslow equations is commonly referred to as the
Thompson-Thames-Mastin (TTM) equations and is given by
2 1 = P ( 1 , 2 ) (8.35)
1 2 1 2
= Q( , ) (8.36)
Using (8.35) the transformed equations:
2
2 a() = g , (8.37)

now become
2
P a
(1) + Qa(2) = g

, (8.38)

where the dependence of ( 1 , 2 ) of P and Q is not explicitly denoted. Trans-
forming to the formulation using the co-variant metric tensor as opposed to the
contravariant metric tensor leads to the standard form of the TTM equations.
2 x 2 x 2 x x x
 
g22 1 1 2g12 1 2 + g11 2 2 = g P 1 + Q 2 (8.39)

Two types of source functions are of interest in this context:
8.3 Differential models for grid generation 137

Source functions to control grid line clustering in the vicinity of grid points
or grid lines.
Source functions to control the direction of the grid lines in the vicinity of the
boundary: an artificial way to impose a Neumann condition on the mapping.

8.3.3 Source function for control of grid density


The common form of the two source functions P and Q in the TTM equations
to achieve grid clustering of grid lines in the vicinity of the grid lines = n
and in the vicinity of the points (i1 , i2 ) is given by:
P ( 1 , 2 ) = (8.40)
N L
X 1 n1 cn |1 n1 | X 1 i1 di [(1 i1 )2 +(2 i2 )2 ]
e bi 1 e
n=1
1
| n |1
i=1
| i1 |
Q( 1 , 2 ) = (8.41)
N L
X 2 n2 cn |2 n2 | X 2 i2 di [(1 i1 )2 +(2 i2 )2 ]
e bi 2 e
n=1
2
| n |2
i=1
| i2 |

For positive(negative) values of an /bi grid lines are attracted(repelled) from the
grid lines = n and the grid points (i1 , i2 ). The control of the grid lines is
done in the logical domain, not in the physical domain which would be much
more desirable. Of course we would rather be able to cluster lines around a
certain point (x1c , x2c ) or in the vicinity of a line x = xc when we expect a
strong gradient in the solution on that location. The logical space grid control
makes designing a grid a little less transparent than wanted.

8.3.4 Source function for control of direction of the grid lines


In many instances we would like to be able to control the direction of the grid
lines, most likely make them orthogonal to the boundary. Clearly this is not
directly possible within the framework of either the Winslow or TTM equa-
tions. Both are elliptic second order partial differential equations and allow the
prescription of a single boundary condition on the boundary of the domain. Of
course we need to impose a Dirichlet boundary condition on all four sides of the
domain to have the grid match up with the four parameterized curves that com-
prise the boundary of the domain. To be able to impose an additional Neumann
boundary condition to control the direction of the grid lines we would have to
raise the order of our partial differential equation to four:e.g. the bi-harmonic
equation. The amount of work and computational resource required to solve the
bi-harmonic equation and the added complexity of handling the large discreti-
sation stencil in the vicinity of the boundary make that this approach is seldom
put in practice. If we stick to our Winslow or TTM equations the only way to
impose a Neumann condition on the boundary is indirectly, by imposing source
terms in the vicinity of the boundary. As an example we will show to impose a
Neumann boundary condition on the lower boundary of the domain ( 2 = 0).
We impose:
"   #
x 1 x x
= a(2) = 1 ( 1 ) 1 + 2 ( 1 ) , (8.42)
2 g11 1
138 8. Introduction to classical grid generation

 
x
where we introduced the vector 1 ,defined as:

 
x x
= n = ga(1) (8.43)
1 1

to have a nice symmetric formulation of the boundary condition. We are not


completely free in our definition of the functions 1 ( 1 ) and 2 ( 1 ), because the
direction of the grid lines should match the direction of the boundary curves
for the two vertices (0, 0 and (1, 0), as indicated in Figure **. This requirement
leads to the following two consistency conditions:

 
1 1 x 2 x x
(0) 1 + (0) = (8.44)

g11 1 2

(0,0) (0,0)

(0,0)

 
1 1 (1) x x = x
+ 2 (1)

(8.45)

g11 1
(1,0)
1
2
(1,0)
(1,0)

The main question is of course how to derive the appropriate source terms in
such a way that the Neumann boundary condition is enforced. Recall that the
TTM equations are given by:

2 x 2 x x
 
g2 2 1 1 2g12 + g11 2 2 = g P 1 + Q 2 (8.46)

The general form of the source terms P and Q for this application is chosen as:
2
P ( 1 , 2 ) = 0 ( 1 )e (8.47)
1 2 1 2
Q( , ) = 0 ( )e (8.48)
(8.49)
2
The factor e blends the source term with the interior of the domain. Im-
posing the source terms will adversely affect the smoothness of the grid in the
interior of the domain, so the sources are only applied where needed.
We can abbreviate (8.46) in the following way:
h i
2
Qx = g 0 ( 1 )a(1) + 0 ( 1
)a(2) e (8.50)

or in vector form:
2
Qx = g 0 ( 1 )a(1) + 0 ( 1 )a(2) e
 
(8.51)

To derive the explicit expression for the two source terms 0 ( 1 ) and 0 ( 1 ) we
require that (8.51) holds on the boundary 2 = 0=

Qx = g 0 ( 1 )a(1) + 0 ( 1 )a(2)
 
(8.52)

We can express the operator Q working on the mapping x in the following way:
8.3 Differential models for grid generation 139

2x 2x 2x
Qx = g22 1 1
2g12 1 2 + g11 2 2 (8.53)

a(1) a(1) a(2)
= g22 2g12 + g11
1 2 2
k k k

= g22 11 2g12 12 g11 22 a(k)

To compute the functions 0 ( 1 ) and 0 ( 1 ) we take the inner product of (8.53)


with a(1) and a(2) , respectively.

a(1) Qx = g 0 ( 1 )a(1) + 0 ( 1 )a(2) a(1) = g0 ( 1 )


 
(8.54)
(2) 1 1
  (2) 1
a Qx = g 0 ( )a(1) + 0 ( )a(2) a = g0 ( ) (8.55)

Denote that:

ijk a(l) a(k) = ijk kl = ijl (8.56)

And we end up with the following expressions for the two source terms:
1 1 1 1
= 0 ( 1 )

g22 11 2g12 12 + g11 22 (8.57)
g
1 2 2 2
= 0 ( 1 )

g22 11 2g12 12 + g11 22 (8.58)
g
To impose these two source terms we need the following geometrical quantities
on the boundary

g11 g12 g22

1 1 1
11 12 22
2 2 2 (8.59)
11 12 22



g

Nearly all of these quantities can be computed from the parameterization of the
boundary curve combined with the prescribed Neumann boundary condition,
for example:

g11 = a(1) a(1) (8.60)


g12 = a(1) a(2) = (8.61)
1 1
a(1) 1 ( 1 )x1 + 2 ( 1 )(x1 ) = 1 ( 1 )

g g
 2
1
= 1 ( 1 )x1 + 2 ( 1 )(x1 ) = (1 ( 1 ))2 + (2 ( 1 ))2

g22 (8.62)
g

g = |a(1) a(1) | = (8.63)
1 
|x1 1 ( 1 )x1 + 2 ( 1 )(x1 ) = g11 2 ( 1 )
g

One difficulty remains in the geometrical quantities that depend on second order
mixed or pure derivatives in the 2 direction. Those can not be computed either
from the parameterization of the curve or the Neumann boundary condition. The
only option is to use a one-sided finite difference approximation into the domain
and lag the computation of the source term behind in the iterative process. The
140

major difference between the iterative process for the Winslow equations and the
TTM equations with grid clustering sources is the fact that we are now lagging
coefficients dependent on second order derivatives, as opposed to the first order
derivatives that comprise the coefficients of the covariant metric tensor. This
difference causes a significant difference in convergence rate between the two
iterations: prescribing orthogonality comes at a price.
References

Aris, R. (1962). Vectors, Tensors and the Basic Equations of Fluid Mechanics.
Englewood Cliffs, N.J.: Prentice-Hall, Inc. Reprinted, Dover, New York,
1989.
Batchelor, G.K. (1967). An Introduction to Fluid Dynamics. Cambridge, UK:
Cambridge University Press.
de Saint-Venant, B. (1843). Memoire sur la dynamique des fluides. C. R.
Acad. Sci. Paris 17, 12401242.
Farrashkhalvat, M. and J.P. Miles (2003). Basic Structured Grid Genera-
tion with an Introduction to Unstructured Grid Generation. Butterworth-
Heinemann.
Hinze, J.O. (1975). Turbulence. New York: McGraw-Hill.
Hirsch, C. (1988). Numerical Computation of Internal and External Flows.
Vol.1: Fundamentals of Numerical Discretization. Chichester: Wiley.
Knupp, P. and S. Steinberg (1993). Fundamentals of Grid Generation. Boca
Raton: CRC Press.
Lighthill, J. (1986). The recently recognized failure of predictability in New-
tonian dynamics. Proc. R. Soc. London A407, 3550.
Nakayama, Y. and W.A. Woods (Eds.) (1988). Visualized Flow; Fluid Mo-
tion in Basic and Engineering Situations Revealed by Flow Visualization.
Oxford: Pergamon.
Navier, C.L.M.H. (1823). Memoire sur les lois du mouvement des fluides.
Mem. Acad. R. Sci. Paris 6, 389416.
Poisson, S.D. (1831). Memoire sur les equations generales de lequilibre et du
mouvement des corps solides elastiques et des fluides. Journal de lEcole
Polytechnique de Paris 13, 139166.
Stokes, G.G. (1845). On the theories of the internal friction of fluids in motion,
and of the equilibrium and motion of elastic solids. Trans. Camb. Phil.
Soc. 8, 287305.
Stokes, G.G. (1851). On the effect of the internal friction of fluids on the
motion of pendulums. Trans. Camb. Phil. Soc. 9, Pt. II, 8106.
van Beek, P., R.R.P. van Nooyen, and P. Wesseling (1995). Accurate
discretization on non-uniform curvilinear staggered grids. J. Comp.
Phys. 117, 364367.
Van Dyke, M. (1982). An Album of Fluid Motion. Stanford: The Parabolic
Press.
Vermolen, F.J., P. Verbeek, C. Vuik, and J. van Kan (2007). Numerical Meth-
ods for Ordinary Differential Equations. Delft: VSSD.
Wesseling, P. (1992). An Introduction to Multigrid Methods. Chichester: Wi-
ley. Available on Internet: www.mgnet.org/mgnet-books-wesseling.html.
Wesseling, P. (2001). Principles of Computational Fluid Dynamics. Heidel-
berg: Springer.
Index

absolute stability, 70 CG, 125, 128


accuracy chaos, 11
uniform, 60 characteristics, 45, 50, 52
Adams-Bashforth scheme, 85, 95 Cholesky decomposition, 120
Adams-Bashforth--scheme, 99 incomplete, 120, 121
Adams-Bashforth-Crank-Nicolson cholinc, 120, 121
scheme, 95, 98 cholinc, 127
Adams-Bashforth- scheme, 85 compatibility condition, 88, 97
aircraft, 11 condition number, 108, 126
amplification factor, 74 conjugate gradients method, 125
artificial viscosity, 30 conservation
of mass, 5, 6
back-substitution, 110, 118 of momentum, 7, 8
backward-facing step problem, 99 conservation form, 18, 19, 43, 86
bandmatrix, 104 conservation law, 5
bandwidth, 109, 115 conservative, 23, 55
lower, 109, 110 consistency, 6870
upper, 109, 110 constitutive relation, 8
barrier function, 38, 40 continuity equation, 6, 9
basic iterative method, 110, 116, 128 continuum hypothesis, 5
benchmark, 114, 115 control volume, 22
BIM, 116118, 123, 124, 129, 132 convection-diffusion equation, I, 13, 14,
Black-Scholes equation, 13 17, 53
body force, 7, 9 dimensionless form, 14
boundary condition, 19, 20, 24, 49, 85, 91 convection-diffusion-reaction equation,
Dirichlet, 19, 20, 24 13
Neumann, 19, 20, 25 convergence, 6870, 110, 115117, 119,
wrong, 20 124, 125, 128, 130, 132
boundary layer, 31, 44 of discretization, 68
equation, 46, 47, 51, 52 rate of , 121
ordinary, 52 coordinates
parabolic, 52, 54 Cartesian, 2
thickness, 31 right-handed, 2
boundary value problem, 19 Courant number, 77
Burgers equation, 19, 72 Courant-Friedrichs-Lewy number, 77
Crank-Nicolson scheme, 78
Cartesian grid, 99 cruise condition, 11
Cartesian tensor notation, 2 curl, 4
cavitation, 7
cd1, 27, 28, 42 dAlemberts paradox, 46
cd2, 58, 59 determinism, 12
cdns, 81 deviatoric stress tensor, 86
cell, 22 diagonally dominant, 109, 110
cell-centered, 23, 28, 37, 41, 89 differential-algebraic system, 93, 94, 97
central discretization, 24 diffusion coefficient, 13
central scheme, 25 diffusion number, 65
CFL number, 77 dimensionless
144 Index

convection-diffusion equation, 14 first order, 120


equations, 9 ICCG, 126, 127
Navier-Stokes equations, 10, 86 ill-posed, 17, 20
parameter, 10, 11 ILU, 110, 118
variables, 10 ILU decomposition, 119, 121
direct method, 110, 112, 116 first order, 119, 121
direct solver, 104 IMEX method, 104
Dirichlet, 52, 53 IMEX scheme, 95
Dirichlet condition, 19 implicit, 77
distinguished limit, 49, 51, 52 incomplete Cholesky decomposition, 120,
distributive iteration, 96, 110, 128, 130, 121
132 first order , 120
divergence theorem, 2 incomplete LU method, 118
driven cavity, 113 incompressibility, 7
incompressible, 6
efficiency, 66, 85, 103, 110, 112, 117, 119, induced norm, 108
127, 128 inertia, 8, 11
eigenvalue, 108, 123 inertia terms, 9
eigenvector, 108, 117, 123 inflow boundary, 50
elliptic, 45 inflow conditions, 87, 92
ERCOFTAC, 1 initial condition, 86
errata, II inner equation, 47, 49
Euler scheme inner product, 2
backward, 77 inner solution, 47, 48
forward, 65, 72, 76, 77, 94 Internet, 1, 107
explicit, 77, 79 irreducible, 109
explicit scheme, 71 irrotational, 4
iteration matrix, 116
Ficks law, 13 iterative method, 110, 112, 116, 121
fill-in, 111, 119 backward Gauss-Seidel, 118
finite difference, I basic, 116, 128
finite element, I distributive, 128, 130, 132
finite volume, I, 22, 54, 90 forward Gauss-Seidel, 118
finite volume method, 17, 22, 44 Gauss-Seidel, 118, 124, 132
fish, 11 ILU, 118
floor, 58 Jacobi, 118, 122, 124, 132
flops, 105, 110, 111, 123 SIMPLE, 129, 130, 132
flux, 23, 24 SIMPLEC, 132
flux vector, 13 SIMPLER, 132
Fourier stationary, 116, 130
analysis, 71
law, 13 Jacobi method, 110, 118, 122, 124, 132
mode, 73 Jacobian, 94
series, 72
stability analysis, 72, 98 K-matrix, 109, 110, 117, 118, 128, 129
fractional step method, 96 kron, 121
free surface conditions, 87, 92 Kronecker delta, 2, 8
friction, 11 Kronecker product, 121
frozen coefficients method, 71, 72 Krylov subspace method, 124, 125, 132

Gauss-Seidel method, 110, 118, 124, 132 Lagrange multiplier, 94


backward, 118, 124 laminar, I, 1, 11
forward, 118, 124 Landaus order symbol, 35
Gaussian elimination, 110, 118 Laplace, 12, 127
Laplace operator, 2, 9
heat equation, 64 Laxs equivalence theorem, 70
heq, 66 length scale, 81
hyperbolic, 45 Leonardo da Vinci, 11
lexicographic order, 58, 119, 121
IC, 120 linear interpolation, 24
Index 145

linearization, 94, 112 induced , 108


extrapolated Picard, 95, 99 matrix , 108
Newton, 85, 94, 99 p- , 108
Picard, 85, 95, 99 vector , 108
local grid refinement, 33 ns1, 85, 99
local mesh refinement, 60 ns2, 85, 99
lower triangular, 109 ns3, 112
lu, 111 numerical diffusion, 30
LU-decomposition, 104 numerical efficiency, 103
luinc, 121 numerical flux, 24

M-matrix, 109, 117119, 124, 128 -scheme, 77, 78, 80, 85, 99
matching principle, 47, 49, 51 one-step scheme, 68
material outer equation, 47, 50, 51
particle, 5, 6, 13 outer solution, 47, 48, 50
property, 5, 13 outflow, 85
volume, 57 outflow boundary, 53, 54
mathematical finance, 13 outflow condition, 17, 52, 88, 92
MATLAB, 18, 27, 41, 56, 58, 59, 66, 99, overrelaxation, 116
103, 125
MATLAB code, 112 p-norm, 108
MATLAB software, II Peclet
matrix mesh number, 30, 57, 61, 105
diagonally dominant, 109, 110 number, 14, 28, 33, 54
irreducible, 109 uniform, 33
K- , 109, 110, 117, 118, 128, 129 uniform accuracy, 54
M- , 109, 117119, 124, 128 uniform computing cost, 54
positive definite, 109, 110 parabolic, 51
sparse, 109, 110 paradox of dAlembert, 46
transpose, 108 Parsevals theorem, 74
triangular, 109 Pentium, 67, 103
matrix norm, 108 physical units, 9
maximum principle, 17, 21, 29, 43, 57, Picard, 85, 95, 99
63, 117 iteration, 112, 128
discrete , 17, 44 linearization, 112
mesh Peclet number, 30, 57, 105 pivoting, 110
mesh Reynolds number, 105, 129 po, 121, 126, 127
mesh size, 23 Poisson equation, 97, 120, 122, 132
momentum equation, 8 positive definite, 109, 110
monotone, 17, 21 positive scheme, 29
multigrid, 107, 112, 125, 132 positive type, 29, 57, 117
multiphase flow, 6 postconditioning, 130
my_cholinc, 120, 127 potential, 4
flow, 3
Navier-Stokes equations, I, 9, 85 preconditioning, 125
dimensionless, 10, 86 predictability of dynamical systems, 12
incompressible, 9 pressure Poisson equation, 97
nonstationary, 107 pressure-correction method, 85, 96, 98,
stationary, 107 129
Neumann, 52, 53 projection method, 96
Neumann condition, 19
Newton, 1, 7, 85, 94, 99 random, 12
Newtonian rate of convergence, 121
fluid, 8 rate of strain, 8
mechanics, 12 rate of strain tensor, 8
non- , 8 regular perturbation, 46
no-slip, 87, 92 regular splitting, 110, 117, 124, 128, 129
norm relaxation parameter, 116
l2 , 74 reordering, 105, 110, 111
residual, 117
146 Index

Reynolds symmetry, 27
mesh number, 105, 129
number, 1, 1012, 33, 54, 61, 86 Taylors formula, 34, 35
transport theorem, 5 tensor
rotation, 4 rate of strain , 8
rounding error, 34 stress , 8
termination criterion, 117
scheme time scale, 81
central, 25 total derivative, 5
finite volume, 26 transport theorem, 5, 6
numerical, 26 transpose, 108
upwind, 25 truncation error, 34
sea-level, 11 global, 18, 34, 68, 114, 116
ship, 11 local, 17, 34, 35, 68, 69, 114
SIMPLE, 110, 129, 130, 132 turbulence, 11
termination criterion, 132 turbulent, I
SIMPLEC, 132 two-step method, 95
SIMPLER, 132
singular perturbation, 34, 46 underrelaxation, 116, 129
singular perturbation theory, 44, 46, 47 uniformly valid, 50
smooth grid, 35, 36 upper triangular, 109
software, 107 upwind discretization, 24
software libraries, 108 upwind scheme, 25, 72, 76, 115, 129
solenoidal, 3, 4, 94
sparse, 27, 104, 109, 110 vector
spdiags, 27, 121 analysis, 1
spectral method, I norm, 108
spectral radius, 108, 123, 124 notation, 2
speed of sound, 7 space, 108
splitting, 129, 130 vectorization, 66
convergent, 117 vertex-centered, 23, 27, 40, 41, 89
regular, 117, 118 virtual value, 92, 93
spy, 111, 121 viscosity
stability, 68, 70, 78, 81, 85, 98 coefficient, 86
absolute, 70, 75, 76 dynamic, 8
analysis, 71, 78 kinematic, 8, 11
Fourier analysis, 71, 72, 98 numerical, 33
local, 71 von Neumann condition, 75
zero- , 70, 75, 76
staggered, 88, 89, 91, 94 wall-clock time, 103
staggered grid, 85 wavenumber, 73
standard atmosphere, 11 website, II, 1
stationary iterative method, 116 well-posed, 17, 20, 51
stencil, 26, 44, 57, 91, 119, 121 wiggles, 21, 29, 60, 61, 64, 88, 117
Stokes windtunnel, 11
equations, 12 wing cord, 11
paradox, 12 wp_iccg, 127
stratified flow, 8
streamfunction, 3, 114, 115 yacht, 11
streamline, 3, 4, 114
stress tensor, 8 zero-stability, 70
deviatoric , 86
stretched coordinate, 47
subcharacteristics, 45
subscript notation, 2
summation convention, 2
surface force, 7
swapping, 114
symmetric positive definite, 125

You might also like