12
Computational Fluid Dynamics Computational Fluid Dynamics http://www.nd.edu/~gtryggva/CFD-Course/ Grétar Tryggvason Lecture 16 March 20, 2017 Computational Fluid Dynamics Computational Methods for Domains with Complex Boundaries http://www.nd.edu/~gtryggva/CFD-Course/ Computational Fluid Dynamics For most engineering problems it is necessary to deal with complex geometries, consisting of arbitrarily curved and oriented boundaries Computational Fluid Dynamics Overview of various strategies Boundary-fitted coordinates (revisited) Grid generation for body-fitted coordinates Cartesian Adaptive Mesh Refinement (AMR) Unstructured grids Outline How to deal with irregular domains Computational Fluid Dynamics Grid Generation From: www.imr.sandia.gov/14imr/imr14_short_course.ppt Computational Fluid Dynamics Originally, rectangular staircasingon rectangular Cartesian grids was used to represent complex boundaries This was followed by body fitted grids, the grids are still structured but grid lines are not straight. In commercial codes, unstructured grids have now mostly replaced body fitted grids Regular structured grids are still of interest, particularly when coupled with Adaptive Mesh Refinement (AMR) and immersed boundaries Various Strategies for Complex Geometries and to concentrate grid points in specific regions Overview

Computational Fluid Computational Methods …gtryggva/CFD-Course2017/Lecture-16...Computational Fluid Dynamics Staircasing Approximate a curved boundary by a the nearest grid lines

  • Upload
    others

  • View
    88

  • Download
    12

Embed Size (px)

Citation preview

Page 1: Computational Fluid Computational Methods …gtryggva/CFD-Course2017/Lecture-16...Computational Fluid Dynamics Staircasing Approximate a curved boundary by a the nearest grid lines

Computational Fluid Dynamics

Computational Fluid Dynamics

http://www.nd.edu/~gtryggva/CFD-Course/

Grétar Tryggvason

Lecture 16March 20, 2017

Computational Fluid Dynamics

Computational Methods for Domains with

Complex Boundaries

http://www.nd.edu/~gtryggva/CFD-Course/

Computational Fluid Dynamics

For most engineering problems it is necessary to deal with complex geometries, consisting of arbitrarily curved and oriented boundaries

Computational Fluid Dynamics

Overview of various strategiesBoundary-fitted coordinates (revisited)Grid generation for body-fitted coordinatesCartesian Adaptive Mesh Refinement (AMR)Unstructured grids

Outline

How to deal with irregular domains

Computational Fluid DynamicsGrid Generation

From: www.imr.sandia.gov/14imr/imr14_short_course.ppt

Computational Fluid Dynamics

Originally, rectangular “staircasing” on rectangular Cartesian grids was used to represent complex boundaries

This was followed by body fitted grids, the grids are still structured but grid lines are not straight.

In commercial codes, unstructured grids have now mostly replaced body fitted grids

Regular structured grids are still of interest, particularly when coupled with Adaptive Mesh Refinement (AMR) and immersed boundaries

Various Strategies for Complex Geometries and to concentrate grid points in specific regions

Overview

Page 2: Computational Fluid Computational Methods …gtryggva/CFD-Course2017/Lecture-16...Computational Fluid Dynamics Staircasing Approximate a curved boundary by a the nearest grid lines

Computational Fluid Dynamics

Staircasing

Approximate a curved boundary by a the nearest grid lines

Computational Fluid Dynamics

Unstructured versus structured grids

structured grids: an ordered layout of

grid points.

unstructured grids: an arbitrary layout of grid

points. Information about the layout must be provided

Unstructured Grids

Computational Fluid Dynamics

Finite Difference methods on body fitted grids are generally derived by mapping the equations

Finite Volume methods are generally derived by using arbitrarily shaped control volumes.

OverviewComputational Fluid Dynamics

Boundary-Fitted Coordinates for

Complex Domains

http://www.nd.edu/~gtryggva/CFD-Course/

Computational Fluid DynamicsBoundary-Fitted Coordinates

In many practical applications it is necessary to deal with complex domains.

For relatively simple domains, the methods that we just developed for rectangular domains and grids can be extended to non-rectangular domains through coordinate mapping.

This was the approach taken in early commercial codes and is still widely used in aerodynamics and turbomachinery computations

Computational Fluid Dynamics

x

y

Boundary-Fitted Coordinates

• Coordinate mapping: transform the domain into a simpler (usually rectangular) domain.

• Boundaries are aligned with a constant coordinate line, thus simplifying the treatment of boundary conditions

• The mathematical equations become more complicated

Page 3: Computational Fluid Computational Methods …gtryggva/CFD-Course2017/Lecture-16...Computational Fluid Dynamics Staircasing Approximate a curved boundary by a the nearest grid lines

Computational Fluid Dynamics

η

ξ

x

y

0=ξ1=ξ0=η

1=η2=η3=η

),(),( ηξ⇒yx

),( yxξξ =),( yxηη =

),(),( ηξfyxf =

Boundary-Fitted CoordinatesComputational Fluid Dynamics

f (x) = f (x(ξ)) = f (ξ)

First consider the 1D case:

Boundary-Fitted Coordinates

dfdx

=dfdξ

dξdx

=dfdξ

dxdξ

⎛⎝⎜

⎞⎠⎟

−1

For the first derivative the change of variables is straightforward using the chain rule:

For the second derivative the derivation becomes considerably more complex:

Computational Fluid Dynamics

The second derivative is given by

ξ∂∂ /x

Where we have used the expression for the fist derivative for the final step. However, since the equations will be discretized in the new grid system, it is important to end upwith terms like , not . x∂∂ /ξ

Boundary-Fitted Coordinates

dfdx

=dfdξ

dξdx

=dfdξ

dxdξ

⎛⎝⎜

⎞⎠⎟

−1

d 2 fdx2 =

ddx

dfdx

⎛⎝⎜

⎞⎠⎟=

ddx

dfdξ

dξdx

⎛⎝⎜

⎞⎠⎟

⎝⎜⎞

⎠⎟=

ddξ

dfdξ

dξdx

⎛⎝⎜

⎞⎠⎟

⎝⎜⎞

⎠⎟dξdx

⎛⎝⎜

⎞⎠⎟

=d 2 fdξ2

dξdx

⎛⎝⎜

⎞⎠⎟

2

+dfdξ

⎛⎝⎜

⎞⎠⎟

dξdx

⎛⎝⎜

⎞⎠⎟

ddξ

dξdx

⎛⎝⎜

⎞⎠⎟=

d 2 fdξ2

dξdx

⎛⎝⎜

⎞⎠⎟

2

+dfdξ

⎛⎝⎜

⎞⎠⎟

ddx

dξdx

⎛⎝⎜

⎞⎠⎟

=d 2 fdξ2

dξdx

⎛⎝⎜

⎞⎠⎟

2

+dfdξ

⎛⎝⎜

⎞⎠⎟

d 2ξdx2

Computational Fluid Dynamics

To do so, we look at the second derivative in the new system

Boundary-Fitted Coordinates

dfdξ

=dfdx

dxdξ

d 2 fdξ2 =

ddξ

dfdξ

⎛⎝⎜

⎞⎠⎟=

ddx

dfdξ

⎛⎝⎜

⎞⎠⎟

dxdξ

=ddx

dfdx

dxdξ

⎛⎝⎜

⎞⎠⎟

dxdξ

⎛⎝⎜

⎞⎠⎟

=d 2 fdx2

dxdξ

⎛⎝⎜

⎞⎠⎟

2

+dfdx

⎛⎝⎜

⎞⎠⎟

dxdξ

⎛⎝⎜

⎞⎠⎟

ddx

dxdξ

=d 2 fdx2

dxdξ

⎛⎝⎜

⎞⎠⎟

2

+dfdx

⎛⎝⎜

⎞⎠⎟

d 2xdξ2

=d 2 fdx2

dxdξ

⎛⎝⎜

⎞⎠⎟

2

+dfdξ

⎛⎝⎜

⎞⎠⎟

dxdξ

⎛⎝⎜

⎞⎠⎟

−1d 2xdξ2

d 2 fdx2 =

d 2 fdξ2

dxdξ

⎛⎝⎜

⎞⎠⎟

−2

−dfdξ

⎛⎝⎜

⎞⎠⎟

dxdξ

⎛⎝⎜

⎞⎠⎟

−3d 2xdξ2

Solving for the original derivative (which is the one we need to transform) we get:

Computational Fluid Dynamics

dxdx

=dxdξ

dξdx

= 1

dxdξ

=dξdx

⎛⎝⎜

⎞⎠⎟

−1

ddξ

dxdξ

dξdx

⎛⎝⎜

⎞⎠⎟=

d 2xdξ2

dξdx

+dxdξ

ddξ

dξdx

⎛⎝⎜

⎞⎠⎟=

d 2xdξ2

dξdx

+dxdξ

⎛⎝⎜

⎞⎠⎟

2d 2ξdx2 = 0

dxdξ

⎛⎝⎜

⎞⎠⎟

2d 2ξdx2 = −

d 2xdξ2

dξdx

= −d 2xdξ2

dxdξ

⎛⎝⎜

⎞⎠⎟

−1

d 2ξdx2 = −

d 2xdξ2

dxdξ

⎛⎝⎜

⎞⎠⎟

−3

By the chain rule we have

For the second derivative we differentiate the above:

Often we need the derivatives of the transformation itself:

Giving:

Boundary-Fitted CoordinatesComputational Fluid Dynamics

),()),(),,((),( ηξηξηξ fyxfyxf ==Change of variables

2D: First Derivatives

ξ∂∂ /x

The equations will be discretized in the newgrid system . Therefore, it is important to end upwith terms like , not .

),( ηξx∂∂ /ξ

Boundary-Fitted Coordinates

Page 4: Computational Fluid Computational Methods …gtryggva/CFD-Course2017/Lecture-16...Computational Fluid Dynamics Staircasing Approximate a curved boundary by a the nearest grid lines

Computational Fluid Dynamics

ηηη

ξξξ

∂∂

∂∂+

∂∂

∂∂=

∂∂

∂∂

∂∂+

∂∂

∂∂=

∂∂

yyfx

xff

yyfx

xff

Using the chain rule, as we did for the 1D case:

We want to derive expressions for in the mapped coordinate system.

yfxf ∂∂∂∂ /,/

Boundary-Fitted CoordinatesComputational Fluid Dynamics

ηξηξηξ ∂∂

∂∂

∂∂+

∂∂

∂∂

∂∂=

∂∂

∂∂ xy

yfxx

xfxf

ξηξηξη ∂∂

∂∂

∂∂+

∂∂

∂∂

∂∂=

∂∂

∂∂ xy

yfxx

xfxf

Solving for the derivatives

Subtracting

⎟⎟⎠

⎞⎜⎜⎝

⎛∂∂

∂∂−

∂∂

∂∂

∂∂=

∂∂

∂∂−

∂∂

∂∂

ξηηξξηηξxyxy

yfxfxf

ηηη

ξξξ

∂∂

∂∂+

∂∂

∂∂=

∂∂

∂∂

∂∂+

∂∂

∂∂=

∂∂

yyfx

xff

yyfx

xff

η∂∂x

ξ∂∂x

Boundary-Fitted Coordinates

Computational Fluid Dynamics

⎟⎟⎠

⎞⎜⎜⎝

⎛∂∂

∂∂−

∂∂

∂∂=

∂∂

⎟⎟⎠

⎞⎜⎜⎝

⎛∂∂

∂∂−

∂∂

∂∂=

∂∂

ηξξη

ξηηξ

xfxfJy

f

yfyfJx

f

1

1

( )( )ηξξηηξ ,,

∂∂=

∂∂

∂∂−

∂∂

∂∂= yxyxyx

J

Solving for the original derivatives yields:

where

is the Jacobian.

Boundary-Fitted CoordinatesComputational Fluid Dynamics

ξηξη

ηξ

ξηξη

ηξ

∂∂=

∂∂=

∂∂=

∂∂=

∂∂=

∂∂=

∂∂=

∂∂=

xx

xx

yy

yy

ff

ff

yf

fxf

f yx

;;;

;;;

A short-hand notation:

Boundary-Fitted Coordinates

Computational Fluid Dynamics

)(1

)(1

ηξξη

ξηηξ

xfxfJ

f

yfyfJ

f

y

x

−=

−=

Rewriting in short-hand notation

ξηηξ yxyxJ −=where

is the Jacobian.

Boundary-Fitted CoordinatesComputational Fluid Dynamics

fx =1J

fyη( )ξ − fyξ( )η

⎡⎣⎢

⎤⎦⎥

fy =1J

fxξ( )η− fxη( )ξ⎡

⎣⎢⎤⎦⎥

These relations can also be written in conservative form:

Boundary-Fitted Coordinates

Since:

fx =1J

fyη( )ξ − fyξ( )η

⎡⎣⎢

⎤⎦⎥ =

1J

fyηξ + fξyη − fyξη − fηyξ⎡⎣ ⎤⎦ =1J

fξyη − fηyξ⎡⎣ ⎤⎦

And similarly for the other equation

Page 5: Computational Fluid Computational Methods …gtryggva/CFD-Course2017/Lecture-16...Computational Fluid Dynamics Staircasing Approximate a curved boundary by a the nearest grid lines

Computational Fluid Dynamics

( ) ( )⎥⎥⎦

⎢⎢⎣

⎡⎟⎠⎞⎜

⎝⎛ −−⎟

⎠⎞⎜

⎝⎛ −=

⎟⎟⎠

⎞⎜⎜⎝

⎛⎟⎠⎞⎜

⎝⎛∂∂−⎟

⎠⎞⎜

⎝⎛∂∂=⎟

⎠⎞⎜

⎝⎛∂∂

∂∂=

∂∂

ξη

ξηηξηξ

ξηηξ

ξη

ηξ

yyfyfJ

yyfyfJJ

yxf

yxf

Jxf

xxf

111

12

2

The second derivatives is found by repeated application of the rules for the first derivative

( ) ( )⎥⎥⎦

⎢⎢⎣

⎡⎟⎠⎞⎜

⎝⎛ −−⎟

⎠⎞⎜

⎝⎛ −=

∂∂

ηξ

ηξξηξη

ηξξη xxfxfJ

xxfxfJJy

f 1112

2

Similarly

2D: Second Derivatives

Boundary-Fitted CoordinatesComputational Fluid Dynamics

∂2 f∂x2 =

1J

1J

fξ yη − fη yξ( )⎛⎝⎜

⎞⎠⎟ ξ

yη −1J

fξ yη − fη yξ( )⎛⎝⎜

⎞⎠⎟η

⎣⎢⎢

⎦⎥⎥

Adding

∂2 f∂y2 =

1J

1J

fηxξ − fξxη( )⎛⎝⎜

⎞⎠⎟η

xξ −1J

fηxξ − fξxη( )⎛⎝⎜

⎞⎠⎟ ξ

xη⎡

⎣⎢⎢

⎦⎥⎥

and

yields an expression for the Laplacian:

2

2

2

22

yf

xf

f∂∂+

∂∂=∇

Boundary-Fitted Coordinates

Computational Fluid Dynamics

∂2 f∂x2 +

∂2 f∂y2 =

1J

1J

fξ yη − fη yξ( )⎛⎝⎜

⎞⎠⎟ ξ

yη −1J

fξ yη − fη yξ( )⎛⎝⎜

⎞⎠⎟η

⎣⎢⎢

⎦⎥⎥+

1J

1J

fηxξ − fξxη( )⎛⎝⎜

⎞⎠⎟η

xξ −1J

fηxξ − fξxη( )⎛⎝⎜

⎞⎠⎟ ξ

xη⎡

⎣⎢⎢

⎦⎥⎥

Boundary-Fitted CoordinatesComputational Fluid Dynamics

q1 = xη2 + yη

2

q2 = xξxη + yξyηq3 = xξ

2 + yξ2

where

∇2 f =∂2 f∂x2 +

∂2 f∂y2 =

1J 2

∂∂ξ

q1 fξ − q2 fη( ) + ∂∂η

q3 fη − q2 fξ( )⎡

⎣⎢

⎦⎥

+1J 3 −q1Jξ fξ + q2 Jη fξ + q2 Jξ fη − q3Jη fη⎡⎣ ⎤⎦

Boundary-Fitted Coordinates

Computational Fluid Dynamics

∇2 f = 1J 2

q1 fξξ − 2q2 fξη + q3 fηη( ) + ∇2ξ( ) fξ + ∇2η( ) fη

Expanding the derivatives yields

where

∇2ξ = 1J 3

J xξη xη − xηη xξ − yηη yξ + yξη yη( ) − q1Jξ + q2Jη[ ]

∇2η = 1J 3

J xξη xξ − xξξ xη − yξξ yη + yξη yξ( ) + q2Jξ − q3Jη[ ]ξξηξηξηξξηξξξ yxyxyxyxJ −−+=

ξηηξηηηηξηξηη yxyxyxyxJ −−+=

Boundary-Fitted CoordinatesComputational Fluid Dynamics

( )ξηηξ yfyfJ

f x −= 1Derivation of

if

yyxx ξξξ +=∇2

ξ=f

ξx = 1Jξξ yη −ξη yξ( ) =

yηJ

hence

ξxx = ξx( )x=

1J

yηJ

⎝⎜

⎠⎟ξ

yη −yηJ

⎝⎜

⎠⎟η

⎢⎢

⎥⎥

similarly

ξyy = ξy( )y=

1J

−xηJ

⎝⎜

⎠⎟η

xξ − −xηJ

⎝⎜

⎠⎟ξ

xη⎡

⎢⎢

⎥⎥

Boundary-Fitted Coordinates

Page 6: Computational Fluid Computational Methods …gtryggva/CFD-Course2017/Lecture-16...Computational Fluid Dynamics Staircasing Approximate a curved boundary by a the nearest grid lines

Computational Fluid Dynamics

Putting them together, it can be shown that(prove it!)

∇2ξ = 1J 3

q1 xη yξξ − yη xξξ( ) − 2q2 xη yξη − yη xξη( ) + q3 xη yηη − yη xηη( )[ ]

∇2η = 1J 3

q1 yξ xξξ − xξ yξξ( ) − 2q2 yξ xξη − xξ yξη( ) + q3 yξ xηη − xξ yηη( )[ ]

Boundary-Fitted CoordinatesComputational Fluid Dynamics

gy fx − gx fy = 1Jgη fξ − gξ fη( )

We also have, for any function andf g

Boundary-Fitted Coordinates

Computational Fluid Dynamics

η

ξ

x

y

0=ξ1=ξ0=η

1=η2=η3=η ),( yxξξ = ),( yxηη =

),(),( ηξfyxf =

Summary: A complex domain can be mapped into a rectangular domain where all grid lines are straight. The equations must, however, be rewritten in the new domain.

)(1

)(1

ηξξη

ξηηξ

xfxfJ

f

yfyfJ

f

y

x

−=

−=Thus:

And more complex expressions for the higher derivatives

Boundary-Fitted CoordinatesComputational Fluid Dynamics

Vorticity-Stream Function

Formulation

Computational Fluid Dynamics

The Navier-Stokes equations in vorticity form are:

Use the transformation relations obtained earlier to write the equations in the new variables

∂ω∂t

+ψ yω x −ψ xω y = ν∇2ω

∇2ψ = −ω

Vorticity-Stream Function FormulationComputational Fluid Dynamics

The Navier-Stokes equations in vorticity form become:

∂ω∂t

+1J

(ψηωξ −ψξωη ) =

ν 1J 2 q1ωξξ − 2q2ωξη + q3ωηη( ) + ∇2ξ( )ωξ + ∇2η( )ωη

⎛⎝⎜

⎞⎠⎟

223

2

221

ξξ

ηξηξ

ηη

yxq

yyxxq

yxq

+=

+=

+=

Vorticity-Stream Function Formulation

1J 2

q1ψξξ − q2ψξη + q3ψηη( ) + ∇2ξ( )ψξ + ∇2η( )ψη = −ω

Page 7: Computational Fluid Computational Methods …gtryggva/CFD-Course2017/Lecture-16...Computational Fluid Dynamics Staircasing Approximate a curved boundary by a the nearest grid lines

Computational Fluid Dynamics

0=ψ

Boundary Conditionsη

Q=ψξ

InflowOutflow

12

2

1

2

121 )( ψψψ −==−= ∫∫ dvdxudyQη = 0, M : No− slip

1=Δ=Δ ηξ

Vorticity-Stream Function Formulation

ξ = 0 & ξ = NFor start by using periodic boundaries

Computational Fluid Dynamics

HOT21)0,(1)0,()0,()1,( ++⋅+== ξψξψξψηξψ ηηη

0=ψ

)0,()0,( 2

22

ξψξω ηηξξ

Jyx +

−=

ω(ξ,0) = −2xξ2 + yξ

2

J 2ψ(ξ,0) −ψ(ξ,1)[ ]

Lower wallStream function:Vorticity: 0= (no-slip)

( )0=η

Vorticity-Stream Function Formulation

Using that

We have:

Computational Fluid Dynamics

Q = (udy − vdx) =0

L∫ dψ =0

M∫ ψM −ψ0

Q=ψ

ω(ξ,M) = −2xξ2 + yξ

2

J 2ψ(ξ,M) −ψ(ξ,M −1)[ ]

Upper wallStream function:

Vorticity:

η = M( )

Vorticity-Stream Function FormulationComputational Fluid Dynamics

Grid Generation by Bilinear

Interpolation

Computational Fluid Dynamics

Simples grid generation is to break the domain into blocks and use bilinear interpolation within each block

As an example, we will write a simple code to grid the domain to the right

(x1,y1)

(x2,y2)(x3,y3)

(x4,y4)(x5,y5)

(x6,y6)(x7,y7)

(x8,y8)

Bilinear InterpolationComputational Fluid Dynamics

Consider an arbitrary shaped quadrilateral block1. Select the ξ and ξ direction.

(x0,y0)

(x1,y1)

(x2,y2)(x3,y3)

ξ

η

N

M2. Divide the

opposite sides evenly with N points in the ξ direction and

M in the ξ direction and draw

straights line between the points

on the opposite sides

Bilinear Interpolation

Page 8: Computational Fluid Computational Methods …gtryggva/CFD-Course2017/Lecture-16...Computational Fluid Dynamics Staircasing Approximate a curved boundary by a the nearest grid lines

Computational Fluid Dynamics

x ξ ,1( ) =N −ξN −1

⎛ ⎝

⎞ ⎠ x0 +

ξ −1N −1

⎛ ⎝

⎞ ⎠ x1

Along the edge between points 0 and 1

Along the edge between points 3 and 2

x ξ ,M( ) =N −ξN −1

⎛ ⎝

⎞ ⎠ x3 +

ξ −1N −1

⎛ ⎝

⎞ ⎠ x2

Then interpolate again for points between the edges

x ξ ,η( ) =M −ηM −1

⎛ ⎝

⎞ ⎠ N −ξN −1

⎛ ⎝

⎞ ⎠ x0 +

ξ −1N −1

⎛ ⎝

⎞ ⎠ x1

⎛ ⎝ ⎜ ⎞

⎠ +

η−1M −1

⎛ ⎝

⎞ ⎠

N −ξN −1

⎛ ⎝

⎞ ⎠ x3 +

ξ −1N −1

⎛ ⎝

⎞ ⎠ x2

⎛ ⎝ ⎜ ⎞

The y-coordinate is found in the same way

Bilinear InterpolationComputational Fluid Dynamics

x ξ ,η( ) =M −ηM −1

⎛ ⎝

⎞ ⎠ N −ξN −1

⎛ ⎝

⎞ ⎠ x0 +

ξ −1N −1

⎛ ⎝

⎞ ⎠ x1

⎛ ⎝ ⎜ ⎞

⎠ +

η−1M −1

⎛ ⎝

⎞ ⎠

N −ξN −1

⎛ ⎝

⎞ ⎠ x3 +

ξ −1N −1⎛ ⎝

⎞ ⎠ x2

⎛ ⎝ ⎜ ⎞

y ξ ,η( ) =M −ηM −1

⎛ ⎝

⎞ ⎠ N −ξN −1

⎛ ⎝

⎞ ⎠ y0 +

ξ −1N −1

⎛ ⎝

⎞ ⎠ y1

⎛ ⎝ ⎜ ⎞

⎠ +

η−1M −1

⎛ ⎝

⎞ ⎠

N −ξN −1

⎛ ⎝

⎞ ⎠ y3 +

ξ −1N −1⎛ ⎝

⎞ ⎠ y2

⎛ ⎝ ⎜ ⎞

(x0,y0)

(x1,y1)

(x2,y2)(x3,y3)

ξ

η

N

M

For a single block, we therefore have:

Bilinear Interpolation

Computational Fluid Dynamics

The grid

Bilinear InterpolationComputational Fluid Dynamics

Sometimes the grid can be improved by smoothing. The simples smoothing is to replace the coordinate of each grid point by the average of the coordinates around it. This process can be repeated several times to improve the smoothness.

Bilinear Interpolation

x i, j( ) = 0.25* x i +1, j( ) + x i −1, j( ) + x i, j +1( ) + x i, j −1( )( )y i, j( ) = 0.25* y i +1, j( ) + y i −1, j( ) + y i, j +1( ) + y i, j −1( )( )

The effect of two smoothing iterations

Computational Fluid Dynamics

Inflow and Outflow Boundary Conditions

Computational Fluid Dynamics

0=ψ

Inflow and outflow Boundary Conditionsη

Q=ψξ

InflowOutflow

12

2

1

2

121 )( ψψψ −==−= ∫∫ dvdxudyQ

slipNo: 0,Outflow:Inflow:0

−===

MN

ηξξ

1=Δ=Δ ηξ

Vorticity-Stream Function Formulation

Page 9: Computational Fluid Computational Methods …gtryggva/CFD-Course2017/Lecture-16...Computational Fluid Dynamics Staircasing Approximate a curved boundary by a the nearest grid lines

Computational Fluid Dynamics

Inlet flow

)(),0( yLCyyu −=

( )0=ξ

Considering a fully-developed parabolic profile

3

3

0

2 6;6

)(LQCLCdyyLyCQ

L==+−= ∫

ω=∂∂−=yuyLy

LQyu );(6),0( 3

⎥⎥⎦

⎢⎢⎣

⎡⎟⎠⎞⎜

⎝⎛−⎟

⎠⎞⎜

⎝⎛=−= ∫

32

0

23 23)(6)(

Ly

LyQdyyyL

LQyQ

y

Vorticity-Stream Function FormulationComputational Fluid Dynamics

Inlet flow

( ) ⎟⎠⎞⎜

⎝⎛ −==

MMLQu ηηηξ 16,0

( ) ⎟⎟⎠

⎞⎜⎜⎝

⎛⎟⎠⎞⎜

⎝⎛−⎟

⎠⎞⎜

⎝⎛=

32

23,0MM

Q ηηηψ

( ) ⎟⎠⎞⎜

⎝⎛ −=

MLQ ηηω 216,0 2

( )0=ξ

Considering a fully-developed parabolic profileand assume that

MLy η=

Vorticity-Stream Function Formulation

Computational Fluid Dynamics

Outflow

ξ

( )N=ξ

Typically, assuming straight streamlines

If is normal to the outflow boundary, this yields

0=∂∂nψ

0=∂∂ξψ

If not, then a proper transformation is needed forn∂

∂ψ

Vorticity-Stream Function FormulationComputational Fluid Dynamics

Results

Computational Fluid Dynamics

% ------------------ Set up the gridab=0.03;at=0.07; w=0.2;for i=1:Nx, s(i)=ds*(i-1);endx=zeros(Nx,Ny);y=zeros(Nx,Ny);

for i=1:Nx, xb(i)=s(i)+0.5*ab*sin(2*pi*s(i))*1.0;yb(i)=ab*cos(4*pi*s(i))*1.0;xt(i)=s(i)+0.0*at*sin(2*pi*s(i));yt(i)=w+at*cos(2*pi*s(i))*1.0;end

for i=1:Nx, for j=1:Nyx(i,j)=xb(i)+(j-1)*(xt(i)-xb(i))/(Ny-1);y(i,j)=yb(i)+(j-1)*(yt(i)-yb(i))/(Ny-1);end,end

hold onfor j=1:Ny, plot(x(1:Nx,j),y(1:Nx,j));endfor i=1:Nx, plot(x(i,1:Ny),y(i,1:Ny));endplot(xt,yt,'k','LineWidth',2), plot(xb,yb,… 'k','LineWidth',2)set(gca,'Box','on'); set(gca,'Fontsize',18, 'LineWidth',2)set(gca,'XTickLabel','')axis equal, axis([0 1 -0.1 0.3]), pause

Simple grid generation

The rest of the code is similar to the vorticity streamfunction code, except longer. The grid metrics are pre-computed

Computational Fluid DynamicsBody fitted grids

0 0.2 0.4 0.6 0.8 1−0.1

0

0.1

0.2

0.3

−0.1

0

0.1

0.2

0.3

Vorticity

Streamfunction

−0.1

0

0.1

0.2

0.3

Vorticity

Using the streamfunction vorticity formulation of the Navier Stokes equations makes it relatively straight forward to develop a code for complex boundaries.

If the boundary is known analytically and it is possible to connect two boundaries by straight lines, then the other grid lines can be generated by simple interpolation.

Page 10: Computational Fluid Computational Methods …gtryggva/CFD-Course2017/Lecture-16...Computational Fluid Dynamics Staircasing Approximate a curved boundary by a the nearest grid lines

Computational Fluid Dynamics

Velocity-Pressure Formulation

Computational Fluid Dynamics

∂u∂t

+∂uu∂x

+∂vu∂y

= −1ρ∂p∂x

+ ν ∂2u∂x2

+∂2u∂y2

⎛⎝⎜

⎞⎠⎟

∂v∂t

+∂uv∂x

+∂vv∂y

= −1ρ∂p∂y

+ ν ∂2v∂x2 +

∂2v∂y2

⎝⎜⎞

⎠⎟

The Navier-Stokes equations in primitive form

Velocity-Pressure Formulation

and continuity equation

0=∂∂+

∂∂

yv

xu

Computational Fluid Dynamics

∂uu∂x

+ ∂vu∂y

= 1J

uu( )ξ yη − uu( )η yξ + uv( )η xξ − uv( )ξ xη[ ]Advection Terms

= 1J

yηuu( )ξ − uuyξη − yξ uu( )η + uuyξη[

+ xξ uv( )η − uvxξη − xηuv( )ξ + uvxξη ]

= 1J

u uyη − vxη( ){ }ξ

+ u vxξ − uyξ( ){ }η

⎡ ⎣ ⎢

⎤ ⎦ ⎥

( ) ( )⎥⎦

⎤⎢⎣

⎡∂∂+

∂∂= uVuU

J ηξ1

Velocity-Pressure FormulationComputational Fluid Dynamics

Contravariant Velocity

ξξηη uyvxVvxuyU −=−= ;

xu,

yv,

C=ξ

UV

C=η

Unit tangent vector along C=ξ

xη ,yη( )

yη ,−xη( ) = nη Unit normal vector

ηηηη vxuyxyvuU −=−⋅= ),(),(

Therefore, is in the direction.ξUηV is in the direction.

Velocity-Pressure Formulation

Computational Fluid Dynamics

∂p∂x

= 1Jpξ yη − pη yξ( )

Pressure Term

Diffusion Term

⎥⎥⎦

⎢⎢⎣

⎡⎟⎠⎞⎜

⎝⎛∂∂−⎟

⎠⎞⎜

⎝⎛∂∂=⎟

⎠⎞⎜

⎝⎛∂∂

∂∂=

∂∂

ξη

ηξ

yxu

yxu

Jxu

xxu 12

2

= 1J1Juξ yη − uη yξ( )⎛

⎝ ⎜

⎞ ⎠ ⎟ ξ

yη −1Juξ yη − uη yξ( )⎛

⎝ ⎜

⎞ ⎠ ⎟ η

yξ⎡

⎣ ⎢

⎦ ⎥

∂2u∂y 2

= 1J1Juη xξ − uξ xη( )⎛

⎝ ⎜

⎞ ⎠ ⎟ η

xξ −1Juη xξ − uξ xη( )⎛

⎝ ⎜

⎞ ⎠ ⎟ ξ

xη⎡

⎣ ⎢

⎦ ⎥

Velocity-Pressure FormulationComputational Fluid Dynamics

∂2u∂x 2

+ ∂2u∂y 2

= 1J

∂∂ξ

⎧ ⎨ ⎩

1Juξ yη

2 − uη yξ yη − uη xξ xη + uξ xη2( )⎡

⎣ ⎢ ⎤ ⎦ ⎥

= 1J

∂∂ξ

q1uξ − q2uη( ) + ∂∂η

q3uη − q2uξ( )⎡

⎣ ⎢ ⎤

⎦ ⎥ �

+ ∂∂η

1Juη xξ

2 − uξ xξ xη − uξ yξ yη + uη yξ2( )⎡

⎣ ⎢ ⎤ ⎦ ⎥ ⎫ ⎬ ⎭

223

2

221

ξξ

ηξηξ

ηη

yxq

yyxxq

yxq

+=

+=

+=

Velocity-Pressure Formulation

Page 11: Computational Fluid Computational Methods …gtryggva/CFD-Course2017/Lecture-16...Computational Fluid Dynamics Staircasing Approximate a curved boundary by a the nearest grid lines

Computational Fluid Dynamics

∂u∂t

+ 1J

∂Uu∂ξ

+ ∂Vu∂η

⎝ ⎜

⎠ ⎟ = − 1

Jρyη

∂p∂ξ

− yξ∂p∂η

⎝ ⎜

⎠ ⎟

+νJ 2

∂∂ξ

q1uξ − q2uη( ) + ∂∂η

q3uη − q2uξ( )⎡

⎣⎢

⎦⎥

u-Momentum Equation

∂v∂t

+1J

∂Uv∂ξ

+∂Vv∂η

⎛⎝⎜

⎞⎠⎟= −

1Jρ

∂p∂η

− xη∂p∂ξ

⎛⎝⎜

⎞⎠⎟

+νJ 2

∂∂ξ

q1vξ − q2vη( ) + ∂∂η

q3vη − q2vξ( )⎡

⎣⎢

⎦⎥

v-Momentum Equation

U = uyη − vxη ; V = vxξ − uyξ( )Velocity-Pressure Formulation

Computational Fluid Dynamics

0=∂∂+

∂∂

yv

xu

Continuity Equation

Using)(1),(1 ηξξηξηηξ xfxf

Jfyfyf

Jf yx −=−=

1J(uξ yη − uη yξ ) + (vη xξ − vξ xη )[ ] = 0

Continuity equation becomes

or

uyη − vxη( )ξ + vxξ − uyξ( )η = 0

Velocity-Pressure Formulation

Computational Fluid DynamicsVelocity-Pressure Formulation

u *−un

Δt= −

1J

∂Uu∂ξ

+∂Vu∂η

&

'()

*++ν

J 2

∂∂ξ

q1uξ − q2uη( ) + ∂∂η

q3uη − q2uξ( )-

./

0

12

v *−vn

Δt= −

1J

∂Uv∂ξ

+∂Vv∂η

&

'()

*++ν

J 2

∂∂ξ

q1vξ − q2vη( ) + ∂∂η

q3vη − q2vξ( )-

./

0

12

The solution algorithm is the same as for regular grids.

un+1 y

η− vn+1x

η( )ξ+ vn+1x

ξ− un+1 y

ξ( )η= 0

un+1 − u *Δt

= −1

Jρyη

∂p∂ξ

− yξ

∂p∂η

'

()*

+,

vn+1 − v *Δt

= −1

Jρxξ

∂p∂η

− xη

∂p∂ξ

'

()*

+,

First we find the predicted velocities

Then we correct the velocity by adding the pressure

Which is fund by substituting the corrections into the incompressibility conditions

Computational Fluid Dynamics

When we work directly with the Cartesian velocity components, a colocated grid is generally used, since the velocities are no longer perpendicular to the boundary.

Velocity-Pressure Formulation

Computational Fluid Dynamics

ηξ −In the plane, a staggered grid system can be used if the contravariant velocities are used

Using this formulation, the same MAC grid and projection method can be used.

p

C=ξ

U V

C=η

Velocity-Pressure Formulation

uyη − vxη( )ξ + vxξ − uyξ( )η = 0

∂U∂ξ

+∂V∂η

= 0

Which can also be written as

The continuity equation isU = uyη − vxη;V = vxξ −uyξ

Computational Fluid Dynamics

The momentum equations can be rearranged to

⎟⎟⎠

⎞⎜⎜⎝

⎛∂∂+

∂∂−⎟⎟⎠

⎞⎜⎜⎝

⎛∂∂+

∂∂+

∂∂

ηξηξ ηηVvUv

xVuUu

ytU

J

= − q1

∂p∂ξ

− q2

∂p∂η

⎛⎝⎜

⎞⎠⎟+νJ

yη∂∂ξ

q1uξ − q2uη( ) + ∂∂η

q3uη − q2uξ( )⎡

⎣⎢

⎦⎥

⎧⎨⎪

⎩⎪

⎟⎠⎞⎜

⎝⎛ +

∂∂−⎟

⎠⎞⎜

⎝⎛ +

∂∂

tv

Jxtu

Jy ηη

U-Momentum Equation

−x η∂∂ξ

q1vξ − q2vη( ) + ∂∂η

q3vη − q2vξ( )⎡

⎣ ⎢ ⎤

⎦ ⎥ ⎫ ⎬ ⎭

Velocity-Pressure Formulation

223

2

221

ξξ

ηξηξ

ηη

yxq

yyxxq

yxq

+=

+=

+=

Page 12: Computational Fluid Computational Methods …gtryggva/CFD-Course2017/Lecture-16...Computational Fluid Dynamics Staircasing Approximate a curved boundary by a the nearest grid lines

Computational Fluid Dynamics

J ∂V∂t

+ xξ∂Uu∂ξ

+ ∂Vu∂η

⎝ ⎜

⎠ ⎟ − yξ

∂Uv∂ξ

+ ∂Vv∂η

⎝ ⎜

⎠ ⎟

= − q3

∂p∂η

− q2

∂p∂ξ

⎛⎝⎜

⎞⎠⎟+νJ

∂∂ξ

q1vξ − q2vη( ) + ∂∂η

q3vη − q2vξ( )⎡

⎣⎢

⎦⎥

⎧⎨⎪

⎩⎪

V-Momentum Equation

−yξ∂∂ξ

q1uξ − q2uη( ) + ∂∂η

q3uη − q2uξ( )⎡

⎣ ⎢ ⎤

⎦ ⎥ ⎫ ⎬ ⎭

where

u = 1JUxξ +Vxη( )

v = 1JVyη +Uyξ( )

Velocity-Pressure Formulation

223

2

221

ξξ

ηξηξ

ηη

yxq

yyxxq

yxq

+=

+=

+=

Computational Fluid Dynamics

Vi , j+1/2n+1 −Vi , j+1/2

*

Δt= −

1Jq3∂p∂η

− q2∂p∂ξ

!

"#

$

%&

!

"#

$

%&i , j+1/2

Ui+1/2, jn+1 −Ui+1/2, j

*

Δt= −

1Jq1∂p∂ξ

− q2∂p∂η

!

"#

$

%&

!

"#

$

%&i+1/2, j

Ui+1/2, j* −Ui+1/2, j

n

Δt=1J−A+D( )

!

"#

$

%&i+1/2, j

Vi , j+1/2* −Vi , j+1/2

n

Δt=1J−A+D( )

!

"#

$

%&i , j+1/2

∂U n+1

∂ξ+∂V n+1

∂η= 0

Split as before:

Derive pressure equation by substituting the correction equation into continuity

Computational Fluid Dynamics

∂U n+1

∂ξ+∂V n+1

∂η= 0

Incompressibility

Ui+1/2, jn+1 −Ui−1/2, j

n+1 +Vi , j+1/2n+1 −Vi , j−1/2

n+1 = 0

Discretize, using that 223

2

221

ξξ

ηξηξ

ηη

yxq

yyxxq

yxq

+=

+=

+=

Δξ = Δη =1

Substitute

0.1. THE NAVIER-STOKES EQUATIONS IN PRIMITIVE FORM 3

U

n+1i+1/2,j � U

⇤i+1/2,j

�t

= � 1

J

(q1@p

@⇠

� q2@p

@⌘

)

!

i+1/2,j

(18)

V

n+1i,j+1/2 � V

⇤i,j+1/2

�t

= � 1

J

(q3@p

@⌘

� q2@p

@⇠

)

!

i,j+1/2

(19)

writing out the pressure derivatives we need to account for the fact that we donot have the pressures at i + 1/2, j and i, j + 1/2 so those need to be inter-polated. Thus (@p/@⌘)i+1/2,j = (pi+1,j+1 + pi,j+1 � pi+1,j�1 � pi,j�1)/4 and(@p/@⇠)i,j+1/2 = (pi+1,j+1 + pi+1,j � pi�1,j+1 � pi�1,j)/4

U

n+1i+1/2,j � U

⇤i+1/2,j

�t

=�1

Ji+1/2,j

(q1)i+1/2,j(pi+1,j � pi,j)�

(q2)i+1/2,j((pi+1,j+1 + pi,j+1 � pi+1,j�1 � pi,j�1)/4

!(20)

V

n+1i,j+1/2 � V

⇤i,j+1/2

�t

=�1

Ji,j+1/2

(q3)i,j+1/2(pi,j+1 � pi,j)�

(q2)i,j+1/2((pi+1,j+1 + pi+1,j � pi�1,j+1 � pi�1,j)/4

!(21)

Substituting gives:

1

Ji+1/2,j

(q1)i+1/2,j(pi+1,j � pi,j)� (q2)i+1/2,j(pi+1,j+1 + pi,j+1 � pi+1,j�1 � pi,j�1)/4

!�

1

Ji�1/2,j

(q1)i�1/2,j(pi,j � pi�1,j)� (q2)i�1/2,j(pi,j+1 + pi�1,j+1 � pi,j�1 � pi�1,j�1)/4

!+

1

Ji,j+1/2

(q3)i,j+1/2(pi,j+1 � pi,j)� (q2)i,j+1/2(pi+1,j+1 + pi+1,j � pi�1,j+1 � pi�1,j)/4

!�

1

Ji,j�1/2

(q3)i,j�1/2(pi,j � pi,j�1)� (q2)i,j�1/2(pi+1,j + pi+1,j�1 � pi�1,j � pi�1,j�1)/4

!=

1

�t

U

⇤i+1/2,j � U

⇤i�1/2,j + V

⇤i,j+1/2 � V

⇤i,j�1/2

!(22)

0.1. THE NAVIER-STOKES EQUATIONS IN PRIMITIVE FORM 3

U

n+1i+1/2,j � U

⇤i+1/2,j

�t

= � 1

J

(q1@p

@⇠

� q2@p

@⌘

)

!

i+1/2,j

(18)

V

n+1i,j+1/2 � V

⇤i,j+1/2

�t

= � 1

J

(q3@p

@⌘

� q2@p

@⇠

)

!

i,j+1/2

(19)

writing out the pressure derivatives we need to account for the fact that we donot have the pressures at i + 1/2, j and i, j + 1/2 so those need to be inter-polated. Thus (@p/@⌘)i+1/2,j = (pi+1,j+1 + pi,j+1 � pi+1,j�1 � pi,j�1)/4 and(@p/@⇠)i,j+1/2 = (pi+1,j+1 + pi+1,j � pi�1,j+1 � pi�1,j)/4

U

n+1i+1/2,j � U

⇤i+1/2,j

�t

=�1

Ji+1/2,j

(q1)i+1/2,j(pi+1,j � pi,j)�

(q2)i+1/2,j((pi+1,j+1 + pi,j+1 � pi+1,j�1 � pi,j�1)/4

!(20)

V

n+1i,j+1/2 � V

⇤i,j+1/2

�t

=�1

Ji,j+1/2

(q3)i,j+1/2(pi,j+1 � pi,j)�

(q2)i,j+1/2((pi+1,j+1 + pi+1,j � pi�1,j+1 � pi�1,j)/4

!(21)

Substituting gives:

1

Ji+1/2,j

(q1)i+1/2,j(pi+1,j � pi,j)� (q2)i+1/2,j(pi+1,j+1 + pi,j+1 � pi+1,j�1 � pi,j�1)/4

!�

1

Ji�1/2,j

(q1)i�1/2,j(pi,j � pi�1,j)� (q2)i�1/2,j(pi,j+1 + pi�1,j+1 � pi,j�1 � pi�1,j�1)/4

!+

1

Ji,j+1/2

(q3)i,j+1/2(pi,j+1 � pi,j)� (q2)i,j+1/2(pi+1,j+1 + pi+1,j � pi�1,j+1 � pi�1,j)/4

!�

1

Ji,j�1/2

(q3)i,j�1/2(pi,j � pi,j�1)� (q2)i,j�1/2(pi+1,j + pi+1,j�1 � pi�1,j � pi�1,j�1)/4

!=

1

�t

U

⇤i+1/2,j � U

⇤i�1/2,j + V

⇤i,j+1/2 � V

⇤i,j�1/2

!(22)

0.1. THE NAVIER-STOKES EQUATIONS IN PRIMITIVE FORM 3

U

n+1i+1/2,j � U

⇤i+1/2,j

�t

= � 1

J

(q1@p

@⇠

� q2@p

@⌘

)

!

i+1/2,j

(18)

V

n+1i,j+1/2 � V

⇤i,j+1/2

�t

= � 1

J

(q3@p

@⌘

� q2@p

@⇠

)

!

i,j+1/2

(19)

writing out the pressure derivatives we need to account for the fact that we donot have the pressures at i + 1/2, j and i, j + 1/2 so those need to be inter-polated. Thus (@p/@⌘)i+1/2,j = (pi+1,j+1 + pi,j+1 � pi+1,j�1 � pi,j�1)/4 and(@p/@⇠)i,j+1/2 = (pi+1,j+1 + pi+1,j � pi�1,j+1 � pi�1,j)/4

U

n+1i+1/2,j � U

⇤i+1/2,j

�t

=�1

Ji+1/2,j

(q1)i+1/2,j(pi+1,j � pi,j)�

(q2)i+1/2,j((pi+1,j+1 + pi,j+1 � pi+1,j�1 � pi,j�1)/4

!(20)

V

n+1i,j+1/2 � V

⇤i,j+1/2

�t

=�1

Ji,j+1/2

(q3)i,j+1/2(pi,j+1 � pi,j)�

(q2)i,j+1/2((pi+1,j+1 + pi+1,j � pi�1,j+1 � pi�1,j)/4

!(21)

Substituting gives:

1

Ji+1/2,j

(q1)i+1/2,j(pi+1,j � pi,j)� (q2)i+1/2,j(pi+1,j+1 + pi,j+1 � pi+1,j�1 � pi,j�1)/4

!�

1

Ji�1/2,j

(q1)i�1/2,j(pi,j � pi�1,j)� (q2)i�1/2,j(pi,j+1 + pi�1,j+1 � pi,j�1 � pi�1,j�1)/4

!+

1

Ji,j+1/2

(q3)i,j+1/2(pi,j+1 � pi,j)� (q2)i,j+1/2(pi+1,j+1 + pi+1,j � pi�1,j+1 � pi�1,j)/4

!�

1

Ji,j�1/2

(q3)i,j�1/2(pi,j � pi,j�1)� (q2)i,j�1/2(pi+1,j + pi+1,j�1 � pi�1,j � pi�1,j�1)/4

!=

1

�t

U

⇤i+1/2,j � U

⇤i�1/2,j + V

⇤i,j+1/2 � V

⇤i,j�1/2

!(22)

0.1. THE NAVIER-STOKES EQUATIONS IN PRIMITIVE FORM 3

U

n+1i+1/2,j � U

⇤i+1/2,j

�t

= � 1

J

(q1@p

@⇠

� q2@p

@⌘

)

!

i+1/2,j

(18)

V

n+1i,j+1/2 � V

⇤i,j+1/2

�t

= � 1

J

(q3@p

@⌘

� q2@p

@⇠

)

!

i,j+1/2

(19)

writing out the pressure derivatives we need to account for the fact that we donot have the pressures at i + 1/2, j and i, j + 1/2 so those need to be inter-polated. Thus (@p/@⌘)i+1/2,j = (pi+1,j+1 + pi,j+1 � pi+1,j�1 � pi,j�1)/4 and(@p/@⇠)i,j+1/2 = (pi+1,j+1 + pi+1,j � pi�1,j+1 � pi�1,j)/4

U

n+1i+1/2,j � U

⇤i+1/2,j

�t

=�1

Ji+1/2,j

(q1)i+1/2,j(pi+1,j � pi,j)�

(q2)i+1/2,j((pi+1,j+1 + pi,j+1 � pi+1,j�1 � pi,j�1)/4

!(20)

V

n+1i,j+1/2 � V

⇤i,j+1/2

�t

=�1

Ji,j+1/2

(q3)i,j+1/2(pi,j+1 � pi,j)�

(q2)i,j+1/2((pi+1,j+1 + pi+1,j � pi�1,j+1 � pi�1,j)/4

!(21)

Substituting gives:

1

Ji+1/2,j

(q1)i+1/2,j(pi+1,j � pi,j)� (q2)i+1/2,j(pi+1,j+1 + pi,j+1 � pi+1,j�1 � pi,j�1)/4

!�

1

Ji�1/2,j

(q1)i�1/2,j(pi,j � pi�1,j)� (q2)i�1/2,j(pi,j+1 + pi�1,j+1 � pi,j�1 � pi�1,j�1)/4

!+

1

Ji,j+1/2

(q3)i,j+1/2(pi,j+1 � pi,j)� (q2)i,j+1/2(pi+1,j+1 + pi+1,j � pi�1,j+1 � pi�1,j)/4

!�

1

Ji,j�1/2

(q3)i,j�1/2(pi,j � pi,j�1)� (q2)i,j�1/2(pi+1,j + pi+1,j�1 � pi�1,j � pi�1,j�1)/4

!=

1

�t

U

⇤i+1/2,j � U

⇤i�1/2,j + V

⇤i,j+1/2 � V

⇤i,j�1/2

!(22)

Computational Fluid Dynamics

0.1. THE NAVIER-STOKES EQUATIONS IN PRIMITIVE FORM 3

U

n+1i+1/2,j � U

⇤i+1/2,j

�t

= � 1

J

(q1@p

@⇠

� q2@p

@⌘

)

!

i+1/2,j

(18)

V

n+1i,j+1/2 � V

⇤i,j+1/2

�t

= � 1

J

(q3@p

@⌘

� q2@p

@⇠

)

!

i,j+1/2

(19)

writing out the pressure derivatives we need to account for the fact that we donot have the pressures at i + 1/2, j and i, j + 1/2 so those need to be inter-polated. Thus (@p/@⌘)i+1/2,j = (pi+1,j+1 + pi,j+1 � pi+1,j�1 � pi,j�1)/4 and(@p/@⇠)i,j+1/2 = (pi+1,j+1 + pi+1,j � pi�1,j+1 � pi�1,j)/4

U

n+1i+1/2,j � U

⇤i+1/2,j

�t

=�1

Ji+1/2,j

(q1)i+1/2,j(pi+1,j � pi,j)�

(q2)i+1/2,j((pi+1,j+1 + pi,j+1 � pi+1,j�1 � pi,j�1)/4

!(20)

V

n+1i,j+1/2 � V

⇤i,j+1/2

�t

=�1

Ji,j+1/2

(q3)i,j+1/2(pi,j+1 � pi,j)�

(q2)i,j+1/2((pi+1,j+1 + pi+1,j � pi�1,j+1 � pi�1,j)/4

!(21)

Substituting gives:

1

Ji+1/2,j

(q1)i+1/2,j(pi+1,j � pi,j)� (q2)i+1/2,j(pi+1,j+1 + pi,j+1 � pi+1,j�1 � pi,j�1)/4

!�

1

Ji�1/2,j

(q1)i�1/2,j(pi,j � pi�1,j)� (q2)i�1/2,j(pi,j+1 + pi�1,j+1 � pi,j�1 � pi�1,j�1)/4

!+

1

Ji,j+1/2

(q3)i,j+1/2(pi,j+1 � pi,j)� (q2)i,j+1/2(pi+1,j+1 + pi+1,j � pi�1,j+1 � pi�1,j)/4

!�

1

Ji,j�1/2

(q3)i,j�1/2(pi,j � pi,j�1)� (q2)i,j�1/2(pi+1,j + pi+1,j�1 � pi�1,j � pi�1,j�1)/4

!=

1

�t

U

⇤i+1/2,j � U

⇤i�1/2,j + V

⇤i,j+1/2 � V

⇤i,j�1/2

!(22)

Resulting in a pressure equation that can be solved in standard ways

Computational Fluid Dynamics

The resulting pressure equation is similar as for regular grids and can be solved in similar ways.

Once the contravariant velocities are found, the velocities in the original coordinates can be found and plotted as before

p

C=ξ

U V

C=η

Velocity-Pressure FormulationComputational Fluid Dynamics

Overview of various strategiesBoundary-fitted coordinates (revisited)Grid generation for body-fitted coordinatesCartesian Adaptive Mesh Refinement (AMR)Unstructured grids

Outline

How to deal with irregular domains