School of Mechanical Aerospace and Civil Engineering
Finite Volume Schemes
T. J. Craft George Begg Building, C41
Contents:
Introduction to CFD
Numerical solution of equations
Finite difference methods
Finite volume methods
Pressurevelocity 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
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+1) 



(i−1,j) 
_{(}_{i}_{,}_{j}_{)} 
(i+1,j) 

(i,j−1)
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.
FiniteVolume 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 nonorthogonal and even unstructured grids. Some examples of how this is done will be presented in later lectures.
The transport equation to be discretized is then integrated over each control volume.
 p. 3
If we considered a general (steady) transport equation for some quantity φ :
^{o}^{r}
∂ ( U _{j} φ ) ∂x _{j}
=
∂x _{j} „ ^{γ} ∂x
∂
∂φ
j « + S _{φ}
▽. ( U φ ) = ▽. ( γ ▽φ ) + S _{φ}
(1)
(2)
Integrating this over the control volume Ω gives:
^{o}^{r}
Z
Ω
∂ ( U _{j} φ ) ∂x _{j}
dV = Z Ω
∂x _{j} „ ^{γ} ∂x
∂
∂φ
j « dV + Z Ω S _{φ} dV
Z Ω ▽. ( U φ ) dV = Z Ω ▽. ( γ ▽φ ) dV + Z Ω S _{φ} dV
(3)
(4)
The convection and diffusion terms can be combined:
Z Ω ▽. ( U φ − γ ▽φ ) dV = Z Ω S _{φ} 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 Ω S _{φ} dV
(6)
 p. 2

p. 4

U 

γ 



φ 
into the control volume. 









Z 



Z 






φ.n dS is the convective ﬂux of φ across the small part of the boundary edge dS , and
▽φ.n dS 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
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 forcemomentum 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 satisﬁed 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 φ − γ ▽φ ) .n dS ≈ ^{X} ( U φ − γ ▽φ ) _{k} . ( n∆ S ) _{k}
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. 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:
f ( s ) ds = Z „ f ( ξ ) + ( s − ξ ) f ^{′} ( ξ ) + ^{(} ^{s} ^{−} ^{ξ} ^{)} ^{2} f ^{′}^{′} ( ξ ) + · · · « ds
2!
(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
f ( ξ ) Z ds + f ^{′} ( ξ ) Z ( s −
ξ ) ds + · · ·
f ( s ) ds =
= f ( ξ )∆ s + O ((∆ s ) ^{2} )
In fact, when ξ is taken as the midpoint 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
FiniteVolume Method on a 2D 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 ﬁnitevolume method starts by integrating the momentum equation over the P control volume:
w
W
e
∆y
Z Z V
_{∂}_{x} ( ρU ^{2} ) + _{∂}_{y} ( ρUV ) dxdy = − Z Z V
∂
∂
∂P
_{∂}_{x} dxdy
+ ZZ V
∂x „ ^{µ} ∂U
∂
∂x 
« + 
∂y „ ^{µ} ∂U ∂ ∂y 
« dxdy 
(10) 

∂P 

∂y 
s 
− Z Z V 
∂x 
dxdy 
(11) 
This leads to
»Z ρU ^{2} dy – w + »Z ρUV dx – n = » Z µ ^{∂}^{U} dy – w + »Z µ ^{∂}^{U} dx – n
e
s
∂x
e
 p. 7
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:
− _{Z}_{Z} V
∂P
∂x
dxdy ≈ „ ^{∂}^{P} ∂x
«
∆ x∆ y
P
(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. 8
Evaluating Diffusive Fluxes
The diffusive ﬂuxes can then be approximated by
^{»}^{Z} _{µ} ∂U ∂x
dy – w + »Z µ ^{∂}^{U} dx – n ≈ » µ ^{∂}^{U} ∆ y – w + » µ ^{∂}^{U} ∆ x – n
e
∂y
s
∂x
e
∂y
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}
This is, again, a second order approximation.
− ( µ ∆ x) _{s}
U _{P} − U _{S}
∆ y
(14)
The discretized diffusion terms in the transport equation can thus be written as
where
and a
d
p
a ^{d} U _{E} + a _{w} U _{W} + a _{n} U _{N} + a ^{d} U _{S} − a
e
d
d
s
d
p
U _{P}
(15)
a ^{d} = ( µ ∆ y/∆ x) _{e}
e
d
a _{n} = ( µ ∆ x/∆ y ) _{n}
= a ^{d} + a _{w} + a _{n} + a ^{d}
e
d
d
s .
a _{w} = ( µ ∆ y/∆ x) _{w}
a ^{d} = ( µ ∆ x/∆ y ) _{s}
d
s
(16)
 p. 9
Evaluating Convective Fluxes
The convection terms can be approximated as
»Z ρU ^{2} dy – w + » Z ρUV dx – n
e
s
e
≈ ^{ˆ} ρU ^{2} ∆ y ^{˜} _{w} + [ ρUV ∆ x] ^{n}
s
= ( ρU ∆ y ) _{e} U _{e} − ( ρU ∆ y ) _{w} U _{w} + ( ρV ∆ x) _{n} U _{n} − ( ρV ∆ x) _{s} U _{s}
= C xe U e − C xw U w + C yn U n − C ys U s
where C _{x}_{e} , C _{x}_{w} , etc are simply the mass ﬂuxes through the east, west, north and south faces.
The values of U at the cell faces, U _{e} , U _{w} , U _{n} and U _{s} 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 commonlyused alternatives are outlined below.
 p. 10
First Order Upwind Scheme
A very simple scheme for approximating cell face values for the convective terms is the ﬁrstorder upwind convection scheme:
U _{e} = (
U _{P}
U _{E}
for C _{x}_{e} > 0 for C _{x}_{e} ≤
0
(17)
P
e
E
This gives a convection contribution to the discretized transport equation of
where
and a
c
_{p} =
− a ^{c} _{e} U _{E} − a _{w} U _{W} − a _{n} U _{N} − a ^{c} U _{S} + a
c
c
s
c
_{p} U _{p}
a ^{c} _{e} = max( − C _{x}_{e} , 0)
a _{n} = max( − C _{y}_{n} , 0)
c
a _{w} = max( C _{x}_{w} , 0)
a ^{c} = max( C _{y}_{s} , 0)
c
s
a ^{c} _{e} + a _{w} + a _{n} + a ^{c} + ( C _{x}_{e} − C _{x}_{w} + C _{y}_{n} − C _{y}_{s} )
c
c
s
(18)
(19)
Note that the coefﬁcients a ^{c} _{e} , etc are all positive, as is a _{p} . Moreover, the ﬁnal set of terms in
c
a
a
c
_{p}
represents the total net mass ﬂux into the cell, which should be zero, so that in practice
_{p} can simply be taken as the sum a ^{c}
c
_{e} + a _{w} + a _{n} + a ^{c}
c
c
s .
 p. 11
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 a _{e} = a ^{d}
e
+ a ^{c}
_{e} , etc, a _{p} = a _{e} + a _{w} + a _{n} + a _{s} , and s _{u} 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 coefﬁcients 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 C _{x}_{e} > 0. Then the scheme approximates
C _{x}_{e} U _{e} ≈ C _{x}_{e} U _{P} = C _{x}_{e} „ U _{e} + ( x _{e} − x _{P} ) „ ^{∂}^{U} « e + O (( x _{e} − x _{P} ) ^{2} ) « ∂x
(21)
The leading error term in this can thus be written as
(Γ u ) e „ ^{∂}^{U} ∂x
«
e
∆
y
where the ‘numerical viscosity’ (Γ _{u} ) _{e} = C _{x}_{e} ∆ x/(2∆ y ) .
 p. 12
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 reﬁned. Since the error in the above scheme decreases only linearly with grid spacing, a very ﬁne grid can be needed in order to achieve sufﬁcient 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. 13
Central Difference Scheme
This scheme simply interpolates linearly between U _{P} and U _{E} to approximate U _{e} . For a uniform grid this gives
U _{e} = 0. 5( U _{E} + U _{P} )
(22)
This is a second order approximation, which can be seen by writing Taylor series expansions for _{U} _{e} and U _{E} :
U _{e} = U _{P} + ( x _{e} − x _{P} ) „ ^{∂}^{U} ∂x
«
U _{E} = U _{P} + ( x _{E} − x _{P} ) „ ^{∂}^{U} ∂x
«
P
P
+
+
O (∆ x ^{2} )
O (∆ x ^{2} )
= U _{P} + 2( x _{e} − x _{P} ) „ ^{∂}^{U} ∂x
«
P
+
O (∆ x ^{2} )
(23)
(24)
Subtracting 0. 5× equation (24) from equation (23) then gives
U _{e} = 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. 14
QUICK Scheme
The QUICK (Quadratic Upwind Interpolation for Convection Kinetics) scheme ﬁts a parabola between three points to approximate U _{e} .
If C _{x}_{e} > 0 a parabola is ﬁtted through the points W , P and E .
If C _{x}_{e} < 0 a parabola is ﬁtted through the
points P , E and EE .
W 

P 
e 
E 

EE 
For C _{x}_{e} > 0, on a regular grid we get
φ _{e} = φ _{P} + ^{φ} ^{E} ^{−} ^{φ} ^{P} − ^{1} _{8} ( φ _{E}
2
− 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. 15 

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 _{E}_{E} , U _{W}_{W} , U _{N}_{N} and U _{S}_{S} 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 coefﬁcients a _{e} , a _{w} , etc. whilst the additional contributions from the QUICK (or other) scheme are simply placed in the source term S _{u} . 

Higher order schemes can also be devised and employed. However, in order to beneﬁt signiﬁcantly 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. 16 
Convection Scheme Performances
 p. 18
 p. 19
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 reﬁned).
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 signiﬁcant oscillations.
The QUICK scheme also represents the steep gradients quite well, but does show some over and undershoots at the base and crest of the step.
 p. 20
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} .
^{x} E
The discretized form of the transport equation can be written as
a _{p} U _{P} = a _{e} U _{E} + a _{w} U _{W} + a _{n} U _{N} + a _{s} U _{S} + s _{u}
(28)
where the coefﬁcients _{a} _{e} , a _{w} , a _{n} and a _{s} contain the convective and diffusive contributions,
_{a}_{n}_{d}
a _{p} = a _{e} + a _{w} + a _{n} + a _{s} .
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 onesided difference approximation). This is typically achieved by setting a _{e} = 0, since then the contributions _{a} _{e} U _{P} and a _{e} U _{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 a _{e} coefﬁcient to zero and adding the desired ﬂux to the source term s _{u} .
 p. 21
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 nonlinear fashion, through the convection terms (and sometimes source terms).
An oftenused 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.
 p. 22
Molto più che documenti.
Scopri tutto ciò che Scribd ha da offrire, inclusi libri e audiolibri dei maggiori editori.
Annulla in qualsiasi momento.