review of basic finite volume method

Upload: ershad-ahamed-c

Post on 10-Apr-2018

218 views

Category:

Documents


0 download

TRANSCRIPT

  • 8/8/2019 Review of Basic Finite Volume Method

    1/6

    School of Mechanical Aerospace and Civil Engineering

    Advanced Modelling & Simulation: CFD

    Review of Basic Finite Volume Methods

    T. J. CraftGeorge Begg Building, C41

    Contents: Review of basic FV method

    Pressure-velocity coupling

    Body-fitted coordinate systems

    Unsteady problems

    Turbulence and other physicalmodelling

    Reading:J. Ferziger, M. Peric, Computational Methods for FluidDynamicsH.K. Versteeg, W. Malalasekara, An Introduction toComputational Fluid Dynamics: The Finite VolumeMethodS.V. Patankar, Numerical Heat Transfer and Fluid FlowNotes: http://cfd.mace.manchester.ac.uk/tmcfd

    - People - T. Craft - Online Teaching Material

    Overview of CFD in Advanced Modelling & Simulation

    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,impingement,separation/reattachment,streamline curvature, . . .

    Complex flow geometries;often turbulent flow

    Heat/mass transfer

    Buoyancy, system rotation,etc...

    U(y)

    Q

    ThotT

    cold

    Most general purpose CFD codes employ Finite Volume (FV)discretization methods.

    Review of Basic Finite Volume Methods 2008/9 2 / 24

    In Modelling & Simulation III we covered

    Basic FV discretization of a single transport equation on rectangular

    grids.

    Use of Taylor series expansions to examine order of accuracy ofschemes.

    The importance of convection terms, and some different schemes forthese (1st order upwind, higher order schemes: QUICK, etc)

    The general trade-off between accuracy and stability.

    In Advanced Modelling & Simulation we will cover

    Revision of the basic FV schemes.

    Pressure-velocity coupling.

    Extension of FV to non-orthogonal, body-fitted, grids.

    Time-dependent problems.

    Modelling considerations for turbulent flows.

    CFD element of the course consists of 12 hours of lectures/examples and

    one laboratory session.

    Review of Basic Finite Volume Methods 2008/9 3 / 24

    The Basic Finite Volume Method

    One important feature of finite volume schemes is their conservation

    properties. Since they are based on applying conservation principles overeach small control volume, global conservation is also ensured.

    Although initially we consider 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 bepresented in later lectures.

    The method starts by dividing the flowdomain into a number of small control

    volumes.

    The grid points where variables arestored are typically defined as beingat the centre of each control volume.

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

    The transport equation(s) are then integrated over each control volume.

    Review of Basic Finite Volume Methods 2008/9 4 / 24

  • 8/8/2019 Review of Basic Finite Volume Method

    2/6

    We consider a general (steady) transport equation for some quantity :

    (Uj)

    xj=

    xj

    xj

    + S (1)

    or .(U) = .() + S (2)

    Integrating this over the control volume gives:

    (Uj)

    xjdV =

    xj

    xj

    dV+

    SdV (3)

    or

    .(U) dV =

    .() dV+

    SdV (4)

    The convection and diffusion terms can be combined:.(U ) dV =

    SdV (5)

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

    The divergence theorem can be used to convert the left hand side volumeintegral to an integral around the boundary, , of the control volume:

    (U ).ndS=

    SdV (6)

    U.ndS is the convective flux of across the part of the boundary edgedS, and .ndS is the diffusive flux across the same boundary part.

    The left hand side of equation (6) is thus simply the total net convectiveand diffusive flux of into the control volume.

    Equation (6) is thus a statement of conservation for the control volume. In

    the case of the momentum equation, where = U for example, it issimply the force-momentum principle applied over the control volume.

    Provided the same expressions are used for fluxes across faces inneighbouring cells, this approach ensures that the conservationproperties will also be satisfied globally over the flow domain.

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

    The surface integral is generally approximated in a discretized form by

    (U ).ndSk

    (U )k.(nS)k (7)

    where (U )k is evaluated at the centre ofedge segment k, and (S)k and nk are the areaand unit vector normal to this edge.

    n

    S

    This approximation of the surface integral can be shown to be of secondorder accuracy; for some function f a Taylor series expansion gives:

    f(s) ds=

    f( ) + (s )f( ) +(s )2

    2!f( ) +

    ds (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 givef(s) ds= f( )

    ds+ f( )

    (s ) ds+

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

    )

    Review of Basic Finite Volume Methods 2008/9 7 / 24

    In fact, when is taken as the mid-point of the face then the aboveapproximation has leading order term of O((s)3).

    The source terms in the volume integral of equation (6) are approximatedas

    SdV SVol (S)PVol (9)

    where S is the average value of S over the control volume and (S)Pis simply its value at the cell centre node P.

    This approximation can also be shown to be generally of second orderaccuracy.

    Review of Basic Finite Volume Methods 2008/9 8 / 24

  • 8/8/2019 Review of Basic Finite Volume Method

    3/6

    Finite-Volume Method on a 2-D Rectangular Grid

    To complete the discretization, one needs to consider how to approximatethe convective and diffusive fluxes at the cell faces and, if necessary, thesource terms at the cell centre.

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

    The velocity U is stored at the nodes P, N, S,E, W, located at control volume centres; cellfaces are denoted by lower case n, s, e, w.

    P EW

    N

    S

    e

    n

    w

    s

    x

    y

    The finite-volume method starts by integrating the momentum equationover the P control volume:

    V

    x(U2) +

    y(UV)dxdy =

    V

    P

    xdxdy

    +

    V

    x

    U

    x

    +

    y

    U

    y

    dxdy (10)

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

    This leads toU2dy

    ew

    +

    UVdx

    ns

    =

    U

    xdy

    ew

    +

    U

    ydx

    ns

    V

    P

    xdxdy

    (11)

    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:

    V

    P

    xdxdy

    P

    x

    P

    xy (12)

    In the example considered, the pressure gradient at the cell centre,

    (P/x)P, is evaluated by interpolating pressure values from surroundingnodes, if necessary. This will be addressed in more detail in later lectures.

    Other source terms can be evaluated similarly, interpolating wherenecessary to estimate cell centre values.

    Review of Basic Finite Volume Methods 2008/9 10 / 24

    Evaluating Diffusive Fluxes

    The diffusive fluxes can then be approximated byU

    xdy

    ew

    +

    U

    ydx

    ns

    U

    xy

    ew

    +

    U

    yx

    ns

    (13)

    The gradients U/x and U/y at the cell faces can be evaluatedusing central differences, so that the diffusion terms become

    (y)eUEUP

    x (y)w

    UPUWx

    + (x)nUNUP

    y (x)s

    UPUSy

    (14)

    This is again a second order, centered, approximation.

    The discretized diffusion terms can thus be written as

    adeUE + adwUW + a

    dnUN+ a

    dsUSa

    dpUP (15)

    where

    ade = (y/x)e adw = (y/x)w a

    dn = (x/y)n a

    ds = (x/y)s

    and adp = ade + adw+ adn + ads.Review of Basic Finite Volume Methods 2008/9 11 / 24

    Evaluating Convective Fluxes

    The convection terms can be approximated asU2dy

    ew

    +

    UVdx

    ns

    U2y

    ew

    +UVx

    ns

    = (Uy)eUe (Uy)wUw + (Vx)nUn (Vx)sUs

    = CxeUeCxwUw + CynUnCysUs (16)

    where Cxe, Cxw, etc are simply the mass fluxes through the east, west,north and south faces.

    The values of U at the cell faces, Ue, Uw, Un and Us need to be obtainedby 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-usedalternatives are outlined below.

    Review of Basic Finite Volume Methods 2008/9 12 / 24

  • 8/8/2019 Review of Basic Finite Volume Method

    4/6

    First Order Upwind Scheme

    A very simple scheme for approximating cell face values for theconvective terms is the first-order upwind convection scheme:

    Ue =

    UP for Cxe> 0

    UE for Cxe 0(17) P Ee

    This gives a convection contribution to the discretized equation ofaceUEa

    cwUWa

    cnUNa

    csUS+ a

    cpUp (18)

    where

    ace = max(Cxe,0) acw = max(Cxw,0)

    acn = max(Cyn,0) acs = max(Cys,0)

    and acp = ace+ a

    cw + a

    cn+ a

    cs+ (CxeCxw + CynCys)

    Note that the coefficients ace, etc are all positive, as is acp. The final set of

    terms in acp is the net mass flux into the cell, which should be zero, so inpractice acp can simply be taken as the sum a

    ce+ a

    cw + a

    cn+ a

    cs.

    Review of Basic Finite Volume Methods 2008/9 13 / 24

    Combining the convection and diffusion terms results in a discretized

    equation of the form

    apUP = aeUE + awUW + anUN+ asUS+ su (19)

    where ae = ade + ace, etc, ap = ae+ aw+ an+ as, and su represents the

    source terms arising from the pressure gradient.

    We thus get a set of equations relating UP to the values of U at

    surrounding nodes.

    Having obtained the coefficients and source terms for each grid cell, theresulting system of equations can be solved by a suitable numericalalgorithm.

    The above upwind scheme is always bounded. However, as implied by itsname, it is only first order accurate.

    To illustrate this, we assume that Cxe> 0. Then the scheme approximates

    CxeUe CxeUP = Cxe

    Ue+ (xP xe)

    U

    x

    e

    + O((xPxe)2)

    (20)

    Review of Basic Finite Volume Methods 2008/9 14 / 24

    The leading error term in this can thus be written as

    (u)e

    U

    x

    e

    y

    where the numerical viscosity (u)e = Cxex/(2y).

    The error is therefore diffusive in nature, and so tends to make thesolution stable, but inaccurate.

    The order of accuracy gives information on how rapidly numerical errorsdecrease as the grid is refined. Since the error in the above schemedecreases only linearly with grid spacing, a very fine grid can be needed

    in order to achieve sufficient accuracy.

    For this reason, whilst first order schemes are often used, it is usuallypreferable to employ a higher order convection scheme to obtainsufficient numerical accuracy.

    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.

    Review of Basic Finite Volume Methods 2008/9 15 / 24

    Central Difference Scheme

    This scheme simply interpolates linearly between UP and UE toapproximate Ue. For a uniform grid this gives

    Ue = 0.5(UE + UP) (21)

    This is a second order approximation, which can be seen by writingTaylor series expansions for UP and UE around Ue:

    UP = Ue+ (xP xe)

    U

    x

    e

    + O(x2) = Ue0.5x

    U

    x

    e

    + O(x2)

    (22)

    UE = Ue+ (xE xe)

    U

    x

    e

    + O(x2) = Ue+ 0.5x

    U

    x

    e

    + O(x2)

    (23)

    Adding equations (23) and (22) then leads to

    Ue = 0.5(UE + UP) + O(x2) (24)

    The central difference scheme is thus more accurate than the first order

    upwind scheme, although it can produce oscillatory solutions.

    Review of Basic Finite Volume Methods 2008/9 16 / 24

  • 8/8/2019 Review of Basic Finite Volume Method

    5/6

    QUICK Scheme

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

    If Cxe> 0 a parabola is fittedthrough the points W, P and E.

    If Cxe< 0 a parabola is fittedthrough the points P, E and EE.

    P E EEeW

    For Cxe> 0, on a regular grid we get

    e = P +EP

    2

    1

    8(E2P+W) (25)

    The QUICK scheme can be shown to be thirdorder accurate.

    However, it is not bounded, and can produceundershoots and overshoots in regions ofsteep gradients.

    P

    W

    E

    Review of Basic Finite Volume Methods 2008/9 17 / 24

    Note that the discretization stencil associated with the QUICK scheme islarger than that of the first and second order schemes outlined earlier,since contributions from UEE, UWW, UNN and USS now appear.

    However, the QUICK (and other) schemes are often coded as deferred

    corrections. This means that the upwind scheme contributions areincluded in the coefficients ae, aw, etc. whilst the additional contributions

    from the QUICK (or other) scheme are simply placed in the source termSu.

    Higher order schemes can also be devised and employed. However, inorder to benefit significantly from them the simple formulations introducedearlier for approximating surface and volume integrals (which are onlysecond order accurate) should also be replaced by a higher ordermethod.

    Review of Basic Finite Volume Methods 2008/9 18 / 24

    Convection Scheme Performances

    As an example, we consider the pure convection problem:

    U

    x+

    V

    y= 0 (26)

    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.

    The exact solution isthe step function

    simply convectedwith the velocity.

    U = 0 U> 0

    The following slides show the resulting profiles of , close to the topboundary y = 2, with U = 0 and U= 0, using the three convectionschemes 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

    V = 1, U = 0

    Review of Basic Finite Volume Methods 2008/9 20 / 24

  • 8/8/2019 Review of Basic Finite Volume Method

    6/6

    V = 1, U= 0.2

    Review of Basic Finite Volume Methods 2008/9 21 / 24

    In the U = 0 case the flow is aligned with the grid lines and all theschemes perform reasonably well (obviously resolving the step changebetter as the grid is refined).

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

    The centred scheme captures the steep gradient better, but showssignificant oscillations.

    The QUICK scheme also represents the steep gradients quite well, andimproves 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 22 / 24

    Boundary Condition Treatments

    For illustration we consider a cell at the east boundary of the flow domain.

    Typical boundary conditions might be one of

    = 0 at xE /x = 0 at xE.

    W P E

    xE The discretized form of the transport equation can be written as

    apP = aeE + awW + anN + asS+ s (27)

    where the coefficients ae, aw, an and as contain the convective and

    diffusive contributions, and ap = ae+ aw+ an+ as.

    The first type of boundary condition above can be simply implemented bysetting the value of E to zero.

    The zero gradient condition can be implemented by setting ae = 0; thecontributions aeP and aeE are then effectively removed from the leftand 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.Review of Basic Finite Volume Methods 2008/9 23 / 24

    Numerical Flow Solver Strategy

    Each momentum equation can be discretized as described, leading to aset of algebraic equations relating the nodal values of U, V and W.

    Other transport equations (for temperature, mass fraction, etc.) can betreated 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 updating of the pressure field isachieved, since we do not have a transport equation for the pressure.

    This issue will be addressed in the next section.Review of Basic Finite Volume Methods 2008/9 24 / 24