Beruflich Dokumente
Kultur Dokumente
Finite-Volume Methods
Most modern general purpose CFD codes use finite volume methods to obtain the
discretized set of equations.
One important feature of finite volume schemes is their conservation properties. Since they
are based on applying conservation principles over each small control volume, global
conservation is also ensured.
Although here we will consider in some detail how they are applied on rectangular Cartesian
grids they can, fairly readily, be adapted to non-orthogonal and even unstructured grids.
Some examples of how this is done will be presented in later lectures.
Contents:
Introduction to CFD
Numerical solution of equations
Finite difference methods
Finite volume methods
Pressure-velocity coupling
Solving sets of linear equations
Unsteady problems
Turbulence and other physical modelling
Body-fitted coordinate systems
Reading:
J. Ferziger, M. Peric, Computational Methods for Fluid
Dynamics
H.K. Versteeg, W. Malalasekara, An Introduction to Computational Fluid Dynamics: The Finite Volume Method
S.V. Patankar, Numerical Heat Transfer and Fluid Flow
Notes: http://cfd.mace.manchester.ac.uk/tmcfd
- People - T. Craft - Online Teaching Material
Introduction
(Uj )
+ S
xj
xj
xj
In earlier lectures we examined finite difference methods, and saw how they could be used
to approximate a differential equation by a set of discretized algebraic ones.
Employing Taylor series analysis allowed us to determine the truncation error of
approximations, and to develop schemes with different orders of accuracy.
Such methods can be applied quite
successfully when the flow geometry allows a
simple Cartesian set of grid points to be
adopted.
or
(i+1,j)
or
However, in complex geometries more work is
needed.
(2)
Z
Z
Z
(Uj )
dV =
S dV
dV +
xj
xj
xj
(i,j+1)
(i1,j) (i,j)
.(U ) = .() + S
(1)
(i,j1)
In such cases it may not be possible, for example, to arrange horizontal grid lines as shown,
meaning we could not approximate /x purely in terms of values along a constant j line.
.(U ) dV =
.() dV +
S dV
(4)
(3)
(5)
The divergence theorem can then be used to convert the volume integral on the left hand
side to an integral around the boundary, , of the control volume:
Z
Z
(U ).ndS =
S dV
(6)
- p. 2
- p. 4
U .ndS is the convective flux of across the small part of the boundary edge dS , and
.ndS is the diffusive flux across the same boundary element.
The left hand side of equation (6) is thus simply the total net convective and diffusive flux of
into the control volume.
Equation (6) is thus essentially a statement of conservation for the control volume. In the
case of the momentum equation, where = U for example, it is simply the force-momentum
principle applied over the control volume.
Provided the same expressions are used for fluxes across faces in neighbouring cells, this
approach thus ensures that the same conservation properties will also be satisfied globally
over the flow domain.
Since the boundary of a control volume is made up of a number of straight edges, the
surface integral is generally approximated in a discretized form by
Z
X
(U ).ndS
(U )k .(nS)k
To complete the discretization, one needs to consider how to approximate the convective
and diffusive fluxes at the cell faces and, if necessary, the source terms at the cell centre.
To see how the method works in practice, consider the
steady U momentum equation in 2 dimensions and a
uniform rectangular grid.
The velocity U is stored at the nodes P , N , S , E , W ,
which are located at the centre of the control volumes,
and the cell faces are denoted by lower case n, s, e, w.
The finite-volume method starts by integrating the
momentum equation over the P control volume:
ZZ
(U 2 ) +
(U V )dxdy =
x
y
(7)
where the summation is taken over the edges of the control volume, (U )k is
evaluated at the centre of edge k, (S)k is the area of the edge and nk is the unit vector
normal to the edge.
ZZ
N
n
W
s
S
x
P
dxdy
x
ZZ
U
dxdy
+
x
y
y
V x
This leads to
Z
n Z
e
Z
Z
e
n Z Z
U
U
P
U 2 dy
U V dx
+
=
+
dy
dx
dxdy
x
y
V x
w
s
w
s
- p. 5
The above approximation of the surface integral can be shown to be of second order
accuracy, since for some function f a Taylor series expansion gives:
Z
f (s) ds =
f () + (s )f () +
(s )2
f () +
2!
ds
(10)
(11)
- p. 7
(8)
for any point lying somewhere on the line being integrated along.
The integration of terms on the right hand side of equation (8) can then be carried out, using
a suitable change of variable, to give
Z
Z
Z
f (s) ds = f ()
ds + f () (s ) ds +
As indicated above when outlining the general finite volume scheme, the source terms can
be approximated by evaluating them at the cell centre and multiplying by the volume of the
cell:
ZZ
P
P
dxdy
xy
(12)
x P
V x
In the example considered, the pressure gradient at the cell centre, (P/x)P , is evaluated
by interpolating pressure values from surrounding nodes, if necessary. This will be
addressed in more detail in later lectures.
= f ()s + O((s)2 )
Other source terms can be evaluated similarly, interpolating where necessary to estimate
cell centre values.
In fact, when is taken as the mid-point of the face then the above approximation has
leading order term of O((s)3 ).
The source terms in the volume integral of equation (6) are generally approximated as
Z
S dV S V ol (S )P V ol
(9)
where S is the average value of S over the control volume and (S )P is simply its value
at the cell centre node P .
This approximation can also be shown to be generally of second order accuracy.
- p. 6
- p. 8
Z
e
n
e
n
U
U
U
U
+
+
dy
dx
y
x
x
y
x
y
w
s
w
s
A very simple scheme for approximating cell face values for the convective terms is the
first-order upwind convection scheme:
(13)
Ue =
The gradients U/x and U/y at the east, west, north and south faces can be evaluated
using a central difference, so that the diffusion terms become
(y)e
UE UP
UP UW
UN UP
UP US
(y)w
+ (x)n
(x)s
x
x
y
y
(14)
UP
UE
(17)
(18)
(15)
ace = max(Cxe , 0)
acw = max(Cxw , 0)
acn = max(Cyn , 0)
acs = max(Cys , 0)
(19)
and acp = ace + acw + acn + acs + (Cxe Cxw + Cyn Cys )
where
ade
adn
= (y/x)e
adw
= (y/x)w
= (x/y)n
ads
= (x/y)s
(16)
Note that the coefficients ace , etc are all positive, as is acp . Moreover, the final set of terms in
acp represents the total net mass flux into the cell, which should be zero, so that in practice
acp can simply be taken as the sum ace + acw + acn + acs .
- p. 9
- p. 11
Combining the convection and diffusion terms results in a discretized equation of the form
ap UP = ae UE + aw UW + an UN + as US + su
e
U 2 dy
U V dx
+
U 2 y w + [U V x]n
s
w
(20)
where ae = ade + ace , etc, ap = ae + aw + an + as , and su represents the source terms arising
from the pressure gradient.
We thus get a set of equations relating UP to the values of U at the surrounding nodes.
Having obtained the coefficients and source terms for each grid cell, the resulting system of
equations can be solved by a suitable numerical algorithm.
where Cxe , Cxw , etc are simply the mass fluxes through the east, west, north and south
faces.
The above upwind scheme is always bounded. However, as implied by its name, it is only
first order accurate.
To illustrate this, we assume that Cxe > 0. Then the scheme approximates
U
Cxe Ue Cxe UP = Cxe Ue + (xe xP )
+ O((xe xP )2 )
x e
(21)
U
(u )e
y
x e
where the numerical viscosity (u )e = Cxe x/(2y).
- p. 10
- p. 12
QUICK Scheme
The error is therefore diffusive in nature, and so tends to make the solution stable, but
inaccurate.
The QUICK (Quadratic Upwind Interpolation for Convection Kinetics) scheme fits a parabola
between three points to approximate Ue .
Recall that the order of accuracy gives information on how rapidly numerical errors decrease
as the grid is refined. Since the error in the above scheme decreases only linearly with grid
spacing, a very fine grid can be needed in order to achieve sufficient accuracy.
For this reason, whilst first order schemes are often used, it is usually preferable to employ a
higher order convection scheme.
EE
E P
1
(E 2P + W )
2
8
(26)
- p. 13
- p. 15
Note that the discretization stencil associated with the QUICK scheme is larger than that of
the first and second order schemes outlined earlier, since contributions from UEE , UW W ,
UN N and USS now appear.
(22)
This is a second order approximation, which can be seen by writing Taylor series expansions
for Ue and UE :
U
Ue = UP + (xe xP )
+ O(x2 )
(23)
x P
U
+ O(x2 )
UE = UP + (xE xP )
x P
U
= UP + 2(xe xP )
+ O(x2 )
(24)
x P
However, the QUICK (and other) schemes are often coded as deferred corrections. This
means that the upwind scheme contributions are included in the coefficients ae , aw , etc.
whilst the additional contributions from the QUICK (or other) scheme are simply placed in
the source term Su .
Higher order schemes can also be devised and employed. However, in order to benefit
significantly from them the simple formulations introduced earlier for approximating surface
and volume integrals (which are only second order accurate) should also be replaced by a
higher order method.
(25)
The central difference scheme is thus more accurate than the first order upwind scheme,
although it can produce oscillatory solutions.
- p. 14
- p. 16
V
U
+
=0
x
y
(27)
on the box 0 < x < 1, 0 < y < 1 with velocities U and V constant and prescribed as a step
function at y = 0 and /x = 0 at x = 0 and x = 1.
x
V = 1, U = 0.2
The exact solution is that the step function is simply convected with the velocity.
y
U =0
U >0
The graphs on the following slides show results with U = 0 and U 6= 0 using the three
convection schemes outlined earlier on grids ranging from 10 to 160 points in the x direction.
- p. 17
- p. 19
In the U = 0 case the flow is aligned with the grid lines and all the schemes perform
reasonably well (obviously resolving the step change better as the grid is refined).
The centred scheme captures the steep gradient better, but shows significant oscillations.
V = 1, U = 0
The QUICK scheme also represents the steep gradients quite well, but does show some
over- and under-shoots at the base and crest of the step.
- p. 18
- p. 20
E
xE
(28)
where the coefficients ae , aw , an and as contain the convective and diffusive contributions,
and ap = ae + aw + an + as .
The first type of boundary condition above can be simply implemented by setting the value
of UE to zero.
The zero gradient condition can be implemented by noting that this implies UE = UP (ie. a
one-sided difference approximation). This is typically achieved by setting ae = 0, since then
the contributions ae UP and ae UE are effectively removed from the left and right hand sides
of equation (28) respectively.
Fixed flux conditions (eg. a prescribed heat flux) can also be implemented by setting the ae
coefficient to zero and adding the desired flux to the source term su .
- p. 21
- p. 22