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 Tcold
◮ Review of basic FV method
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 discretization methods.
- People - T. Craft - Online Teaching Material
Review of Basic Finite Volume Methods 2008/9 2 / 24

◮ In Modelling & Simulation III we covered The Basic Finite Volume Method
◮ Basic FV discretization of a single transport equation on rectangular
grids. ◮ One important feature of finite volume schemes is their conservation
◮ Use of Taylor series expansions to examine order of accuracy of properties. Since they are based on applying conservation principles over
each small control volume, global conservation is also ensured.
schemes.
◮ The importance of convection terms, and some different schemes for ◮ Although initially we consider how they are applied on rectangular
these (1st order upwind, higher order schemes: QUICK, etc) Cartesian grids they can, fairly readily, be adapted to non-orthogonal and
◮ The general trade-off between accuracy and stability. even unstructured grids. Some examples of how this is done will be
presented in later lectures.
◮ In Advanced Modelling & Simulation we will cover ◮ The method starts by dividing the flow
◮ Revision of the basic FV schemes. domain into a number of small control
◮ Pressure-velocity coupling. volumes.
◮ Extension of FV to non-orthogonal, body-fitted, grids. ◮ The grid points where variables are
◮ Time-dependent problems. stored are typically defined as being
◮ Modelling considerations for turbulent flows. at the centre of each control volume.

◮ Extra boundary nodes are often added, as shown in the figure.


◮ CFD element of the course consists of 12 hours of lectures/examples and
one laboratory session. ◮ The transport equation(s) are then integrated over each control volume.
Review of Basic Finite Volume Methods 2008/9 3 / 24 Review of Basic Finite Volume Methods 2008/9 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φ Ω
∂ xj ∂ xj ∂ xj
(1) (U φ − γ ∇φ ).ndS = Sφ dV (6)
∂Ω Ω
δΩ
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 Ω
Z Z Z ◮ Equation (6) is thus a statement of conservation for the control volume. In
or ∇.(U φ ) dV = ▽.(γ ∇φ ) dV + Sφ dV (4) the case of the momentum equation, where φ = U for example, it is
Ω Ω Ω
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
neighbouring cells, this approach ensures that the conservation
Z Z
∇.(U φ − γ ∇φ ) dV = Sφ dV (5)
Ω Ω properties will also be satisfied globally over the flow domain.

Review of Basic Finite Volume Methods 2008/9 5 / 24 Review of Basic Finite Volume Methods 2008/9 6 / 24

◮ The surface integral is generally approximated in a discretized form by


Z n
(U φ − γ ▽φ ).ndS ≈ ∑(U φ − γ ▽φ )k .(n∆S)k (7)
∂Ω k ∆S
◮ In fact, when ξ is taken as the mid-point of the face then the above
where (U φ − γ ▽φ )k is evaluated at the centre of Ω approximation has leading order term of O((∆s)3 ).
edge segment k , and (∆S)k and nk are the area δΩ
and unit vector normal to this edge. ◮ The source terms in the volume integral of equation (6) are approximated
as Z
◮ This approximation of the surface integral can be shown to be of second Sφ dV ≈ Sφ Vol ≈ (Sφ )P Vol (9)
order accuracy; for some function f a Taylor series expansion gives: Ω

Z Z 
(s − ξ )2 ′′
 where Sφ is the “average” value of Sφ over the control volume and (Sφ )P
f (s) ds = f (ξ ) + (s − ξ )f ′ (ξ ) + f (ξ ) + · · · ds (8) is simply its value at the cell centre node P.
2!
for any point ξ lying somewhere on the line being integrated along. ◮ This approximation can also be shown to be generally of second order
accuracy.
◮ 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 2008/9 7 / 24 Review of Basic Finite Volume Methods 2008/9 8 / 24
Finite-Volume Method on a 2-D Rectangular Grid ◮ This leads to
e Z n Z
∂U
e Z
∂U
n ZZ
∂P
Z
To complete the discretization, one needs to consider how to approximate ρ U 2 dy + ρ UVdx = µ dy + µ dx − dxdy
∂x ∂y V ∂x

w s w s
the convective and diffusive fluxes at the cell faces and, if necessary, the (11)
source terms at the cell centre.
N
◮ To see how the method works in practice, Evaluating Source Terms
n
consider the steady U momentum equation in ◮ As indicated above when outlining the general finite volume scheme, the
2-D and a uniform rectangular grid. W P E
w e ∆y source terms can be approximated by evaluating them at the cell centre
◮ The velocity U is stored at the nodes P, N, S, and multiplying by the volume of the cell:
s
E, W , located at control volume centres; cell ZZ
∂P

∂P

∆x ∆y
S
faces are denoted by lower case n, s, e, w. − dxdy ≈ (12)
∆x
V ∂x ∂x P
◮ The finite-volume method starts by integrating the momentum equation
over the P control volume: ◮ In the example considered, the pressure gradient at the cell centre,
(∂ P/∂ x )P , is evaluated by interpolating pressure values from surrounding
∂ ∂ ∂P
ZZ ZZ
(ρ U 2 ) + (ρ UV )dxdy = − dxdy P e E EE nodes, if necessary. This will be addressed in more detail in later lectures.
V ∂x ∂y V ∂x
∂ ∂U ∂ ∂U
ZZ    
+ µ + µ dxdy (10)
◮ Other source terms can be evaluated similarly, interpolating where
V ∂x ∂x ∂y ∂y necessary to estimate cell centre values.
Review of Basic Finite Volume Methods 2008/9 9 / 24 Review of Basic Finite Volume Methods 2008/9 10 / 24

Evaluating Diffusive Fluxes


P E Evaluating Convective Fluxes
◮ The diffusive fluxes can then be approximated by
Z
∂U
e Z
∂U
n 
∂U
e 
∂U
n ◮ The convection terms can be approximated as
µ dy + µ dx ≈ µ ∆y + µ ∆x (13)
∂x w ∂y s ∂x w ∂y s
Z e Z n h ie h in
ρ U 2 dy + ρ UVdx ≈ ρ U 2 ∆y + ρ UV ∆x
w s
◮ The gradients ∂ U/∂ x and ∂ U/∂ y at the cell faces can be evaluated w s

using central differences, so that the diffusion terms become = (ρ U∆y )e Ue − (ρ U∆y )w Uw + (ρ V ∆x )n Un − (ρ V ∆x )s Us
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
(14) where Cxe , Cxw , etc are simply the mass fluxes through the east, west,
north and south faces.
◮ This is again a second order, centered, approximation.

◮ The discretized diffusion terms can thus be written as ◮ The values of U at the cell faces, Ue , Uw , Un and Us need to be obtained
by interpolation between nodal values.
ade UE + adw UW + adn UN + ads US − adp UP (15)
where ◮ The scheme used to interpolate these values will affect both the stability
ade = (µ ∆y /∆x )e adw = (µ ∆y /∆x )w adn = (µ ∆x /∆y )n ads = (µ ∆x /∆y )s and accuracy of the overall solution, and a few commonly-used
alternatives are outlined below.
and adp = ade + adw + adn + ads .
Review of Basic Finite Volume Methods 2008/9 11 / 24 Review of Basic Finite Volume Methods 2008/9 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 2008/9 13 / 24 Review of Basic Finite Volume Methods 2008/9 14 / 24

◮ The leading error term in this can thus be written as Central Difference Scheme
∂U
 
(Γu )e ∆y ◮ This scheme simply interpolates linearly between UP and UE to
∂x e
approximate Ue . For a uniform grid this gives
where the ‘numerical viscosity’ (Γu )e = Cxe ∆x /(2∆y ). 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.5∆x + O(∆x 2)
decrease as the grid is refined. Since the error in the above scheme ∂x e ∂x e
decreases only linearly with grid spacing, a very fine grid can be needed (22)
in order to achieve sufficient accuracy. ∂U ∂U
   
UE = Ue + (xE − xe ) + O(∆x 2) = Ue + 0.5∆x + 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 convection scheme to obtain
sufficient numerical accuracy. ◮ Adding equations (23) and (22) then leads to
Ue = 0.5(UE + UP ) + O(∆x 2) (24)
◮ Note, however, that in practical applications it is a fairly common practice
to 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 2008/9 15 / 24 Review of Basic Finite Volume Methods 2008/9 16 / 24
QUICK Scheme
◮ The QUICK (Quadratic Upwind Interpolation for Convection Kinetics) ◮ Note that the discretization stencil associated with the QUICK scheme is
scheme fits a parabola between three points to approximate Ue . larger than that of the first and second order schemes outlined earlier,
since contributions from UEE , UWW , UNN and USS now appear.
◮ If Cxe > 0 a parabola is fitted
through the points W , P and E.
W P e E EE ◮ However, the QUICK (and other) schemes are often coded as “deferred
◮ If Cxe < 0 a parabola is fitted corrections”. This means that the upwind scheme contributions are
through the points P, E and EE. included in the coefficients ae , aw , etc. whilst the additional contributions
from the QUICK (or other) scheme are simply placed in the source term
◮ For Cxe > 0, on a regular grid we get Su .
φE − φP 1
φe = φP + − (φE − 2φP + φW ) (25) ◮ Higher order schemes can also be devised and employed. However, in
2 8
W order to benefit significantly from them the simple formulations introduced
◮ The QUICK scheme can be shown to be third earlier for approximating surface and volume integrals (which are only
P E
order accurate. second order accurate) should also be replaced by a higher order
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 2008/9 17 / 24 Review of Basic Finite Volume Methods 2008/9 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 the resulting 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 (with corresponding grid spacings in the y direction).
Review of Basic Finite Volume Methods 2008/9 19 / 24 Review of Basic Finite Volume Methods 2008/9 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.

V = 1, U = 0.2 ◮ In this case the numerical diffusion introduced by the first order upwind
scheme is clearly present.

◮ 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 2008/9 21 / 24 Review of Basic Finite Volume Methods 2008/9 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
◮ φ = 0 at x
◮ Other transport equations (for temperature, mass fraction, etc.) can be
E
◮ ∂ φ /∂ x = 0 at x .
treated similarly.
E
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 updating of the pressure field is
◮ Fixed flux conditions (eg. prescribed heat flux) can also be implemented achieved, since we do not have a transport equation for the pressure.
by setting ae to zero and adding the desired flux to the source term sφ . This issue will be addressed in the next section.
Review of Basic Finite Volume Methods 2008/9 23 / 24 Review of Basic Finite Volume Methods 2008/9 24 / 24

You might also like