Sie sind auf Seite 1von 6

School of Mechanical Aerospace and Civil Engineering

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-tted coordinate systems
Reading:
J. Ferziger, M. Peric, Computational Methods for Fluid
Dynamics
H.K. Versteeg, W. Malalasekara, An Introduction to Com-
putational 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
Finite Volume Schemes
T. J. Craft
George Begg Building, C41
- p. 2
Introduction
In earlier lectures we examined nite 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 ow geometry allows a
simple Cartesian set of grid points to be
adopted.
However, in complex geometries more work is
needed.
(i,j) (i1,j) (i+1,j)
(i,j+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.
Another drawback of nite difference schemes, particularly when applied to engineering
uids problems, is that care has to be taken in approximations in order to ensure
conservation properties.
- p. 3
Finite-Volume Methods
Most modern general purpose CFD codes use nite volume methods to obtain the
discretized set of equations.
One important feature of nite 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.
The method starts by dividing the ow domain
into a number of small control volumes.
The grid points at which variables are stored
are then typically dened as being at the
centre of each control volume.
Extra boundary nodes are often added, as
shown in the gure.
The transport equation to be discretized is then integrated over each control volume.
- p. 4
If we considered a general (steady) transport
equation for some quantity :
(U
j
)
x
j
=

x
j


x
j

+ S

(1)
or
.(U) = .() + S

(2)

Integrating this over the control volume gives:


Z

(U
j
)
x
j
dV =
Z

x
j


x
j

dV +
Z

dV (3)
or
Z

.(U) dV =
Z

.() dV +
Z

dV (4)
The convection and diffusion terms can be combined:
Z

.(U ) dV =
Z

dV (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

(U ).ndS =
Z

dV (6)
- p. 5
U.ndS is the convective ux of across the small part of the boundary edge dS, and
.ndS is the diffusive ux across the same boundary element.
The left hand side of equation (6) is thus simply the total net convective and diffusive ux 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 uxes across faces in neighbouring cells, this
approach thus ensures that the same conservation properties will also be satised globally
over the ow 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

(U ).ndS
X
k
(U )
k
.(nS)
k
(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 n
k
is the unit vector
normal to the edge.
- p. 6
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 =
Z
f() + (s )f

() +
(s )
2
2!
f

() +

ds (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
f(s) ds = f()
Z
ds + f

()
Z
(s ) ds +
= f()s + O((s)
2
)
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

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. 7
Finite-Volume Method on a 2-D Rectangular Grid
To complete the discretization, one needs to consider how to approximate the convective
and diffusive uxes 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 nite-volume method starts by integrating the
momentum equation over the P control volume:
P
E W
N
S
e
n
w
s
x
y
ZZ
V

x
(U
2
) +

y
(UV )dxdy =
ZZ
V
P
x
dxdy
+
ZZ
V

U
x

+

y

U
y

dxdy (10)
This leads to
Z
U
2
dy

e
w
+
Z
UV dx

n
s
=
Z

U
x
dy

e
w
+
Z

U
y
dx

n
s

ZZ
V
P
x
dxdy (11)
- p. 8
Evaluating Source Terms
As indicated above when outlining the general nite volume scheme, the source terms can
be approximated by evaluating them at the cell centre and multiplying by the volume of the
cell:

ZZ
V
P
x
dxdy

P
x

P
xy (12)
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.
Other source terms can be evaluated similarly, interpolating where necessary to estimate
cell centre values.
- p. 9
Evaluating Diffusive Fluxes
The diffusive uxes can then be approximated by
Z

U
x
dy

e
w
+
Z

U
y
dx

n
s

U
x
y

e
w
+

U
y
x

n
s
(13)
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
U
E
U
P
x
(y)
w
U
P
U
W
x
+ (x)
n
U
N
U
P
y
(x)
s
U
P
U
S
y
(14)
This is, again, a second order approximation.
The discretized diffusion terms in the transport equation can thus be written as
a
d
e
U
E
+ a
d
w
U
W
+ a
d
n
U
N
+ a
d
s
U
S
a
d
p
U
P
(15)
where
a
d
e
= (y/x)e a
d
w
= (y/x)w
a
d
n
= (x/y)n a
d
s
= (x/y)s (16)
and a
d
p
= a
d
e
+ a
d
w
+ a
d
n
+ a
d
s
.
- p. 10
Evaluating Convective Fluxes
The convection terms can be approximated as
Z
U
2
dy

e
w
+
Z
UV dx

n
s

U
2
y

e
w
+ [UV x]
n
s
= (Uy)eUe (Uy)wUw + (V x)nUn (V x)sUs
= CxeUe CxwUw + CynUn CysUs
where Cxe, Cxw, etc are simply the mass uxes through the east, west, north and south
faces.
The values of U at the cell faces, Ue, Uw, Un and Us need to be obtained by interpolation
between nodal values.
The scheme used to interpolate these values will affect both the stability and accuracy of the
overall solution, and a few commonly-used alternatives are outlined below.
- p. 11
First Order Upwind Scheme
A very simple scheme for approximating cell face values for the convective terms is the
rst-order upwind convection scheme:
Ue =
(
U
P
for C
xe
> 0
U
E
for C
xe
0
(17)
P E
e
This gives a convection contribution to the discretized transport equation of
a
c
e
U
E
a
c
w
U
W
a
c
n
U
N
a
c
s
U
S
+ a
c
p
Up (18)
where
a
c
e
= max(Cxe, 0) a
c
w
= max(Cxw, 0)
a
c
n
= max(Cyn, 0) a
c
s
= max(Cys, 0) (19)
and a
c
p
= a
c
e
+ a
c
w
+ a
c
n
+ a
c
s
+ (Cxe Cxw + Cyn Cys)
Note that the coefcients a
c
e
, etc are all positive, as is a
c
p
. Moreover, the nal set of terms in
a
c
p
represents the total net mass ux into the cell, which should be zero, so that in practice
a
c
p
can simply be taken as the sum a
c
e
+ a
c
w
+ a
c
n
+ a
c
s
.
- p. 12
Combining the convection and diffusion terms results in a discretized equation of the form
a
p
U
P
= a
e
U
E
+ a
w
U
W
+ a
n
U
N
+ a
s
U
S
+ s
u
(20)
where ae = a
d
e
+a
c
e
, 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 U
P
to the values of U at the surrounding nodes.
Having obtained the coefcients and source terms for each grid cell, the resulting system of
equations can be solved by a suitable numerical algorithm.
The above upwind scheme is always bounded. However, as implied by its name, it is only
rst order accurate.
To illustrate this, we assume that Cxe > 0. Then the scheme approximates
CxeUe CxeU
P
= Cxe

Ue + (xe x
P
)

U
x

e
+ O((xe x
P
)
2
)

(21)
The leading error term in this can thus be written as
(u)e

U
x

e
y
where the numerical viscosity (u)e = Cxex/(2y).
- p. 13
The error is therefore diffusive in nature, and so tends to make the solution stable, but
inaccurate.
Recall that the order of accuracy gives information on how rapidly numerical errors decrease
as the grid is rened. Since the error in the above scheme decreases only linearly with grid
spacing, a very ne grid can be needed in order to achieve sufcient accuracy.
For this reason, whilst rst order schemes are often used, it is usually preferable to employ a
higher order convection scheme.
Note, however, that in practical applications it is a fairly common practice to begin a
calculation with a rst order scheme, for its stability, and then switch to a higher order one
once the solution is closer to convergence.
- p. 14
Central Difference Scheme
This scheme simply interpolates linearly between U
P
and U
E
to approximate U
e
. For a
uniform grid this gives
Ue = 0.5(U
E
+ U
P
) (22)
This is a second order approximation, which can be seen by writing Taylor series expansions
for Ue and U
E
:
Ue = U
P
+ (xe x
P
)

U
x

P
+ O(x
2
) (23)
U
E
= U
P
+ (x
E
x
P
)

U
x

P
+ O(x
2
)
= U
P
+ 2(xe x
P
)

U
x

P
+ O(x
2
) (24)
Subtracting 0.5 equation (24) from equation (23) then gives
Ue = 0.5(U
E
+ U
P
) + O(x
2
) (25)
The central difference scheme is thus more accurate than the rst order upwind scheme,
although it can produce oscillatory solutions.
- p. 15
QUICK Scheme
The QUICK (Quadratic Upwind Interpolation for Convection Kinetics) scheme ts a parabola
between three points to approximate Ue.
If Cxe > 0 a parabola is tted through the
points W, P and E.
If Cxe < 0 a parabola is tted through the
points P, E and EE.
P E EE
e
W
For Cxe > 0, on a regular grid we get
e =
P
+

E

P
2

1
8
(
E
2
P
+
W
) (26)
The QUICK scheme can be shown to be third order
accurate.
However, it is not bounded, and can produce
undershoots and overshoots in regions of steep
gradients.
P
W
E
- p. 16
Note that the discretization stencil associated with the QUICK scheme is larger than that of
the rst and second order schemes outlined earlier, since contributions from U
EE
, U
WW
,
U
NN
and U
SS
now appear.
However, the QUICK (and other) schemes are often coded as deferred corrections. This
means that the upwind scheme contributions are included in the coefcients 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 benet
signicantly 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.
- p. 17
Convection Scheme Performances
As an example, we consider the pure convection problem:
U
x
+
V
y
= 0 (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.
The exact solution is that the step function is simply convected with the velocity.
y
x
U = 0
y
x
U > 0
The graphs on the following slides show results with U = 0 and U = 0 using the three
convection schemes outlined earlier on grids ranging from 10 to 160 points in the x direction.
- p. 18
y
x
V = 1, U = 0
- p. 19
y
x
V = 1, U = 0.2
- p. 20
In the U = 0 case the ow is aligned with the grid lines and all the schemes perform
reasonably well (obviously resolving the step change better as the grid is rened).
When U = 0 the ow is not aligned with the grid lines.
In this case the numerical diffusion introduced by the rst order upwind scheme is clearly
present.
The centred scheme captures the steep gradient better, but shows signicant oscillations.
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. 21
Boundary Condition Treatments
For illustration we consider a cell at the east
boundary of the ow domain.
Typical boundary conditions might be of the form
U = 0 at x
E
U/x = 0 at x
E
.
W P E
x
E
The discretized form of the transport equation can be written as
apU
P
= aeU
E
+ awU
W
+ anU
N
+ asU
S
+ su (28)
where the coefcients ae, aw, an and as contain the convective and diffusive contributions,
and ap = ae + aw + an + as.
The rst type of boundary condition above can be simply implemented by setting the value
of U
E
to zero.
The zero gradient condition can be implemented by noting that this implies U
E
= U
P
(ie. a
one-sided difference approximation). This is typically achieved by setting ae = 0, since then
the contributions aeU
P
and aeU
E
are effectively removed from the left and right hand sides
of equation (28) respectively.
Fixed ux conditions (eg. a prescribed heat ux) can also be implemented by setting the ae
coefcient to zero and adding the desired ux to the source term su.
- p. 22
Numerical Flow Solver Strategy
Each momentum equation can be discretized as described, leading to a set of algebraic
equations relating the nodal values of U, V and W.
Other transport equations (for temperature, mass fraction, etc.) can be treated similarly.
However, the equations are coupled in a non-linear fashion, through the convection terms
(and sometimes source terms).
An often-used practice is to solve the equations in an iterative, segregated, manner:
Assemble the discretized equations for U, and hence update U.
Assemble the discretized equations for V , and hence update V .
Assemble the discretized equations for W, and hence update W.
Update the pressure eld.
Repeat until the solution has converged.
At this stage it is not clear how the updating of the pressure eld is achieved, since we do not
have a transport equation for the pressure. This issue will be addressed in the next lecture.

Das könnte Ihnen auch gefallen