You are on page 1of 11

Department of Mechanical & Aerospace Engineering


AERO 4304: Computational Fluid Dynamics

Winter 2013

Lecture 4: Fundamentals of Numerical Methods

Lecture summary
In this lecture, we will discuss
overview of discretization schemes (finite-difference, finite-element, finite-volume)
introduction to computational grids for CFD
properties of numerical methods
sources of error in numerical methods

Overview of discretization schemes

The conservation equations that govern the fluid flow were discussed in Lecture 2,
and general properties of PDEs were discussed in Lecture 3. Now we are going
to discuss how the governing equations are solved. The first step is to define the
appropriate governing equations for a given problem, which involves deciding if the
flow is compressible or incompressible, viscous or inviscid, steady or transient, etc.
Once an appropriate mathematical model has been selected, one has to decide how to
discretize the equations. Discretization is a process where the continuous differential
equations are approximated by a system of algebraic equations for the variables at
some discrete locations in time and space. There are many approaches, but the most
popular in CFD are the finite-difference (FD) method, the finite volume (FV) method,
and the finite element (FE) method.


Finite difference method

The FD method is the oldest method for the numerical solution of PDEs, having originated with Leonard Euler in the 18th century. For simple geometries, the FD method
is the easiest method to implement. The starting point is the conservation equation
in differential form. The solution domain is covered by a grid with nodes spaced a
finite distance apart. At each grid point, the differential equation is approximated by
replacing the partial derivatives by approximations that are functions of the terms
of the neighbouring grid nodes. The result is one algebraic equation per grid node,

AERO 4304

Lecture 4

with the variable value at that grid point and a certain number of neighbouring grid
points appearing as unknowns. Taylor series expansion is commonly used to obtain
the approximations to the first and second derivatives; this is discussed further below.
The advantages of the FD method are that it is simple and effective for simple
geometries, and high-order schemes can be easily constructed (well discuss what
high-order means later in this lecture). The disadvantages are that it conservation
is not ensured unless special care is taken (well discuss what conservation means
later in this lecture) and that it is generally restricted to simple geometries.


Finite volume methods

The starting point for the FV method is integral form of the conservation equations.
The solution domain is sub-divided into a finite number of contiguous control volumes
(CVs, hence the name finite volume). In general, the CV can be polyhedral (any
number of sides), although tetrahedrals (4-sided) and hexahedrals (6-sided) are most
common. The conservation equations are applied to each CV. For each CV, the
variables values are approximated at a computational node located at the centroid of
the CV (called a cell-centered FV method) or at the vertices of the CV (called a
node-centered FV method). Interpolation is used to express variable values at the
CV surfaces in terms of nodal or vertex values. The surface and volume integrals in the
integral conservation equations are integrated using a suitable numerical integration
(also called quadrature) method. As a result, one algebraic equation is obtained for
each CV containing values from a number of neighbouring CVs.
The advantages of the FV method are that it is suitable to any type of grid, so that
complicated geometries can be accommodated, and it is conservative by construction.
The method is simple to understand, as each of the terms have physical meaning. An
advantage of the FV method is that discretization orders higher than second are
difficult to develop in 3D, which means that it may achieve lower accuracy than other
methods for a given grid.


Finite element methods

Similar to the FV method, the FE method begins with the integral form of the
governing equations, and the domain is sub-divided into a set of discrete volumes or
elements. The variation of a flow variable within an element is approximated by an
m-degree polynomial (often m = 1 or 2 is used). Of course, the approximation does
not satisfy the PDE exactly, leaving a residual, so the equations are multiplied by
a weight function before they are integrated over the entire domain. The derivative
of the integral with respect to each nodal value is set to zero, which corresponds to
finding the weight function that produces the minimum residual. The result is a set
of non-linear algebraic equations that are solved using a suitable numerical method.
The advantages of FE methods are the ability to deal with complex geometries

AERO 4304

Lecture 4

(like the FV method), the grids are easily refined by simply sub-dividing them, and
have optimality properties for certain types of equations. The disadvantages is that
the matrices of the linearized equations are not well structured and so it is difficult
to find efficient solution methods.

Introduction to computational grids in CFD

The three methods discussed above for discretizing the Navier-Stokes equations have
something in common: they sub-divide the solution domain into discrete locations in
space through a form of a computational grid. The computational grid (which is also
referred to as a mesh) has arguably one of the biggest effects on the quality of a CFD
solution. We will be seeing different kinds of computational grids in this course, so it
is worthwhile spending a little time to acquaint ourselves with the terminology and
different kinds of grids that can be used.
A high-quality mesh improves the accuracy of the CFD solution and improves
the convergence rate (that is, the speed at which the discretized governing equations
are solved) relative to a poor mesh. The parameters that determine the quality of a
computational grid for CFD are varied. Among the important ones are:
Cell volume: the volume of the grid cells. The volume should be small enough
that many cells are contained with the regions of interest in the flow.
Cell area: the area of the cell faces. The area should be small enough to capture
variations in the flux of flow properties.
Orthogonality of grid lines: how orthogonal the grid lines are relative to the
direction of greatest change in the flow. Particularly near walls, where the wallnormal gradients can be very high, it is desirable for the grid to be as orthogonal
to the surface as possible.
Cell aspect ratio: the ratio of a cells height to width (in 2D) or its largest
to smallest dimension (in 3D). Depending on the type of cell, having a large
aspect ratio can cause serious issues in the computation. For square (in 2D) or
hexahedral (in 3D) cells, large aspect ratios do not normally have a detrimental
effect on the solution, but for triangular (2D) or tetrahedral (3D) cells, large
aspect ratios imply highly-skewed cells.
Skewness of cells: how large the angle is between cell faces. If there are highlyskewed cells, there will be small angles between cell faces, which leads to errors
when the sine or cosine of the small angle are taken.
Rate of change of cell volume: how rapidly the size of adjacent cells increases or
decreases. Most CFD solvers cannot tolerate a rate-of-increase in the cell size
from one cell to another that exceeds 15-20%.

AERO 4304

Lecture 4

Figure 1: Example of a structured grid in two dimensions with Ni nodes in the

i-coordinate direction and Nj nodes in the j-coordinate direction.
There are two main categories of grids used in CFD: structured and unstructured.
These are described in the following sections.


Structured grids

A structured grid is composed of congruent parallelograms (in 2D) or parallelepipeds

(in 3D). Each cell in the grid can be addressed by an index (i, j) in two dimensions
or (i, j, k) in three dimensions. The vertex of each cell has coordinates (i dx, j dy)
in 2D or (i dx, j dy, k dz) in 3D for some real numbers dx, dy, dz representing the
grid spacing. An example of a structured grid is shown in Fig. 1.
In general, there three main types of structured grids:
1. O-grids: Grid lines wrap around and meet the first point. As a result, some of
the grid lines look like a letter O. There is a joined boundary between the
first and last grid points. An O-grid is illustrated in Fig. 2(a)
2. C-grids: Grid lines are shaped roughly like a letter C. One grid line will bend
backwards and meet up with itself. An example C-grid around an airfoil is
illustrated in Fig. 2(b)
3. H-grids: A structured grid that is not an O- or a C-grid is called an H-grid. For
example, the grid illustrated in Fig. 1 is an H-grid.
Sometimes, a combination of the different types of structured grids are needed for
a complex geometry. In such an instance, a multiblock structured grid can be built
from mating multiple blocks of structured grids. For instance, Fig. 3 shows a singleand multi-block grid for meshing a pipe flow. In a single block grid, orthogonality is
not respected in the corners of the pipe and the mesh is coarse along the top, bottom,

AERO 4304

Lecture 4

Figure 2: Examples of an (a) O-grid around a cylinder and a (b) C-grid around an
and sides. These problems are solved by using a multiblock structured grid that
combines an H-grid and a O-grid. Very complicated geometries have been meshed
with multiblock grids. For instance, Fig. 4 shows an entire aircraft meshed with a
multiblock structured grid.
Structured grids have numerous advantages. The finite-difference approximation
of the governing equations are easy to express in terms of finite differences between
mutually orthogonal coordinate directions, which can be conveniently mapped to the
i and j indices in a structured grid. Also, the placement of nodes can be moreprecisely refined, and mesh refinement in general is easier with a structured grid.
Orthogonality of grid lines is easier to maintain in a structured grid, and in fact, it
may be satisfied by the very nature of the grid, as can be seen in the H- and O-grids
illustrated in Figs. 1 and 2.
There are also some disadvantages to structured grids as well. They are often very
time-consuming and difficult to make, and as a result, require a great deal of expertise
in using the grid-generation software and patience in building the grid. Many structured grids waste nodes because of the way the mesh is refined near a surface. For
example, the C-grid in Fig. 2(b) has a dense concentration of grid lines to resolve the
airfoil surfaced, but this results in a large number of nodes downstream of the airfoil
even though the flow development there is not of interest. Boundary conditions are
sometimes difficult to implement with a degree of accuracy because often the nodes in
the grid do not coincide with the boundaries of the domain. Furthermore, it is difficult to use within adaptive solution methods, which are a kind of method that refines
the grid as the CFD solution progresses to improve the accuracy of the solution.

AERO 4304

Lecture 4

Figure 3: Comparison of a single- and multi-block grid in a circular pipe.

Figure 4: Example of a multiblock grid around an aircraft.

AERO 4304

Lecture 4

Figure 5: Example of a unstructured grid around an aircraft.


Unstructured grids

An unstructured grid is constructed from simple shapes, often triangles (2D) or tetrahedrals (3D) but sometimes other polyhedrals as well, arranged in an irregular pattern
within the computational space. Rather than nodes being identified by a set of indices, unstructured grids use a list of connectivity that specifies the way a given set
of indices makes up an element. An unstructured grid provides maximum flexibility;
any complicated geometry can mapped with an unstructured grid, and it is easy to
locally refine the grid (in principle) by simply sub-dividing the cell into smaller cells.
As a result, the problem of wasted cells due to grid refinement encountered in structured grids does not occur in unstructured grids. An example of an unstructured grid
is shown in Fig. 5.
In general, finite element and finite volume methods are preferred when using
unstructured grids. The chief disadvantage of unstructured grids is the difficulty
in achieving high-order accuracy with discretization strategies that are suitable for
unstructured grids. Also, it is often more complicated to decompose unstructured

AERO 4304

Lecture 4

grids when running a simulation in parallel on multiple processors.

Properties of numerical methods

Whatever discretization method is chosen, it must possess certain properties to ensure

that the solution is accurate. The most important properties are described below.



The difference between the exact, continuous PDE and the approximate discrete
equation is termed the truncation error. Whenever we approximate a derivative
in the governing equation, the approximation is not exact, and there is some error
between the approximated and exact value. The magnitude of the error is a function
of the grid spacing. For a method to be consistent, the truncation error must become
zero when the mesh spacing tends to zero.


Order of accuracy

If the discrete approximation for the most important term in a discretized equation is
proportional to (x)n or (t)n , we call the method an nth -order approximation; n > 0
is required for consistency. The magnitude of the truncation error is not necessarily
proportional to (x)n , but the rate at which the truncation error reduces as the grid
spacing is decreased is proportional to (x)n .



Even if the discretization method is consistent, it does not necessarily mean that
the solution of the system of equations will become exact in the limit of small step
size. For that to happen, the scheme must also be stable. A scheme is stable if it
does not magnify small errors that appear in the course of performing the numerical
calculations. In an unstable scheme, small errors are magnified and cause the solution
to diverge, possibly leading to an overflow error within the computer (a hardware error
that occurs when the computer memory is asked to store a number that is too large
to be represented). For some schemes, ensuring stability may impose restrictions on
the maximum or minimum timestep or grid-spacing size.



A numerical method is convergent if the difference between the solution of the discretized equation and the exact solution of the differential equation tends to zero as
the grid spacing tends to zero. It is related to consistency and stability; if a scheme
is consistent but not stable, it cannot converge. Convergence is tested by repeating

AERO 4304

Lecture 4

the simulation on successively-refined grids. If the method is stable and the same
approximations are made for each trial, the solution is considered to be converged;
the converged solution is often termed the grid-independent solution.



As the equations that are solved are conservation laws, the numerical scheme should
also ensure that conservation is respected on a local and global basis. If the differential
equations are discretized in their strong conservation form (recall Lecture 2) and a
FV method is used, conservation is guaranteed for individual CVs and for the global
solution domain. Conservation places a constraint on the solution error, because if
mass, momentum, and energy are conserved within the solution domain, errors can
only improperly redistribute these quantities. On the other hand, non-conservative
schemes can produce artificial sources and sinks that alter the local and global mass,
momentum, or energy balance. The error due to non-conservation is also difficult to
approximate, so conservative schemes are preferred.



The solution to the discretized equation must lie with proper bounds. Physically nonnegative quantities like density, absolute pressure, kinetic energy of turbulence, etc.,
must always be positive. Some equations require that the minimum and maximum
values must occur along the solution boundaries, such as the heat equation with
no sources present. The ability of a numerical scheme to respect these bounds is
called boundedness. Boundedness is difficult to guarantee. Higher-order schemes may
produce undershoots or overshoots in the vicinity of sharp gradients, which is usually
an indication that the local grid spacing is too coarse. Such unbounded variations
may lead to instability or convergence issues as well.



The solution of the discretized equations are only approximate solutions and there is
a measure of error associated with any numerical method. The accuracy of a scheme
is the measure of how large the error is.

Sources of error in numerical methods

To understand accuracy, we need to appreciate the source of errors in numerical

schemes. Every numerical scheme always has three kinds of systemic errors present:
1. Modelling errors: Models are used to predict behaviour that is too difficult or
expensive to calculate. As the output of the model is only a prediction, the

AERO 4304

Lecture 4


modelling error is defined as the difference between the actual flow and the
exact solution of the model.
2. Discretization errors: Defined as the difference between the exact solution of the
differential equations and the exact solution of the algebraic system of equations
obtained by discretization.
3. Iteration errors: Defined as the difference between the iterative and exact solutions of the algebraic system of equations.
4. Round-off error : Defined as the difference between the exact value of a number
and the representation of that number in a real computer with a finite number
of digits. Because numbers cannot be represented exactly in computer memory,
but must be rounded to a finite number of digits, this rounding may affect
the solution. In particular, while discretization error often decreases with grid
refinement, the round-off error frequently scales on the number of grid points
and so increases.
It is important to be aware of the existence of these types of error, and to make note
of the distinction between the different sources of error. Sometimes different types
of errors may cancel each other out. For example, a simulation with a fine grid may
actually produce a poorer solution than a simulation with a coarse grid, even though
finer-grid case should have, by definition, lower error.

Example: To illustrate the concept of consistency, stability, and convergence, consider the following equation:
u u

= 0, x R, t 0


together with the initial data

cos2 x if |x|
u(x, 0) =
if |x|


This equation is solved numerically using the FD method with a particular kind of
scheme that is known to be consistent. A grid size of x = 0.04 is used to discretize
the spatial x direction and a time step size of t = x is used to discretize time.
Values of = 0.9 and = 1.1 are used. The results obtained from the two values
of are shown in Fig. 6(a) and (b), respectively. For < 1, the scheme is stable
and produces a left-propagating wave. For > 1, the scheme is unstable. Even
though the errors introduced at each step are not much bigger than before, they grow
exponentially in subsequent time steps. Eventually, the wave solution is obliterated
by a saw-tooth pattern oscillation. This rapid blow-up of a saw-tooth mode is typical

AERO 4304

Lecture 4


Figure 6: Solutions to Eqn. 1 with (a) = 0.9 and (b) = 1.1. The scheme is stable
in (a) and unstable in (b).
of unstable FD formulas. Figure 6 illustrates that consistency of the a scheme does
not guarantee stability; both solutions are based on the same consistent scheme, but
one is unstable because the timestep is too large. We may say that the timestep is
outside of the stability bounds of the method. The stable solution is convergent while
the unstable solution cannot converge. This illustrates a fundamental behaviour of
FD schemes: if a consistent scheme is stable, it is likely that it will converge.