Vous êtes sur la page 1sur 6

School of Mechanical Aerospace and Civil Engineering

Introduction
TPFE MSc CFD-1
◮ In earlier lectures we saw how finite difference methods could
approximate a differential equation by a set of discretized algebraic ones.
◮ Employing Taylor series analysis allowed us to determine truncation
errors, and to develop schemes with different orders of accuracy.
Basic Finite Volume Methods
◮ Such methods are relatively easy to apply (i,j+1)
T. J. Craft when the flow geometry allows a simple
George Begg Building, C41 Cartesian set of grid points to be adopted.
(i−1,j) (i,j) (i+1,j)
◮ However, in complex geometries more
work is needed. (i,j−1)
Reading:
J. Ferziger, M. Peric, Computational Methods for Fluid ◮ In such cases it may not be possible to arrange orthogonal grid lines as
Dynamics shown, meaning we could not approximate ∂ φ /∂ x purely in terms of
H.K. Versteeg, W. Malalasekara, An Introduction to values along a constant j line.
Computational Fluid Dynamics: The Finite Volume
Method ◮ Another drawback of finite difference schemes in engineering fluids
S.V. Patankar, Numerical Heat Transfer and Fluid Flow
Notes: http://cfd.mace.manchester.ac.uk/tmcfd problems is that care is needed to ensure conservation properties.
- People - T. Craft - Online Teaching Material
Basic Finite Volume Methods 2010/11 2 / 23

The Basic Finite Volume Method ◮ We consider a general (steady) transport equation for some quantity φ :

◮ One important feature of finite volume schemes is their conservation ∂ (Uj φ ) ∂ ∂φ


 
properties. Since they are based on applying conservation principles over = γ + Sφ (1) Ω
∂ xj ∂ xj ∂ xj
each small control volume, global conservation is also ensured. δΩ
or ▽.(U φ ) = ▽.(γ ▽φ ) + Sφ (2)
◮ 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
unstructured grids. ◮ Integrating this over the control volume Ω gives:

∂ (Uj φ ) ∂ ∂φ
 
The method starts by dividing the flow
Z Z Z

dV = γ dV + Sφ dV (3)
domain into a number of small control Ω ∂ xj Ω ∂ xj ∂ xj Ω
volumes. Z Z Z
or ∇.(U φ ) dV = ▽.(γ ∇φ ) dV + Sφ dV (4)
◮ The grid points where variables are Ω Ω Ω
stored are typically defined as being
at the centre of each control volume. ◮ The convection and diffusion terms can be combined:
Z Z
◮ Extra boundary nodes are often added, as shown in the figure. ∇.(U φ − γ ∇φ ) dV = Sφ dV (5)
Ω Ω
◮ The transport equation(s) are then integrated over each control volume.
Basic Finite Volume Methods 2010/11 3 / 23 Basic Finite Volume Methods 2010/11 4 / 23
◮ The divergence theorem can be used to convert the left hand side volume ◮ The surface integral is generally approximated in a discretized form by
integral to an integral around the boundary, ∂ Ω, of the control volume: Z n
(U φ − γ ▽φ ).ndS ≈ ∑(U φ − γ ▽φ )k .(n∆S)k (7)
∆S
Z Z
(U φ − γ ∇φ ).ndS = Sφ dV (6) ∂Ω k
∂Ω Ω
where (U φ − γ ▽φ )k is evaluated at the centre of Ω
◮ U φ .ndS is the convective flux of φ across the part of the boundary edge edge k of the cell, and (∆S)k and nk are the area δΩ
dS, and γ ∇φ .ndS is the diffusive flux across the same boundary part. and unit vector normal to this edge.

◮ The left hand side of equation (6) is thus simply the total net convective ◮ This approximation of the surface integral can be shown to be of second
and diffusive flux of φ into the control volume. order accuracy; for some function f a Taylor series expansion gives:
(s − ξ )2 ′′
Z Z  
◮ Equation (6) is thus a statement of conservation for the control volume. In f (s) ds = f (ξ ) + (s − ξ )f ′ (ξ ) + f (ξ ) + · · · ds (8)
2!
the case of the momentum equation, where φ = U for example, it is
simply the force-momentum principle applied over the control volume. 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
◮ Provided the same expressions are used for fluxes across faces in be carried out, using a suitable change of variable, to give
neighbouring cells, this approach ensures that the conservation Z Z Z
properties will also be satisfied globally over the flow domain. f (s) ds = f (ξ ) ds + f ′ (ξ ) (s − ξ ) ds + · · ·

= f (ξ )∆s + O((∆s)2 )
Basic Finite Volume Methods 2010/11 5 / 23 Basic Finite Volume Methods 2010/11 6 / 23

◮ In fact, when ξ is taken as the mid-point of the face then the above Finite-Volume Method on a 2-D Rectangular Grid
approximation has leading order term of O((∆s)3 ), and the approximation
is third order.
◮ To complete the discretization, one needs to consider how to approximate
the convective and diffusive fluxes at the cell faces and, if necessary, the
◮ The source terms in the volume integral of equation (6) are approximated
source terms at the cell centre.
as Z
N
Sφ dV ≈ Sφ Vol ≈ (Sφ )P Vol (9) ◮ To simplify the explanation for now, consider
Ω n
the steady U momentum equation in 2-D and
where Sφ is the “average” value of Sφ over the control volume and (Sφ )P a uniform rectangular grid. W P E
w e ∆y
is simply its value at the cell centre node P.
◮ The velocity U is stored at the nodes P, N, S, s
◮ This approximation can also be shown to be generally of second order E, W , located at control volume centres; cell
S
accuracy. faces are denoted by lower case n, s, e, w.
∆x

◮ The finite-volume method starts by integrating the momentum equation


over the P control volume:
∂ ∂ ∂P
ZZ ZZ
(ρ U 2 ) + (ρ UV )dxdy = − dxdy P e E EE
V ∂x ∂y V ∂x
∂ ∂U ∂ ∂U
ZZ    
+ µ + µ dxdy (10)
V ∂x ∂x ∂y ∂y
Basic Finite Volume Methods 2010/11 7 / 23 Basic Finite Volume Methods 2010/11 8 / 23
◮ This leads to Evaluating Diffusive Fluxes
∂U ∂U ∂P
Z e Z n Z e Z n ZZ
◮ The diffusive fluxes can then be approximated by
ρ U 2 dy + ρ UVdx = µ dy + µ dx − dxdy
w s ∂x w ∂y s V ∂x
Z
∂U
e Z
∂U
n 
∂U
e 
∂U
n
(11) µ dy + µ dx ≈ µ ∆y + µ ∆x (13)
∂x w ∂y s ∂x w ∂y s

Evaluating Source Terms ◮ The gradients ∂ U/∂ x and ∂ U/∂ y at the cell faces can be evaluated
using central differences, so that the diffusion terms become
◮ The source terms can be approximated by evaluating them at the cell
centre and multiplying by the volume of the cell: UE − UP U − UW U − UP U − US
(µ ∆y )e − (µ ∆y )w P + (µ ∆x )n N − (µ ∆x )s P
∆x ∆x ∆y ∆y
∂P ∂P
 
(14)
ZZ
− dxdy ≈ ∆x ∆y (12)
V ∂x ∂x P ◮ This is again a second order, centered, approximation.
◮ The discretized diffusion terms can thus be written as
◮ In the example considered, the pressure gradient at the cell centre,
(∂ P/∂ x )P , is evaluated by interpolating pressure values from surrounding ade UE + adw UW + adn UN + ads US − adp UP (15)
nodes, if necessary. This will be addressed in more detail in later lectures.
where
◮ Other source terms can be evaluated similarly, interpolating where ade = (µ ∆y /∆x )e adw = (µ ∆y /∆x )w adn = (µ ∆x /∆y )n ads = (µ ∆x /∆y )s
necessary to estimate cell centre values.
and adp = ade + adw + adn + ads .
Basic Finite Volume Methods 2010/11 9 / 23 Basic Finite Volume Methods 2010/11 10 / 23

Evaluating Convective Fluxes First Order Upwind Scheme

◮ The convection terms can be approximated as ◮ A very simple scheme for approximating cell face values for the
Z e Z n h ie h in convective terms is the first-order upwind convection scheme:
ρ U 2 dy + ρ UVdx ≈ ρ U 2 ∆y + ρ UV ∆x (
w s w s UP for Cxe > 0
Ue = (17) P e E
= (ρ U∆y )e Ue − (ρ U∆y )w Uw + (ρ V ∆x )n Un − (ρ V ∆x )s Us UE for Cxe ≤ 0

= Cxe Ue − Cxw Uw + Cyn Un − Cys Us (16)


◮ This gives a convection contribution to the discretized equation of
where Cxe , Cxw , etc are simply the mass fluxes through the east, west,
−ace UE − acw UW − acn UN − acs US + acp Up (18)
north and south faces.
where
◮ The values of U at the cell faces, Ue , Uw , Un and Us need to be obtained ace = max(−Cxe , 0) acw = max(Cxw , 0)
by interpolation between nodal values. acn = max(−Cyn , 0) acs = max(Cys , 0)
and acp = ace + acw + acn + acs + (Cxe − Cxw + Cyn − Cys )
◮ The scheme used to interpolate these values will affect both the stability
and accuracy of the overall solution, and a few commonly-used ◮ Note that the coefficients ace , etc are all positive, as is acp . The final set of
alternatives are outlined below. terms in acp is the net mass flux into the cell, which should be zero, so in
practice acp can simply be taken as the sum ace + acw + acn + acs .
Basic Finite Volume Methods 2010/11 11 / 23 Basic Finite Volume Methods 2010/11 12 / 23
◮ Combining the convection and diffusion terms results in a discretized ◮ The leading error term in this can thus be written as
equation of the form
∂U
 
ap UP = ae UE + aw UW + an UN + as US + su (19) (Γu )e ∆y
∂x e
where ae = ade + ace , etc, ap = ae + aw + an + as , and su represents the where the ‘numerical viscosity’ (Γu )e = Cxe ∆x /(2∆y ).
source terms arising from the pressure gradient.
◮ The error is therefore diffusive in nature, and so tends to make the
◮ We thus get a set of equations relating UP to the values of U at
solution stable, but inaccurate.
surrounding nodes.

◮ Having obtained the coefficients and source terms for each grid cell, the
◮ The order of accuracy gives information on how rapidly numerical errors
resulting system of equations can be solved by a suitable numerical decrease as the grid is refined. Since the error in the above scheme
algorithm. decreases only linearly with grid spacing, a very fine grid can be needed
in order to achieve sufficient accuracy.
◮ The above upwind scheme is always bounded. However, as implied by its
name, it is only first order accurate. ◮ For this reason, whilst first order schemes are often used, it is usually
preferable to employ a higher order scheme.
◮ To illustrate this, we assume that Cxe > 0. Then the scheme approximates
◮ Note, however, that in practical applications it is a fairly common practice
∂U
   
Cxe Ue ≈ Cxe UP = Cxe Ue + (xP − xe ) + O((xP − xe )2 ) (20) to begin a calculation with a first order scheme, for its stability, and then
∂x e switch to a higher order one once the solution is closer to convergence.
Basic Finite Volume Methods 2010/11 13 / 23 Basic Finite Volume Methods 2010/11 14 / 23

Central Difference Scheme QUICK Scheme

◮ This scheme simply interpolates linearly between UP and UE to ◮ The QUICK (Quadratic Upwind Interpolation for Convection Kinetics)
approximate Ue . For a uniform grid this gives scheme fits a parabola between three points to approximate Ue .
Ue = 0.5(UE + UP ) (21) ◮ If Cxe > 0 a parabola is fitted
◮ This is a second order approximation, which can be seen by writing through the points W , P and E.
W P e E EE
Taylor series expansions for UP and UE around Ue : ◮ If Cxe < 0 a parabola is fitted
∂U ∂U
   
through the points P, E and EE.
UP = Ue + (xP − xe ) + O(∆x 2 ) = Ue − 0.5∆x + O(∆x 2)
∂x e ∂x e
(22) ◮ For Cxe > 0, on a regular grid we get
∂U ∂U φE − φP 1
   
UE = Ue + (xE − xe ) + O(∆x 2) = Ue + 0.5∆x + O(∆x 2) φe = φP + − (φE − 2φP + φW ) (25)
∂x e ∂x e 2 8
W
(23) ◮ The QUICK scheme can be shown to be third
P E
◮ Adding equations (23) and (22) then leads to order accurate.
Ue = 0.5(UE + UP ) + O(∆x 2) (24) ◮ However, it is not bounded, and can produce
P E
◮ The central difference scheme is thus more accurate than the first order undershoots and overshoots in regions of
upwind scheme, although it can produce oscillatory solutions. steep gradients.
Basic Finite Volume Methods 2010/11 15 / 23 Basic Finite Volume Methods 2010/11 16 / 23
◮ Note that the discretization stencil associated with the QUICK scheme is Convection Scheme Performances
larger than that of the first and second order schemes outlined earlier,
since contributions from UEE , UWW , UNN and USS now appear. ◮ As an example, we consider the pure convection problem:
◮ QUICK (and other) schemes are often coded as “deferred corrections”. ∂ Uφ ∂ V φ
+ =0 (26)
This means that the upwind scheme contributions are included in the ∂x ∂y
coefficients ae , aw , etc. whilst the additional contributions from the
on the box 0 < x < 1 and 0 < y < 2 with velocities U and V constant and φ
QUICK (or other) scheme are simply placed in the source term Su .
prescribed as a step function at y = 0 and ∂ φ /∂ x = 0 at x = 0 and x = 1.
◮ This maintains the five point stencil of points treated implicitly, and the
positivity of the coefficient matrix.
◮ The exact solution is
◮ Higher order schemes can also be devised and employed. However, in the step function
order to benefit significantly from them the simple formulations introduced simply convected
earlier for approximating surface and volume integrals (which are only with the velocity.
second order accurate) should also be replaced by a higher order
method.
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.
Basic Finite Volume Methods 2010/11 17 / 23 Basic Finite Volume Methods 2010/11 18 / 23

V = 1, U = 0 V = 1, U = 0.2

Basic Finite Volume Methods 2010/11 19 / 23 Basic Finite Volume Methods 2010/11 20 / 23
◮ In the U = 0 case the flow is aligned with the grid lines and all the Boundary Condition Treatments
schemes perform reasonably well (obviously resolving the step change
better as the grid is refined).
◮ For illustration we consider a cell at the east boundary of the flow domain.
◮ When U 6= 0 the flow is not aligned with the grid lines. ◮ Typical boundary conditions might be one of W E
P

◮ In this case the numerical diffusion introduced by the first order upwind φ = 0 at xE or ∂ φ /∂ x = 0 at xE
scheme is clearly present. ◮ The discretized form of the transport equation can be written as xE

ap φP = ae φE + aw φW + an φN + as φS + sφ (27)
◮ The centred scheme captures the steep gradient better, but shows
significant oscillations. where the coefficients ae , aw , an and as contain the convective and
diffusive contributions, and ap = ae + aw + an + as .
◮ The QUICK scheme also represents the steep gradients quite well, and ◮ The first type of boundary condition above can be simply implemented by
improves rapidly as the grid is refined. However, it does show some over- setting the value of φE to zero.
and under-shoots at the base and crest of the step.
◮ The zero gradient condition can be implemented by setting ae = 0; the
contributions ae φP and ae φE are then effectively removed from the left
and right hand sides of equation (27) respectively.
◮ Fixed flux conditions (eg. prescribed heat flux) can also be implemented
by setting ae to zero and adding the desired flux to the source term sφ .
Basic Finite Volume Methods 2010/11 21 / 23 Basic Finite Volume Methods 2010/11 22 / 23

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 field.

◮ Repeat until the solution has converged.

◮ At this stage it is not clear how the pressure field is updated, since we do
not have a transport equation for the pressure. This issue is addressed in
the following section.
Basic Finite Volume Methods 2010/11 23 / 23

Vous aimerez peut-être aussi