Lecture Notes CFD 2014-2015
Lecture Notes CFD 2014-2015
Wesseling
updated by D.R. van der Heul
ELEMENTS OF
COMPUTATIONAL FLUID
DYNAMICS
Faculty ITS
Applied Mathematics
Preface
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.
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
Preface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . I
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/
, = . (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 ).
11 = 22 = = dd = 1, = 0, 6= ,
Divergence theorem
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
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 .
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.
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
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.
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
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.
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
Conservation of momentum
Z Z Z
d
u dV = fb dV + fs dS . (1.13)
dt
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)
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).
Constitutive relation
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
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.
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 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).
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
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.
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.
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
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.
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..
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.
To explain how the maximum principle can tell us whether the exact solution
is monotone;
To explain the discrete maximum principle that may be satisfied by the nu-
merical scheme;
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
Since Z
1
Ld = (u ,1 )|0 , (2.2)
An exact solution
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:
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
(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
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):
Maximum principle
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
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:
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
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.
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
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
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
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
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.
(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
(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
(),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)
(),1 J+1/2
= J+1/2 b. (2.37)
J+1/2
= J + hJ b/2 . (2.38)
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).
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.
Lh j = j1 j1 + j0 j + j1 j+1 = qj , j = 1, , J , (2.42)
Stencil notation
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
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
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.
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 (*).
in stencil notation:
X
Lh j = jk j+k = qj , j = 1, , J .
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.
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
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).
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
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)
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.
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 ,
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:
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.
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
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
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
The grid is called rough if the mesh size hj varies abruptly, or more precisely, if
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),
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.
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
|ej | Ej , j = 1, , J . (2.73)
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
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.
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
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
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 = 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
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
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)
What are the conditions for a scheme to be of positive type? Which desirable property do positive
schemes have?
Derive the condition to be satisfied by the step size h for the central scheme to be of positive type
on a uniform grid.
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:
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:
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.
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).
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 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;
Exercise 3.1.1. Show that equation (3.1) is in conservation form by using The-
orem 1.2.1.
Subcharacteristics
u , = q , q = q u, . (3.6)
x,s = u . (3.7)
,s = , x,s = u , .
,s = q . (3.8)
A paradox
x2
P4
C2
P3
P2
C1
x1
P1 1
Figure 3.1. Streamline pattern.
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.
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
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
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
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 ,
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
This gives us the inner solution. In terms of the unstretched variable x2 the
inner solution is given by
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 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.
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
x2
x1
1
Figure 3.3. Characteristics of equation (3.6) in a channel flow.
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).
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).
(1, x2 ) = f3 (x2 ).
(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.
Problem statement
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
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
Gc
H2
Gf
h2
H1
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
If we sum (3.31) over all cells only boundary fluxes remain, so that the scheme
is conservative (cf. Sect. 2.3).
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
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
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.
Lh ij 0, i = 2, , I 1, j = 2, , J 2 ,
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)).
Ay = b .
ym = ij , m = i + (j 1)I . (3.40)
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
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
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.
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.
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).
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
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
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.
What is the essential feature that makes it possible to have accuracy and efficiency Peclet-uniform?
Why do we want this property?
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:
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.
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
Discretization in time
(n+1
j nj )/ + Lh nj = 0 , n = 0, , N , N T / , (4.12)
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 ,
n+1 = An ,
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.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.
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
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)
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
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
x2
xj
x2j
2
x1
x1j
1
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
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
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.
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.
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
xj = jh , j = 0, 1, , J 1 1/h .
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
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
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
xj = (j1 h1 , j2 h2 ) , j = 0, , J 1 1/h , = 1, 2 .
As a consequence we have
X
c eij = 0, j Gh c = 0, . (4.35)
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 .
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.
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
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
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 , .
d(1 cos ) 1 , ,
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
n+1
j = nj c(nj nj1 ) , c u /h . (4.46)
h/u , (4.48)
The -scheme
(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 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
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,
dc
= Lh ()cn (4.55)
dt
4.4 Fourier stability analysis 75
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 = |u | /h , d = 2 /h2 (4.63)
(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
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
Problem statement
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) ,
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.
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
5.1 Introduction
Only the primitive variable formulation will be discussed. This means that the
velocity components and the pressure will be used as unknowns.
The purpose of this chapter is to present a numerical method for the incom-
pressible Navier-Stokes equations. In particular, we will:
Equations of motion
Re = 0 U L/ ,
The deviatoric stress tensor (i.e. the viscous part of the stress tensor) is denoted
by . From equation (1.17) it follows that
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:
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.
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:
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
Outflow conditions
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.
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
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.
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
Z
u1,t + (u1 u1 + p Re1 u1.1 ),1 + (u1 u2 Re1 u1,2 ),2 d
=
j+1/2,k
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.
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 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.
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 .
Inflow conditions
Outflow conditions
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,
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
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.
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
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.
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
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 .
pj+1/2k
= 1
2 (pjk + pj+1k ) . (5.24)
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
u2 j0 = u2 j1 , (5.26)
u1 jK+1 = u1 jK , (5.27)
u2 jK+1 = u2 jK (5.28)
Inflow conditions
Outflow conditions
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
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
Summary of equations
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 ,
(un+1 2 n 2
= (un1 jk )2 + 2un1 jk u1
1 jk ) = (u1 jk + u1 jk ) jk .
2 n
(un+1 n+1
1 jk ) = u1 jk u1 jk .
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 ) .
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
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.
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
Temporal accuracy
which very likely results in a pressure field pn1/2 with the same order of tem-
poral accuracy as the velocity field.
Stability
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.
A E
C D
Figure 5.9. The backward-facing step problem.
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
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
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.
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
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
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.
1
10
2
10
3
10
0 500 1000 1500 2000 2500
Figure 5.13. Convergence history for backward-facing step problem, code ns2.
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
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
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.
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.
Write down the general formulation of the discretized nonstationary incompressible Navier-Stokes
equations.
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.
(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 u) = 2(u )u + 2u ( u) (6.4)
(u )u = u ( u) + ( 21 u u) (6.5)
2 u = u + ( u) = u (6.6)
=u p = 12 u u + p (6.7)
u,t u = p (6.8)
= 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.
si = ez n (6.11)
or discretely:
1 X
i = usj kxcTj xcTj1 k (6.14)
Adual
Tj Conni
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
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
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.
The controlvolumes for the discretisation of the momentum equations are overlapping. Does this
violate global momentum conservation?
7. Discretisation on a boundary conforming grid.
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.
|a() | =
6 1, |a() | =
6 1 (7.3)
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.
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
x1 = r cos (7.16)
x2 = r sin
x3 = z
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:
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
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.
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
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
Obviously this tensor is symmetric, because the order of the terms is irrelevant:
g = g (7.46)
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.
g 1 1 T1121...
2 ...
= T21...
1 2 ...
(7.55)
T N = T N , (7.56)
but of course T 6= T .
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)
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)
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)
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)
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.
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)
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.
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.
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)
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
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() 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)
u
, = 0 (7.115)
u
+ u u , = p, + ,
(7.116)
t
= Re1 u
, + u, (7.117)
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)
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:
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.
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)
( 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
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 ).
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
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
x1 x11 x1 x10
L0 (x1 ) = L1 (x1 ) = (8.9)
x10 x11 x11 x10
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
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 **.
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
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:
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:
(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.
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
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
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)
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
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.
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.
x
where we introduced the vector 1 ,defined as:
x x
= n = ga(1) (8.43)
1 1
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)
Denote that:
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:
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
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