Week 9
Week 9
11
    10 ai,j ui,j = bi,j ui+1,j + ci,j ui−1,j + (di,j ūi,j+1 + ei,j ūi,j−1 + fi,j )
Here ū is the currently available value in storage and all the coefficients including
fi,j are known. for each j, we shall get a system of equations if we susbtitute
i = 2......L − 1. In other words, for each j, a tridiagonal matrix is available
which can be solved for all i row of points at that j. Once one complete row is
evaluated for any particular j, the next j will be taken up, and so on.
(b) Horizontal Sweep Forward may be written in pseudo FORTRAN code as
                                  DO 20 I = 2, L - 1
                                  DO 20 J = 2, M - 1
    20 ai,j ui,j = di,j ui,j+1 + ei,j ui,j−1 + (bi,j ūi+1,j + ci,j ūi−1,j + fi,j )
 Again ū is the currently available value in storage from previous calculations.
For each i, we get a system of equation if we substitute j = 2....M − 1. A
tridiagonal matrix is available for each i. Once one complete column of points
are evaluated for any particular i, the next i will be taken up and so on. The
vertical sweep upward and downward are repeated. Similarly the horizontal
sweep forward and rearward are also repeated until convergence is achieved.
For solving tridiagonal system, the tridiagonal matrix algorithm (TDMA) due
to Thomas (1949) is deployed. The above mentioned evaluation procedure is
known as line-by-line TDMA.
                       M
                                           N i,j+1
                     M−1
                                 W         P i,j        E
                                        i−1,j           i+1,j
                                           S
                        2
                                                i,j−1
                 j
                         1
                             1      2              L−1          L
with a Poisson equation for the pressure and momentum equations for the
computation of velocity. It was basically developed to solve problems with
free surfaces, but can be applied to any incompressible fluid flow problem. A
modified version of the original MAC method due to Hirt and Cook (1972) has
been used by researchers to solve a variety of flow problems.
    The text discusses the modified MAC method and highlights the salient
features of the solution algorithm so that the reader is able to write a com-
puter program with some confidence. The important ideas on which the MAC
algorithm is based are:
  1. Unsteady Navier-Stokes equations for incompressible flows in weak con-
     servative form and the continuity equation are the governing equations.
  2. Description of the problem is elliptic in space and parabolic in time. Solu-
     tion will be marched in the time direction. At each time step, a converged
     solution in space is obtained but this converged solution at a time step
     may not be the solution of the physical problem.
  3. If the problem is steady, in its physical sense, then after a finite number
     of steps in time direction, two consecutive time steps will show identical
     solutions. However, in a machine-computation this is not possible hence a
     very small upper bound, say, “STAT” is predefined. Typically, STAT may
     be chosen between 10−3 and 10−5 . If the maximum discrepency of any
     of the velocity components for two consecutive time steps at any location
     over the entire space does not exceed STAT, then it can be said that the
     steady solution has evolved.
                                                 Solution of Navier-Stokes.. 6.13
                   ũn+1      n
                     i,j,k − ui,j,k                               n
                                      = [CON DIF U − DP DX]i,j,k
                         ∆t
   or
                                                                      n
                 ũn+1      n
                   i,j,k = ui,j,k + ∆t [CON DIF U − DP DX]i,j,k                 (6.19)
                               n
   [CON DIF U − DP DX]i,j,k consists of convective and diffusive terms,
                                                                               n+1
   and the pressure gradient. Similarly, the provisional values for ṽi,j,k        and
     n+1
   w̃i,j,k can be explicitly computed. These explicitly advanced velocity com-
   ponents may not constitute a realistic flow field. A divergence-free velocity
   field has to exist in order to describe a plausible incompressible flow situa-
   tion. Now, with these provisional ũn+1         n+1         n+1
                                         i,j,k , ṽi,j,k and w̃i,j,k values, continuity
   equation is evaluated in each cell. If (∇ · V ) produces a nonzero value,
   there must be some amount of mass accumulation or annihilation in each
   cell which is not physically possible. Therefore the pressure at any cell is
   directly linked with the value of the (∇·V ) of that cell. Now, on one hand
   the pressure has to be calculated with the help of the nonzero divergence
   value and on the other, the velocity components have to be adjusted.
   The correction procedure continues through an iterative cycle untill the
   divergence-free velocity field is ensured. Details of the procedure will be
   discussed in the subsequent section.
6. Boundary conditions are to be applied after each explicit evaluation for
   the time step is accomplished. Since the governing equations are elliptic in
   space, boundary conditions on all confining surfaces are required. More-
   over, the boundary conditions are also to be applied after every pressure-
   velocity iteration. The five types of boundary conditions to be considered
6.14 Computational Fluid Dynamics
      are rigid no-slip walls, free-slip walls, inflow and outflow boundaries, and
      periodic (repeating) boundaries.
                                                     ui,j+1,k
                                         vi,j,k
                                                                 vi+1,j.k
                                                                                δy
                                       θi,j.k
                                        p            ui,j.k                  ui+1,j,k
                          ui−1,j,k        i,j.k                 vi+1,j−1,k
                              wi,j.k−1    vi,j−1,k
                                                                             δz
δx ui,j−1,k
              ∂(u2 )    1
                     =     [(ui,j,k + ui+1,j,k )(ui,j,k + ui+1,j,k )
               ∂x      4δx
                         + α|(ui,j,k + ui+1,j,k )|(ui,j,k − ui+1,j,k )
                          − (ui−1,j,k + ui,j,k )(ui−1,j,k + ui,j,k )
                          − α|(ui−1,j,k + ui,j,k )|(ui−1,j,k − ui,j,k )
                     ≡ DU U DX
            ∂(uv)    1
                  =     [(vi,j,k + vi+1,j,k )(ui,j,k + ui,j+1,k )
             ∂y     4δy
                      + α|(vi,j,k + vi+1,j,k )|(ui,j,k − ui,j+1,k )
                        − (vi,j−1,k + vi+1,j−1,k )(ui,j−1,k + ui,j,k )
                        − α|(vi,j−1,k + vi+1,j−1,k )|(ui,j−1,k − ui,j,k )
                   ≡ DU V DY
6.16 Computational Fluid Dynamics
            ∂(uw)    1
                  =     [(wi,j,k + wi+1,j,k )(ui,j,k + ui,j,k+1 )
              ∂z    4δz
                      + α|(wi,j,k + wi+1,j,k )|(ui,j,k − ui,j,k+1 )
                      − (wi,j,k−1 + wi+1,j,k−1 )(ui,j,k−1 + ui,j,k )
                         − α|(wi,j,k−1 + wi+1,j,k−1 )|(ui,j,k−1 − ui,j,k )
                   ≡ DU W DZ
                         ∂p   pi+1,j,k − pi,j,k
                            =                   ≡ DP DX
                         ∂x          δx
with
Factor α is chosen in such a way that the differencing scheme retains “some-
thing” of second-order accuracy and the required upwinding is done for the
sake of stability. A typical value of α is between 0.2 and 0.3. As mentioned
earlier, the quantity ũn+1
                        i,j,k is now evaluated explicitly from the discretized form
of Equation (6.2) as
                                                                 n
                  ũn+1      n
                    i,j,k = ui,j,k +δt [CON DIF U − DP DX]i,j,k
where
Similarly, we evaluate
                     n+1      n                                 n
                   ṽi,j,k = vi,j,k +δt [CON DIF V − DP DY ]i,j,k            (6.20)
                   n+1      n                                 n
                 w̃i,j,k = wi,j,k +δt [CON DIF W −      DP DZ]i,j,k          (6.21)
                                                          Solution of Navier-Stokes.. 6.17
As discussed earlier, the explicitly advanced tilde velocities may not necessarily
lead to a flow field with zero mass divergence in each cell. This implies that, at
this stage the pressure distribution is not correct, the pressure in each cell will
be corrected in such a way that there is no net mass flow in or out of the cell.
In the original MAC method, the corrected pressures were obtained from the
solution of a Poisson equation for pressure. A related technique developed by
Chorin (1967) involved a simultaneous iteration on pressure and velocity com-
ponents. Vieceli (1971) showed that the two methods as applied to MAC are
equivalent. We shall make use of the iterative correction procedure of Chorin
(1967) in order to obtain a divergence-free velocity field. The mathematical
methodology of this iterative pressure-velocity correction procedure will be dis-
cussed herein.
The relationship between the explicitly advanced velocity component and ve-
locity at the previous time step may be written as
                                [pni,j,k − pni+1,j,k ]
        ũn+1      n
          i,j,k = ui,j,k + δt                          + δt [CON DIF U ]ni,j,k     (6.22)
                                         ∆x
where [CON DIF U ]ni,j,k is only the contribution from convection and diffusion
terms. On the other hand, the corrected velocity component (unknown) will be
related to the corrected pressure (also unknown) in the following way:
                                [pn+1      n+1
                                  i,j,k − pi+1,j,k ]
        un+1      n
         i,j,k = ui,j,k + δt                           + δt [CON DIF U ]ni,j,k     (6.23)
                                       ∆x
From Equations (6.22) and (6.23)
                                                 [pci,j,k − pci+1,j,k ]
                        un+1       n+1
                         i,j,k − ũi,j,k = δt
                                                          δx
where the pressure correction may be defined as
                                   pci,j,k = pn+1      n
                                              i,j,k − pi,j,k
                                                                     [pci,j,k − pci+1,j,k ]
                            un+1        n+1
                             i,j,k −→ ũi,j,k                   + δt                                       (6.24)
                                                                                 δx
                                                                         [pci,j,k − pci−1,j,k ]
                      un+1          n+1
                       i−1,j,k −→ ũi−1,j,k                       − δt                                     (6.25)
                                                                                    δx
                             n+1        n+1
                                                                     [pci,j,k − pci,j+1,k ]
                            vi,j,k −→ ṽi,j,k                   + δt                                       (6.26)
                                                                                 δy
                       n+1          n+1
                                                                         [pi,j,k − pci,j−1,k ]
                                                                            c
                      vi,j−1,k −→ ṽi,j−1,k                       − δt                                     (6.27)
                                                                                    δy
                             n+1        n+1
                                                                      [pci,j,k − pci,j,k+1 ]
                            wi,j,k −→ w̃i,j,k                   + δt                                       (6.28)
                                                                                 δz
                       n+1          n+1
                                                                          [pci,j,k − pci,j,k−1 ]
                      wi,j,k−1 −→ w̃i,j,k−1                        − δt                                    (6.29)
                                                                                    δz
The correction is done through the continuity equation. Plugging-in the above
relationship into the continuity equation (6.1) yields
            " n+1
               ui,j,k − un+1           n+1       n+1          n+1        n+1
                                                                                #
                           i−1,j,k   vi,j,k  − vi,j−1,k     wi,j,k  − wi,j,k−1
                                   +                     +
                       δx                     δy                     δz
            " n+1
               ũi,j,k − ũn+1         n+1       n+1          n+1        n+1
                                                                                #
                           i−1,j,k   ṽi,j,k − ṽi,j−1,k    w̃i,j,k − w̃i,j,k−1
         =                         +                     +
                       δx                     δy                     δz
                c               c        c
                 pi+1,j,k − 2pi,j,k + pi−1,j,k       pi,j+1,k − 2pi,j,k + pci,j−1,k
                                                       c            c
         −δt                       2               +                   2
                              (δx)                                (δy)
            pci,j,k+1 − 2pci,j,k + pci,j,k−1
                                             
         +                                                                          (6.30)
                          (δz)2
or
or
                                                 −(Div)i,j,k
                         pci,j,k = h                                        i        (6.32)
                                                  1         1          1
                                       2δt       δx2
                                                       +   δy 2
                                                                  +   δz 2
                                                       (Div)i,j,k
                              ∇2 (pci,j,k ) =                                          (6.35)
                                                          δt
    The Eqn. (6.35) can be solved implicitly using appropriate boundary condi-
tions for pc at the confining boundaries.
                                       
                      vi,1,k =   0
                                         for i = 2 to ire
                                       
                      ui,1,k = −ui,2,k
                                        and k = 2 to kre
                      wi,1,k = −wi,2,k
If the left side-wall is a free-slip (vanishing shear) boundary, the normal velocity
must be zero and the tangential velocities should have no normal gradient.
                                           
                          wi,j,1 = 0 
                                              for i = 2 to ire
                          ui,j,1 = ui,j,2
                                            and j = 2 to jre
                           vi,j,1 = vi,j,2
If the front plane is provided with inflow boundary conditions, it should be spec-
ified properly. Any desired functional relationship may be recommended. Gen-
erally, normal velocity components are set to zero and a uniform or parabolic
axial velocity may be deployed. Hence with reference to Fig. 6.8, we can write
                                                
              v1,j,k =          −v2,j,k         
                                                
              w1,j,k =          −w2,j,k            for j = 2 to jre
                                                
              u1,j,k =          1.0   or        
                                                 and  k = 2 to kre
              u1,j,k = 1.5 1 − ((jm − j)/jm )2
                                               
                                         1111111
                                         0000000
                               φ i−1,j   0000000
                                         1111111
                                            φ                                      φ i+1,j
                                         0000000
                                         1111111
                                                 U i−1,j     i,j        U i,j                     U i+1,j
              v, j, y                    0000000
                                         1111111
                                         0000000
                                         1111111
                                   V i−1,j−1                  V i,j−1                V i+1,j−1
                                         0000000
                                         1111111
                                             U i−1,j−1     φi,j−1        U i,j−1                  U i+1,j−1
u, i, x
                                  ξ
 φi+ 21 ,j = 0.5(φi,j + φi+1,j ) − (φi−1,j − 2φi,j + φi+1,j )                                    for ui,j ≤ 0 (6.41)
                                  3
and
                                  ξ
 φi− 21 ,j = 0.5(φi,j + φi−1,j ) − (φi−2,j − 2φi−1,j + φi,j )                                    for ui,j > 0 (6.42)
                                  3
                                                 Solution of Navier-Stokes.. 6.23
The parameter ξ can be chosen to increase the accuracy or to alter the diffusion-
like characteristics. It may be pointed out ξ = 3/8 corresponds to the QUICK
scheme of Leonard(1979).
Let us consider two-dimensional momentum equation in weak conservative form
which is given by
                                          1 ∂2u ∂2u
                                                   
                   ∂u    ∂u    ∂u    ∂p
                      +u    +v    =−    +      + 2                             (6.44)
                   ∂t    ∂x    ∂y    ∂x Re ∂x2  ∂y
Finally the discretization of the term ∂(uv)/∂y for the x-momentum equation
will be accomplished in the following way:
  ∂(uv)        1
        =0.25
   ∂y         8δy
         [3ui,j+1 (vi,j+1 + vi,j + vi+1,j+1 + vi+1,j )
           + 3ui,j (vi,j + vi,j−1 + vi+1,j + vi+1,j−1 )
           − 7ui,j−1 (vi,j−1 + vi,j−2 + vi+1,j−1 + vi+1,j−2 )
           + ui,j−2 (vi,j−2 + vi,j−3 + vi+1,j−2 + vi+1,j−3 )]   f or     V > 0 (6.46)
 ∂(uv)        1
       =0.25
  ∂y         8δy
        [−ui,j+2 (vi,j+2 + vi,j+1 + vi+1,j+2 + vi+1,j+1 )
          + 7ui,j+1 (vi,j+1 + vi,j + vi+1,j+1 + vi+1,j )
          − 3ui,j (vi,j + vi,j−1 + vi+1,j + vi+1,j−1 )
          − 3ui,j−1 (vi,j−1 + vi,j−2 + vi+1,j−1 + vi+1,j−2 )] f or       V < 0 (6.47)
where
                      V = vi,j + vi+1,j + vi,j−1 + vi+1,j+1
6.24 Computational Fluid Dynamics
vi,j vi+1,j
ui,j
                                      vi,j−1      vi+1,j−1
             v,j,y
u,i,x
                   2                              2
          Ec   µU∞             L                U∞          1
             =    2
                     ·                   =              ·
          Re    L      ρcp U∞ (Tw − T∞ )   cp (Tw − T∞ ) ρU∞ L/µ
and
                               cp T ∞   cp γRT∞
                                   2
                                      =       2
                                U∞       γRU∞
Hence,
                                                       
                         1         1            Tw
                            =         2
                                                   −1
                         Ec   (γ − 1)M∞         T∞
or
                                               2
                                      (γ − 1)M∞
                             Ec =
                                    ((Tw /T∞ ) − 1)
where
                                                           m
                                   S ∗m ≡ P e [CON V T ]i,j,k
       ∂(uθ)    1
             =     [ui,j,k (θi,j,k + θi+1,j,k ) + α|ui,j,k | (θi,j,k − θi+1,j,k )
        ∂x     2δx
Then
                                                             
                                            2    2  2
                     A∗m − θi,j,k              + 2+ 2               = S ∗m
                                           δx2  δy δz
                                                            Solution of Navier-Stokes.. 6.29
or
                                                A∗m − S ∗m
                            θi,j,k = h                                i                         (6.53)
                                            2         2          2
                                           δx2
                                                 +   δy 2
                                                            +   δz 2
where
                 m          m              m          m                      m          m
                θi+1,j,k + θi−1,j,k       θi,j+1,k + θi,j−1,k               θi,j,k+1 + θi,j,k−1
        A∗m =                         +                                 +
                      (δx)2                       (δy)2                           (δz)2
θi,j,k in Equation (6.53) may be assumed to be the most recent value and it
                     m′
may be written as θi,j,k . In order to accelerate the speed of computation we
introduce an overrelaxation factor ω. Thus
                                           h ′              i
                         m+1      m          m        m
                        θi,j,k = θi,j,k + ω θi,j,k − θi,j,k             (6.54)
                                            ′
        m                            m                                m+1
where θi,j,k is the previous value, θi,j,k the most recent value and θi,j,k the cal-
culated better guess. The procedure will continue till the required convergence
is achieved. This is equivalent to Gauss-Seidel procedure for solving a system
of linear equations.
References
     1. Biswas, G., Torii, K., Fujii, D., and Nishino, K., Numerical and Exper-
        imental Determination of Flow Structure and Heat Transfer Effects of
        Longitudinal Vortices in a Channel Flow, Int. J. Heat Mass Transfer,
        Vol. 39, pp. 3441-3451, 1996.
     2. Biswas, G., Breuer, M. and Durst, F., Backward-Facing Step Flows for
        Various Expansion Ratios at Low and Moderate Reynolds Numbers, Jour-
        nal of Fluids Engineering (ASME), Vol. 126, pp. 362-374, 2004.
     3. Brandt, A., Dendy, J.E and Rupppel, H., The Multigrid Method for Semi-
        Implicity Hydrodynamics Codes, J. Comput. Phys, Vol. 34, pp. 348-370,
        1980.
     4. Braza, M., Chassaing P. and Ha Minh, H., Numerical Study and Phys-
        ical Analysis of the Pressure and Velocity Fields in the Near-Wake of a
        Circular Cylinder, J. Fluid Mech., Vol. 165, pp. 79-130, 1986.
     5. Chorin, A.J., Numerical Method for Solving Incompressible Viscous Flow
        Problems, J. Comput. Phys., Vol. 2, pp. 12-26, 1967.
     6. Davis, R.W. and Moore, E. F., A Numerical Study of Vortex Shedding
        from Rectangles, J. Fluid Mech., 116: 475-506, 1982.
6.30 Computational Fluid Dynamics
Problems
 1. Develop the MAC and SIMPLE algorithms described in this chapter for
    a steady one dimensional flow field u(y), driven by a constant (but as yet
    undetermined) pressure gradient. For definiteness, flow in a parallel plate
    channel can be considered.
 2. For a two-dimensional flow, show that the MAC type iterative correc-
    tion of pressure and velocity field through the implicit continuity equa-
    tion is equivalent to the solution of Poisson equation for pressure. How
    does the procedure avoid the need of directly applying pressure-boundary-
    conditions?
 3. Compare the solutions obtained by the stream function-vorticity method
    with those presented in this chapter for the following problems:
      (a) Developing flow in a parallel plates channel;
      (b) Flow past a square cylinder (Re < 200);
      (c) Flow past a periodic array of square cylinders (Re < 50).
 4. Apply MAC method to solve the shear driven cavity flow problem shown
    in Figure 6.13. Take a grid size of 51 × 51 and solve the flow equations
    for Re = 400.
 5. The Navier-Stokes equations in three-dimensional spherical-polar coordi-
    nate system in θ direction may be written as
                                                                               !
                  ∂Vθ       ∂Vθ    Vθ ∂Vθ      Vφ    ∂Vθ     Vr Vθ    Vφ2 cotθ
             ρ         + Vr      +        +        ·     +         −
                   ∂t        ∂r     r ∂θ     rsinθ ∂φ          r          r
                        2
               ∂p        ∂ Vθ    2 ∂Vθ    1 ∂ 2 Vθ   cotθ ∂Vθ
     = −           +µ          +       +           + 2
              r∂θ         ∂r2    r ∂r     r2 ∂θ2       r ∂θ
                          2
                                                                      
                  1      ∂ Vθ    2 ∂Vr       Vθ       2cotθ cscθ ∂Vφ
         +             ·      + 2       − 2 2 −
              r2 sin2 θ ∂φ2      r ∂θ      r sin θ        r2       ∂φ