Basic Aspects of Discretization

56
Basic Aspects of Discretization http://aircraftdesign.nuaa.edu.cn/aca/Slide/17-Basic%20Aspects%20of%20Discretization.pdf

Transcript of Basic Aspects of Discretization

Page 1: Basic Aspects of Discretization

Basic Aspects of Discretization

http://aircraftdesign.nuaa.edu.cn/aca/Slide/17-Basic%20Aspects%20of%20Discretization.pdf

Page 2: Basic Aspects of Discretization

Solution Methods

• Singularity Methods– Panel method and VLM

• Simple, very powerful, can be used on PC

• Nonlinear flow effects were excluded

• Direct numerical Methods (Field Methods)– Finite difference approach

• Direct numerical solution of differential equations

– Finite volume approach• Direct approximations to the integral form of the governing

equations

Page 3: Basic Aspects of Discretization

Area of CFD

• Grid generation

• Flowfield discretization algorithms

• Efficient solution of large systems of equations

• Massive data storage and transmission technology methods

• Computational flow visualization

Page 4: Basic Aspects of Discretization

Outline• Approximations to partial derivatives• Finite difference representation of Partial Differential

Equations– Discretization– Consistency– Stability– Convergence

• Explicit and implicit approaches• The finite volume technique• Boundary conditions• Stability analysis

Page 5: Basic Aspects of Discretization

Approximations to partial derivatives

• Mathematic basis– Taylor series expansions

0 0 0

2 2 3 3

0 0 2 3

( ) ( )( ) ( )2 6x x x

df x d f x d ff x x f x xdx dx dx

∆ ∆+ ∆ = + ∆ + + +

Page 6: Basic Aspects of Discretization

• The ways to obtain finite difference representations of derivatives– Forward difference

– Backward difference

– Central difference

Page 7: Basic Aspects of Discretization

• Forward differencefirst order accurate

one-sided difference approximation

0 0 0

2 2 3 3

0 0 2 3

( ) ( )( ) ( )2 6x x x

df x d f x d ff x x f x xdx dx dx

∆ ∆+ ∆ = + ∆ + + +

0 0

20 0

2

( ) ( ) 12x x

f x x f xdf d fxdx x dx

+ ∆ −= − ∆ −

0

0 0( ) ( ) ( )x

f x x f xdf O xdx x

+ ∆ −= + ∆

∆Truncation Error

Page 8: Basic Aspects of Discretization

• Backward difference

first order accurate

one-sided difference approximation

0 0 0

2 2 3 3

0 0 2 3

( ) ( )( ) ( )2 6x x x

df x d f x d ff x x f x xdx dx dx

∆ ∆− ∆ = − ∆ + − +

0

0 0( ) ( ) ( )x

f x x f xdf O xdx x

− ∆ −= + ∆

Page 9: Basic Aspects of Discretization

• Central difference

Second order accurate

Two-sided difference approximation

0 0

3 3

0 0 3

( )( ) ( ) 23x x

df x d ff x x f x x xdx dx

∆+ ∆ − − ∆ = + ∆ + +

0

20 0( ) ( ) ( )2x

f x x f x xdf O xdx x

+ ∆ − − ∆= + ∆

0 0 0

2 2 3 3

0 0 2 3

( ) ( )( ) ( )2 6x x x

df x d f x d ff x x f x xdx dx dx

∆ ∆+ ∆ = + ∆ + + +

0 0 0

2 2 3 3

0 0 2 3

( ) ( )( ) ( )2 6x x x

df x d f x d ff x x f x xdx dx dx

∆ ∆− ∆ = − ∆ + − +

Page 10: Basic Aspects of Discretization

The finite difference approximation to the second derivative

• Adding the Taylor series expressions for the forward and backward expansions results in the following expression.

0

22 4

0 0 0 2( ) ( ) 2 ( ) ( ) ( )x

d ff x x f x x f x x O xdx

+ ∆ + − ∆ = + ∆ + ∆

0

220 0 0

2 2

( ) 2 ( ) ( ) ( )( )x

f x x f x f x xd f O xdx x

+ ∆ − + − ∆= + ∆

Page 11: Basic Aspects of Discretization

Shorthand NotationNomenclature for use in partial differential equation difference expressions

Page 12: Basic Aspects of Discretization

Shorthand Notation

1, ,

, 1,

1, 1, 2

( ) 1

( ) 1

( ) 22

i j i j

i j i j

i j i j

f ff O x st order forward differencex x

f ff O x st order backward differencex x

f ff O x nd order central differencex x

+

+ −

−∂= + ∆

∂ ∆−∂

= + ∆∂ ∆

−∂= + ∆

∂ ∆

21 , 1, 2

2 2

2( ) 2

( )i i j i jf f ff O x nd order central difference

x x+ −− +∂

= + ∆∂ ∆

Page 13: Basic Aspects of Discretization

Finite difference representation of Partial Differential Equations

Steps and Requirements to Obtain a Valid Numerical Solution

Page 14: Basic Aspects of Discretization

• On the selection of a finite difference approximation– Depends on the physics of the problem being studied

– Any scheme that fails to represents the physics correctly willfail when you attempt to obtain a solution

Connection between grid points used in numerical method and equation type

Page 15: Basic Aspects of Discretization

Example of Finite difference representation of PDE

• Heat equation

2

2

xu

tu

∂∂

=∂∂ α

Grid nomenclature for discretization

Using a forward difference in time, and a central difference in space

Page 16: Basic Aspects of Discretization

Discussion on Steps of Numerical Solution

• Discretization

• Consistency

• Stability

• Convergence

Page 17: Basic Aspects of Discretization

• Discretization– This is the process of replacing derivatives by finite

difference approximations.

– This introduces an error due to the truncation error arising from the finite difference approximation and any errors due to treatment of BC’s.

The size of the truncation error will depend locally on the solution.

In most cases we expect the discretization error to be larger than round-off error.

Page 18: Basic Aspects of Discretization

• Consistency– A finite-difference representation of a PDE is

consistent if the difference between the PDE and its difference representation vanishes as the mesh is refined, i.e.,

– Consider a case where the truncation error is O(∆t / ∆x). In this case we must let the mesh go to zero just such that:

Page 19: Basic Aspects of Discretization

• Stability– A stable numerical scheme is one for which errors from any

source (round-off, truncation) are not permitted to grow in thesequence of numerical procedures as the calculation proceedsfrom one marching step, or iteration, to the next, thus:

errors grow→ unstableerrors decay → stable

– Comments• Stability is normally thought of as being associated with

marching problems

• Stability requirements often dictate allowable step sizes

• In many cases a stability analysis can be made to define thestability requirements.

Page 20: Basic Aspects of Discretization

• Convergence– The solution of the FDE’s should approach the

solution of the PDE as the mesh is refined.

– Lax Equivalence Theorem (linear, initial value problem):

• For a properly posed problem, with a consistent finite difference representation, stability is the necessary and sufficient condition for convergence.

– In practice, numerical experiments must be conducted to determine if the solution appears to be converged with respect to mesh size.

Page 21: Basic Aspects of Discretization

Two Different Approaches

• There are many difference techniques used in CFD, you will find that any technique falls into one or the other of following two different general approaches:

– Explicit approach

– Implicit approach

Page 22: Basic Aspects of Discretization

Explicit Scheme• Heat equation

2

2

xu

tu

∂∂

=∂∂ α

– The solution at time step n is known. At timen+1 there is only one unknown.

• Finite difference equation1

1 12 ( 2 )( )

n nn n ni ii i i

u u u u ut x

α+

+ −

−= − +

∆ ∆

Page 23: Basic Aspects of Discretization

Grid points used in typical explicit calculation

– the value of u at i and the n+1 time step:

– we can solve for each new value explicitly without solving a system of equations in terms of known values from the previous time step.

11 12 ( 2 )

( )n n n n ni i i i i

tu u u u ux

α++ −

∆= + − +

Page 24: Basic Aspects of Discretization

• Discussions on explicit scheme– Advantages:

• Relative simple to set up and program

• This scheme is easily vectorized and a natural for massively parallel computation

– Disadvantage:• Stability requirements require very small steps sizes

Page 25: Basic Aspects of Discretization

Implicit Scheme

– Grid points used in typical implicit calculation

– The finite difference representationwe need to find the values along n+1simultaneously.

11 1 1

1 12 ( 2 )( )

n nn n ni ii i i

u u u u ut x

α++ + +

+ −

−= − +

∆ ∆

Page 26: Basic Aspects of Discretization

• This leads to a system of algebraic equations that must besolved.

• Defining

• The finite difference equation became:

11 1 1

1 12 ( 2 )( )

n nn n ni ii i i

u u u u ut x

α++ + +

+ −

−= − +

∆ ∆

Page 27: Basic Aspects of Discretization

• The approach that leads to the formulation of a problem requiring the simultaneous solution of a system of equations is known as an implicit scheme.

• Advantage:– Stability requirements allow a large step size

• Disadvantages:– More complicated to set up and program

– This scheme is harder to vectorize or parallelize

– Since the solution of a system of equations is required at each step, the computer time per step is much larger than in the explicit approach.

Page 28: Basic Aspects of Discretization

Example - Elliptic PDE

• Using Laplace’s equation as the model problem

0=+ yyxx φφ

Grid points used in a typical representation of an elliptic equation

Page 29: Basic Aspects of Discretization

• Use the second order accurate central difference formulas at i,j:

22

,1,,1 )()(

2xO

xjijiji

xx ∆+∆

+−= −+ φφφ

φ 22

1,,1, )()(

2yO

yjijiji

yy ∆+∆

+−= −+ φφφ

φ

0)(

2

)(

22

1,,1,2

,1,,1 =∆

+−+

+− −+−+

yxjijijijijiji φφφφφφ

• If ∆x = ∆y, solve this equation for φij :

)( 1,1,,1,141

, −+−+ +++= jijijijiji φφφφφ

Page 30: Basic Aspects of Discretization

• This expression illustrates the essential physics offlows governed by elliptic PDE’s:

– φij depends on all the values around it

– all values of φ must be found simultaneously

– computer storage requirements are much greater than thoserequired for parabolic and hyperbolic PDE’s

)( 1,1,,1,141

, −+−+ +++= jijijijiji φφφφφ

Page 31: Basic Aspects of Discretization

• Solution schemes– Because of the large number of mesh points, it is

generally not practical to solve the system of equations

– Instead, an iterative procedure is usually employed.• Initial guess for the solution is made and then each mesh

point in the flow field is updated repeatedly until the values satisfy the governing equation.

– This iterative procedure can be thought of as having a time-like quality

Page 32: Basic Aspects of Discretization

A Note on Conservation Form

• Care must be taken if the flow field has discontinuities (shocks) – The correct solution of the partial differential equation will only be

obtained if the conservative forms of the governing equations are used.

2D steady x-momentum equationthe conservative formsthe classical standard forms

Page 33: Basic Aspects of Discretization

The Finite Volume Technique

• Each conservation law had both differential andintegral statements.

• The integral form is more fundamental, notdepending on continuous partial derivatives.

• The finite volume method discretize the theintegral form of the equations.

Page 34: Basic Aspects of Discretization

Example of Finite Volume Approach

• Conservation of mass in the integral statement

• Introducing the specific notation and assuming 2-D flow, the conservation law can be rewritten as:

Where H=( F, G) = ρV, q = ρ

Hx = F = ρu , Hy = G = ρv

dV dSt

ρ ρ∂= −

∂ ∫∫∫ ∫∫ V ni

0dV dSt

∂+ =

∂ ∫∫ ∫q H ni

Page 35: Basic Aspects of Discretization

• Using the definition of n in Cartesian coordinates, and consideringfor illustration the Cartesian system given above

Basic nomenclature for finite volume analysis

along AB, n = -j, dS = dx, and: H•n dx = - Gdx

along BC, n = i, dS = dy, and: H•n dy = F dy

in general: H•n ds = F dy - Gdx

Page 36: Basic Aspects of Discretization

• Using the general grid the integral statement, can be written as:

• Define the quantities over each face (AB) :

Here A is the area of the quadrilateral ABCD, and qi,j is the average value of q over ABCD.

,( ) ( ) 0DA

j kAB

Aq F y G xt

∂+ ∆ − ∆ =

∂ ∑

0dV dSt

∂+ =

∂ ∫∫ ∫q H ni • Similarly for faces BC, CD and AD

Page 37: Basic Aspects of Discretization

• Assuming A is not a function of time, and combining:

Along AB

Along BC

Along CD

Along DA

Page 38: Basic Aspects of Discretization

• Supposing the grid is regular Cartesian as shownabove. Then A = ∆x∆y, and along:

Page 39: Basic Aspects of Discretization
Page 40: Basic Aspects of Discretization

Comments on Finite Volume Method

• Differences between finite difference and finite volume method– Finite difference

• Approximates the governing equation at a point

• Finite difference methods were developed earlier, the analysis of methods is easier and further developed

– Finite volume• Approximates the governing equation over a volume

• Finite volume is the most physical in fluid mechanics codes, and is actually used in most codes.

Page 41: Basic Aspects of Discretization

Comments on Finite Volume Method

• The advantages of the finite volume method– Good conservation of mass, momentum, and energy

using integrals when mesh is finite size

– Easier to treat complicated domains • integral discretization [averaging] easier to figure out,

implement, and interpret

– Average integral concept much better approach when the solution has shock waves (i.e. the partial differential equations assume continuous partial derivatives).

Page 42: Basic Aspects of Discretization

Boundary Conditions

• We have obtained expressions for interior points on themesh.

• What about expressions for points on the boundary ?

Near-field BC

Far-field BC

Page 43: Basic Aspects of Discretization

Handle the Far-field BC (1)

• “Go out” far enough and set φ = 0 for φ → 0, as the distance from the body goes to infinity

– Advantage• Simple and frequently used

– Disadvantage• Require excessive use of grid points in regions

where we normally aren’t interested in the details of the solution.

Page 44: Basic Aspects of Discretization

Handle the Far-field BC (2)

• Transform the equation to another coordinate system, and satisfy the boundary condition explicitly at infinity

Page 45: Basic Aspects of Discretization

Handle the Far-field BC (3)

• Blocks of Grids– The grid points are used efficiently in the region of

interest.• a dense “inner” grid

• a “coarse” outer grid.

• Adaptive Grid– The grid will adjust automatically to concentrate

points in regions of large flow gradients.

Page 46: Basic Aspects of Discretization

Handle the Far-field BC (4)

• Match the numerical solution to an analyticapproximation for the farfield boundary condition.– The boundary numerical solution reflects the correct

physics at the boundary• It allows the outer boundary to be placed at a reasonable

distance from the body, and properly done.

– Particularly important in the solution of the Eulerequations.

– Effort is still underway to determine the best way toimplement this approach.

Page 47: Basic Aspects of Discretization

Handle the Far-field BC

• Comments– BC’s on the FF boundary are important, and can be especially

important for Euler codes which march in time to a steady state final solution.

– How to best enforce the FF BC is still under study - research papers are still being written describing new approaches.

0

0

0

=∂

∂+

∂∂

+∂∂

+∂∂

+∂∂

=∂

∂+

∂∂

+∂∂

+∂∂

+∂∂

=∂

∂+

∂∂

+∂∂

+∂∂

+∂∂

zp

zww

ywv

xwu

tw

yp

zvw

yvv

xvu

tv

xp

zuw

yuv

xuu

tu

ρ

ρ

ρ

Page 48: Basic Aspects of Discretization

Handle the Near-field BC (1)

• Using a standard grid and allow the surface to intersect grid lines in an irregular manner

Page 49: Basic Aspects of Discretization

Handle the Near-field BC (2)

• Using the surface of the body as a coordinate surface

Body conforming grid for easy application of BCs on curved surfaces

Page 50: Basic Aspects of Discretization

Handle the Near-field BC (3)

• Using thin airfoil theory boundary conditions

Approximate approach to boundary condition specification

Page 51: Basic Aspects of Discretization

Finite difference representation of the BC's(1)

• Using Laplace’s Equation as an example

• Two types of boundary conditions associated with the boundary:– The Dirichlet problem

• The value φ on the boundary is simply specified, and no special difference formulas are required.

– The Neumann problem• ∂ φ /∂n is specified, and special difference formulas are required.

0=+ yyxx φφ

Page 52: Basic Aspects of Discretization

Finite difference representation of the BC's(2)

The normal velocity, v, is zero at the outer boundary

Dummy Row

Outer Boundary

The required boundary condition at j = NY is:

The equations are then solved up to YNY, and whenever you needφ at NY+1, simply use the value at NY-1.

Page 53: Basic Aspects of Discretization

Finite difference representation of the BC's(3)

Thin airfoil theory boundary conditions at the surface

( nondimensionalized by U∞ )

Using central differences at j =2

Dummy Row

Page 54: Basic Aspects of Discretization

Stability Analysis• Introduction

– In many cases some finite difference representation proved impossible to obtain solutions.

• Frequently the reason was the choice of an inherently unstable numerical algorithm.

– In this section we present one of the classical approaches to the determination of stability criteria for use in CFD.

– These types of analysis provide insight into grid and step size requirements

• Step size : time steps

• Grid size : spatial size

Page 55: Basic Aspects of Discretization

Von Neumann Stability Analysisfor parabolic equation (heat equation)

Assume at t = 0, that an error, possibly due to finite length arithmetic, is introduced in the form:

Using the explicit finite difference representation

Page 56: Basic Aspects of Discretization

Substitute Eq. (1) into (2), and solve for ψ (t + ∆t)