Sei sulla pagina 1di 6
School of Mechanical Aerospace and Civil Engineering Finite Volume Schemes T. J. Craft George Begg

School of Mechanical Aerospace and Civil Engineering

Finite Volume Schemes

T. J. Craft George Begg Building, C41

Contents:

Introduction to CFDSchemes T. J. Craft George Begg Building, C41 Contents: Numerical solution of equations Finite difference methods

Numerical solution of equationsGeorge Begg Building, C41 Contents: Introduction to CFD Finite difference methods Finite volume methods

Finite difference methodsIntroduction to CFD Numerical solution of equations Finite volume methods Pressure-velocity coupling Solving

Finite volume methodsNumerical solution of equations Finite difference methods Pressure-velocity coupling Solving sets of linear equations

Pressure-velocity couplingof equations Finite difference methods Finite volume methods Solving sets of linear equations Unsteady problems

Solving sets of linear equationsmethods Finite volume methods Pressure-velocity coupling Unsteady problems Turbulence and other physical modelling

Unsteady problemsPressure-velocity coupling Solving sets of linear equations Turbulence and other physical modelling Body-fitted

Turbulence and other physical modellingcoupling Solving sets of linear equations Unsteady problems Body-fitted coordinate systems Reading: J. Ferziger, M.

Body-fitted coordinate systemsUnsteady problems Turbulence and other physical modelling Reading: J. Ferziger, M. Peric, Computational Methods for

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

- People - T. Craft - Online Teaching Material Introduction In earlier lectures we examined finite
- People - T. Craft - Online Teaching Material Introduction In earlier lectures we examined finite

Introduction

In earlier lectures we examined finite difference methods, and saw how they could be used to approximate a differential equation by a set of discretized algebraic ones.- People - T. Craft - Online Teaching Material Introduction Employing Taylor series analysis allowed us

Employing Taylor series analysis allowed us to determine the truncation error of approximations, and to develop schemes with different orders of accuracy.equation by a set of discretized algebraic ones. Such methods can be applied quite successfully when

Such methods can be applied quite successfully when the flow geometry allows a simple Cartesian set of grid points to be adopted.and to develop schemes with different orders of accuracy. However, in complex geometries more work is

However, in complex geometries more work is needed.allows a simple Cartesian set of grid points to be adopted. (i,j+1) (i−1,j) ( i ,

(i,j+1) (i−1,j) ( i , j ) (i+1,j)
(i,j+1) (i−1,j) ( i , j ) (i+1,j)
(i,j+1) (i−1,j) ( i , j ) (i+1,j)
(i,j+1) (i−1,j) ( i , j ) (i+1,j)
(i,j+1) (i−1,j) ( i , j ) (i+1,j)
(i,j+1)
(i,j+1)

(i,j+1)

(i,j+1)
(i,j+1)
(i,j+1)
(i−1,j) ( i , j ) (i+1,j)

(i−1,j)

(i−1,j)

(i,j)

( i , j )

(i+1,j)

(i+1,j)
(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. ∂φ/∂x purely in terms of values along a constant j line.

Another drawback of finite difference schemes, particularly when applied to engineering fluids problems, is that care has to be taken in approximations in order to ensure conservation properties.purely in terms of values along a constant j line. Finite-Volume Methods Most modern general purpose

approximations in order to ensure conservation properties. Finite-Volume Methods Most modern general purpose CFD codes
approximations in order to ensure conservation properties. Finite-Volume Methods Most modern general purpose CFD codes

Finite-Volume Methods

Most modern general purpose CFD codes use finite volume methods to obtain the discretized set of equations.to ensure conservation properties. Finite-Volume Methods One important feature of finite volume schemes is their

One important feature of finite volume schemes is their conservation properties. Since they are based on applying conservation principles over each small control volume, global conservation is also ensured.volume methods to obtain the discretized set of equations. Although here we will consider in some

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.small control volume, global conservation is also ensured. The method starts by dividing the flow domain

The method starts by dividing the flow domain into a number of small control volumes.
The method starts by dividing the flow domain
into a number of small control volumes.
The grid points at which variables are stored
are then typically defined as being at the
centre of each control volume.
Extra boundary nodes are often added, as
shown in the figure.

The transport equation to be discretized is then integrated over each control volume.boundary nodes are often added, as shown in the figure. - p. 3 If we considered

be discretized is then integrated over each control volume. - p. 3 If we considered a

- p. 3

is then integrated over each control volume. - p. 3 If we considered a general (steady)

If we considered a general (steady) transport equation for some quantity φ : φ :

or

( U j φ ) ∂x j

=

∂x j γ ∂x

∂φ

j « + S φ

. ( U φ ) = . ( γ φ ) + S φ

(1)

(2)

Integrating this over the control volume Ω gives: gives:

Ω δΩ
δΩ

or

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:▽ . ( γ ▽ φ ) dV + Z Ω S φ dV (3) (4)

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: , of the control volume:

Z ( U φ γ φ ) .ndS = Z S φ dV

(6)

U γ   φ into the control volume.   Z   Z φ.n dS is
U

U

γ

U γ   φ into the control volume.   Z   Z
 

φ

into the control volume.

U γ   φ into the control volume.   Z   Z
U γ   φ into the control volume.   Z   Z
U γ   φ into the control volume.   Z   Z
U γ   φ into the control volume.   Z   Z
 

Z

U γ   φ into the control volume.   Z   Z
 

Z

U γ   φ into the control volume.   Z   Z
U γ   φ into the control volume.   Z   Z
U γ   φ into the control volume.   Z   Z

φ.n dS is the convective flux of φ across the small part of the boundary edge dS , and

φ.n dS is the diffusive flux across the same boundary element.

The left hand side of equation (6) is thus simply the total net convective and diffusive flux 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 force-momentum principle applied over the control volume.

Provided the same expressions are used for fluxes across faces in neighbouring cells, this approach thus ensures that the same conservation properties will also be satisfied globally over the flow 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 . ( nS ) 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.

the edge and n k is the unit vector normal to the edge. - p. 5

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

) P is simply its value at the cell centre node P . This approximation can

This approximation can also be shown to be generally of second order accuracy.

- p. 6

be shown to be generally of second order accuracy. - p. 6 Finite-Volume Method on a

Finite-Volume Method on a 2-D Rectangular Grid

To complete the discretization, one needs to consider how to approximate the convective and diffusive fluxes at the cell faces and, if necessary, the source terms at the cell centre.- p. 6 Finite-Volume Method on a 2-D Rectangular Grid To see how the method works

To see how the method works in practice, consider the steady U momentum equation in 2 dimensions and a uniform rectangular grid. U momentum equation in 2 dimensions and a uniform rectangular grid.

The velocity U is stored at the nodes P , N , S , E , W 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 finite-volume method starts by integrating the momentum equation over the P control volume: P control volume:

w

N n
N
n
the momentum equation over the P control volume: w N n W P e E ∆

W

P
P

e

E
E

y

s S
s
S
∆x
∆x

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∂P ∂y s − Z Z V ∂x dxdy (11) »Z ρU 2 dy – w

»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 finite volume scheme, the source terms can be approximated by evaluating them at the cell centre and multiplying by the volume of the cell:U dx – n e s ∂x e - p. 7 Evaluating Source Terms − Z

ZZ V

∂P

∂x

dxdy P ∂x

«

xy

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 ( ∂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.pressure values from surrounding nodes, if necessary. This will be addressed in more detail in later

Other source terms can be evaluated similarly, interpolating where necessary to estimate cell centre values. -

- p. 8

Evaluating Diffusive Fluxes

The diffusive fluxes can then be approximated byEvaluating Diffusive Fluxes » Z µ ∂U ∂x dy – w + »Z µ ∂ U

»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 ∂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.U W ∆ x + ( µ ∆ x ) n U N − U P

( µ x) s

U P U S

y

(14)

The discretized diffusion terms in the transport equation can thus be written as− ( µ ∆ x ) s U P − U S ∆ y (14) where

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)

∆ x ) w a d = ( µ ∆ x/ ∆ y ) s d

- p. 9

Evaluating Convective Fluxes

The convection terms can be approximated asx/ ∆ y ) s d s (16) - p. 9 Evaluating Convective Fluxes »Z ρU

»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 xe , C xw , etc are simply the mass fluxes through the east, west, north and south faces.

The values of U at the cell faces, U e , U w , U n and U 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 commonly-used alternatives are outlined below.need to be obtained by interpolation between nodal values. - p. 10 First Order Upwind Scheme

and a few commonly-used alternatives are outlined below. - p. 10 First Order Upwind Scheme A

- p. 10

a few commonly-used alternatives are outlined below. - p. 10 First Order Upwind Scheme A very

First Order Upwind Scheme

A very simple scheme for approximating cell face values for the convective terms is the first-order upwind convection scheme:are outlined below. - p. 10 First Order Upwind Scheme U e = ( U P

U e = (

U P

U E

for C xe > 0 for C xe

0

(17)

P

U E for C x e > 0 for C x e ≤ 0 (17) P

e

E

E for C x e > 0 for C x e ≤ 0 (17) P e

This gives a convection contribution to the discretized transport equation ofE for C x e > 0 for C x e ≤ 0 (17) P e

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 xe , 0)

a n = max( C yn , 0)

c

a w = max( C xw , 0)

a c = max( C ys , 0)

c

s

a c e + a w + a n + a c + ( C xe C xw + C yn C ys )

c

c

s

(18)

(19)

Note that the coefficients a c e , etc are all positive, as is a p . Moreover, the a c e , etc are all positive, as is a p . Moreover, the final set of terms in

c

a

a

c

p

represents the total net mass flux 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 .

the sum a c c e + a w + a n + a c c

- p. 11

a c c e + a w + a n + a c c c s

Combining the convection and diffusion terms results in a discretized equation of the forma c c e + a w + a n + a c c c s

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. U P to the values of U at the surrounding nodes.

Having obtained the coefficients and source terms for each grid cell, the resulting system of equations can be solved by a suitable numerical algorithm.U P to the values of U at the surrounding nodes. The above upwind scheme is

The above upwind scheme is always bounded. However, as implied by its name, it is only first order accurate.equations can be solved by a suitable numerical algorithm. To illustrate this, we assume that C

To illustrate this, we assume that C x e > 0 . Then the scheme approximates C xe > 0. Then the scheme approximates

C xe U e C xe U P = C xe 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 ase + O (( x e − x P ) 2 ) « ∂x (21) (Γ

u ) e U ∂x

«

e

y

where the ‘numerical viscosity’ u ) e = C xe x/(2∆ y ) .

U ∂x « e ∆ y where the ‘numerical viscosity’ (Γ u ) e = C

- p. 12

The error is therefore diffusive in nature, and so tends to make the solution stable,

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

Recall that the order of accuracy gives information on how rapidly numerical errors decrease as the grid is refined. Since the error in the above scheme decreases only linearly with grid spacing, a very fine grid can be needed in order to achieve sufficient accuracy.and so tends to make the solution stable, but inaccurate. For this reason, whilst first order

For this reason, whilst first order schemes are often used, it is usually preferable to employ a higher order convection scheme.grid can be needed in order to achieve sufficient accuracy. Note, however, that in practical applications

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 switch to a higher order one once the solution is closer to convergence.preferable to employ a higher order convection scheme. - p. 13 Central Difference Scheme This scheme

higher order one once the solution is closer to convergence. - p. 13 Central Difference Scheme

- p. 13

one once the solution is closer to convergence. - p. 13 Central Difference Scheme This scheme

Central Difference Scheme

This scheme simply interpolates linearly between U P and U E to approximate U e . For a uniform grid this 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 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 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 first order upwind scheme, although it can produce oscillatory solutions.= 0 . 5( U E + U P ) + O (∆ x 2 )

scheme, although it can produce oscillatory solutions. - p. 14 QUICK Scheme The QUICK (Quadratic Upwind

- p. 14

although it can produce oscillatory solutions. - p. 14 QUICK Scheme The QUICK (Quadratic Upwind Interpolation

QUICK Scheme

The QUICK (Quadratic Upwind Interpolation for Convection Kinetics) scheme fits a parabola between three points to approximate U e . U e .

If C x e > 0 a parabola is fitted through the points W , P C xe > 0 a parabola is fitted through the points W , P and E .

If C x e < 0 a parabola is fitted through the C xe < 0 a parabola is fitted through the

points P , E and EE .

W

W

W P e E EE

P

e

e

E

W P e E EE

EE

For C x e > 0 , on a regular grid we get C xe > 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.− 1 8 ( φ E 2 − 2 φ P + φ W ) (26)

However, it is not bounded, and can produce undershoots and overshoots in regions of steep gradients.The QUICK scheme can be shown to be third order accurate. W P E   -

W P E
W
P
E
and overshoots in regions of steep gradients. W P E   - p. 15 Note that
 

-

p. 15

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

 

-

p. 16

Convection Scheme Performances As an example, we consider the pure convection problem: ∂Uφ + ∂V

Convection Scheme Performances

As an example, we consider the pure convection problem: ∂Uφ + ∂V φ = 0
As an example, we consider the pure convection problem:
∂Uφ + ∂V φ
= 0
(27)
∂x
∂y
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
y
x
x
U
= 0
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. 17
y
x
V = 1, U = 0

- p. 18

in the x direction. - p. 17 y x V = 1, U = 0 -
in the x direction. - p. 17 y x V = 1, U = 0 -
y x V = 1, U = 0. 2
y
x
V = 1, U = 0. 2

- p. 19

17 y x V = 1, U = 0 - p. 18 y x V =

In the U = 0 case the flow is aligned with the grid lines and all 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 U

= 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.When U = 0 the flow is not aligned with the grid lines. The centred scheme

The centred scheme captures the steep gradient better, but shows significant oscillations.by the first order upwind scheme is clearly present. The QUICK scheme also represents the steep

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.is clearly present. The centred scheme captures the steep gradient better, but shows significant oscillations. -

the steep gradients quite well, but does show some over- and under-shoots at the base and

- p. 20

Boundary Condition Treatments For illustration we consider a cell at the east boundary of the

Boundary Condition Treatments

For illustration we consider a cell at the east boundary of the flow domain.Boundary Condition Treatments Typical boundary conditions might be of the form U = 0 at x

we consider a cell at the east boundary of the flow domain. Typical boundary conditions might

Typical boundary conditions might be of the form

U = 0 at x E ∂U/∂x = 0 at x E .

W P E
W
P
E

x E

The discretized form of the transport equation can be written as0 at x E ∂U/∂x = 0 at x E . W P E x E

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 coefficients a e , a w , a n and a s contain the convective and diffusive contributions,

and

a p = a e + a w + a n + a s .

The first type of boundary condition above can be simply implemented by setting the value of U E to zero. 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 U E = U P (ie. a one-sided 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 flux conditions (eg. a prescribed heat flux) can also be implemented by setting the a e coefficient to zero and adding the desired flux to the source term s a e coefficient to zero and adding the desired flux to the source term s u .

and adding the desired flux to the source term s u . - p. 21 Numerical

- p. 21

the desired flux to the source term s u . - p. 21 Numerical Flow Solver

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 . U , V and W .

Other transport equations (for temperature, mass fraction, etc.) can be treated similarly.equations relating the nodal values of U , V and W . However, the equations are

However, the equations are coupled in a non-linear fashion, through the convection terms (and sometimes source terms).temperature, mass fraction, etc.) can be treated similarly. An often-used practice is to solve the equations

An often-used practice is to solve the equations in an iterative, segregated, manner:through the convection terms (and sometimes source terms). Assemble the discretized equations for U , and

Assemble the discretized equations for U , and hence update U . U , and hence update U .

Assemble the discretized equations for V , and hence update V . V , and hence update V .

Assemble the discretized equations for W , and hence update W . W , and hence update W .

Update the pressure field.the discretized equations for W , and hence update W . Repeat until the solution has

Repeat until the solution has converged.for W , and hence update W . Update the pressure field. At this stage it

At this stage it is not clear how the updating of the pressure field is achieved, since we do not have a transport equation for the pressure. This issue will be addressed in the next lecture.equations for W , and hence update W . Update the pressure field. Repeat until the

since we do not have a transport equation for the pressure. This issue will be addressed

- p. 22