CFD

Attribution Non-Commercial (BY-NC)

99 views

CFD

Attribution Non-Commercial (BY-NC)

- Development and Validation of a c++ Object Oriented Cfd Code for Heat Transfer Analysis
- Marine Applications of Cfd
- CFD Lectures
- CFD
- CFD Tutorials
- Ship Resistance and Propulsion
- Resistance
- CFD intro
- CFD Project Titles
- Ship Resistance calculation for a fishing vessel
- Best Practice Guidelines for Turbo Machinery CFD
- Marine Hydrodynamics
- nptel cfd notes
- Fluid Flow for the Rest of Us
- Turbulence Modelling
- CFDNotes06 (1)
- Steam Power Plants English
- marine hydrodynamics mit notes
- Numerical Simulations - Examples and Applications in Computational Fluid Dynamics
- Amano and Sunden -- Computational Fluid Dynamics and Heat Transfer

You are on page 1of 44

An Introduction to CFD

by Changhong HU

hu@riam.kyushu-u.ac.jp

6-1 Kasuga-koen, Kasuga, Fukuoka 816-8580, JAPAN

CONTENTS

1. General introduction 2. Governing equations 3. Basics of discretization 4. Finite difference method 5. Finite volume method 6. Upwind schemes 7. CIP method 8. Numerical methods for incompressible flows 9. Solution of linear system 10. Problems with complex geometries 11. Free surface flows 12. Turbulence modeling Appendix A. Sample program for 2D flow around a square cylinder

References

Text Books [1] [2] [3] [4] [5] [6] [7] [8] [9] 1995 1994 2001 1996 J.H. Ferziger and M. Peric, Computational Methods for Fluid Dynamics, Springer (2002) J.D. Anderson, Jr, Computational Fluid Dynamics, the Basics with Applications, McGraw-Hill, (1995) S.V. Patankar, Numerical Heat Transfer and Fluid Flow, McGraw-Hill, Transfer, McGraw-Hill, (1984) H.Tennekes and J.L. Lumley, A First Course in Turbulence, The MIT Press (1972) [10] J.F. Tompson, Numerical Grid Generation, North-Holland, New York (1985) [11] 2003 (1980) D.A. Anderson, J.C. Tannchill and R.H. Pletcher, Computational Fluid Mechanics and Heat

CFD Journals [1] [2] [3] [4] [5] [6] [7] [8] Journal of Computational Physics International Journal of Computational Fluid Dynamics International Journal for Numerical Methods in Fluids International Journal for Numerical Methods in Engineering Computer and Fluids SIAM J. on Numerical Analysis Mathematics of Computation Computer Method in Applied Mechanics and Engineering

1. INTRODUCTION

Computational fluid dynamics (CFD) is widely used by both academics and industries as an efficient tool to predict fluid motion and heat transfer. It has been an equal important tool as experiment and theory for fluid dynamics research as shown in Fig. 1.1. Many applications of CFD to ship and ocean engineering problems can also be found in recent years, such as prediction of ship resistance, ship-wave interaction, hot gas movement from a ship fire, etc. In this lecture we will study the basics of CFD method and its applications in some hydrodynamic problems. This lecture is for beginners who are interested in but may have not learned CFD before.

In this manuscript we adopt the Cartesian tensor indicial notation. For coordinates we use

xi , i = 1, 2, 3 . For velocities we use ui , i = 1, 2, 3 . Sometimes we write x, y, z in place of x1 , x2 , x3 , and u, v, w in place of u1 , u2 , u3 . When describing finite difference schemes, we use i, j, k and n to indicate the cell addresses in x-, y- , z-direction and the time level, respectively. Vector expression is also used such as u = ue x + vex + wex The governing for a compressible fluid can be written as:

(ui ) + =0 t x i

u i u i = p + f + + uj i t x j x i x j 2 2S ij ij Skk 3

(2.1)

(2.2)

E E Q qi + ui = + ui fi + t x i x i t x j

2 2Sij ij S kk pui ij + ui 3

(2.3)

Equation (2.1) is the continuity equation, (2.2) is the momentum equation (Navier-Stokes equation) and (2.3) is the energy equation, where is the density, ui is the velocity, p is the pressure and and

is the fluid viscosty. fi denotes a body force such as the gravity force. In the energy equation

(2.3), E denotes the internal energy, Q is the heat release rate. The governing equations (2.1) (2.3) are non-linear, coupled and very difficult to solve. In fact, no general solution has been found until now. For many problems, simplification of these equations is possible and the simplified equations are used for CFD. In the applications of our interest, incompressible assumption can be made. That is, we assume the fluid density is constant and neglect the effect of temperature. Since for most of hydrodynamic problems associated with ship and ocean engineering, the Mach number is low (Ma < 0.3) and the temperature difference is also small ( T<30), such assumption does not introduce large error. The governing equations for incompressible flow can be as follows. ui =0 x i

ui t + uj ui x j = 2ui 1 p + fi + x i x j x j

(2.4) (2.5)

These governing equations can be further simplified. One of the simplest models is the potential flow. The flow is assumed to be inviscid and irrotational. Then there exists a velocity potential , such that the velocity vector can be defined as u = . The continuity equation (2.4) becomes Laplace equation for as:

2 = 0 Potential flow method Basic Equations. Viscous flow method (2.6)

2 =0 xi xi

Laplaces Eq.

ui =0 xi

2 p u =H i xi xi t xi

Poisson Eq.

p 1 + + ui ui + f i t 2 = const.

Bernoullis Eq. Analytical based method

Dui = Dt 2ui 1 p + fi xi x j x j

The momentum equation (2.5) can be integrated to give the Bernoulli equation, which is used to obtain the pressure after the velocity potential is solved. The numerical solution of potential flow model is carried out by analytical based methods. As shown in Fig. 2.1, what we are going to discuss in this lecture is the numerical method for viscous flow, which is generally interpreted as the CFD method. The physical explanation of Navier-Stokes equation (2.5) is shown in Fig. 2.2, in which we only consider gravity force for the body force, i.e., fi = g i 3 .

ui t

u j

ui x j

p xi

2 ui x j x j

g i 3

Source term

Transient term

Advection term

Pressure term

Diffusion term

Rate of convection

Pressure force

Dui Dt

mass acceleration

Sum of forces

The governing equations are often put into nondimensional form. A typical nondimensionalizing procedure is

i = x

xi u t i = i , t = , u , L U LU

= p

p U 2

where the nondimensional variables are denoted by a hat, and L is the reference length, U is the reference velocity. The nondimensional form of equation (2.5) can be

i i u u 1 2u 1 p j i = +u + + 2 i3 j i j x j Fr t x x Re x parameters, the Reynolds number and the Froude number, which are defined as follows. Reynolds number: Re =

(2.7)

From now we will eliminate the hat in (2.7) for simplicity. In this equation we have two important

(2.8)

Froude number: Fr 2 =

(2.9)

By considering the continuity equation, the Navier-Stokes equation (2.7) can be written in different forms for convenience of numerical solutions. For example:

Divergence Form:

ui t

ui

+ uj

ui x j

2 p 1 ui 1 + + 2 i 3 x i Re x j x j Fr

(2.10)

(2.11)

Rotational Form:

ui

u u = i j + uj t x i x i x j

2 1 1 ui 1 p + u j u j + + 2 i 3 Re x j x j Fr 2

(2.12)

3. BASICS OF DISCRETIZATION

The above described partial differential equations have generally no analytical solutions. Numerical solution, which gives answer at discrete points (grid points) in a computation domain, is a practical way to obtain an approximate solution. To do a numerical calculation, we need to approximate the derivatives of the partial differential equations using the values at discreted grid points. This can be illustrated in Fig. 3.1 which shows a one dimensional case. In his case, the partial derivative is replaced by an algebraic difference expression.

ux ( x ) =

u ( x ) u ( x + x ) u ( x ) = lim x 0 x x

u ( x + x )

(3.1)

u ( x)

x + x

For small spacing of grid points x , equation (3.1) is an good approximation. A general way to construct a finite difference expression of partial derivative is using Taylor expansion. For instance, let

ui stands for the velocity at grid point i, the velocities at neighboring grid points can be expressed in

terms of a Taylor series expanded about point i as:

2 3 4 u ( x ) u ( x ) u ( x ) u ui 1 = ui + ( x ) i + 2 i+ 3 i+ 4 i+" 2! x 3! x 4! x x 2 3 4

(3.2)

From (3.2) we can obtain some commonly used schemes for finite difference method (FDM): Forward difference

( u x )i =

Backward difference

ui +1 ui + O ( x ) x ui ui 1 + O ( x ) x ui +1 ui 1 + O ( x 2 ) x

(3.3)

( u x )i =

Central difference

(3.4)

( u x )i =

(3.5)

Note that in these expressions, we only use some of the terms in Eq. (3.2). The neglected terms cause

Backward

ui 1

ui

Exact

ui +1

Central

xi

Forward

xi +1

i-1

i+1

truncation errors of the schemes. The second term in (3.3) (3.5) means the order of truncation error, e.g., O ( x ) means first-order-accurate. The significance of those schemes can be shown in Fig. 3.2. For constructing finite difference scheme for higher order derivatives, more grid points may be required. The expression of ui 2 by Taylor expansion is

ui 2

2 3 4 u ( 2x ) u ( 2x ) u ( 2x ) u = ui + ( 2x ) i + 2 i+ 3 i+ 4 i+" 2! x 3! x 4! x x 2 3 4

(3.6)

Then we obtain:

2u ui +1 2ui + ui 1 x 2 4u ui +1 2ui + ui 1 + O ( x 2 ) 2 i= 4 i+ " = 2 2 x x 12 x x 3u ui + 2 2ui +1 2ui 1 + ui 2 x 2 5u ui + 2 2ui +1 2ui 1 + ui 2 + O ( x 2 ) 3 i= 5 i+" = 3 3 2 x 4 x 2 x x (3.7) (3.8)

In discretization of advection term of a transportation equation, such as the Navier-Stokes equation, an upwind difference scheme is often used. Taking the following linear advection equation as a simple example,

u u +c =0 t x

(3.9)

where c is the advection velocity. If c is positive, the equation describes the propagation of a wave in the positive direction of x-axis. The first order upwind difference for the advection term of (3.9) can be built by using one-side difference scheme as:

ui ui 1 + O ( x ) c > 0 c u x c i= x ui +1 ui + O ( x ) c < 0 c x

Equation (3.10) can be written in the following compact form:

(3.10)

c x ui +1 2ui + ui 1 u u u c + c ui ui 1 c c ui +1 ui c i= + = c i +1 i 1 + x x x 2 2 2 2x 2 x

derivative.

(3.11)

It is clear that the first order upwind scheme introduces a term that is proportional to second order

The remaining issue of the discretization is about the time term. We list some often-used schemes below using the following time-dependent equation:

u = f (u ) t

Euler explicit Euler implicit

(3.12)

ui

n +1

ui = f (u n ) i t ui = f ( u n +1 ) i t

n

ui

n +1

Crank-Nicolson

ui

n +1

n f ( u n +1 ) + f ( u n ) ui i i = 2 t

By using the above-described discretization techniques, we can obtain a finite difference expression of a partial differential equation, e.g., Navier-Stokes equation, for numerical solution. There are several important properties of numerical solution method. Here three of them, consistency, stability and convergence, are discussed below.

Consistency is the condition on structure of numerical formulation. It says that the discretized

equation should become the original partial differential equation as the time step and the grid spacing tend to zero. If equation (3.9) is discretized by the Euler explicit and the upwind difference scheme, the following discretized equation can be obtained for the case of c>0.

ui u n uin1 +c i =0 (3.13) t x The consistency property means when t 0 and x 0 , Eq. (3.13) should become (3.9). ui

n +1

n +1 i n i n

The truncation error becomes zero, and the consistency condition is satisfied for the discretization by Eq. (3.13).

t 0

Stability is the condition on solution of numerical scheme. It says that the errors should not be

magnified in the numerical solution and a bounded solution to the discretized equation can be obtained. The most popular method to analyze the stability of a numerical scheme is the Von Neumann method. Again taking Eq. (3.13) as an example, we have

ui

where C =

n +1

= ui C ( uin uin1 )

n

(3.14)

c t is called the Courant number, which is one of the key parameters in CFD. Suppose x

n

can be divided into an exact solution part and an error or disturbance part

i + i ui = u

n n

i n +1 = u i n C ( u in u in1 ) u

Extracting (3.15) from (3.14), we have the equation about the error.

(3.15)

i n +1 = i n C ( in in1 )

The disturbance can be expressed by a Fourier series as:

n jkix i n = k e , k =1 N

(3.16)

(i = 1, 2, ", N ),

j = 1

(3.17)

n jki x e , and As (3.16) is a linear equation, we only need to consider one component, in,k = k

n +1 jki x n jki x n jki x n jk (i 1)x k e = k e C (k e k e )

(3.18)

10

n +1 k

n k

= 1 C (1 e jk x )

(3.18)

1 0 C 1

Convergence is the condition on solution of the numerical scheme, it says that the numerical

solution of the discretized equation should tend to the exact solution of the original partial differential equation as the time step and the grid spacing tend to zero. Let ui

n

in = uin u i x , n t

The convergence condition requires

n t 0 i x 0

=0 lim

In this chapter we use the following two-dimensional incompressible Navier-Stokes equation as an example to demonstrate the finite difference method. u p u u 1 2u 2u +u +v = + + t x y x Re x 2 y 2 v p v v 1 2v 2v +u +v = + + t x y y Re x 2 y 2 (4.1) (4.2)

y

i-1,j+1 i-1,j i-1,j-1

x

i,j+1 i+1,j+1 i+1,j i+1,j-1

ui , j y

i,j i,j-1

11

As shown in Fig. 4.1, the computation domain is covered by a grid. The grid points are noted by an index i which runs in the x direction and an index j which runs in the y direction. Therefore (i, j) indicates an grid point in the computation domain, and (i+1, j) is the right point, (i-1, j) is the left point, (i, j+1) is the above point, (i, j-1) is the lower point. The finite difference method solves the Navier-Stokes equations in a discrete way, i.e., these partial differential equations are replaced by a system of algebraic equations by the following discretization procedure. Discretization of the derivatives in Eq. (4.1) can be as follows using the values at grid points:

1 n uin, + u j ui , j = + O (t ) t t i , j

uin+1, j uin1, j u = + O (x 2 ) 2x x i , j uin, j +1 uin, j 1 u = + O (y 2 ) 2 y x i , j pin+1, j pin1, j p = + O( x 2 ) 2x x i , j uin+1, j 2uin, j + uin1, j 2u + O (x 2 ) 2 = 2 x x i , j uin, j +1 2uin, j + uin, j 1 2u = + O ( y 2 ) 2 2 y y i , j

1 n uin, + j ui , j

+ uin, j

uin+1, j uin1, j

2 x

n i, j 2 n i 1, j

+ vin, j u

n i , j +1

uin, j +1 uin, j 1

2y

2u + u

n i, j 2

pin+1, j pin1, j

2x

+ + O ( t , x 2 , y 2 ) x y The discretized equation for Eq. (4.2) can be obtained in a similar way.

n i +1, j

1 u + Re

2u + u

n i , j 1

(4.3)

Equation (4.3) is a system of algebraic equations, and solution of them gives an approximate flow field expressed by the values at the grid points.

Instead of using a grid in FDM, in finite volume method the computation domain is divided into a number of control volume as shown in Fig. 5.1. The flow variable value for each control volume is defined at the volume center. Interpolation is used to approximate the value at the volume surface. Further FVM uses governing equations that are written in a conservation form. For example, Eq. (4.1) is written as follows for FVM.

12

u 2 1 u 1 u + uv =0 u + p + t x Re x y Re y

(5.1)

The discretized equation can be obtained by integration of (5.1) over a control volume:

+ u t x

S

+ p

1 u 1 u uv dS = 0 + Re x y Re y

n n

(5.2)

n 1 uin, + j ui , j

1 u 1 u 2 xy + u 2 + p y 1 y u + p Re x i + , j Re x i 1 , j

2 2

1 u 1 u + uv x uv x = 0 Re y i , j + 1 Re y i , j 1

2 2

(5.3)

where the velocities at the volume surface can be obtained by a linear interpolation as: u

n 1 i+ , j 2

uin+1, j + uin, j 2

, u

1 i , j 2

uin1, j + uin, j 2

x

i, j+1 i, j+1/2 i -1/2, j i,j i +1/2, j i +1, j i, j-1/2 i, j-1

i -1, j

In modern CFD, the upwind scheme for advection term is widely used in the computation of flows in high Reynolds number. Comparing to the central difference scheme, the upwind scheme generally gives more accurate prediction of propagation of information in a flow, and less oscillations in the solution. Here we discuss some popular upwind schemes.

6.1 Upwind Schemes for FDM

13

f f +u =0 t x

(6.1)

The first order upwind scheme has been given by (3.10) and (3.11). As the first order scheme may introduce too much numerical diffusion, which is proportional to the advection velocity and the grid spacing, it is only used for relatively low Reynolds number problems. For computation of high Reynolds number flow, the following third order upwind scheme is often used.

2 fi +1 + 3 f i 6 f i 1 + fi 2 u f 6x u i= x fi + 2 + 6 f i +1 3 fi 2 fi 1 u 6x

Or in compact form we have

if u > 0

(6.2)

if u < 0

3 fi + 2 + 8 fi +1 8 f i 1 + fi 2 u x fi + 2 4 fi +1 + 6 fi 4 f i 1 + fi 2 f u i= u 12x 3 4 x 4 x

(6.3)

In the right hand side of(6.3), the first term represents a central difference, the second term is proportional to 4 f x 4 , works as numerical diffusion term.

6.2 Upwind Schemes for FVM

In FVM, the conservation form of the 1-D advection equation (6.1) is used:

(uf ) f + =0 t x

(6.4)

f i 1

f i 1 2

fi

f i +1 2

f i +1

xi 1 2

xi

xi +1 2

Using the control volume shown in Fig. 6.1, the advection term of (6.4) can be discretized as:

(uf ) 1 x i x (uf )i + 1 (uf )i 1 2 2

(6.5)

The basic idea of upwind scheme for FVM is to use an upwind side value to approximate the volume surface value f

i+ 1 2

or f

1 2

14

f 1 = f i +1 i+ 2 for u>0, fi 1 = fi 2

f 1 = fi i+ 2 for u<0 f i 1 = f i 1 2

u (f f ) u > 0 i 1 x i (uf )i 1 u 2 ( fi +1 fi ) u < 0 x

or in a unified form,

(uf ) 1 (uf )i + 1 2 x i x

(6.6)

A widely used high order upwind scheme is known as the QUICK scheme (Quadratic interpolation for Convective Kinematics), which uses a quadratic interpolation to express f For example:

i+ 1 2

or f

1 2

i+

1 2

3 6 1 fi +1 + fi fi1 8 8 8 = 1 6 3 fi +2 + fi +1 + fi 8 8 8

u>0 u<0

Then we have

(6.7)

7. CIP METHOD

7.1 The Principle of CIP Method

As described in the previous chapter, using an upwind differencing technique for the advection term of Navier-Stokes equations is necessary for a stable numerical calculation. The cost of the use of upwind scheme is introducing excessive numerical diffusion and associated inaccuracies. Efforts to reduce such numerical diffusion have resulted in many high order upwind schemes, e.g., QUICK, TVD, et al. About 20 years ago CIP method was also presented for the first time as a high order upwind scheme. To explain the CIP method we start from the following 1D advection equation:

f f +u =0 t x

(7.1)

This equation represents a translational motion of a wave with velocity u. We can use different finite difference schemes for numerical solution of this equation. As shown in Fig 7.1 (a) (c), a first-order upwind scheme, which can be constructed by adjacent two grid points, results in numerical diffusion. We find that the profile of f becomes smoother after time stepping. The reason for this

15

numerical diffusion is that by linear interpolation the information about the profile inside the grid cell is lost. We can build a high-order upwind scheme by using more than two grid points to reconstruct the profile inside the grid cell. However, such high-order scheme generally has the problem of overshooting. The CIP scheme, which is illustrated in Fig. 1 (d), shows a different way from the conventional high-order schemes to reconstruct the profile inside a grid cell. It uses the grid point value and its spatial derivative (gradient) in two grid points to form a cubic polynomial to approximate the profile.

u t

(a)

(b)

(c)

(d)

gradient

Fig.7.1. The principle of the CIP method. (a) The solid line is the initial profile and the dashed line is an exact solution after advection, shown in (b) at discretized points. (c) When (b) is linearly interpolated, numerical diffusion appears. (d) In the CIP, the spatial derivative also propagates and the profile inside a grid cell is retrieved. (reproduced from Yabe, et al. JCP) By differentiating Eq. (7.1) with respective to x, we have the equation about the spatial derivative as

g g u , +u = g t x x

(7.2)

where g = f x . For simplicity we assume a constant advection velocity. Then Eq. (7.2) has the same form as Eq. (7.1). For the case of u > 0 we may approximate a profile for f n inside the

upwind cell [ xi 1 , xi ] as

Fi n ( x ) = ai ( x xi ) + bi ( x xi ) + ci ( x xi ) + di .

3 2

(7.3)

16

u t

Fi n fi n +1

fi n

Fi n+1

xi 1

Fig.7.2.

xi

As shown in Fig. 7.2 the profile at the time step n+1 is obtained by shifting the profile with

u t , i.e., the time evolution of the function f and g can be obtained by using the following

Lagrangian invariants.

fi n +1 = Fi n ( xi u t ) , gin +1 = dFi n ( xi u t ) dx .

(7.4)

Therefore we call the CIP scheme as a Semi-Lagrangian method. The four unknown coefficients in Eq. (7.3) can be determined by using known quantities fi n ,

n n fi and gin1 . It is not difficult to obtain 1 , gi n n gin + gin1 2 ( f i f i 1 ) , x 2 x 3 ci = gin , di = f i n . n n 2 gin + gin1 3 ( f i f i 1 ) x 2 x

ai =

bi =

(7.5)

CIP was at first interpreted as Cubic-Interpolated Propagation, which can be easily imagined from the above discussion. However, development of CIP method has resulted in many schemes that not only use cubic but also other order of polynomials, CIP was recently interpreted as Constrained Interpolation Profile. Comparing to conventional upwind schemes CIP has the following features: 1. Compact high order scheme. CIP uses function as well as its spatial derivatives as dependent variables for constructing profile. Therefore, a cubic polynomial can be determined by using the information at grid points that belong to one grid cell. 2. Sub-cell resolution. Owing to the use of spatial derivatives the profile inside a grid cell can be well reconstructed. This means that to achieve a certain computational accuracy less grid number may be used by CIP scheme than by conventional high-order upwind schemes. 3. According to the procedure shown in Eq. (7.4), the calculation costs do not increase even if the additional variables (spatial derivatives) are introduced.

7.2. CIP Formulation in Multi-dimensions

17

We write a general advection equation about a function and the equation about its spatial derivative as

+ ui =0, t xi ( ) t + ui ( ) xi =

( i = 1, 2, 3 ) , ( = x1 , x2 , x3 ),

(7.6) (7.7)

ui , xi

where = xi . As shown in the next section, by using a fractional step method, the right hand side (RHS) term of Eq. (7.7) can be treated in a different calculation step. Then the time evolution of and can be done by the CIP scheme described in the previous section. We shall give the cubic polynomials for two- and three-dimensional cases.

n (1 , 2 )

n +1 ( x1i , x2 j )

( x1iw , x2 jw )

x2

x1

( x1i , x2 jw )

1 , x 2 ) (x

( x1i , x2 j )

( x1iw , x2 j )

(u1 , u2 )

Fig.7.3. CIP Interpolation for two-dimensional case

For a two-dimensional case, let us consider a grid point (i, j). We can find an upwind cell with four grid points, (i, j), (iw, j), (i, jw), and (iw, jw). Here, iw=i-sign(u1), jw=j-sign(u2). Then a cubic polynomial to approximate the spatial distribution of the function in the upwind cell can be written as

n (1 , 2 ) = C301 + C211 2 + C1212 + C032

3 2 2 2 2 3

(7.8)

where 1 = x1 x1i , 2 = x2 x2 j . There are 10 unknown coefficients in Eq. (7.8), Cmn , which can be determined by the known values of n and

( )

at grid points (i, j), (iw, j) and (i, jw), and the

value of n at the grid point (iw, jw). Here the superscript n denotes the current time level. The concept of CIP interpolation for two-dimensional case is shown in Fig. 7.3.

18

It should be noted here that as we do not use the continuity condition for

( )

at the grid

point (iw, jw) , which is the farthest grid point from the concerning point (i, j), The profile near (iw, jw) may not be correct by Eq. (7.8). A cubic polynomial determined by using all continuity conditions can be as follows:

3 3 3 2 2

2 2

(7.9)

However, numerical tests showed that the difference between the results using Eqs (7.8) and (7.9) is negligible. Therefore in our numerical method we use Eq. (7.8) for the sake of simplicity. For the same reason we also use a less-term formula for three-dimensional case as described below. Let us consider a grid point (i, j, k) for three-dimensional case, we can find an upwind cell with eight grid points, (i, j, k), (iw, j, k), (i, jw, k), (i, j, kw), (iw, jw, k), (iw, j, kw), (i, jw, kw) and (iw, jw, kw). Here, kw=k-sign(u3). The cubic polynomial we are using to approximate the profile in the upwind cell is

3 3 3

2 2 2 2 2

2 200 1 2 2

(7.10)

+ C1001 + C0102 + C0013 + C000 where 3 = x3 x3k . Eq. (7.10) contains 20 terms. The 20 unknown coefficients, Clmn , can be determined by using the known values of n and

( )

and (i, j, kw), and the value of n at the grid points (iw, jw, k), (iw, j, kw), (i, jw, kw) and (iw, jw, kw). Since there are 32 continuity conditions that can be used for one cell, we can write a cubic polynomial that is determined by 32 continuity conditions as follows, although we do not use it in our computation model.

3 3 3 3 3

3 3 3 3

2 2 3 3 3 2 2 2 2

+ C3001 + C0302 + C0033 + C111123 + C2101 2 + C0212 3 + C10213 + C12012 + C01223 + C2011 3

2 2 2

(7.11)

2 2 2

+ C1001 + C0102 + C0013 + C000 Once the interpolation function is determined, the advection calculation by Eqs (7.6) and (7.7) is

19

n +1 ( x ) = n ( x u n t ) ,

(7.12) (7.13)

( )

n +1

( x) =

n ( x un t ) .

The above-described method is the most popular way for multi-dimensional formulation of CIP scheme, which is called A-type CIP scheme. Another multi-dimensional extension method is to make use of a directional splitting method, by which the multi-dimensional CIP calculation can be done by repeating one-dimensional CIP calculation. The concept is shown in Fig.7.4 for a two-dimensional case.

( x1i , x2 jw )

( x1iw , x2 jw )

( x1i , x2 jw )

( x1iw , x2 jw )

n +1

(x

1i

, x2 j

)

1 , x 2 ) (x

step 2 step 1

( x1iw , x2 j )

2 ) ( x1i , x

1 , x 2 ) (x

( x1i , x2 j )

( x1i , x2 j )

( x1iw , x2 j )

(u1 , u2 )

(u1 , u2 )

Fig. 7.4. Concept for A-type, C-type and M-type CIP schemes in two dimensions Here we introduce two such kind of CIP method: C-type CIP and M-type CIP. C-type CIP Step 1 2 ) = CIP 1D in, j , ( x2 ) , in, jw , ( x2 ) Ai = n ( x1i , x

n i, j

n i , jw

2 , , x2 = x

x2 Ai =

2 ) = CIP 1D ( x1 ) , ( x1 x2 ) , ( x1 ) x1 Ai = x1 n ( x1i , x

n n i, j i, j

n i , jw

, ( x1 x2 )

n i , jw

2 , , x2 = x

x1 x2 Ai =

n n n n 2 ) = 2 . x1 n ( x1i , x CIP 1D ( x1 ) , ( x1 x2 ) , ( x1 ) , ( x1 x2 ) , x2 = x i j i j i jw i , , , , jw x2 x2

20

Step 2

1 in, + j = CIP 1D ( Ai , x Ai , Aiw , x Aiw , x1 = x1 ) ,

1 1

1 x1 in, + j =

1 x1 x2 in, + j =

The C-type CIP is as same accurate as the A-type CIP. The merit is its easy extension to multi-dimensions. The demerit is some extra dependent variables, for two-dimensional case the second order derivative x1 x2 , should be introduced. To avoid using higher order spatial derivatives, a so-called M-type CIP scheme was developed. M-type CIP Step 1 2 ) = CIP 1D in, j , ( x2 ) , in, jw , ( x2 ) Ai = n ( x1i , x

n i, j

n i , jw

2 , , x2 = x

x2 Ai =

x1 Ai = FDM 1D ( x1 ) , ( x1 )

n i, j

n i , jw

2 , , x2 = x

Step 2

1 in, + j = CIP 1D ( Ai , x Ai , Aiw , x Aiw , x1 = x1 ) ,

1 1

1 x1 in, + j =

Here we have used a linear interpolation denoted as FDM_1D. The precision of M-type CIP scheme may be less than A-type and C-type CIP schemes. However, numerical experiments have shown that the difference in the computation results by the three schemes is not remarkable. For the sake of simplicity M-type scheme is often used in multi-dimensional computations.

21

One of the difficulties in solving incompressible flow is that there is no independent equation for the pressure, whose gradient contributes to the momentum equations. Further, the continuity equation is not a dynamic equation, but provides a kinematic constraint for velocity field. Effects to solve such difficulty have resulted in many numerical methods for incompressible flow in the past several decades. In this lecture we shall discuss the methods using governing equations of primitive variables (u, p) as follows.

ui x i ui t + uj u i x j =0

2 1 ui p + Re x j x j x i

(8.1) (8.2)

Harlow and W Welch elch (1965) Chorin (1968) MAC Family Amsden and Harlow (1970) Hirt and Cook (1972) Patankar (1980)

SIMPLE (Semi-Implicit Method for Pressure-Linked Equations) SIMPLER (SIMPLE Revised) FS (Fractional Step) Patankar (1980)

Yanenko (1971)

A list of currently often-used numerical methods for incompressible flows is shown in Fig. 8.1. To treat the difficulty of pressure-velocity coupling, most of these methods apply a way to construct the pressure field so as to satisfy the continuity equation. In the following, we describe a method for an uniform flow past a square, as an example to learn how to code a Fortran program for a CFD calculation of an incompressible flow. We shall use the MAC method, an old method that has initiated many modern incompressible flow solvers, and can still be found in many applications. To explain the MAC method the following vector form of the governing equation is used.

22

u = 0 u 1 + ( uu ) = p + u t Re

(8.3) (8.4)

There are 3 significant features for MAC method. The first feature is that a pressure equation is derived by taking divergence of Eq. (8.4). We have

2 p n +1 = D n +1 D n 1 2 n + D ( unu n ) t Re

(8.5)

where D = u is the divergence of the velocity field. The pressure is solved by Equation (8.5) to satisfy the continuity equation (8.3). This leads to the second feature, a cycle-to-cycle self-adjustment procedure. In (8.5), let D n +1 = 0 , but D n = u n 0 , i.e., let the velocity divergence at the current time step remain in (8.5) to modify the pressure distribution. The pressure equation to be solved becomes

2 p n +1 = Dn 1 2 n + D ( unun ) t Re

(8.6)

The third feature is the use of staggered mesh as shown in Fig. 8.2, in which the pressure and the velocity components are defined at different locations. In Cartesian coordinates, the staggered arrangement offers several advantages over the collocated arrangement in which all variables are defined at the same grid point. The biggest advantage of staggered arrangement is the strong coupling between the velocities and the pressure. This helps to avoid numerical oscillations in pressure and velocity field.

23

CV of v

CV of p

vi , j +1 2

1 j+ 2 j 1 2 i 1 2

ui +1 2, j

CV of u

pij

i +

1 2

Fig. 8.2. Staggered arrangement of velocity components and pressure We shall use the finite volume method for discretization. It should be noted that as shown in

the figure 8.2, the control volume for the pressure and the velocity components are in different locations due to the staggered arrangement. Here we write the discretized equations for coding a computation program using MAC method to solve a uniform past a square cylinder. The governing equations for a 2-D incompressible flow can be as:

u v + =0 x y

2u 2u u u 2 uv p 1 + + = + 2 + 2 t x y x Re y x v uv v 2 p 1 2v 2v + + = + + t x y y Re x 2 y 2

( 8.8) + ( 8.9 ) x y

2D 2D 2 p 2 p 2u 2 2v 2 2uv D + = 2 + + 2 2 2 2 2 2 x y x y x y y t x

(8.10)

where D =

D D n +1 D n Dn . t t t

24

Discretization of the governing equation (8.7) - (8.10) can be carried out by finite volume method as follows. For momentum equation (8.8) and (8.9), discretizations are obtained by integration over the control volume of u

1 i+ , j 2

and v

i, j +

1 2

, respectively.

(ui +1, j )2 (ui, j )2 u 2 uv + = + CX = 1 y x x i+ ,j

2

1 1 1 1 i+ ,j + i+ ,j + 2 2 2 2

1 1 1 1 i+ ,j i+ ,j 2 2 2 2

y v (vi, j +1 )2 (vi, j )2 y

(8.11)

uv v 2 + CY = 1 = x y i, j +

2

1 1 1 1 i+ ,j + i+ ,j + 2 2 2 2

1 1 1 1 i , j + i , j + 2 2 2 2

(8.12)

As has been pointed, for numerical stability, a upwind scheme is required for such advection term. Here we apply a first order scheme.

u Taking ui +1, j ui +1, j ui, j ui, j as an example, the first order upwind scheme give 1 x x i+ ,j

2 2

ui +1, j ui +1, j =

ui +1, j + ui +1, j 2

1 i+ ,j 2

ui +1, j ui +1, j 2

3 i+ ,j 2

ui , j ui , j =

u i , j + ui , j 2

1 i , j 2

ui , j ui , j 2

1 i+ ,j 2

Doing such discretization to all advection terms in (8.8) and (8.9), we obtain

u 2 uv + CX = 1 y x i+ ,j

2

1 1 i+ ,j 2 2

(u

1 i+ ,j 2

+u

1 i + , j 1 2

) v

1 1 i+ ,j 2 2

(u

1 i + , j 1 2

1 i+ ,j 2

)}

(8.13)

25

uv v 2 CY = + 1 x y i, j +

2

1 {u 1 1 (v 1 + v ) + u 1 1 (v 1 v ) 1 1 ,j + i+ ,j + i, j + i, j + i +1, j + i +1, j + 2x i + 2 2 2 2 2 2 2 2 u

1 1 i , j + 2 2

(v

i 1, j +

1 2

+v

i, j +

1 2

) u

1 1 i ,j + 2 2

(v

i 1, j +

1 2

i, j +

1 2

)}

1 {v (v 1 + v 3 ) + vi , j +1 (v 1 v 3 ) vi, j (v 1 + v 1 ) vi, j (v 1 + v 1 )} i, j + i, j + i, j + i, j i, j + i, j i, j + 2y i , j +1 i, j + 2 2 2 2 2 2 2 2

(8.14) For diffusion term of the momentum equations a central difference scheme is applied.

2u 2u 1 1 + 2 = VX = 2 x y i + 1, j Re Re

2

(u x )

i +1, j

u x

i, j

1 + Re

(u y )

1 1 i+ ,j + 2 2

u y y

1 1 i+ ,j 2 2

u 3 2u 1 + u 1 u 1 2u 1 + u 1 i+ ,j i+ ,j i , j i + , j +1 i+ ,j i + , j 1 1 2 2 2 2 2 2 = + 2 2 Re x y

(8.15)

1 1 2v 2v VY = + = 2 2 Re x Re y i, j + 1

2

(v x )

1 1 i+ ,j + 2 2

v x x

1 1 i ,j + 2 2

1 Re

(v y )

i , j +1

v y

i, j

v 2v 1 + v v 3 2v 1 + v 1 1 1 i +1, j + i, j + i 1, j + i, j + i, j + i, j 1 2 2 2 2 2 2 = + 2 2 Re x y

u n +11 = u n

i+ ,j 2

1 i+ ,j 2

p pi, j n CX + VX i +1, j + t x pi , j +1 pi , j n + t + CY VY y

(8.17) (8.18)

v n +11 = v n

i, j + 2

i, j +

1 2

pi +1, j 2pi, j + pi 1, j x

2

= Ri, j

(8.19)

26

2u 2 2v 2 D 2uv 2 D 2D 1 + + Ri, j = 2 2 2 2 2 y x y Re x y t x i, j = x 2 x 2 1 u 1 1v 1 1 u 1 1v 1 1 u 1 1v 1 1 + u 1 1v 1 1 , , , , , , i j i j i j i j i j i j + + + + + + + + i j i j , , x y 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 + Di +1, j 2Di, j + Di 1, j Di, j +1 2Di, j + Di, j 1 Di, j 1 + + x 2 y 2 Re t ui2+1, j 2ui2, j + ui21, j vi2, j +1 2vi2, j + vi2, j 1

(8.20)

and Di, j =

1 i+ ,j 2

u x

1 i , j 2

i, j +

1 2

u y

i, j

1 2

Since most of the CPU time will be spent to solve the Poisson equation (8.19), the use of a fast solution method is important for increasing the total computation efficiency. Eq. (8.19) represents a sparse linear system for p. We rewrite it as

Ax = b ,

(9.1)

where A is a M M matrix, x and b are vectors with M elements. Here M = NX NY , and NX, NY are grid number in x- and y-direction, respectively. For a sparse linear system we need to use an iterative method for numerical solution. There are two types of iterative methods: the stationary method and the nonstationary method. The stationary method is an old method. However, it is easy to understand and implement. The treatment of boundary condition on complicated geometry is simple. In the initial stage of code development the stationary method is often applied for the Poisson equation. Typical stationary methods are as follows: Jacobi method:

p

k +1 i, j

k i, j

(9.2)

Gauss-Seidel method:

1 p k 2p k + p k +1 pik, j +1 2pik, j + pik,+ i, j i +1, j i 1, j j 1 1 k Ri, j = + + pik,+ p 2 2 j i, j x y

(9.3)

27

where

most efficient stationary method. Nevertheless the rate of convergence is too low to be used for the large-scale linear system in a three-dimensional computation. In the past 20 years a lot of nonstationary iterative methods are developed. The name of nonstationary iterative may come from the use of iteration-dependent coefficients. These methods are usually hard to understand, but they can be highly effective. The efficiency of the method largely depends on the so-called preconditioner. The widely used CG methods (Conjugate Gradient) belong to nonstationary iterative methods. Another fast solution method that need to note is the multigrid method.

10. PROBLEM WITH COMPLEX GEOMETRIES

Generally a practical engineering flows may contain complex geometries. For example, in the problem of a floating body moving in a free surfacee, we need to treat the free surface and body boundary, which are not comformal to the Cartesian grid lines. The numerical methods for the problem with complex geometries can be roughly divided into two categories: domain dividing method and domain embedding method as shown in Fig. 10.1. For domain dividing method, we do not solve the domain outside the water but let the free surface and the body surface as moving domain boundaries to be determined. A curvilinear grid or an unstructured grid that adapted to these boundaries is required. The advantage of this method is its high resolution for boundary layer computation. However, the grid generation for problems with complex boundaries is troublesome and re-grinding process for unsteady problems is computationally costly. The domain embedding method uses a Cartesian grid, and sometimes is also called Cartesian grid method. The use of Cartesian grid can greatly simplify the structure of the code and increase the computation efficiency for problems with complicated free surfaces and moving bodies. The disadvantages of this method are the difficulty in capturing the inner boundaries and the low accuracy of the calculation around those interfaces.

28

(b)

Domain

In this Chapter we introduce a domain dividing approach in which a finite difference method based on coordinate transformation is used.

As shown in Fig 10.2, a structured grid is used in the physical plane, in which each grid line is a line of constant coordinate or . The body boundary is one of the grid line. The correspondent computational grid is uniform with regular boundaries. The two grids have the following relations.

= (x , y ) = (x , y ) x = x (, ) y = y (, )

(10.1)

= x x y x y x x = x x y x y

(10.2)

29

x x i J = det = x i

y = x y x y y

(10.3)

Now we consider a coordinate transformation for the following governing equations for 2-D incompressible flow.

u v + =0 x y 1 u u u p 2u 2u +u +v = + + t x y x Re x 2 y 2 1 v v v p 2v 2v +u +v = + + 2 2 t x y y Re y x

f x = x f y fx f y y y f f x

(10.7)

fx y = 1 fy x J

(10.8)

y = x / J

x = y / J

x = y / J

y = x / J

(10. 9)

2 2 2 2 where = x + y , = x x + y y and = x + y .

(10.10)

y u u v v y + x =0 x

y p y p y u y u x u x u u 1 = + +v u +u Re t J J J J J J y v y v x v x v x p x p v 1 = v +u +v + Re t J J J J J J

These transformed equations are then solved numerically in the computation domain shown in Fig. 10.2, which has regular computation domain and uniform grid spacing.

30

In the coordinate transformation method, the quality of the grid is very important for the accuracy of computation. Many methods have been proposed for generation of a curvilinear grid. An example is the method based on the solution of elliptic partial differential equations. In this method, the curvilinear coordinates is assumed to satisfy the following equation,

xx + yy = P (x , y ) + yy = Q (x , y ) xx

(10.14)

where P and Q are functions that control the properties of the coordinates. The equations can be transformed to computation plane for numerical solution.

x 2x + x = J 2 x P (, ) + x Q (, ) 2 y 2y + y = J y P (, ) + y Q (, )

(10.15)

The difficulty in computation of free surface flows is that the free surface is a moving boundary which has to be determined in the solution. Further, suitable boundary conditions are needed at the free surface. Basically, methods to determine the position of free surface can be classified into two groups, the interface tracking method and the interface capturing method. The interface tracking method can treat the free surface as a sharp interface. A boundary fitted curvilinear grid or an unstructured grid are used and advanced when the free surface is moved. The advantage of this method is that an accurate boundary condition can be set on the free surface. The disadvantage is that regridding process is generally costly and this method is not applicable to high nonlinear problem in which the free surface may be largely distorted or broken. The interface capturing method does not define the interface as a sharp boundary. The shape of interface is computed by a function to denote the existence of a free surface in a computation cell. The computation is performed on a fixed grid and the free surface is treated as an inner interface. The most famous interface capturing method may be the MAC (Marker and Cell) method in which massless particles are introduced to calculate the motion of free surface. Another commonly used method is the VOF (Volume of Fluid) method in which a function c to denote the fraction of fluid in each computation cell is introduced. c=1 means a fluid cell and c=0 means a empty cell while a cell of 0<c<1 contains a free surface. The VOF function satisfies the following transportation equation.

c c + ui =0 t x i

(11.1)

Recently the level set method (LSM) has also become an important interface capturing

31

method. This method introduces a level set function . The free surface is defined as the surface of = 0 . Other values of this function has no significance but to make it as a smooth function to represent a signed distance from the surface. This function follows the same transportation as (11.1).

+ ui =0 t x i

(11.2)

CIP method, if used as an interface capturing, is considered as a VOF-like method. In this method, Eq. (11.1) is solved by CIP scheme.

12. TURBULENCE MODELING

Most of practical flows are turbulent and require special treatment in numerical calculations. Turbulent flows are highly unsteady, three-dimensional and contain a lot of vorticity. Numerical solution of all these temporal and spatial fluctuations, i.e. direct numerical simulation (DNS), is restricted to a few very simple cases. In general, we need to use mathematical models to approximate the effect of turbulence. The turbulence models can be classified into two groups: time averaged model and space filtered model. The time averaged models solve Reynolds averaged Navier-Stokes (RANS) equations, include 0-equation models (Prandtl mixing length model), 1-equation models (k model), 2-equation models ( k model), and Reynolds stress model. The space filtered models are also called large eddy simulation (LES) methods, include the SGS model (Smagorinsky Subgrid model) and the Dynamic SGS model.

12.1 RANS Model In the conventional time averaging procedure, a quantity f can be divided into a time

1 f = t

t0 +t

(12.1)

t0

fdt

(12.2)

f = 0 , f = f , f +g = f + g , f g = f g = 0

f g = ( f + f ) (g + g ) = f g + f g + f g + f g = f g + f g + f g + f g = f g + f g

We apply the above definitions to the following governing equations for incompressible

32

flows.

ui x i ui t 1 u + =0

(12.3)

1 p + (2Sij ) x i x j

(ui u j ) x j

(12.4)

ui x i ui t + (ui u j ) x j

=0

(12.5)

1 p + 2Sij uiu j x i x j

(12.6)

There is an unknown term in (12.6), uiu j , called Reynolds stress term, which is required to be modeled with the known averaged values. Many methods have been developed to approximate this term, and most of them use the Boussinesq assumption:

2 uiu j = 2t Sij ij k 3

(12.7)

where k = uiui 2 is the kinetic energy of turbulence and t is called turbulent viscosity or eddy viscosity. Equation (12.6) is then reduced to

ui t + u i u j x j =

1 p + 2 ( + t ) Sij x j x i

(12.8)

If the turbulent viscosity is known, this equation can be solved. There are several methods that can be used to determine the turbulent viscosity, we will describe a widely used model in the following, the k model. The equations for this model are:

t =

C k 2

(12.9)

t k k (u j k ) + = + 2t S ij S ij x j x t x j k j

(12.10)

(u j ) 2 t + = + 2 C S S C 1 2 t x j x j k t ij ij k x j

(12.11)

where is a turbulence dissipation rate. There are five model constants in this model, and the following values are often used.

33

C = 0.09

C 1 = 1.44

C 2 = 1.92

k = 1.0

= 1.3

The k model has the advantage of simple implementation due to the use of an isotropic eddy viscosity. It is also very stable for many engineering applications. The disadvantages of this model also arise from its isotropic assumption, resulting in bad prediction of normal turbulent stresses, curvature effects, irrotational strains (stagnation flow), and separation flow.

12.2 Large Eddy Simulations The basic idea in LES is to resolve large grid scales (GS) flow motions and model small

(subgrid-scales, SGS) turbulent fluctuations. Large eddy simulations make use of a space filtering procedure to obtain averaged equations. By the following decomposition, a quantity f can be divided into a resolved GS component and an unresolved SGS component as: f = f +f (12.12) by using a filtering operation that can be

f

G (x , ) f ( )d

(12.13)

Applying to (12.3) and (12.4), one obtains a set of filtered equations very similar to the RANS equations.

ui x i ui t + (ui u j ) x j = =0

(12.14)

1 p + (2Sij + ij ) x j x i

(12.15)

ij = uiu j uiu j

(12.16)

which is needed to be modeled. The earliest and most commonly used model is the Smagorinsky SGS model. This model assume

1 ij ij kk = 2eSij 3

j i and the SGS eddy viscosity can be derived to give where Sij = + 2 x x j i

(12.17)

1 u

e = (C S ) S

2

(12.18)

S = (2S ij Sij ) . The filter scale is usually assumed to be equal to grid scale. The model

12

34

constant CS can be determined by theory to give C s = 0.2 . It can be seen that a significant feature of this SGS model is it has only one empirical constant.

Appendix A. Sample program for 2D flow around a square cylinder

Here we show a sample program to solve two-dimensional incompressible flows for better understanding of the CFD knowledge described in this lecture. The basic scheme is MAC method. The computation example is a uniform flow past a stationary square cylinder. Fig. A1 shows a computed result of flow pattern. The Reynolds number is Re = is the width the cylinder, U0 is the velocity of ambient flow.

U 0 B = 200 , where B

Fig. A2 and A3 show the computed force coefficients. The forces due to pressure and due to viscosity are obtained by integration of the pressure and the viscous stress over the cylinder surface, respectively.

c******************************************************************* c* 2-D Navier-Stokes Solver * c* * c* Flow Past a Square Cylinder *

35

c******************************************************************* c------------------------------------------------------------------c coded by Changhong Hu at 10/August/2003 in RIAM c------------------------------------------------------------------parameter(nx=240,ny=80,mp=10000,im=nx+2,jm=ny+2) implicit real*8(a-h,o-z) common /blk1/ uc(0:im,0:jm), vc(0:im,0:jm) & , u(0:im,0:jm), v(0:im,0:jm) & ,uw(0:im,0:jm), vw(0:im,0:jm) & , d(0:im,0:jm), p(0:im,0:jm) & ,ind(0:im,0:jm) common /blk2/dx,dy,dt,re1,fpx,fpy,fvx,fvy,uin dimension th(mp),fpxh(mp),fpyh(mp),fvxh(mp),fvyh(mp) c=================================================================== t=0.0 tmax=100 dt=0.01 dt0=dt tout=0 dtout=dt*10 nf=0 uin0=1d0 tint=1d0 c------------------------------------------------------------------call initset c>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> do n=1,10000 c t=t+dt if(t.gt.tmax) goto 1000 c------------------------------------------------------------------if(t.lt.tint)then uin=uin0*t/tint else uin=uin0 endif c------------------------------------------------------------------call pressure c------------------------------------------------------------------call velocity c------------------------------------------------------------------call bc c------------------------------------------------------------------call force c------------------------------------------------------------------c determine time step by CFL condition c------------------------------------------------------------------alpha=0.5 umax=1d-10 vmax=1d-10 do j=1,ny do i=1,nx abu=abs(uc(i,j)/dx)

36

abv=abs(vc(i,j)/dy) umax=max(umax,abu) vmax=max(vmax,abv) enddo enddo dt=min(dt0,alpha/umax,alpha/vmax) c------------------------------------------------------------------c for output c------------------------------------------------------------------if(t.ge.tout) then nf=nf+1 tout=tout+dtout th(nf)=t fpxh(nf)=fpx fpyh(nf)=fpy fvxh(nf)=fvx fvyh(nf)=fvy write(*,100)n,t,fpx,fpy,fvx,fvy endif 100 format('n=',I5,' t=',F8.3/' fpx=',F9.4,' fpy=',F9.4 & ,' fvx=',F9.4,' fvy=',F9.4) c------------------------------------------------------------------enddo 1000 continue c<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< open(10,file='force.dat') open(11,file='vector.dat') c do i=1,nf write(10,110)th(i),fpxh(i),fpyh(i),fvxh(i),fvyh(i) enddo 110 c format(5(1x,f10.6)) close (10) do j=1,ny do i=1,nx x1=(i-0.5)*dx y1=(j-0.5)*dy du=0.5*uc(i,j) dv=0.5*vc(i,j) write(11,111)x1-du,y1-dv,x1+du,y1+dv enddo enddo 111 format(4(1x,f10.6)) c------------------------------------------------------------------stop end c******************************************************************* subroutine initset c******************************************************************* c-------------------------------------------------------------------

37

parameter(nx=240,ny=80,mp=10000,im=nx+2,jm=ny+2) implicit real*8(a-h,o-z) common /blk1/ uc(0:im,0:jm), vc(0:im,0:jm) , u(0:im,0:jm), v(0:im,0:jm) & ,uw(0:im,0:jm), vw(0:im,0:jm) & & , d(0:im,0:jm), p(0:im,0:jm) & ,ind(0:im,0:jm) common /blk2/dx,dy,dt,re1,fpx,fpy,fvx,fvy,uin c------------------------------------------------------------------c computational conditions c------------------------------------------------------------------c** grid spacings dx=0.1 dy=0.1 c** Reynolds number re=1.0d2 re1=1d0/re c------------------------------------------------------------------c mesh definition c c | | c ---|-----------------|--| c | c | p(i,j) | c u(i,j) uc(i,j) | c | vc(i,j) | | | c c -uw(i,j)---v(i,j)----|--c vw(i,j) | | c | c c------------------------------------------------------------------initial set c c------------------------------------------------------------------do j=0,ny+1 do i=0,nx+1 u(i,j)=0.0 v(i,j)=0.0 uc(i,j)=0.0 vc(i,j)=0.0 uw(i,j)=0.0 vw(i,j)=0.0 ind(i,j)=1 enddo enddo c------------------------------------------------------------------c ind(i,j) = 1 : flow cell c =-1 : boundary cell, no-slip c =-2 : boundary cell, slip c =-10 : solid cell c------------------------------------------------------------------do j=36,45

38

do i=51,60 ind(i,j)=-10 enddo enddo do j=36,45 ind(51,j)=-1 ind(60,j)=-1 enddo do i=51,60 ind(i,36)=-1 ind(i,45)=-1 enddo c------------------------------------------------------------------return end c******************************************************************* subroutine pressure c******************************************************************* c------------------------------------------------------------------parameter(nx=240,ny=80,mp=10000,im=nx+2,jm=ny+2) implicit real*8(a-h,o-z) common /blk1/ uc(0:im,0:jm), vc(0:im,0:jm) & , u(0:im,0:jm), v(0:im,0:jm) & ,uw(0:im,0:jm), vw(0:im,0:jm) & , d(0:im,0:jm), p(0:im,0:jm) & ,ind(0:im,0:jm) common /blk2/dx,dy,dt,re1,fpx,fpy,fvx,fvy,uin c------------------------------------------------------------------dimension r(nx,ny) c------------------------------------------------------------------do 10 j=1,ny do 10 i=1,nx if(ind(i,j).lt.0)goto 10 d(i,j)=(u(i+1,j)-u(i,j))/dx+(v(i,j+1)-v(i,j))/dy 10 continue c------------------------------------------------------------------om=1.8 ddx=dx*dx ddy=dy*dy ddx1=1./ddx ddy1=1./ddy dxy1=1./dx/dy omega=0.5*om*ddx*ddy/(ddx+ddy) c------------------------------------------------------------------do 20 j=1,ny do 20 i=1,nx if(ind(i,j).lt.0)goto 20 qqq=-(uc(i+1,j)**2-2.0*uc(i,j)**2+uc(i-1,j)**2)*ddx1 & -(vc(i,j+1)**2-2.0*vc(i,j)**2+vc(i,j-1)**2)*ddy1 & -(uw(i+1,j+1)*vw(i+1,j+1)+uw(i,j)*vw(i,j) & -uw(i+1,j)*vw(i+1,j)-uw(i,j+1)*vw(i,j+1))*2.0*dxy1

39

r(i,j)=qqq+d(i,j)/dt +re1*((d(i+1,j)-2.0*d(i,j)+d(i-1,j))*ddx1 +(d(i,j+1)-2.0*d(i,j)+d(i,j-1))*ddy1) 20 continue c------------------------------------------------------------------do 300 n=1,100 & & resp=0.0 do 100 j=1,ny do 100 i=1,nx if(ind(i,j).lt.0)goto 100 dpdxx=(p(i+1,j)-2*p(i,j)+p(i-1,j))*ddx1 dpdyy=(p(i,j+1)-2*p(i,j)+p(i,j-1))*ddy1 pres=omega*(dpdxx+dpdyy-r(i,j)) resp=max(resp, abs(pres)) p(i,j)=p(i,j)+pres continue do j=1,ny p(0,j)=p(1,j) p(nx+1,j)=p(nx,j) enddo do i=1,nx p(i,0) =p(i,1) p(i,ny+1)=p(i,ny) enddo do 200 j=1,ny do 200 i=1,nx if(ind(i,j).gt.0)goto 200 if(ind(i+1,j).lt.0)goto 210 p(i,j)=p(i+1,j) if(ind(i-1,j).lt.0)goto 220 p(i,j)=p(i-1,j) if(ind(i,j+1).lt.0)goto 230 p(i,j)=p(i,j+1) if(ind(i,j-1).lt.0)goto 200 p(i,j)=p(i,j-1) continue

100

if(resp.lt.1d-6) goto 500 300 continue c------------------------------------------------------------------500 continue c write(*,*)'no. of sor=',n,' resp=',sngl(resp) c------------------------------------------------------------------return end c******************************************************************* subroutine velocity c*******************************************************************

40

c------------------------------------------------------------------parameter(nx=240,ny=80,mp=10000,im=nx+2,jm=ny+2) implicit real*8(a-h,o-z) common /blk1/ uc(0:im,0:jm), vc(0:im,0:jm) & , u(0:im,0:jm), v(0:im,0:jm) & ,uw(0:im,0:jm), vw(0:im,0:jm) & , d(0:im,0:jm), p(0:im,0:jm) & ,ind(0:im,0:jm) common /blk2/dx,dy,dt,re1,fpx,fpy,fvx,fvy,uin c------------------------------------------------------------------dimension uuu(0:im,0:jm),vvv(0:im,0:jm) c=================================================================== do i=0,nx+1 do j=0,ny+1 uuu(i,j)=0d0 vvv(i,j)=0d0 enddo enddo do 10 i=1,nx do 10 j=1,ny if(ind(i,j).lt.0) goto 10 if(ind(i-1,j).lt.0) goto 20 uuu(i,j)=u(i,j)+dt*( -0.5/dx*( (uc(i ,j) *(u(i, j)+u(i+1,j)) +abs(uc(i ,j))*(u(i, j)-u(i+1,j))) -(uc(i-1,j) *(u(i-1,j)+u(i, j)) +abs(uc(i-1,j))*(u(i-1,j)-u(i, j)))) -0.5/dy*( (vw(i,j+1) *(u(i, j)+u(i,j+1)) +abs(vw(i,j+1))*(u(i, j)-u(i,j+1))) -(vw(i, j) *(u(i,j-1)+u(i, j)) +abs(vw(i, j))*(u(i,j-1)-u(i, j)))) +re1*((u(i+1,j)+u(i-1,j)-2.0*u(i,j))/(dx**2) +(u(i,j+1)+u(i,j-1)-2.0*u(i,j))/(dy**2)) +(p(i-1,j)-p(i,j) )/dx)

& & & & & & & & & & & 20

10

continue if(ind(i,j-1).lt.0) goto 10 vvv(i,j)=v(i,j)+dt*( & -0.5/dx*( (uw(i+1,j) *(v(i, j)+v(i+1,j)) & +abs(uw(i+1,j))*(v(i, j)-v(i+1,j))) & -(uw(i, j) *(v(i-1,j)+v(i, j)) & +abs(uw(i, j))*(v(i-1,j)-v(i, j)))) (vc(i, j) *(v(i ,j)+v(i,j+1)) & -0.5/dy*( & +abs(vc(i, j))*(v(i ,j)-v(i,j+1))) vc(i,j-1) *(v(i,j-1)+v(i, j)) & -( & +abs(vc(i,j-1))*(v(i,j-1)-v(i, j)))) & +re1*((v(i+1,j)+v(i-1,j)-2.0*v(i,j))/(dx**2) & +(v(i,j+1)+v(i,j-1)-2.0*v(i,j))/(dy**2)) & +(p(i,j-1)-p(i,j))/dy) continue do i=0,nx+1

41

do j=0,ny+1 u(i,j) =uuu(i,j) v(i,j) =vvv(i,j) enddo enddo c------------------------------------------------------------------return end c******************************************************************* subroutine bc c******************************************************************* parameter(nx=240,ny=80,mp=10000,im=nx+2,jm=ny+2) implicit real*8(a-h,o-z) common /blk1/ uc(0:im,0:jm), vc(0:im,0:jm) & , u(0:im,0:jm), v(0:im,0:jm) & ,uw(0:im,0:jm), vw(0:im,0:jm) , d(0:im,0:jm), p(0:im,0:jm) & ,ind(0:im,0:jm) & common /blk2/dx,dy,dt,re1,fpx,fpy,fvx,fvy,uin c------------------------------------------------------------------c Boundary condition for velocity c------------------------------------------------------------------c cylinder c------------------------------------------------------------------do 200 j=1,ny do 200 i=1,nx if(ind(i,j).gt.0)goto 200 if(ind(i+1,j).lt.0)goto 210 if(ind(i,j).eq.-1.and.ind(i,j-1).lt.0)v(i,j)=-v(i+1,j) if(ind(i,j).eq.-2.and.ind(i,j-1).lt.0)v(i,j)=v(i+1,j) 210 if(ind(i-1,j).lt.0)goto 220 if(ind(i,j).eq.-1.and.ind(i,j-1).lt.0)v(i,j)=-v(i-1,j) if(ind(i,j).eq.-2.and.ind(i,j-1).lt.0)v(i,j)=v(i-1,j) 220 if(ind(i,j+1).lt.0)goto 230 if(ind(i,j).eq.-1.and.ind(i-1,j).lt.0)u(i,j)=-u(i,j+1) if(ind(i,j).eq.-2.and.ind(i-1,j).lt.0)u(i,j)=u(i,j+1) 230 if(ind(i,j-1).lt.0)goto 200 if(ind(i,j).eq.-1.and.ind(i-1,j).lt.0)u(i,j)=-u(i,j-1) if(ind(i,j).eq.-2.and.ind(i-1,j).lt.0)u(i,j)=u(i,j-1) 200 continue c------------------------------------------------------------------c wall c------------------------------------------------------------------do j=0,ny+1 u(0,j)=uin u(1,j)=uin u(nx+1,j) = u(nx,j) u(nx+2,j) = u(nx,j) v(0,j)=0d0 v(nx+1,j)= v(nx,j) enddo

42

do i=0,nx+1 u(i,0) =u(i,1) u(i,ny+1)=u(i,ny) v(i,1)=0d0 v(i,0)=0d0 v(i,ny+1)=0d0 v(i,ny+2)=0d0 enddo c------------------------------------------------------------------c center velocity & corner velocity c------------------------------------------------------------------do i=0,nx+1 do j=0,ny+1 uc(i,j)=0.5*(u(i,j)+u(i+1,j)) vc(i,j)=0.5*(v(i,j)+v(i,j+1)) enddo enddo do i=1,nx+1 do j=1,ny+1 uw(i,j)=0.5*(u(i,j-1)+u(i,j)) vw(i,j)=0.5*(v(i-1,j)+v(i,j)) enddo enddo c------------------------------------------------------------------return end c******************************************************************* subroutine force c******************************************************************* parameter(nx=240,ny=80,mp=10000,im=nx+2,jm=ny+2) implicit real*8(a-h,o-z) common /blk1/ uc(0:im,0:jm), vc(0:im,0:jm) & , u(0:im,0:jm), v(0:im,0:jm) & ,uw(0:im,0:jm), vw(0:im,0:jm) & , d(0:im,0:jm), p(0:im,0:jm) & ,ind(0:im,0:jm) common /blk2/dx,dy,dt,re1,fpx,fpy,fvx,fvy,uin c------------------------------------------------------------------c Forces on the cylinder c------------------------------------------------------------------fpx=0d0 fpy=0d0 fvx=0d0 fvy=0d0 do 200 j=1,ny do 200 i=1,nx if(ind(i,j).gt.0)goto 200 if(ind(i+1,j).lt.0)goto 210 fpx=fpx-p(i+1,j)*dy fvy=fvy+re1*vc(i+1,j)*dy*2/dx if(ind(i-1,j).lt.0)goto 220

210

43

fpx=fpx+p(i-1,j)*dy fvy=fvy+re1*vc(i-1,j)*dy*2/dx 220 if(ind(i,j+1).lt.0)goto 230 fpy=fpy-p(i,j+1)*dx fvx=fvx+re1*uc(i,j+1)*dx*2/dy 230 if(ind(i,j-1).lt.0)goto 200 fpy=fpy+p(i,j-1)*dx fvx=fvx+re1*uc(i,j-1)*dx*2/dy 200 continue c------------------------------------------------------------------return end

- Development and Validation of a c++ Object Oriented Cfd Code for Heat Transfer AnalysisUploaded byAghajani
- Marine Applications of CfdUploaded byaravind
- CFD LecturesUploaded bymyrazainal
- CFDUploaded byPankaj Gupta
- CFD TutorialsUploaded byOsama A Ghani
- Ship Resistance and PropulsionUploaded byMerrel
- ResistanceUploaded byAmr Moro
- CFD introUploaded byJohn Philip
- CFD Project TitlesUploaded byThota Sri K Haritha
- Ship Resistance calculation for a fishing vesselUploaded byMahdi
- Best Practice Guidelines for Turbo Machinery CFDUploaded byShabaz Sadiq
- Marine HydrodynamicsUploaded bySanjay Madaka
- nptel cfd notesUploaded byHemaprasanth
- Fluid Flow for the Rest of UsUploaded byhlkatk
- Turbulence ModellingUploaded byapi-3803751
- CFDNotes06 (1)Uploaded byPraveen P Jose
- Steam Power Plants EnglishUploaded byMirza Zubair Raza
- marine hydrodynamics mit notesUploaded byRafael Castelo Branco Goulart
- Numerical Simulations - Examples and Applications in Computational Fluid DynamicsUploaded bycarlosnavalmaster
- Amano and Sunden -- Computational Fluid Dynamics and Heat TransferUploaded byseriouslion
- Resistance CalculationUploaded byRajesh Kumar Reddy
- Computational fluid dynamicsUploaded bykevinmuri
- Computational Fluid DynamicsUploaded byFlorica Balog
- Cfd Simulation pptUploaded bySambhav Jain
- CFDUploaded byRafael Cavalcante
- ParaView User's Guide v3.14Uploaded byg_demonaco
- Cfd Manual FluentUploaded byLaxman Kumar
- Validation of CFD Codes for Slamming 26 10Uploaded bydan10000
- Computational Fluid Mechanics and Heat TransferUploaded byTomer Saley
- Non DimensionalizationUploaded byRajeev Raj's

- ABAQUS Element Selection CriteriaUploaded bycoteesh
- Naca Report 990Uploaded bysubha_aero
- r1 Arb Low Mass Presentation 5-18-2010Uploaded bysubha_aero
- matlabUploaded bysubha_aero
- 10 Low and High Cycle FatigueUploaded byPRASAD326
- Bluff BodiesUploaded byestrella
- TriDiag-Asilomar06Uploaded bysubha_aero
- A Design Approach & Selected Wind-tunnel Results at High Subsonic Speeds for Wing-tip Mounted WingletsUploaded bysubha_aero
- Module 3 Lesson 4Uploaded bysubha_aero
- LectureUploaded bysudhakar1705
- A DESIGN APPROACH & SELECTED WIND-TUNNEL RESULTS AT HIGH SUBSONIC SPEEDS FOR WING-TIP MOUNTED WINGLETS.pdfUploaded bysubha_aero
- Boeing Blended WingletUploaded bysubha_aero
- TS-03Uploaded byJulio Herrera Venegas
- Wing LetsUploaded byRuslan Agani
- A380B L To DragUploaded bysubha_aero
- A380RoedtsUploaded byAjith Lal J S
- A380Buescher.pdfUploaded byharrysalmon
- A380 ReferenceUploaded bysubha_aero
- Tailor Weld BlanksUploaded bysubha_aero
- Towing BasicsUploaded bysubha_aero
- McCormick - Aerodynamics, Aeronautics and Flight Mechanics [Partial Scan p1-179]Uploaded byPum Pui
- Bridge dynamicsUploaded bysubha_aero
- FAA-8083-30_Ch05.pdfUploaded bySezgin Bayrak
- FAA-8083-30_Ch01.pdfUploaded byJoão Miguel
- Ch14TechniquesOfFailureAnalysis.pdfUploaded byJuan
- Annual Reviews Materials Research 2015. (45) page 391-431 overview dual phase steels.pdfUploaded bysubha_aero
- Unit 1 IntroductionUploaded bysubha_aero
- Vibration Control Book 07Uploaded bybilleo_intern
- Failure Analysis of a Car Suspension System Ball JointUploaded bysubha_aero
- LS-PrePost Intro 2016Uploaded byRay Faiers

- KV JMO 2015 SolutionsUploaded byPremMehta
- fGarchUploaded bywfwerfgwgsr
- Lecture Note 1Uploaded byMohammad Soleeh
- MTH301 MidTerm 2010Uploaded byAinul Hassan
- 52115-mt----reliability engineeringUploaded bySRINIVASA RAO GANTA
- MC0072 - Set 2Uploaded bynikeneel
- HW1 (1)Uploaded bySurajkumar Harikumar
- ECE R13 2-1.pdfUploaded byHassan
- Curve FittingUploaded byJaphet Gabatan
- ModelingUploaded byCostas Aggelidis
- Bradford Skow -- Why Does Time PassUploaded byDamir Đirlić
- Vectors in R^3Uploaded byKhalid Almuteri
- MCQ class XUploaded byVikas Kanodia
- Math56a LecturesUploaded bySahil Agarwal
- 2015 Exam Marking GuidelinesUploaded byM
- Sub ManifoldsUploaded bygoyaltarun
- Probabilistic RoboticsUploaded bymcx_123
- Differential EquationsUploaded byBen Kwapong
- Calculus by and for Young PeopleUploaded byAnonymous Q82UI7zA
- Unit 2 Discrete-Time Signal and SystemsUploaded byJPR EEE
- Help AnClimUploaded byhcsrecs
- 3 Fundamentals of CNC Programming I (CNC Course CD)Uploaded byJimmy Rodriguez
- Image Processing Assignment 2 2012Uploaded byAvinash Hegde
- MATH3175 Fa10 Practice6 SolUploaded byoscura
- CSE_Syllabus_Booklet_4_Yr_BTech_Revised_060120163.pdfUploaded bykappi4u
- 81314_13.pdfUploaded byPavan Gisadi
- Unsur – unsur aljabarUploaded byIcha Cahya
- Homework 12 AssignmentUploaded byspexican924
- RepositoryUploaded byarefinhasib07
- Ch23 (Young-Freedman) Parte 2Uploaded byJorgeCortez