13
Computational Fluid Dynamics Computational Fluid Dynamics http://www.nd.edu/~gtryggva/CFD-Course/ Grétar Tryggvason Lecture 15 March 20, 2017 Computational Fluid Dynamics Solving the Navier-Stokes Equations in Primitive Variables http://www.nd.edu/~gtryggva/CFD-Course/ Computational Fluid Dynamics The projection method for incompressible flows—revisited Colocated grids Methods for the incompressible Navier-Stokes Equations Moin and Kim Bell, et al Artificial compressibility Methods for all speeds Outline Computational Fluid Dynamics h u i , j n +1 = 0 Discretization in time u i, j n +1 u i , j n Δt = A i, j n −∇ h P i, j + D i, j n Summary of discrete vector equations No explicit equation for the pressure! Evolution of the velocity Constraint on velocity Computational Fluid Dynamics u i , j n +1 u i , j t Δt = −∇ h P i , j u i , j n +1 = u i, j t −Δt h P i, j u i , j t u i, j n Δt = A i, j n + D i, j n u i, j t = u i, j n + Δt A i, j n + D i, j n ( ) u i, j n +1 u i , j n Δt = A i, j n −∇ h P i, j + D i, j n Split by introducing the temporary velocity u t into and Projection Method Discretization in time Computational Fluid Dynamics u i, j n + 1 = u i , j t −Δt h P i, j h u i , j n +1 = 0 h u i , j n +1 = h u i, j t −Δt h ⋅∇ h P i, j 0 To derive an equation for the pressure we take the divergence of and use the mass conservation equation h 2 P i, j = 1 Δt h u i, j t The result is Discretization in time

Computational Fluid Solving the Dynamics Navier-Stokes ...gtryggva/CFD-Course2017/Lecture-15-2017.pdfComputational Fluid Dynamics Colocated grids Computational Fluid Dynamics Colocated

  • Upload
    others

  • View
    18

  • Download
    2

Embed Size (px)

Citation preview

  • Computational Fluid Dynamics

    Computational Fluid Dynamics

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

    Grétar Tryggvason

    Lecture 15March 20, 2017

    Computational Fluid Dynamics

    Solving theNavier-StokesEquations in

    Primitive Variables

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

    Computational Fluid Dynamics

    The projection method for incompressible flows—revisited

    Colocated grids

    Methods for the incompressible Navier-Stokes Equations Moin and Kim Bell, et al Artificial compressibility

    Methods for all speeds

    OutlineComputational Fluid Dynamics

    ∇h ⋅ui , jn +1 = 0

    Discretization in time

    ui, jn +1 − ui, j

    n

    Δt= −A i, j

    n − ∇hPi, j +Di, jn

    Summary of discrete vector equations

    No explicit equation for the pressure!

    Evolution of the velocity

    Constraint on velocity

    Computational Fluid Dynamics

    ui , jn +1 − ui , j

    t

    Δt= −∇hPi , j ⇒ ui , j

    n +1 = ui, jt − Δt ∇hPi, j

    ui , jt − ui, j

    n

    Δt= −Ai, j

    n +Di, jn ⇒ ui, j

    t = ui, jn + Δt −Ai, j

    n + Di, jn( )

    ui, jn +1 − ui, j

    n

    Δt= −A i, j

    n − ∇hPi, j +Di, jn

    Split

    by introducing the temporary velocity ut

    into

    and

    Projection Method

    Discretization in timeComputational Fluid Dynamics

    ui, jn +1 = ui, j

    t − Δt ∇ hPi, j

    ∇h ⋅ui , jn +1 = 0

    ∇h ⋅ui , jn +1 =∇h ⋅ui, j

    t − Δt ∇h ⋅∇hPi, j0

    To derive an equation for the pressure we take the divergence of

    and use the mass conservation equation

    ∇h2Pi, j =

    1Δt

    ∇h ⋅ui, jt

    The result is

    Discretization in time

  • Computational Fluid Dynamics

    ui , jn +1 = ui , j

    t − Δt ∇hPi, j

    ui , jt = ui, j

    n + Δt −Ai , jn +Di, j

    n( )

    ∇h2Pi, j =

    1Δt

    ∇h ⋅ui, jt

    1. Find a temporary velocity using the advection and the diffusion terms only:

    2. Find the pressure needed to make the velocity field incompressible

    3. Correct the velocity by adding the pressure gradient:

    Discretization in timeComputational Fluid Dynamics

    ui+1/2,j-1 pi+1,j-1pi,j-1

    vi,j-3/2

    ui+1/2,j+1

    ui+1/2,j

    pi+1,j+1pi,j+1

    vi,j+3/2

    pi+1,jpi,j

    vi,j+1/2

    vi,j-1/2

    vi-1,j-3/2

    vi-1,j+3/2

    vi-1,j+1/2

    vi-1,j-1/2

    vi-1,j-3/2

    vi-1,j+3/2

    vi-1,j+1/2

    vi-1,j-1/2

    pi-1,j-1

    pi-1,j+1

    pi-1,j

    ui-1/2,j-1

    ui-1/2,j+1

    ui-1/2,j

    ui+1/2,j-1

    ui+1/2,j+1

    ui+1/2,j

    ui+1/2,j-1

    ui+1/2,j+1

    ui+1/2,j

    The Staggered (MAC) Grid

    vi,j+1/2

    Pi,ju i-1/2,j ui+1/2,j

    vi,j-1/2

    v - cell

    u - cell

    The Staggered

    Grid

    Computational Fluid Dynamics

    Velocity and pressure Velocity and vorticity

    Computational Fluid Dynamics

    Colocated grids

    Computational Fluid Dynamics

    Colocated gridsAlthough staggered grids have been very successful, in some cases it is desirable to use co-located (or colocated) grids where all variables are located at the same physical point.

    Computational Fluid Dynamics

    vi,j+1/2

    Pi,jui-1/2,j ui+1/2,j

    vn

    uw ue

    vsvi,j-1/2

    Pi,j,ui,j,vi,j

    Colocated gridsStaggered grids

    All variables are stored at the same location

  • Computational Fluid Dynamics

    First idea: use averaging for the variables on the edges:�

    ui, j* = ui, j − ΔtA(ui, j

    n )

    ui, jn+1 = ui, j

    * − Δth(pe − pw )

    uen+1 − uw

    n+1 + vnn+1 − vs

    n+1 = 0

    pe =12pi+1, j + pi, j( )

    ui, jn+1 = ui, j

    * − Δth12pi+1, j + pi, j( ) − 12 pi, j + pi−1, j( )

    ⎛ ⎝ ⎜

    ⎞ ⎠ ⎟

    ue =12ui+1, j + ui, j( )

    ui, jn+1 = ui, j

    * − Δt2h

    pi+1, j − pi−1, j( )

    Split equations for the u velocity

    Computational Fluid Dynamics

    Substituting

    ui, jn +1 = ui, j

    * −Δt2h

    pi+1, j − pi, j−1( )into

    uen +1 − uw

    n+1 + vnn +1 − vs

    n +1 = 0

    yields

    pi+2, j + pi− 2, j + pi, j+2 + pi, j− 2 − 4 pi, j =2hΔt

    ui+1, j* − ui−1, j

    * + vi, j+1* −vi, j−1

    *( )

    ue =12ui+1, j + ui, j( ) and

    Computational Fluid Dynamics

    The pressure points are also uncoupled and the pressure field can develop oscillations

    A straight forward application discretization on colocated grids results in a very wide stencil for the pressure

    Computational Fluid Dynamics

    The remedy is to find the pressures that make the edge velocities incompressible

    Rhie and Chow. AIAA Journal. 21 (1983), 1525-1532.

    Computational Fluid Dynamics

    vn

    uw ue

    vs

    Pi,j,ui,j,vi,j

    Instead of interpolating (the final velocity)

    uen +1 = ue

    * −Δth

    pi+1, j − pi, j( )

    ue* =12ui+1, j* + ui, j

    *( )

    uen +1 =

    12ui+1, jn +1 + ui, j

    n+1( )

    interpolate (the intermediate velocity)

    and then find

    In effect, “pretend” we are using a staggered grid!

    The Rhie and Chow method

    Computational Fluid Dynamics

    uen +1 = ue

    * −Δth

    pi+1, j − pi, j( )

    uen +1 − uw

    n+1 + vnn +1 − vs

    n +1 = 0

    ue* =12ui+1, j* + ui, j

    *( )

    ue* −Δth

    pi+1, j − pi, j( )⎛ ⎝ ⎞ ⎠ − uw* −

    Δth

    pi, j − pi−1, j( )⎛ ⎝ ⎞ ⎠

    + vn* −Δth

    pi, j+1 − pi, j( )⎛ ⎝ ⎞ ⎠ − vs

    * − Δth

    pi, j − pi, j−1( )⎛ ⎝ ⎞ ⎠ = 0

    pi+1, j + pi−1, j + pi, j+1 + pi, j−1 − 4 pi, j =hΔt

    ue* − uw

    * + vn* − vs

    *( )Rearrange:

    Substitute

    whereinto

    giving

  • Computational Fluid Dynamics

    Substituting for the velocities:

    pi+1, j + pi−1, j + pi, j+1 + pi, j−1 − 4 pi, j =h2Δt

    ui+1, j* − ui−1, j

    * + vi, j+1* −vi, j−1

    *( )

    ui, jn +1 = ui, j

    * −Δt2h

    pi+1, j − pi−1, j( )

    pe =12pi+1, j + pi, j( )

    For the correction of the momentum equation we still use the average of the pressures

    giving

    Computational Fluid Dynamics

    The boundary conditions for the velocity are now very simple: The velocity at nodes on the wall is simply the wall velocity.

    The pressure boundary is more complex:

    Computational Fluid Dynamics

    Find the pressure gradient by applying the Navier-Stokes equations at a point at the boundary

    ρ∂v∂t

    + u∂v∂x

    + v∂v∂y

    ⎛ ⎝ ⎜ ⎞

    ⎠ = −

    ∂p∂y

    + µ∂ 2v∂x 2

    +∂ 2v∂y2

    ⎛ ⎝ ⎜ ⎞

    ⎠ ⎟

    At the wall, most of the terms are zero

    ∂p∂y

    = µ∂ 2v∂y 2

    pi,2 − pi,1h

    = µ∂ 2v∂y 2

    ⎞ ⎠ ⎟ i,1

    Evaluated by one-sided differences

    i,1

    i,2

    pi,2 − pi,1h

    = µ vi,1n − 2vi,2

    n + vi,3n

    h2

    Computational Fluid Dynamics

    Define:

    We can write:

    i,1

    i,2

    pi,2 − pi,1h

    = µ vi,1n − 2vi,2

    n + vi,3n

    h2

    pi,2 − pi,1 =hΔtvi,1*

    vi,1* = Δt

    hpi,2 − pi,1( ) = µΔth2 vi,1

    n − 2vi,2n + vi,3

    n( )

    Computational Fluid Dynamics

    Write the pressure equation for j=2

    pi,2 − pi,1 =hΔtvi,1*

    pi+1,2 + pi−1,2 + pi,3 + pi,1 − 4 pi,2 =h2Δt

    ui+1,2* − ui−1,2

    * + vi,3* −vi,1

    *( )

    And use

    For the pressure at j=1

    Computational Fluid Dynamics

    The algorithm is therefore:

    1. First find predicted velocities:

    ui, j* = ui, j − ΔtA(u

    n )

    2. Find pressure by solving:

    pi+1, j + pi−1, j + pi, j+1 + pi, j−1 − 4 pi, j =h2Δt

    ui+1, j* − ui−1, j

    * + vi, j+1* −vi, j−1

    *( )

    3. Correct the velocities:

    and

    ui, jn +1 = ui, j

    * −Δt2h

    pi+1, j − pi−1, j( ) and

    suitably modified at the boundaries

    vi, j* = vi, j − ΔtA(v

    n )

    vi, jn+1 = vi, j

    * −Δt2h

    pi, j+1 − pi. j−1( )

  • Computational Fluid Dynamics

    % projection method in primitive variables on a colocated mesh nx=19;ny=19;dt=0.0025;nstep=300;mu=0.1;maxit=100;beta=1.2;h=1/nx; time=0; u=zeros(nx,ny);v=zeros(nx,ny);p=zeros(nx,ny); ut=zeros(nx,ny);vt=zeros(nx,ny); u(2:nx-1,ny)=1.0; for is=1:nstep for i=2:nx-1,for j=2:ny-1 ut(i,j)=u(i,j)+dt*(-(0.5/h)*(u(i,j)*(u(i+1,j)-u(i-1,j))+v(i,j)*(u(i,j+1)-u(i,j-1)))+(mu/h^2)*(u(i+1,j)+u(i-1,j)+u(i,j+1)+u(i,j-1)-4*u(i,j))); vt(i,j)=v(i,j)+dt*(-(0.5/h)*(u(i,j)*(v(i+1,j)-v(i-1,j))+v(i,j)*(v(i,j+1)-v(i,j-1)))+ (mu/h^2)*(v(i+1,j)+v(i-1,j)+v(i,j+1)+v(i,j-1)-4*v(i,j))); end,end vt(2:nx-1,1)=(mu*dt/h^2)*(v(2:nx-1,3)-2*v(2:nx-1,2)); vt(2:nx-1,ny)=(mu*dt/h^2)*(v(2:nx-1,ny-2)-2*v(2:nx-1,ny-1)); ut(1,2:ny-1)=(mu*dt/h^2)*(u(3,2:ny-1)-2*u(2,2:ny-1)); ut(nx,2:ny-1)=(mu*dt/h^2)*(u(nx-2,2:ny-1)-2*u(nx-1,2:ny-1)); for it=1:maxit % solving for pressure p(2:nx-1,1)=p(2:nx-1,2)+(h/dt)*vt(2:nx-1,1); p(2:nx-1,ny)=p(2:nx-1,ny-1)-(h/dt)*vt(2:nx-1,ny); p(1,2:ny-1)=p(2,2:ny-1)+(h/dt)*ut(1,2:ny-1); p(nx,2:ny-1)=p(nx-1,2:ny-1)-(h/dt)*ut(nx,2:ny-1); for i=2:nx-1,for j=2:ny-1 p(i,j)=beta*0.25*(p(i+1,j)+p(i-1,j)+p(i,j+1)+p(i,j-1)- (0.5*h/dt)*(ut(i+1,j)-ut(i-1,j)+vt(i,j+1)-vt(i,j-1)))+(1-beta)*p(i,j); end,end

    p(floor(nx/2),floor(ny/2))=0.0; % set the pressure in the center. Needed since bc is not incorporated into eq end u(2:nx-1,2:ny-1)=ut(2:nx-1,2:ny-1)-(0.5*dt/h)*(p(3:nx,2:ny-1)-p(1:nx-2,2:ny-1)); v(2:nx-1,2:ny-1)=vt(2:nx-1,2:ny-1)-(0.5*dt/h)*(p(2:nx-1,3:ny)-p(2:nx-1,1:ny-2)); time=time+dt hold off,quiver(flipud(rot90(u)),flipud(rot90(v)),'r'); hold on;axis([1 nx 1 ny]);axis square,pause(0.01) end plot(10*u(floor(ny/2),1:nx)+floor(nx/2),1:nx),hold on; plot([1,nx],[floor(ny/2),floor(ny/2)]),plot([floor(nx/2),floor(nx/2)],[1,ny]) plot(10*v(1:nx,floor(ny/2))+floor(ny/2));axis square,axis([1,nx, 1,ny])

    Computational Fluid Dynamics

    Colocated grids

    2 4 6 8 10 12 14 16 18

    2

    4

    6

    8

    10

    12

    14

    16

    18

    Re=10

    Computational Fluid Dynamics

    Why colocated grids:Sometimes simpler for body fitted gridsEasy to use methods for hyperbolic equationsEasier to implement AMRSome people just don’t like staggered grids!

    Computational Fluid Dynamics

    The two-dimensional programs developed in the project and shown here can be extended to fully three-dimensional flows in a relatively straight forward way, replacing u(i,j) by u(i,j,k), etc. The time required to run the code increases significantly and visualizing the output becomes more challenging.

    Computational Fluid Dynamics

    Higher Order in Time

    Computational Fluid Dynamics

    Forward in time, centered in space (summary):

    u* −u n

    Δt= −A u n( ) + ν∇2u n

    ∇2p = 1Δt

    ∇ ⋅u*

    u n+1 = u* −Δt∇p

    U 2 =max(u2 + v 2)

    Time step limitations

    where

    Δtadv ≤2νU 2

    & Δtdiff ≤14h2

    ν

    τ = LU

    Δt '= Δtτ

    ≤ 2νU 2

    UL

    = 2Re

    Δt '= Δtτ

    ≤ 14h2

    νUL

    = 14

    hL

    ⎛ ⎝ ⎜

    ⎞ ⎠ ⎟ 2

    Re

    Therefore the nondimensional time step is:

    And Δt à 0 for Re à 0 and Re à ∞

    and

    Define

  • Computational Fluid Dynamics

    Forward in time, centered in space:

    Δt '= 2Re

    Δt '= 14hL

    ⎛ ⎝ ⎜

    ⎞ ⎠ ⎟ 2

    Re

    What is the maximum timestep?

    Δt à 0 for Re à 0 and Re à ∞

    and

    Increasing h

    h à 0 Re

    Δt’

    Δt 'max =12hL�

    ReΔt ' max = 8Lh

    Computational Fluid Dynamics

    Second order in time—Predictor-Corrector

    u* −u n

    Δt= −∇u nu n + ν∇2u n

    ∇2p* = 1Δt

    ∇ ⋅u*

    u1 = u* −Δt∇p*

    u ** − u1

    Δt= −∇u1u1+ν∇2u1

    ∇2p** = 1Δt

    ∇⋅u **

    u 2 = u ** − Δt∇p**

    u n+1 = 12u n + u 2( )

    Then average the results

    Backward step using the predicted velocity:

    A second order method can be developed by first taking a forward step, then a backward step and average the results:

    Computational Fluid Dynamics

    Advanced Solvers

    For low Re, use implicit methods for diffusion termFor high Re, use stable advection schemes

    Combine both for schemes intended for all Re

    Computational Fluid Dynamics

    Other Methods

    Computational Fluid Dynamics

    Fully Implicit

    un +1 − un

    Δt=12

    − A (un ) +A(un +1)( ) +ν ∇h2un + ∇ h2un+1( )[ ] −∇p∇ ⋅un+1 = 0

    Solve by iteration

    Rarely used due to the complications of the nonlinear system that must be solved for the advection terms

    Computational Fluid Dynamics

    Adam-Bashford/Crank-Nicolson

    un +1 − un

    Δt= −

    32A(un ) − 1

    2A(un−1)⎛ ⎝

    ⎞ ⎠ +

    ν2

    ∇h2un + ∇ h

    2un+1( ) −∇p∇ ⋅un+1 = 0

    ˜ u −un

    Δt= − 3

    2A (un ) − 1

    2A (un−1)⎛ ⎝

    ⎞ ⎠ +

    ν2∇ h

    2un

    un +1 - ˜ u Δt

    = −∇p + ν2∇ h

    2un+1

    ∇ ⋅un+1 = 0

    ∇ h2p = 1

    Δt∇ ⋅ ˜ u

    Split:

    The correction equation is implicit and must be solved by an iteration in the same way as the pressure equation

  • Computational Fluid Dynamics

    Method of Kim and Moin (JCP 59 (1985), 8-23)

    ˜ u −un

    Δt= − 3

    2A (un ) − 1

    2A (un−1)⎛ ⎝

    ⎞ ⎠ +

    ν2

    ∇ h2un + ∇h2 ˜ u ( )

    un +1 − ˜ u Δt

    = −∇φ

    ∇ ⋅un+1 = 0

    ∇ h2φ =

    1Δt

    ∇⋅ ˜ u

    The first equation is implicit and must be solved by an iteration in the same way as the pressure equation

    Computational Fluid Dynamics

    un +1 − un

    Δt= −

    32

    A(un ) − 12

    A(un−1)⎛ ⎝ ⎞ ⎠ +

    ν2

    ∇h2un + ∇ h

    2un+1( ) + ν2 ∇h2 ˜ u −∇ h

    2un+1( ) −∇φ

    ν2∇h

    2 ˜ u −∇ h2un+1( ) −∇φ = ν2∇ h

    2φ −∇φ = ∇p

    Where we have added and subtracted an implicit diffusion term.

    un +1 − ˜ u Δt

    = −∇φ

    we can rewrite the last terms as:

    ∇p

    Using

    Notice that Φ is not exactly p. Adding the first two equations gives

    Computational Fluid Dynamics

    Method of Bell, Colella and Glaz (JCP 85 (1989), 7-83)

    un +1 − un

    Δt= −A (un+1/ 2) + ν

    2∇ h2un + ∇h

    2un +1( ) − ∇p∇ ⋅un+1 = 0

    A Godunov method is used for the advection terms

    Computational Fluid Dynamics

    The Artificial Compressibility Method (Chorin, 1967, JCP 2, 12-26)

    ∂u∂t

    = −A(u) + ν∇2u − ∇p

    ∂ p∂t

    =−1ε∇ ⋅u

    ε is a numerical parameter, in effect an artificial velocity of sound. At steady state

    ∇ ⋅u = 0

    ∂u∂t

    = −A(u) + ν∇2u − ∇p − 12∇ ⋅u( )u

    Sometimes we keep additional terms

    ∂u∂t

    = −A(u) + ν∇2u − ∇p − 12∇ ⋅u( )u − 1

    ε∇ ∇ ⋅u( )

    Computational Fluid Dynamics

    Many other methods have been proposed

    SIMPLE (Semi-Implicit Method for Pressure-Linked Equations). One of the earliest method for steady state problems. Many extensions.

    PISO (Pressure Implicit with Split Operator). Similar to the projection method but iterates to enforce incompressibility

    Computational Fluid Dynamics

    The SIMPLE (Semi-Implicit Method for Pressure Linked Equations) family of methods for the steady state solution

    At steady state we have

    0 = −A(u) + ν∇2u − ∇p∇ ⋅u = 0

    apu p = alulneighbours∑ −∇ph

    ∇ ⋅u = 0

    After discretization the momentum equation can be written as:

    Where the sum is over nonlinear terms since the coefficients depend on the velocity

  • Computational Fluid Dynamics

    In SIMPLE based methods we solve the discrete momentum equation

    approximately using an estimation of the pressure and then correct it by adding pressure.

    Since the momentum equation is an approximation, this is not the final velocity and we therefore continue iterating until convergence

    apu p = alul

    neighbours∑ −∇ph

    p = p* + p 'u = u* + u '

    ∇2 p ' = − 1

    Δt∇ ⋅u p

    *

    Computational Fluid Dynamics

    The SIMPLE Algorithm:

    1.  Guess the pressure field p*

    2.  Solve the momentum equations to get u* and v* (using u to find ap)

    3.  Solve for p’

    4.  Compute new pressure

    5.  Compute new velocity

    6.  Take the corrected pressure as the new guess p* and go to step 2, using the new velocity for the coefficient

    u p = u p

    * − ∇ph

    p = p* + p '

    ∇2 p ' = − 1

    Δt∇ ⋅u*

    apu p

    * = alul*

    neighbours∑ −∇ph*

    In the original SIMPLE method we drop this term

    Computational Fluid Dynamics

    There is no good reason for neglecting the neighboring points in step 2 when updating the velocities (except that they are not known!) and in the SIMPLEC (SIMPLE Corrected) the neighboring velocities are estimated using the values from the last iteration.

    In SIMPLER (SIMPLE Revisited) method pressure is found from the new velocity.

    In the PISO (Pressure Implicit with Splitting of Operators) method the first estimate for the velocities is followed by another one where the preliminary velocities are used to get a better estimate.

    Computational Fluid Dynamics

    Higher orderin time for the pressure-

    velocity formulation

    Computational Fluid Dynamics

    u * − u n12 Δt

    = −∇u nu n +ν∇2u n

    ∇2p* = 2Δt

    ∇⋅u *

    u1 = u * − Δt2∇p*

    u ** − u n12 Δt

    = −∇u1u1+ν∇2u1

    ∇2p** = 2Δt

    ∇⋅u **

    u 2 = u ** − Δt2∇p**

    continue for the second step:

    First a half step:A complete Runge-Kutta time integration (Weinan E.)

    Computational Fluid Dynamics

    u *** − u n

    Δt= −∇u 2u 2 +ν∇2u 2

    ∇2p*** = 1Δt

    ∇⋅u ***

    u 3 = u *** − Δt∇p***

    k = Δt −∇u 3u 3 +ν∇2u 3( )

    u+ = 13 −un + u1+ 2u 2 + u 3( ) + 16 k

    ∇2p+ = 1Δt

    ∇⋅u+

    u n+1 = u+ − Δt∇p+

    And finally

    Then compute

    Take a full step using the predicted velocity

    A complete Runge-Kutta time integration (continued)

  • Computational Fluid Dynamics

    u * − u n12 Δt

    = −∇u nu n +ν∇2u n

    u ** − u *12 Δt

    = −∇u *u * +ν∇2u *

    u *** − u n

    Δt= −∇u *u * +ν∇2u *

    u+ = 13 −un + u * + 2u ** + u ***( ) + Δt6 −∇u

    ***u *** +ν∇2u ***( )

    ∇2p+ = 1Δt

    ∇⋅u+

    u n+1 = u+ − Δt∇p+

    Simplified Fourth order method

    Computational Fluid Dynamics

    Boundary conditionsInflow and outflow

    Computational Fluid Dynamics

    Boundary conditions

    Fully enclosed flowDriven cavity

    Internal flow (inflow & outflow)

    External flowFlow over bodies

    Computational Fluid Dynamics

    For fully enclosed domains, such as in the driven cavity problem, the application of the boundary conditions is relatively straight forward.

    For domains with inflows it is usually reasonable to specify the velocity profile at the inlet

    The major problem is how to handle outflow boundaries in such a way that the fluid leaves in a “physically plausible” way

    Computational Fluid Dynamics

    The Backward Facing Step Problem

    Velocity given

    u = u(y)v = 0

    ∂u∂x

    = 0

    ∂v∂x

    = 0

    Computational Fluid Dynamics

    u

    vnx+1,j

    P

    unx,j Pnx,j

    u P

    v

    u

    unx+1,j

    u

    vnx+2,j

    vv(nx+2,1:ny+1)=v(nx+1,1:ny+1);

    u(nx+1,j)=u(nx,j);

    p(nx,j)=(1/2)*(p(nx,j+1)+p(nx,j-1)-(h/dt)*(v(nx+1,j+1)-v(nx+1,j)));

    ∂u∂x

    = 0

    ∂v∂x

    = 0

    For the pressure, obtain an equation by applying conservation of mass to the control volume next to the boundary

  • Computational Fluid Dynamics

    Example

    Computational Fluid Dynamics

    Simplified Backward Facing Step Problem

    Velocity given

    u = u(y)v = 0

    ∂u∂x

    = 0

    Velocity gradient given

    ∂v∂x

    = 0

    Computational Fluid Dynamics

    0 5 10 15 20 25 30 350

    2

    4

    6

    8

    10

    12

    14

    16

    18

    20

    Velocity

    Computational Fluid Dynamics

    5 10 15 20 25 30

    2

    4

    6

    8

    10

    12

    14

    16

    18

    Velocity+vorticity

    Computational Fluid Dynamics

    05

    1015

    20

    0

    10

    20

    30

    40-2.5

    -2

    -1.5

    -1

    -0.5

    0

    0.5

    Pressure

    Inflow

    Computational Fluid Dynamics

    Periodic Boundary conditionsIn many cases it is possible to use periodic boundary conditions, where what flows out through one boundary reappears flowing in through the opposite boundary. Such conditions are particularly suitable for theoretical studies of idealized flows. For such boundaries it is easiest to specify the pressure drop, but by adjusting the pressure gradient it is possible to specify the volume flux

  • Computational Fluid Dynamics

    External flow

    Free outflow

    Free stream (uniform flow, for example)

    Boundary of computational domain

    Computational Fluid Dynamics

    Other ways to deal with free-stream boundaries

    Include potential flow perturbationCompute flow from vorticity distributionMap the boundary at infinity to a finite distance

    Fundamentally, the specification of the boundary conditions does not have a unique solution and is also faced by experimentalists. However, by taking the boundaries far away and checking the solution for the effect of moving the boundaries, good results can be obtained

    Computational Fluid Dynamics

    For compressible flow the challenges are even greater since reflected waves can propagate upstream. Two main approaches are in use:

    Non-reflecting boundary conditions where characteristics or the linearized equations are used to specify the boundary state, and

    Absorption or damping layers where the solution is smoothed out gradually to minimize reflected waves

    Computational Fluid Dynamics

    The Advection

    Terms

    Computational Fluid Dynamics

    The advection terms can be written in several different forms

    ∇⋅uu = u ⋅∇u = 12u ⋅∇u+ 1

    2∇⋅uu

    =12∇ u ⋅u( )+ ∇×u( )×u = 12∇ u ⋅u( )+w×u

    ∂ρu∂t

    +∇⋅ρuu = ρ ∂u∂t+u ⋅∇u

    ⎝⎜

    ⎠⎟= ρ

    ∂u∂t+∇⋅uu

    ⎝⎜

    ⎠⎟

    Using mass conservation

    Using incompressibility

    w =∇×u

    For incompressible flows we can rewrite the nonlinear term in several ways:

    Most forms seem to give comparable results

    Here

    Computational Fluid Dynamics

    Methods for all speeds

  • Computational Fluid Dynamics

    Compressible low speed flows pose a particular challenge since the sound speed is very fast and the time step limitations can therefore be very severe. A number of methods have been proposed to handle both incompressible and compressible flowsMost of them use the energy equation in terms of the time derivative of the pressure

    Computational Fluid Dynamics

    Yabe’s Method ∂ρ∂t+∇⋅ρu = 0

    ∂u∂t+u ⋅∇u = −1

    ρ∇p

    ∂p∂t+u ⋅∇p = −ρc2∇⋅u

    ρ* − ρn

    Δt= −un ⋅∇ρn

    u* −un

    Δt= −un ⋅∇un

    p* − pn

    Δt= −un ⋅∇pn

    ρn+1 − ρ*

    Δt= −ρ*∇⋅un+1

    un+1 −u*

    Δt=−1ρ*∇pn+1

    pn+1 − p*

    Δt= −ρ*c2∇⋅un+1

    Split the equations

    Seong Y. Yoon and T. Yabe. The unified simulation for incompressible and compressible flow by the predictor-corrector scheme based on the CIP method. Computer Physics Communications 119 (1999) 149-158

    Use the governing equations in non-conservative from

    and

    Computational Fluid Dynamics

    ρ* − ρn

    Δt= −un ⋅∇ρn

    u* −un

    Δt= −un ⋅∇un

    p* − pn

    Δt= −un ⋅∇pn

    ρn+1 − ρ*

    Δt= −ρ*∇⋅un+1

    un+1 −u*

    Δt=−1ρ*∇pn+1

    pn+1 − p*

    Δt= −ρ*c2∇⋅un+1

    !u−u*

    Δt=−1ρ*∇p*

    δ p = pn+1 − p*

    un+1 − !uΔt

    =−1ρ*

    ∇pn+1 −∇p*( ) = −∇δ pρ*

    Split momentum again

    and

    whereTake divergence of the correction equation

    ∇⋅ un+1 − !u = −Δt ∇δ pρ*

    ⎝⎜

    ⎠⎟

    and

    Computational Fluid Dynamics

    ∇⋅ un+1 − !u = −Δt ∇δ pρ*

    ⎝⎜

    ⎠⎟ ∇⋅un+1 −∇⋅ !u = −Δt ∇⋅ ∇δ p

    ρ*⎛

    ⎝⎜

    ⎠⎟

    pn+1 − p*

    Δt= −ρ*c2∇⋅un+1 ∇⋅un+1 = − p

    n+1 − p*

    ρ*c2Δt= −

    δ pρ*c2Δt

    −δ p

    ρ*c2Δt−∇⋅ !u = −Δt ∇⋅ ∇δ p

    ρ*⎛

    ⎝⎜

    ⎠⎟

    ∇⋅∇δ pρ*

    ⎝⎜

    ⎠⎟−

    δ pρ*c2Δt

    =∇⋅ !u

    Rewrite the pressure equation

    substitute

    or

    or

    Rearrange:

    Computational Fluid Dynamics

    ρ* = ρn −Δtun ⋅∇ρn

    u* = un −Δtun ⋅∇un

    p* = pn −Δtun ⋅∇pn

    ∇⋅∇δ pρ*

    ⎝⎜

    ⎠⎟−

    δ pρ*c2Δt

    =∇⋅ !u

    ρn+1 = ρ* −Δt ρ*∇⋅un+1

    un+1 = !u− Δtρ*∇δ p

    pn+1 = p* +δ p

    The steps are

    Predictor step

    Solve pressure equation

    Corrector step

    !u = u* − Δtρ*∇p*Preliminary velocity

    Computational Fluid Dynamics

    Kwatra’s Method ∂ρ∂t+∇⋅ρu = 0

    ∂ρu∂t

    +∇⋅ρuu = −∇p

    ∂E∂t

    +∇⋅Eu = −∇⋅ pu

    Use the governing equations in conservative form

    Nipun Kwatra, Jonathan Su, Jo ́n T. Gre ́tarsson, and Ronald Fedkiw. A method for avoiding the acoustic time step restriction in compressible flow. Journal of Computational Physics 228 (2009) 4146–4161

    ∂p∂t+u ⋅∇p = −ρc2∇⋅u

    Supplemented by the pressure equations

  • Computational Fluid Dynamics

    ρn+1 − ρn

    Δt= −un ⋅∇ρn

    ρn+1un+1 − ρn+1u*

    Δt= −∇p

    En+1 − E*

    Δt= −∇⋅ pun

    ρn+1u* − ρnun

    Δt= −∇ρnunun

    E* − En

    Δt= −∇⋅Enun

    un+1 = u* − Δtρn+1

    ∇p

    Start by finding the new density

    Then split the momentum and energy equation

    and

    The corrected velocity is given by

    Computational Fluid Dynamics

    ∂p∂t+u ⋅∇p = −ρc2∇⋅u

    ∇⋅un+1 =∇⋅u* −Δt∇⋅ ∇pρn+1⎛

    ⎝⎜

    ⎠⎟

    ∇⋅u ≈ ∇⋅un+1

    ∂p∂t+u ⋅∇p = ρc2∇⋅u* −Δtρc2∇⋅ ∇p

    ρn+1⎛

    ⎝⎜

    ⎠⎟

    pn+1 − pn

    Δt+u ⋅∇p = ρc2∇⋅u* −Δtρc2∇⋅ ∇p

    n+1

    ρn+1⎛

    ⎝⎜

    ⎠⎟

    The divergence of the corrected velocity is:

    Take in the pressure equation

    Use the pressure equation to eliminate the divergence at n+1

    Approximate the time derivative by an Euler step

    Computational Fluid Dynamics

    The steps are:

    ρn+1 = ρn −Δt un ⋅∇ρn

    u* = ρn

    ρn+1un − Δt

    ρn+1∇ρnunun

    E* = En −Δt ∇⋅Enun

    Predictor step

    Δtρc2∇⋅ ∇pn+1

    ρn+1⎛

    ⎝⎜

    ⎠⎟+pn+1 − pn

    Δt= −u ⋅∇p+ ρc2∇⋅u*Pressure equation

    un+1 = u* − Δtρn+1

    ∇p

    En+1 = E* −Δt ∇⋅ punCorrector equation

    Computational Fluid Dynamics

    Several other methods have been proposed for all speed flows, based on similar considerations