27
Ae232a. © Tim Colonius 1 Finite difference schemes Alternative to function approximations for (spatial) discretization of PDE Collocation method is the limit of FD Related to Lagrange Poly Similar to Lagrange Polynomial, but applied locally Measure of errors – points per wavelength

Unevenly Spaced Grid

Embed Size (px)

Citation preview

Page 1: Unevenly Spaced Grid

Ae232a. © Tim Colonius 1

Finite difference schemes

•  Alternative to function approximations for (spatial) discretization of PDE

•  Collocation method is the limit of FD •  Related to Lagrange Poly

–  Similar to Lagrange Polynomial, but applied locally

•  Measure of errors – points per wavelength

Page 2: Unevenly Spaced Grid

Ae232a. © Tim Colonius 2

FD discretization of PDE Method of lines

•  Semi-discrete approach •  Approximate each term in the equation locally based on

function values at nearby points •  Not always unambiguous because continuous terms can

be written in different forms (e.g. apply chain rule), and discrete approximations do not necessarily obey these continuous identities

•  Different approximations usually needed for “interior” points than boundary or near-boundary points

•  Leads to a system of ODE

Page 3: Unevenly Spaced Grid

Ae232a. © Tim Colonius 3

Finite-difference Formulae:

•  Simplest to derive using Taylor-series expansion

Stencil Size: l+r+1

Page 4: Unevenly Spaced Grid

Ae232a. © Tim Colonius 4

Page 5: Unevenly Spaced Grid

Simply done in maple

Ae232a. © Tim Colonius 5

Classroom Note:Calculation of Weights in Finite Difference Formulas Bengt Fornberg, SIAM Rev. 40, 685 (1998)

Page 6: Unevenly Spaced Grid

Ae232a. © Tim Colonius 6

Notes

•  Higher order derivatives similar •  On evenly spaced grid, symmetry/antisymmetry for even/

odd derivatives automatically zeros the odd/even equations

•  “Biased” (no symmetry) schemes are useful for representing points near the ‘edge’ of a domain.

•  Construction of stencils larger than ~3 points need to be constructed with care due to instability.

•  Geometry handled by overset grids.

Page 7: Unevenly Spaced Grid

Ae232a. © Tim Colonius 7

Unevenly spaced grid

A better approach is to solve on a curvilinear grid

Page 8: Unevenly Spaced Grid

Geometry is handled by overset grids

Ae232a. © Tim Colonius 8

Page 9: Unevenly Spaced Grid

Ae232a. © Tim Colonius 9

Can we do better using same stencil?

•  Suppose we use derivatives at adjacent points in our formula

Page 10: Unevenly Spaced Grid

Ae232a. © Tim Colonius 10

Notes

•  Terminology: –  “Compact Finite Difference” –  “Padé Finite Difference” –  “Implicit Finite Difference”

•  Better accuracy and smaller stencil for same order •  Can play same games to derive forward/backward

biased schemes •  But….we have coupled terms on the LHS •  In matrix form:

Page 11: Unevenly Spaced Grid

Ae232a. © Tim Colonius 11

Solution

•  If we take at most L=R=1 tridiagonal matrix •  If we take at most L=R=2 penta-diagonal matrix

•  Still O(N) computations to compute the derivative •  More computations •  Bad for parallel computations •  Obvious question…is the better accuracy for, say, the 4th order

compact scheme (compared to explicit scheme) cost effective?

–  4 times smaller leading error –  E4 requires 3A + 2M per N –  C4 requires 3A + 3M per N

•  The answer is generally yes, but we will discuss more later

Page 12: Unevenly Spaced Grid

Ae232a. © Tim Colonius 12

Optimized Finite Difference Schemes

•  Note that we have used all of the coefficients to minimize the error in the limit of h 0.

•  Perhaps we should examine errors at finite h and see if we can choose (some or all of) the coefficients more wisely?

•  How do we examine error at finite h?

•  Need to pick a function (or class of functions)

•  How about cosine and sine?

Page 13: Unevenly Spaced Grid

Ae232a. © Tim Colonius 13

Fourier Analysis of Differencing Errors

•  Consider FD schemes applied to periodic problems •  Compare FD derivative to spectral derivative for each

wavenumber •  Later this analysis will be crucial in understanding the

stability of FD schemes

Page 14: Unevenly Spaced Grid

Ae232a. © Tim Colonius 14

Fourier analysis of differencing errors

•  For local approximations (Finite-difference) it is useful to compare results to Spectrally accurate method.

•  Analyze how accurate local differencing is for complex exponential at a given wavelength

•  Gives nonlocal information about error (i.e. information at all scales)

•  Rigorously restricted to periodic domains, but also useful as an approximate analysis for the interior of large domains

Page 15: Unevenly Spaced Grid

Ae232a. © Tim Colonius 15

The modified wavenumber

Page 16: Unevenly Spaced Grid

Ae232a. © Tim Colonius 16

Explicit formula for modified wavenumber

Page 17: Unevenly Spaced Grid

Ae232a. © Tim Colonius 17

Centered 1st Derivative Examples

3pt

5pt 7pt

Page 18: Unevenly Spaced Grid

Ae232a. © Tim Colonius 18

2 ppw

3pt

5pt

7pt

3 ppw 4 ppw 10 ppw

Points per wavelength

Page 19: Unevenly Spaced Grid

Ae232a. © Tim Colonius 19

Biased schemes

•  Have complex modified wavenumbers

Page 20: Unevenly Spaced Grid

Ae232a. © Tim Colonius 20

2nd Derivative Approximations (symmetric)

3 pt (2nd order)

5 pt (4th order)

7 pt (6th order)

Page 21: Unevenly Spaced Grid

Ae232a. © Tim Colonius 21

6th order compact (r=l=2, R=L=1),

6th order explicit (r=l=3,R=L=0)

4th order explicit (r=l=2,R=L=0)

4th order compact (r=l=1, R=L=1),

Compact schemes (1st deriv)

Page 22: Unevenly Spaced Grid

Ae232a. © Tim Colonius 22

The modified wavenumber (another derivation)

Page 23: Unevenly Spaced Grid

Ae232a. © Tim Colonius 23

The modified wavenumber

Page 24: Unevenly Spaced Grid

Ae232a. © Tim Colonius 24

Centered 1st Derivative Examples

3pt

5pt 7pt

6th order compact (r=l=2, R=L=1),

6th order explicit (r=l=3,R=L=0)

4th order explicit (r=l=2,R=L=0)

4th order compact (r=l=1, R=L=1),

Explicit schemes

Implicit (compact, Padé) schemes

Page 25: Unevenly Spaced Grid

Ae232a. © Tim Colonius 25

Optimized FD schemes

•  Choose some coefficients to give a certain order of accuracy

•  Choose some coefficients to give a good modified wavenumber relation:

–  e.g. Make k’=k at some particular points –  Minimize the error in k’-k

•  Choose some coefficients to give other desirable properties –  Efficiency? –  Low storage? –  Parallalizability? –  And so on

Page 26: Unevenly Spaced Grid

Ae232a. © Tim Colonius 26

Efficiency

•  Different schemes have different operation counts

•  Real cost is CPU time to compute a derivative, can be estimated with operation count

•  Weight PPW with operation count to get normalized cost –  Aside: scheme can also impact maximum stable time step for a

given PDE. The plot on the next page accounts for this for the model advection equation, ut + ux = 0

Page 27: Unevenly Spaced Grid

Ae232a. © Tim Colonius 27

Efficiency

Ref: Colonius & Lele, Prog. Aerosp. Science, 2005