You are on page 1of 6

School of Mechanical Aerospace and Civil Engineering Overview of CFD in Advanced Modelling & Simulation

Advanced Modelling & Simulation: CFD


Material builds on that covered in Modelling & Simulation III.
Our general aim in CFD is to be able to simulate a wide range of flows:
Boundary layers,
U(y)
impingement,
Review of Basic Finite Volume Methods separation/reattachment,
streamline curvature, . . . Q

T. J. Craft
George Begg Building, C41 Complex flow geometries;
often turbulent flow

Contents:
Reading: Heat/mass transfer
J. Ferziger, M. Peric, Computational Methods for Fluid Thot
Review of basic FV method Tcold
Dynamics
Pressure-velocity coupling H.K. Versteeg, W. Malalasekara, An Introduction to Buoyancy, system rotation,
Body-fitted coordinate systems Computational Fluid Dynamics: The Finite Volume etc. . .
Unsteady problems Method
S.V. Patankar, Numerical Heat Transfer and Fluid Flow Most general purpose CFD codes employ Finite Volume (FV)
Turbulence and other physical
Notes: http://cfd.mace.manchester.ac.uk/tmcfd
modelling - People - T. Craft - Online Teaching Material
discretization methods.
Review of Basic Finite Volume Methods 2010/11 2 / 24

Modelling & Simulation III covered The Basic Finite Volume Method
Basic FV discretization on rectangular grids.
Examining the order of accuracy of numerical schemes. One important feature of finite volume schemes is their conservation
The importance of convection terms, and some different schemes for properties. Since they are based on applying conservation principles over
these (1st order upwind, higher order schemes: QUICK, etc) each small control volume, global conservation is also ensured.
The general trade-off between accuracy and stability. Initially we consider how they are applied on rectangular Cartesian grids.
In later lectures we see how to adapt them to non-orthogonal and even
In Advanced Modelling & Simulation we will cover
unstructured grids.
Revision of the basic FV schemes.
Pressure-velocity coupling on staggered and collocated grids. The method starts by dividing the flow
Extension of FV to non-orthogonal, body-fitted, grids. domain into a number of small control
Time-dependent problems. volumes.
Modelling considerations for turbulent flows. The grid points where variables are
stored are typically defined as being
CFD element of the course consists of 12 hours of lectures/examples and
at the centre of each control volume.
one laboratory session.
Rather than teach how to use a particular CFD code, the course aims to Extra boundary nodes are often added, as shown in the figure.
give an understanding of the approximations and numerical treatments
found in most general CFD codes. The transport equation(s) are then integrated over each control volume.
Review of Basic Finite Volume Methods 2010/11 3 / 24 Review of Basic Finite Volume Methods 2010/11 4 / 24
We consider a general (steady) transport equation for some quantity : The divergence theorem can be used to convert the left hand side volume
integral to an integral around the boundary, , of the control volume:
(Uj )
  Z Z
= + S (1) (U ).ndS = S dV (6)
xj xj xj

or .(U ) = .( ) + S (2) U .ndS is the convective flux of across the part of the boundary edge
dS, and .ndS is the diffusive flux across the same boundary part.
Integrating this over the control volume gives:
The left hand side of equation (6) is thus simply the total net convective
(Uj ) and diffusive flux of into the control volume.
Z Z   Z
dV = dV + S dV (3)
xj xj xj
Equation (6) is thus a statement of conservation for the control volume. In
the case of the momentum equation, where = U for example, it is
Z Z Z
or .(U ) dV = .( ) dV + S dV (4)
simply the force-momentum principle applied over the control volume.

The convection and diffusion terms can be combined: Provided the same expressions are used for fluxes across faces in
Z Z neighbouring cells, this approach ensures that the conservation
.(U ) dV = S dV (5) properties will also be satisfied globally over the flow domain.

Review of Basic Finite Volume Methods 2010/11 5 / 24 Review of Basic Finite Volume Methods 2010/11 6 / 24

The surface integral is approximated in a discretized form by In fact, when is taken as the mid-point of the face then the above
approximation has leading order term of O((s)3 ), and the approximation
Z n
(U ).ndS (U )k .(nS)k (7) is third order.
k S
The source terms in the volume integral of equation (6) are approximated
where (U )k is evaluated at the centre of
as

Z
edge k of the cell, and (S)k and nk are the area S dV S Vol (S )P Vol (9)
and unit vector normal to this edge.

where S is the average value of S over the control volume and (S )P


This approximation of the surface integral can be shown to be of second
is simply its value at the cell centre node P.
order accuracy; for some function f a Taylor series expansion gives:
(s )2
Z Z  
f (s) ds = f ( ) + (s )f ( ) + f ( ) + ds (8)
This approximation can also be shown to be generally of second order
2! accuracy.
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 +

= f ( )s + O((s) ) 2

Review of Basic Finite Volume Methods 2010/11 7 / 24 Review of Basic Finite Volume Methods 2010/11 8 / 24
Finite-Volume Method on a 2-D Rectangular Grid This leads to
U U P
Z e Z n Z e Z n ZZ
U 2 dy + UVdx = dy + dx dxdy
To complete the discretization, one needs to consider how to approximate
w s x w y s V x
the convective and diffusive fluxes at the cell faces and, if necessary, the (11)
source terms at the cell centre.
N Evaluating Source Terms
To simplify the explanation for now, consider
n
the steady U momentum equation in 2-D and The source terms can be approximated by evaluating them at the cell
a uniform rectangular grid. W w
P
e E
centre and multiplying by the volume of the cell:
y

The velocity U is stored at the nodes P, N, S, s


ZZ
P

P

E, W , located at control volume centres; cell dxdy x y (12)
S V x x P
faces are denoted by lower case n, s, e, w.
x

The finite-volume method starts by integrating the momentum equation In the example considered, the pressure gradient at the cell centre,
over the P control volume: ( P/ x )P , is evaluated by interpolating pressure values from surrounding
ZZ
P
ZZ nodes, if necessary. This will be addressed in more detail in later lectures.
( U 2 ) + ( UV )dxdy = dxdy P e E EE
V x y V x Other source terms can be evaluated similarly, interpolating where
U U
ZZ    
+ + dxdy (10) necessary to estimate cell centre values.
V x x y y
Review of Basic Finite Volume Methods 2010/11 9 / 24 Review of Basic Finite Volume Methods 2010/11 10 / 24

Evaluating Diffusive Fluxes Evaluating Convective Fluxes


P E
The diffusive flux integrals can be approximated by The convection terms can be approximated as
U U U U
Z e Z n  e  n
dy + dx y + x (13) Z e Z n h ie h in
x w y s x w y s U 2 dy + UVdx U 2 y + UV x
w s w s
The gradients U/ x and U/ y at the cell faces can be evaluated = ( Uy )e Ue ( Uy )w Uw + ( V x )n Un ( V x )s Us
using central differences, so that the diffusion terms become
UE UP U UW U UP U US = Cxe Ue Cxw Uw + Cyn Un Cys Us (16)
( y )e ( y )w P + ( x )n N ( x )s P
x x y y where Cxe , Cxw , Cyn and Cys are simply the mass fluxes through the east,
(14)
west, north and south faces.
This is again a second order, centered, approximation.
The values of U at the cell faces, Ue , Uw , Un and Us need to be obtained
The discretized diffusion terms can thus be written as
by interpolation between nodal values.
ade UE + adw UW + adn UN + ads US adp UP (15)
where The scheme used to interpolate these values affects both the stability
and accuracy of the overall solution, and a few commonly-used
ade = ( y /x )e adw = ( y /x )w adn = ( x /y )n ads = ( x /y )s alternatives are outlined below.
and adp = ade + adw + adn + ads .
Review of Basic Finite Volume Methods 2010/11 11 / 24 Review of Basic Finite Volume Methods 2010/11 12 / 24
First Order Upwind Scheme Combining the convection and diffusion terms results in a discretized
equation of the form
A very simple scheme for approximating cell face values for the ap UP = ae UE + aw UW + an UN + as US + su (19)
convective terms is the first-order upwind convection scheme:
( where ae = ade + ace , etc, ap = ae + aw + an + as , and su represents the
UP for Cxe > 0 P e source terms arising from the pressure gradient.
Ue = (17) E
UE for Cxe 0
We thus get a set of equations relating UP to the values of U at
surrounding nodes.
This gives a convection contribution to the discretized equation of
Having obtained the coefficients and source terms for each grid cell, the
ace UE acw UW acn UN acs US + acp Up (18) resulting system of equations can be solved by a suitable numerical
where algorithm.
ace = max(Cxe , 0) acw = max(Cxw , 0)
The above upwind scheme is always bounded. However, as implied by its
acn = max(Cyn , 0) acs = max(Cys , 0)
name, it is only first order accurate.
and acp = ace + acw + acn + acs + (Cxe Cxw + Cyn Cys )
To illustrate this, we assume that Cxe > 0. Then the scheme approximates
Note that the coefficients ace , etc are all positive, as is acp . The final set of
U
   
terms in acp is the net mass flux into the cell, which should be zero, so in Cxe Ue Cxe UP = Cxe Ue + (xP xe ) + O((xP xe )2 ) (20)
practice acp can simply be taken as the sum ace + acw + acn + acs . x e

Review of Basic Finite Volume Methods 2010/11 13 / 24 Review of Basic Finite Volume Methods 2010/11 14 / 24

The leading error term in this can thus be written as Central Difference Scheme
U U
   
Cxe (x /2) = (u )e y This scheme simply interpolates linearly between UP and UE to
x e x e
approximate Ue . For a uniform grid this gives
where the numerical viscosity (u )e = Cxe x /(2y ). Ue = 0.5(UE + UP ) (21)

The error is therefore diffusive in nature, and so tends to make the This is a second order approximation, which can be seen by writing
solution stable, but inaccurate. Taylor series expansions for UP and UE around Ue :
U U
   
The order of accuracy gives information on how rapidly numerical errors UP = Ue + (xP xe ) + O(x 2 ) = Ue 0.5x + O(x 2)

x e x e
decrease as the grid is refined. Since the error in the above scheme (22)
decreases only linearly with grid spacing, a very fine grid can be needed
U U
   
to obtain a grid independent solution. UE = Ue + (xE xe ) + O(x 2) = Ue + 0.5x + O(x 2)
x e x e
For this reason, whilst first order schemes are often used, it is usually (23)
preferable to employ a higher order scheme. Adding equations (23) and (22) then leads to
Note, however, that in practical applications it is common practice to Ue = 0.5(UE + UP ) + O(x 2) (24)
begin a calculation with a first order scheme, for its stability, and then The central difference scheme is thus more accurate than the first order
switch to a higher order one once the solution is closer to convergence. upwind scheme, although it can produce oscillatory solutions.
Review of Basic Finite Volume Methods 2010/11 15 / 24 Review of Basic Finite Volume Methods 2010/11 16 / 24
QUICK Scheme 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 , UWW , UNN and USS now appear.
The QUICK (Quadratic Upwind Interpolation for Convection Kinetics)
scheme fits a parabola between three points to approximate Ue .
QUICK (and other) schemes are often coded as deferred corrections.
If Cxe > 0 a parabola is fitted This means that the upwind scheme contributions are included in the
through the points W , P and E. coefficients ae , aw , etc. whilst the additional contributions from the
W P E EE
e QUICK (or other) scheme are simply placed in the source term Su .
If Cxe < 0 a parabola is fitted
through the points P, E and EE. This maintains the five point stencil of points treated implicitly, and the
positivity of the coefficient matrix.
For Cxe > 0, on a regular grid we get
E P 1 Higher order schemes can also be devised and employed. However, in
e = P + (E 2P + W ) (25) order to benefit significantly from them the simple formulations introduced
2 8
W earlier for approximating surface and volume integrals (which are only
The QUICK scheme can be shown to be third second order accurate) should also be replaced by a higher order
P E
order accurate. method.

However, it is not bounded, and can produce


P E
undershoots and overshoots in regions of
steep gradients.
Review of Basic Finite Volume Methods 2010/11 17 / 24 Review of Basic Finite Volume Methods 2010/11 18 / 24

Convection Scheme Performances

As an example, we consider the pure convection problem:


U V
+ =0 (26)
x y
on the box 0 < x < 1 and 0 < y < 2 with velocities U and V constant and
prescribed as a step function at y = 0 and / x = 0 at x = 0 and x = 1.
V = 1, U = 0

The exact solution is


the step function
simply convected
with the velocity.

U =0 U >0
The following slides show profiles of , close to the top boundary y = 2,
with U = 0 and U 6= 0, using the three convection schemes outlined
earlier on uniform grids ranging from 10 to 160 points in the x direction.
Review of Basic Finite Volume Methods 2010/11 19 / 24 Review of Basic Finite Volume Methods 2010/11 20 / 24
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).

When U 6= 0 the flow is not aligned with the grid lines.

In this case the numerical diffusion introduced by the first order upwind
scheme is clearly present.
V = 1, U = 0.2
The centred scheme captures the steep gradient better, but shows
significant oscillations.

The QUICK scheme also represents the steep gradients quite well, and
improves rapidly as the grid is refined. However, it does show some over-
and under-shoots at the base and crest of the step.

Review of Basic Finite Volume Methods 2010/11 21 / 24 Review of Basic Finite Volume Methods 2010/11 22 / 24

Boundary Condition Treatments Numerical Flow Solver Strategy

For illustration we consider a cell at the east boundary of the flow domain. Each momentum equation can be discretized as described, leading to a
set of algebraic equations relating the nodal values of U, V and W .
Typical boundary conditions might be one of W P E Other transport equations (for temperature, mass fraction, etc.) can be
= 0 at xE or / x = 0 at xE treated similarly.
xE However, the equations are coupled in a non-linear fashion, through the
The discretized form of the transport equation can be written as
convection terms (and sometimes source terms).
ap P = ae E + aw W + an N + as S + s (27) An often-used practice is to solve the equations in an iterative,
where the coefficients ae , aw , an and as contain the convective and segregated, manner:
diffusive contributions, and ap = ae + aw + an + as . Assemble the discretized equations for U, and hence update U.

The first type of boundary condition above can be simply implemented by Assemble the discretized equations for V , and hence update V .

setting the value of E to zero. Assemble the discretized equations for W , and hence update W .

The zero gradient condition can be implemented by setting ae = 0; the Update the pressure field.

contributions ae P and ae E are then effectively removed from the left Repeat until the solution has converged.
and right hand sides of equation (27) respectively.
At this stage it is not clear how the pressure field is updated, since we do
Fixed flux conditions (eg. prescribed heat flux) can also be implemented not have a transport equation for the pressure. This issue is addressed in
by setting ae to zero and adding the desired flux to the source term s . the following section.
Review of Basic Finite Volume Methods 2010/11 23 / 24 Review of Basic Finite Volume Methods 2010/11 24 / 24