You are on page 1of 86

Lectures on

Applied Thermal Fluid Dynamics



Computational Thermal Fluid Dynamics
Prof. Carlo Nonino
Academic Year 2018/19
(v.18.9.18)

Contents
1 Introduction to CFD 3
1.1 Main Concepts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
1.2 Uses of CFD . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4

I Thermal Fluid Dynamics Review 7


2 Equations of Thermal Fluid Dynamics 7
2.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
2.2 Mass Balance . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
2.3 Thermal Energy Balance . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
2.4 Momentum Balance . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
2.5 Other Equations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17

II CFD Fundamentals 20
3 Partial Dierential Equations (PDEs) 20
3.1 Denitions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20
3.2 Classication of PDEs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22
3.3 Boundary Conditions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26

4 Finite Dierence Method (FDM) 33


4.1 Basic Concepts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33
4.2 Direct Approach . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34
4.3 Taylor-Series-Based Approximations . . . . . . . . . . . . . . . . . . . . . . 35
4.4 2-D Problems . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38

5 Accuracy of Numerical Solutions 42


5.1 Errors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42
5.2 Order of Accuracy . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45

1
6 Grids 48
6.1 Types of Grids . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48
6.2 Practical Aspects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51

III Finite Volume Method (FVM) 53


7 Preliminaries 53
7.1 Basic Concepts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 53

8 Space Integration 57
8.1 Source Term . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 57
8.2 Diusion Term . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 58
8.3 Advection Term . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 60

9 Final Algebraic Equation (1) 64


9.1 Steady-State Problems . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 64

10 Time Integration 67
10.1 Preliminaries . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 67
10.2 Two-Level Methods . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 68
10.3 Multilevel Methods . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 71

11 Final Algebraic Equation (2) 71


11.1 Time-Dependent Problems . . . . . . . . . . . . . . . . . . . . . . . . . . . 71

IV Incompressible Navier-Stokes Equations 74


12 Solution Methods 74
12.1 Possible Approaches . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 74
12.2 Segregated Solution Algorithms . . . . . . . . . . . . . . . . . . . . . . . . 77

13 FVM Implementation of the Projection Algorithm 81


13.1 Predictor Step . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 81
13.2 Corrector Step . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 85

2
1 Introduction to CFD
1.1 Main Concepts
Denitions
• Computational Fluid Dynamics (CFD): branch of uid mechanics that uses nu-
merical methods to solve uid ow problems.
• Numerical methods: methods to solve dierential equations not in an analytical
form through symbolic manipulations, but in an approximate form through a huge
amount of algebraic operations having numbers as results.

• Numerical methods require a domain discretization, i.e., locating a (very) large


number of points (nodes) where the approximate solution is found.

• Computational Thermal Fluid Dynamics: CFD + heat (and mass) transfer.

Analytical vs. Numerical Solutions


• Analytical solution:
 exact and dened in the continuum (innite points);
 can only be found for simple geometries and boundary conditions.

• Numerical solution:
 approximate and dened in a large but nite number of points;
 can even be found for complex geometries and boundary conditions (engineering
applications).

Numerical Solution of a Problem


Steps to solve numerically a real problem (unlimited denition domain):
 physical model: simplication of the problem (after identing the relevant as-
pects);
 domain model: identication of a nite solution domain;
 mathematical model: equations and boundary conditions that describe the
simplied problem;
 domain discretization: domain subdivisions and location of nodes;
 application of a numerical method to discretize the governing dierential
equations and construct a system of linear algebraic equations;
 solution of the system of algebraic equations to nd the approximate solution
to the problem.

3
Numerical Methods
• Finite dierence method
• Finite volume method (Control volume method)
 Finite element method (FEM)
 Boundary element method (BEM)
 Spectral methods
 Meshless methods

1.2 Uses of CFD


Fields of Applications of CFD
• Aerospace (external ows, engine parts).
• Automotive (internal and external ows, engine parts).
• Energy (heat exchangers, combustion chambers, furnaces, air conditioning).
• Turbomachinery (turbines, pumps, fans).
• Chemical plant design (chemical reactors, mixers).
• Mechanical plant design (plant components).
• Meteorology (weather forcast).
• Electronics (cooling of electronic components).
• Marine engineering (hydrodynamics of hulls, propellers, aerodynamics of sails, etc.).
• Foundry (metal fusion, mold lling, continuous casting).
• Environment (meteorology, dispersion of pollutants, res, indoor comfort).
• Microuidics (micro heat exchangers, micro mixers).
• Biomedicine (heart valves, blood vessels, etc.).
• Fluid-structure interaction (2 physics involved).

4
CFD Market
• Value of CFD market (worldwide) in 2014: > $ 1, 000, 000, 000.

Why CFD?
• CFD is a very convenient way to study ow problems.
• CFD is less expensive than experiments and gives more complete information.
• CFD is not intrusive.
• CFD is repeatable.
• CFD parametric studies are much faster than experimental ones.
• CFD could be the only alternative to experiments (too expensive or dangerous).

Importance of Simulations
• Evaluate dierent designs for selection of an acceptable one.
• Study the system behavior under o-design conditions.
• Determine safety limits for the system.
• Improve or modify existing systems.
• Determine the eects of dierent design variables for optimization purposes.
• Investigate the sensitivity of the design to dierent variables.

Warnings
• The CFD analysis is based on models.
• One cannot expect to obtain more information than what models can give.

• CFD can give a false sense of simplicity.

• Appropriate use of CFD codes requires at least some knowledge of the implemented
models and methods.
• Possible risks if the CFD analysis is carried out by unskilled users:

 GIGO (Garbage In, Garbage Out);

 CFD (Colorul Fluid Dynamics, instead of Computational Fluid Dynamics).

5
CFD and Experiments
• CFD contains assumptions (models) that sometimes produce false results.
• CFD is not suciently reliable (yet) to completely replace experiments.
• CFD does not replace experiments, but it represents their complement (seeing
is believing even if there can be errors of measurement or due to the use of scaled
models).

• CFD models must be validated using experimental results.


• Denitions
 Validation: making sure that the adopted model is correct (it concerns the
problem).

 Verication: making sure that the model equations have been correctly imple-
mented and solved (it concerns the computer program and the solution).

Aims of This Course


1. Give an understanding of the processes involved in converting dierential equations
to sets of algebraic (discretized) equations.
2. Allow an appreciation of the accuracy and stability issues associated with dierent
approximations.

3. Provide an understanding of how the resulting sets of equations are solved, and how
coupled sets of equations are handled.
• Note 1 : A number of commercial CFD codes (ANSYS Fluent, Star-CCM+, Comsol,
...) are available which may appear  easy-to-use. Open source codes (OpenFoam,
Elmer, ...), instead, are not as user friendly.

• Note 2 : A good understanding of the above issues and of the numerical methods
employed by the programs is necessary to

 obtain reliable results;


 recognize whether obtained solutions make sense or not.

6
Part I
Thermal Fluid Dynamics Review
2 Equations of Thermal Fluid Dynamics
2.1 Introduction
Hypotheses
• Newtonian uid: viscosity independent of velocity −→ shear stress proportional
to shear rate (rate of the shearing deformation). In a Couette ow

du
τyx = µ
dy

• Incompressible ow: density independent of pressure.


• Two-dimensional ow (extensions to 3-D are straightforward).
• Laminar ow (governing equations are of general validity, but grid resolution re-
quired to analyze turbulent ows is often prohibitively high −→ turbulence models
(not covered in this course)).

Notation
• Vectors    
ax bx
a= b=
ay by

• Scalar product
s = a · b = ax b x + ay b y

• Alternative notation
 
T bx
s = a b = [ax ay ] = ax b x + ay b y
by

• Gradient and divergence operators


 
 ∂ 
   

∂x
 ∂ ∂
∇= ∇· =

 ∂  ∂x ∂y
 
∂y

7
Balances
• Divergence (Gauss) theorem
Z Z  
nx
∇ · a dV = n · a dA n=
V A ny

Z   Z
∂ax ∂ay
+ dV = (nx ax + ny ay ) dA
V ∂x ∂y A

• General form of a balance (in words)


accumulation = inf low − outf low + generation

• In a symbolic form
Z Z Z Z Z
∂(...)
dV = n · (...)dA + (...)dV = ∇ · (...)dV + (...)dV
V ∂ϑ A V V V

Z
[(...) + (...) + (...)] dV = 0
V

2.2 Mass Balance


Continuity Equation
Arbitrary reference domain
• Mass balance (no mass sources)
y
X X  Au
∆m = ṁe − ṁu ∆ϑ

• For ∆ϑ → 0 n
dm X X dm
= ṁe − ṁu d

V

Ae
Z  
dm ∂ρ u
= dV w=
dϑ ∂ϑ v
V w
x
X X Z Z
ṁe − ṁu = − ρw · n dA = − ∇ · (ρw) dV
A V

• Balance equation (V arbitrary)

Z  
∂ρ
+ ∇ · (ρw) dV = 0
V ∂ϑ

8
• Continuity equation (general form)
∂ρ ∂ρ ∂(ρu) ∂(ρv)
+ ∇ · (ρw) = 0 + + =0
∂ϑ ∂ϑ ∂x ∂y

• For a steady state ow


∂(ρu) ∂(ρv)
∇ · (ρw) = 0 + =0
∂x ∂y

• For a constant density ow (ρ = const, steady and unsteady)


∂u ∂v
∇·w =0 + =0
∂x ∂y

2.3 Thermal Energy Balance


Thermal Energy Equation in Vector Form
• Conservative form


(ρcp t) + ∇ · (ρwcp t) = ∇ · (λ∇t) + q̇
∂ϑ

• If ρ = const, which implies that ∇ · w = 0, and cp = const

∇ · (ρwcp t) = ρcp ∇ · (wt) = ρcp w · ∇t + ρcp t∇ · w = ρcp w · ∇t

• Non-conservative form
Dt ∂t
ρcp = ρcp + ρcp w · ∇t = ∇ · (λ∇t) + q̇
Dϑ ∂ϑ

• Material (substantial, total) derivative

D ∂
= +w·∇
Dϑ ∂ϑ

• If λ = const
∇ · (λ∇t) = λ∇2 t

9
Remarks
• Terms of the equations:
∂ ∂t
 unsteady terms: (ρcp t) ρcp
∂ϑ ∂ϑ
 advection (convection) terms:
∇ · (ρwcp t) ρcp w · ∇t

diusion terms:
 ∇ · (λ∇t) λ∇2 t
 source term: q̇
• Note 1: the work of the viscous forces (viscous dissipation) has been neglected.
• Note 2: a pressure term has been neglected (only valid if p = const or ρ = const).
• Note 3: if ρ = const −→ cp = cv = c.
• Note 4: conservative and non-conservative forms are only equivalent in the con-
tinuum, but not when discretized.
• Note 5: energy eq. with w = 0 −→ heat conduction equation.

Thermal Energy Equation in Cartesian Coordinates


• Conservative form

∂ ∂ ∂
(ρcp t) + (ρucp t) + (ρvcp t)
∂ϑ ∂x ∂y
   
∂ ∂t ∂ ∂t
= λ + λ + q̇
∂x ∂x ∂y ∂y

• Non-conservative form
   
∂t ∂t ∂t
ρcp + ρcp u +v
∂ϑ ∂x ∂y
   
∂ ∂t ∂ ∂t
= λ + λ + q̇
∂x ∂x ∂y ∂y

• If λ = const  2
∂ 2t
    
∂ ∂t ∂ ∂t ∂ t
λ + λ =λ +
∂x ∂x ∂y ∂y ∂x2 ∂y 2

10
2.4 Momentum Balance
Tensors
• Tensors: mathematical entities which represents the generalization of scalars and
vectors.

• In a 2-D space a scalar has 1 component, a vector 2 components, a tensor 2×2 = 4


components.

• Rank (order): number of indices necessary to identify the components.

• Scalars have 0 indices, vectors 1 index, second order tensors 2 indices, higher order
tensors more than 2 indices.

• Viscous stress tensor: second order tensor used to model the part of the stress that
can be attributed to the strain rate.

Viscous Stress Tensor


Viscous stress components

• Denition in 2-D

" #
τxx τxy
T=
τyx τyy

• T is symmetric: τxy = τyx


• Notation: τyx is a stress in the x direc-
tion acting on a face normal to the y di-
rection.

• A face is positive if its outward normal points in the + coordinate direction.


• A stress component is positive if it acts on a + face in the + coordinate direction
or on a − face in the − coordinate dir.

• Normal stress: positive (negative) if it produces tension (compression).

Tensor Operations
• Scalar product of two vectors w · w or wT w (result: a scalar)
 
u
= u2 + v 2
 
w·w = u v
v

• Dyadic (tensor) product of two vectors ww or w ⊗ w (result: a tensor)


   
u   uu uv
ww = u v =
v vu vv

11
• Vector product of a vector and a tensor n · T (result: a vector)
" #!T ( )
  τxx τxy nx τxx + ny τyx
n·T= nx ny =
τyx τyy nx τxy + ny τyy

• It is not commutative: n · T 6= T · n.

Momentum Equations in Vector Form


• Conservative form


(ρw) + ∇ · (ρww) = −∇p + ∇ · T + ρg
∂ϑ

where  
 ∂p  ( )
gx
 
∂x
 
∇p = g=

 ∂p 
 gy
 
∂y
• The divergence of a tensor is similar to the vector product of a vector and a tensor
∂ ∂
 
  T  (ρuu) + (ρvu) 

∂ ∂ ρuu ρuv
 ∂x ∂y 
∇ · (ρww) = =
∂x ∂y ρvu ρvv  ∂ ∂ 

 (ρuv) + (ρvv) 

∂x ∂y

• Note: the divergence operator lowers ranks of tensors by 1: applied to vectors


−→ scalars; applied to tensors −→ vectors.

• It can be shown that

∇ · (ρww) = ρw · ∇w + w∇ · (ρw)

• If ρ = const −→ ∇ · w = 0 −→ ∇ · (ρww) = ρw · ∇w
• Non-conservative form
Dw ∂w
ρ =ρ + ρw · ∇w = −∇p + ∇ · T + ρg
Dϑ ∂ϑ

• The gradient of a vector is similar to the dyadic product of two vectors


 
∂  ∂u ∂v
 

 
∂x ∂x ∂x 
   
∇w = u v = 

 ∂ 

 ∂u ∂v 
 
∂y ∂y ∂y

12
• Note: according to some texts, the gradient of a vector is dened as the transpose
T
of ∇w, i.e., as (∇w) (equivalent to the Jacobian matrix
of the vector eld).

• Advection term (vector product of a vector and a tensor)


T 
∂u ∂u

∂u ∂v
 

 ρu + ρv 

   ∂x ∂x   ∂x ∂y 
ρw · ∇w = 
 ρu ρv  ∂u
  =
∂v   ∂v ∂v 
 ρu
 + ρv 

∂y ∂y ∂x ∂y
• Alternative form of the advection term: ρ(w · ∇)w (dierent operations, but same
results).

• Divergence of the viscous stress tensor

∂ ∂
 
 ∂x (τxx ) + (τyx )
" #!T  
τxx τxy
  
∂ ∂ ∂y 
∇·T= =
∂x ∂y τyx τyy  ∂ ∂ 

 (τxy ) + (τyy ) 

∂x ∂y
• Note: in some cases the total stress tensor σ, which models the eects of both
viscous stresses and internal pressure, appears in the momentum equations.
• Total stress tensor
" #
τxx − p τxy
σ = −pI + T =
τyx τyy − p

where I is the unit tensor " #


1 0
I=
0 1

• In the momentum equations, the terms −∇p + ∇ · T are replaced by

∇ · σ = ∇ · (−pI + T)

Momentum Equations in Cartesian Coordinates


• Conservative form
∂ ∂ ∂ ∂p ∂ ∂
(ρu) + (ρuu) + (ρvu) = − + (τxx ) + (τyx ) + ρgx
∂ϑ ∂x ∂y ∂x ∂x ∂y
∂ ∂ ∂ ∂p ∂ ∂
(ρv) + (ρuv) + (ρvv) = − + (τxy ) + (τyy ) + ρgy
∂ϑ ∂x ∂y ∂y ∂x ∂y

• Non-conservative form
∂u ∂u ∂u ∂p ∂ ∂
ρ + ρu + ρv =− + (τxx ) + (τyx ) + ρgx
∂ϑ ∂x ∂y ∂x ∂x ∂y
∂v ∂v ∂v ∂p ∂ ∂
ρ + ρu + ρv =− + (τxy ) + (τyy ) + ρgy
∂ϑ ∂x ∂y ∂y ∂x ∂y

13
Stokes' Constitutive Equations
• Viscous stress tensor
 2
T = µ ∇w + (∇w)T − µ(∇ · w) I

3

∂u ∂u
 
 ∂x ∂y 
(∇w)T = 
 ∂v

∂v 
∂x ∂y
• Components of the viscous stress tensor
∂u 2 ∂v 2
τxx = 2µ − µ∇ · w τyy = 2µ − µ∇ · w
∂x 3 ∂y 3



∂u ∂v
τxy = τyx = µ +
∂y ∂x
 
• If ρ = const −→ ∇ · w = 0 −→ T = µ ∇w + (∇w)T

Navier-Stokes Equations in Vector Form (∇ · w = 0)


• Conservative form


(ρw) + ∇ · (ρww) = −∇p + ∇ · µ ∇w + (∇w)T + ρg
  
∂ϑ

• Non-conservative form
∂w
+ ρw · ∇w = −∇p + ∇ · µ ∇w + (∇w)T + ρg
  
ρ
∂ϑ

• Diusion term
     
∂ ∂u ∂ ∂u ∂v
 2 ∂x µ ∂x + ∂y µ ∂y + µ ∂x

 

n h io  

T
∇ · µ ∇w + (∇w) =    
 ∂ ∂v ∂u ∂ ∂v 

 µ +µ +2 µ 

∂x ∂x ∂y ∂y ∂y
 

14
Simplication of the Diusion Term
• It can be shown that
∇ · (∇w)T = ∇(∇ · w)

• If µ = const and ρ = const, i.e., ∇ · w = 0

∇ · µ ∇w + (∇w)T = µ[∇ · (∇w) + ∇ · (∇w)T ]


  

= µ[∇ · (∇w) + ∇(∇ · w)] = µ∇ · (∇w) = µ∇2 w = ∇ · (µ∇w)

Simplied diusion term


∂ 2u ∂ 2u 
 

 µ
 ∂x2 + µ 
2 ∂y 2 
µ∇ w =
 ∂ 2v ∂ 2v 

 µ

+ µ 
∂x 2 ∂y 2

• Alternative form
T
∂u ∂v
 
 µ ∂x µ ∂x 
 
 ∂ ∂
∇ · (µ∇w) =  
 ∂u

 ∂x ∂y ∂v 
µ µ
∂y ∂y

     
∂ ∂u ∂ ∂u
 ∂x µ ∂x + µ

 

 
∂y ∂y 
=    
 ∂ ∂v ∂ ∂v 

 µ + µ 

∂x ∂x ∂y ∂y
 

• The simplied form is usually found in textbooks for the case of µ = const, the
alternative one is more suitable for discretization.

The Boussinesq Approximation


• It allows the solution of natural convection problems using the formulation of the
Navier-Stokes equations valid for ρ = const.
• It reduces the nonlinearity of the problem −→ faster convergence and lower com-
putational costs.

• It isaccurate when density variations are small.


• Assumption: density variations have no eects on the ow eld except when they
give rise to buoyancy forces.

• It requires rewriting the buoyancy term ρg and redening pressure by subtracting


the hydrostatic component −ρ0 gH , (H : elevation; subscript 0: reference condition).

• The − sign is necessary because pressure decreases for increasing elevation.

• For a uid at rest: p = const + (−ρ0 gH).

15
• Pressure is expressed as the sum of two contributions
p = p̃ − ρ0 gH −→ p̃ = p + ρ0 gH

p̃: deviation from the hydrostatic pressure (p̃ = const for a uid at rest).

• Pressure and buoyancy terms of N-S equations are modied


−∇p + ρg = −∇p̃ + ρ0 g∇H + ρg = −∇p̃ + (ρ − ρ0 )g

where g∇H = −g since

∂H ∂H g
∇H = i+ j=j and j=−
∂x ∂H g

• The change from p to p̃ is often referred to as pressure shift.


• Boussinesq approximation: the density variation is only important in the buoyancy
term and can be neglected in the rest of the equation.
 
1 ∂ρ ∼ 1 ρ − ρ0
[dρ = −βρdT ]p −→ β=− =−
ρ ∂T p ρ t − t0

ρ − ρ0 ∼
= −ρβ(t − t0 )

β: thermal expansion coecient. For ideal gases: β = 1/T .


• Final forms of the modied pressure and buoyancy terms
−∇p + ρg = −∇p̃ − ρβ(t − t0 )g

• Note 1: Since for a uid at rest p̃ = const and ∇p̃ = 0 −→ ∇p̃ 6= 0 is only a function
of the ow eld.

• Note 2: Isothermal ow −→ buoyancy term equal to zero.

Simplied Navier-Stokes Equations in Vector Form


• Conservative form

(ρw) + ∇ · (ρww) = −∇p̃ + ∇ · (µ∇w) − ρβ(t − t0 )g
∂ϑ

• Non-conservative form
Dw ∂w
ρ =ρ + ρw · ∇w = −∇p̃ + ∇ · (µ∇w) − ρβ(t − t0 )g
Dϑ ∂ϑ

• Validity: ρ = const, µ = const, Boussinesq approximation.


• Note: From now on, ˜ omitted to lighten the notation.

16
Simplied Navier-Stokes Equations in Cartesian Coordinates
• Conservative form
   
∂ ∂ ∂ ∂p ∂ ∂u ∂ ∂u
(ρu) + (ρuu) + (ρvu) = − + µ + µ
∂ϑ ∂x ∂y ∂x ∂x ∂x ∂y ∂y
− ρβ(t − t0 )gx
   
∂ ∂ ∂ ∂p ∂ ∂v ∂ ∂v
(ρv) + (ρuv) + (ρvv) = − + µ + µ
∂ϑ ∂x ∂y ∂y ∂x ∂x ∂y ∂y
− ρβ(t − t0 )gy

• Non-conservative form
   
Du ∂u ∂u ∂u ∂p ∂ ∂u ∂ ∂u
ρ =ρ + ρu + ρv =− + µ + µ
Dϑ ∂ϑ ∂x ∂y ∂x ∂x ∂x ∂y ∂y
− ρβ(t − t0 )gx
   
Dv ∂v ∂v ∂v ∂p ∂ ∂v ∂ ∂v
ρ =ρ + ρu + ρv =− + µ + µ
Dϑ ∂ϑ ∂x ∂y ∂y ∂x ∂x ∂y ∂y
− ρβ(t − t0 )gy

Forced, Natural and Mixed Convection


• Reynold and Grashof numbers

ρUref Lref Uref Lref gβ(ts − t0 )L3ref


Re = = Gr =
µ ν ν2

Gr
• 1 −→ forced convection;
Re2
Gr
• 1 −→ natural convection;
Re2
Gr
• ∼1 −→ mixed convection.
Re2

2.5 Other Equations


The Stream Function ψ
• 2-D ows.
Scalar function, only dened for

• Meaning: the stream function dierence between two points in the ow is equal to
the volumetric ow rate per unit depth through any line connecting those points.
2
Units: [m /s].

• Relation with velocity components


∂ψ ∂ψ
u= v=−
∂y ∂x

17
• Continuity equation automatically satised
∂u ∂v ∂ 2ψ ∂ 2ψ
+ = − ≡0
∂x ∂y ∂x∂y ∂y∂x

• Stream function equation (Poisson equation)


∂ 2ψ ∂ 2ψ ∂v ∂u
∇2 ψ = + 2 = −ωz ωz = −
∂x2 ∂y ∂x ∂y

• Vorticity ω = ∇ × w: twice the local angular velocity.

Streamlines
• Streamline: a line that at each point is tangent to the local velocity vector.
• Properties:
 they can never cross;
 in steady ows they coincide with the uid particle trajectories;
 in 2-D ows, between two streamlines, the volumetric ow rate is constant;
 in 2-D ows, they coincide with the contour lines of the stream function
(useful for ow visualization).

Example of streamline plot

• Streamlines can also be approximated bypolylines with vertex coordinates obtained


by time integration from suitable starting points (only way in 3-D).

• Drawbacks: possible approximation errors + information only on velocity direc-


tion, but not on value.

18
Equations in Cylindrical Coordinates
• Continuity, energy and momentum equations can also be written in cylindrical co-
ordinates.
• Useful for the solution of axisymmetric problems (axisymmetric domain + ax-
isymmetric boundary conditions).

• The solution is the same on any radial plane passing through the symmetry axis −→
a 3-D problem can be solved as a 2-D problem.

Example of axisymmetric domain

19
Part II
CFD Fundamentals
3 Partial Dierential Equations (PDEs)
3.1 Denitions
Well-Posed Problem
• A problem is well posed if:
 the solution to the governing PDE exists (condition always satised if the equa-
tion describes a physical problem);
 the solution is unique (condition satised if domain, solution procedure, bound-
ary and initial conditions are appropriate  underspecied problem −→ no solu-
tion; overspecied prob. −→ solution with no physical meaning);
 the solution depends continuously upon initial and boundary conditions,
i.e., small variations of i.c. or b.c. −→ small variations in the solution (relevant
property since these conditions are never precisely known).

• The mathematical character of dierential equations must be known for the se-
lection of the appropriate solution domain, solution procedure, boundary and initial
conditions.

• The character can be easily determined for linear (or linearized) PDEs containing
only rst and second order derivatives.

Linear PDEs
• A PDE is linear if it is of rst degree in all of its unknowns and partial derivatives
(no multiplications among them, coecients independent of the unknowns).

• Example of linear PDE (if ρ, cp , q̇ independent of t)

∂t
ρcp + ρcp w · ∇t = λ∇2 t + q̇
∂ϑ

• Example of nonlinear PDE (even if ρ, µ = const )


∂w
ρ + ρw · ∇w = µ∇2 w − ∇p − ρβ(t − t0 )g
∂ϑ

• The two equations have the same structure, but the second one is nonlinear because
of the term w · ∇w.
• The numerical solution of a nonlinear equations requires linearization.

20
Linearization
• An iterative procedure is necessary: the solution procedure is repeated until a
suitable convergence criterion is satised.

• One or more unknowns (or derivatives) in the nonlinear terms are replaced by appro-
priate coecients so that only one unknown (or derivative) remains in each term.
• Example of linearization of the term w · ∇w: in iteration k + 1, w · ∇w −→ wk · ∇w
(Picard's method).

• wk is the solution at the previous iteration and, thus, it is known −→ it is a vector


of coecients −→ the term w · ∇w has been linearized.
• Convergence is reached when ||wk+1 − wk || <  (very small).
• Other convergence criteria are based on the residuals of the discretized equations.

• Note: any equation with thermophysical properties that are dependent on the
unknowns in nonlinear and must be linearized and solved iteratively.

Iterative Solution

21
Iterations and Relaxation
Convergence without relaxation Under-relaxation required

• Vvery often relaxation is necessary to obtain convergence with iterative proce-


dures.
• Iterations start from guessed initial values of the dependent variable (φ ≡ t, u, v,
etc.) that are necessary to evaluate the linearized terms.
• Relaxation allows to slow down the changes of φ to avoid divergence of the solution.

• Explicit relaxation (at the end of iteration k + 1)


φk+1 = φk + ω (φk+1 k k+1
calc − φ ) = ω φcalc + (1 − ω) φ
k

with ω<1 (under-relaxation); φk : old value; φk+1


calc : new calculated value; φk+1 : new
value actually used.

• Note: often ω is not constant: ω << 1 in the rst iterations and then increased to
ω∼1 when aproaching to convergence.

• Implicit relaxation techniques can also be adopted (e.g.: pseudo-transient solutions).

3.2 Classication of PDEs


Mathematical Character of PDEs
• Classication of PDEs with reference to two independent variables (ξ, η) and the
general linear second-order PDE (coecients are constants or functions of ξ and
η, but not of φ)
∂ 2φ ∂ 2φ ∂ 2φ ∂φ ∂φ
A 2
+ B + C 2
+D +E +Fφ+G=0
∂ξ ∂ξ ∂η ∂η ∂ξ ∂η
• Only thecoecients of the second order terms are important.
• The mathematical character (nature) of a PDE is related to the sign of the
discriminant B 2 − 4 A C .
• An equation is classied as:

 elliptic 2
if B − 4 A C < 0;
 parabolic 2
if B − 4 A C = 0;
 hyperbolic 2
if B − 4 A C > 0.

• If coecients change sign, a PDE can have dierent characters in dierent parts of
the domain.

22
Types of Propagation
• Elliptic PDEs describe isotropic, .i.e., in all the directions, propagation processes
that have already reached the steady-state (equilibrium problems, e.g., steady-state
diusion).

• Hyperbolic PDEs describe propagation processes in well dened directions without


any diusion (similar to the propagation of undamped waves) (e.g., pure convection).

• Parabolic PDEs describe propagation processes in well dened directions, but with
diusion, in many cases evolving toward steady state (e.g., transient diusion) or fully-
developed conditions (similar to the propagation of damped waves).

• If a PDE has more than 2 independent variables −→ classication based on 2


variables at the time.

• PDE can have a mixed character depending on the couple of independent variables
considered and/or the relevance of some of the terms in the equation.

Examples of Classication
1. 2-D steady-state heat conduction equations (Laplace and Poisson equations)

∂ 2t ∂ 2t ∂ 2t ∂ 2t
λ + λ =0 λ + λ + q̇ = 0
∂x2 ∂y 2 ∂x2 ∂y 2

ξ = x; η = y −→ A = λ > 0 B=0 C=λ>0


B 2 − 4 A C = 0 − 4 · λ · λ = −4 λ2 < 0 =⇒ elliptic
2. 1-D wave equation
∂ 2φ 2
2∂ φ
−c =0
∂ϑ2 ∂x2

ξ = ϑ; η = x −→ A = 1 > 0 B=0 C = −c2 < 0


B 2 − 4 A C = 0 − 4 · 1 · (−c2 ) = 4 c2 > 0 =⇒ hyperbolic
3. 1-D transient heat conduction equation (Fourier equation)

∂t ∂ 2t
ρc −λ 2 =0
∂ϑ ∂x

ξ = ϑ; η = x −→ A = 0 B=0 C = −λ < 0
B 2 − 4 A C = 0 − 4 · 0 · (−λ) = 0 =⇒ parabolic
4. Thermal boundary layer equation (ξ = x; η = y )

∂t ∂t ∂ 2t
ρcu + ρcv −λ 2 =0
∂x ∂y ∂y

23
ξ = x; η = y −→ A = 0 B=0 C = −λ < 0
B 2 − 4 A C = 0 − 4 · 0 · (−λ) = 0 =⇒ parabolic
5. 1-D pure advection (rst order wave) equation (type of transport: imagine a cork
oating down a river)
∂t ∂t
ρc + ρcu =0
∂ϑ ∂x

There are no second derivatives, but it is possible to take the derivatives of both
members with respect to ϑ or x.
Taking the derivatives with respect to ϑ and dividing by ρc
∂ 2t ∂ 2t
+ u =0
∂ϑ2 ∂x∂ϑ

ξ = ϑ; η = x −→ A = 1 B=u C=0
B 2 − 4 A C = u2 − 4 · 1 · 0 = u2 > 0 =⇒ hyperbolic
6. 2-D advective transport equation

∂t ∂t
ρcu + ρcv =0
∂x ∂y

Taking the derivatives with respect to x and dividing by ρc


∂ 2t ∂ 2t
u + v =0
∂x2 ∂x∂y

ξ = x; η = y −→ A = u B=v C=0
B 2 − 4 A C = v2 − 4 · u · 0 = v2 > 0 =⇒ hyperbolic
7. 2-D transient heat conduction equation (Fourier equation)

∂ 2t ∂ 2t
 
∂t
ρc =λ + + q̇
∂ϑ ∂x2 ∂y 2

It is parabolic in time (ξ = ϑ; η = x or ξ = ϑ; η = y) and elliptic in space (ξ = x;


η = y ).
8. 2-D transient thermal energy equation

hyperbolic elliptic
z }| { z  2 }| 2 {
∂t ∂t ∂t ∂ t ∂ t
ρc +ρ c u +v =λ 2
+ 2 +q̇
∂ϑ ∂x ∂y ∂x ∂y
| {z } | {z }
| {z }
parabolic

It has a mixed character (parabolic-hyperbolic-elliptic).

24
Remarks
• Inuence of dierent terms on the character of thetransient thermal energy eq.:
 the diusion term determines the elliptic character; combined with the un-
steady term, if present, it yields a parabolic (in time) nature of the equation;
 the advection term determines a character that is hyperbolic in space ; com-
bined with the unsteady term, if present, it yields a nature of the equation that
is also hyperbolic in time.

• The prevailing character depends on the relative magnitude of the advection and
diusion terms:

 diusion term much larger than advection term −→ the character is parabolic
elliptic in space;
in time,

 advection term much larger than diusion term −→ the character is hyperbolic
in both space and time.

Importance of the Mathematical Character of a PDE


• It is important because it determines the type of

 domain of denition (closed or open);


 required boundary conditions (number and type);

 applicable solution procedure (depending on the type of propagation described


by the equation).

• Note: for hyperbolic equations, the solution can only propagate along characteristic
lines (characteristics).

• Forward marching procedure: the solution at a new time (space) level is found
from the solution at previous time (space) levels.

Types of domains of denition

• Elliptic equations: closed domain −→ simultaneous solution at all points of the


domain −→ boundary conditions on the entire boundary (boundary-value-problems).

• Parabolic equations: open domain (propagation in one direction) −→ forward


marching procedure −→ initial/inlet condition required (initial-boundary-value-problems).
• Hyperbolic equations: open domain (propagation only along characteristics) −→
forward marching procedure −→ initial/inlet condition required (initial-boundary-
value-problems).

25
3.3 Boundary Conditions
Why Boundary Conditions?
• Boundary conditions are necessary to make the solution of the problem possible.
• Boundary conditions must be imposed after considering two aspects of the problem:

 the mathematical aspect (appropriate b.c. must comply with the mathematical
character of the governing equations);
 the physical aspect (appropriate b.c. should replace the eects of the portions
of the physical domain that are neglected when solving the problem on a nite
computational domain).

Types of Boundary Conditions


• There are three types of boundary conditions ( rst kind, second kind and third
kind b.c.) applied on the corresponding three types of boundaries.

Types of boundaries

• First kind (Dirichlet) b.c. (on boundary S1 ): it species the values of the solution
on the boundary
φ = f1 (ϑ, x)

• Second kind (Neumann) b.c. (on boundary S2 ): it species the values of the
normal derivative of the solution on the boundary
∂φ
= f2 (ϑ, x)
∂n

• Third kind (Robin) b.c. (on boundary S3 ): it species a linear combination of the
values of the solution and of its derivative on the boundary

∂φ
a(ϑ, x) φ + b(ϑ, x) = f3 (ϑ, x)
∂n

• Note: a, b , f 1 , f 2 e f3 are arbitrary functionas.

26
Remarks
• The normal derivative on the boundary can be expressed as
  
∂φ ∂φ ∂φ nx ∂φ ∂φ
= ∇φ · n = = nx + ny
∂n ∂x ∂y ny ∂x ∂y

• Not all types of boundaries must necessarily be present.


• It is not correct to apply Neumann b.c. on the entire boundary. Dirichlet or
Robin b.c. must be applied at least in one point, otherwise the solution can only
be determined up to an arbitrary constant.

• With reference to the heat conduction equation the b.c. are

t = ts on S1 (imposed temperature);

∂t
−λ = qs00 on S2 (imposed heat ux);
∂n
∂t
−λ = α (t − ta ) on S3 (convection b.c.).
∂n
• Only linear b.c. can be used in numerical solutions of PDEs.

• Nonlinear b.c. (e.g.: radiation b.c.) must be linearized within an iterative proce-
dure.

• Example: radiation b.c. (for a convex gray surface with emissivity ε, contained in a
cavity) at start of iteration (k + 1)
∂t
= εσ T 4 − Ta4 = εσ T 2 + Ta2 T 2 − Ta2
  
−λ
∂n
∼ 2
+ Ta2 T(k) + Ta T(k+1) − Ta
  
= εσ T(k)

= αr(k) t(k+1) − ta


(k) 2
• αr = σε(T(k) + Ta2 )(T(k) + Ta ) is an equivalent convection coecient that makes
the linearized radiation b.c. similar to the convection b.c. (values at iteration (k) are
known).

Types of Boundaries
• Domain boundaries can be:

 physical (solid walls);


 articial (inow, outow, symmetry and periodic boundaries);
• Symmetry and periodic (in the ow or in the transverse directions) boundaries allow
reduction in the size of the computational domain.
a signicant

27
• Symmetry boundary conditions can be applied on the symmetry axis if there is:
 geometrical symmetry and steady-state ow;

 symmetry of boundary conditions on the other boundaries;

 no forces acting in the direction perpendicular to the symmetry axis.

• Note 1: mathematical b.c. on any type of boundaries can never reproduce reality in
anexact way.
• Note 2: in general, it is easier to impose b.c. on boundaries normal to one of the
coordinate axes.

Examples
Symmetric domain Nonsymmetric domain

Periodic domain

Boundary Conditions for the Thermal Energy Equation


• Solid walls: rst (Dirichlet), second (Neumann) or third (Robin) kind b.c. (as for
the heat conduction equation).

∂t ∂t
t = ts −λ = qs00 −λ = α (t − ta )
∂n ∂n

• Inow boundaries: rst kind (Dirichlet) b.c. (usually the entrance temperature is
known)
t = te

• Outow boundaries.
 Problem: the elliptic nature of the equation requires b.c. on all boundaries,
but its hyperbolic nature requires no b.c. on outow boundaries.

28
 Solution: impose the weakest possible (Neumann) b.c. on boundaries located
far enough from the region of interest since this b.c. is not completely consistent
with the physics
∂t
=0
∂n

• Example

t
t = te n f = qs
00

n

t = ts t
=0
n

• Symmetry boundaries: no heat ux −→ Neumann b.c.

∂t
=0
∂n

• Periodic boundaries: in corresponding points of bound. 1 and 2

t2 = t1 + ∆tbulk

with ∆tbulk problem dependent for periodicity in the ow direction, ∆tbulk = 0 for
periodicity in the transverse direction.

Boundary Conditions for the Navier-Stokes Equations


• Solid walls: no-slip (Dirichlet) b.c. (viscosity does not allow slip of uid molecules at
the wall)
un = ut = 0 −→ u=v=0

• Inow boundaries: rst kind (Dirichlet) b.c. since, usually, the entrance velocity is
known.

If the inow boundary is normal to one of the coordinate axes and to the ow
direction (un 6= 0, ut = 0)
 on boundaries normal to the x axis

u = ue (y) v=0

29
 on boundaries normal to the y axis

u=0 v = ve (x)
• Outow boundaries: things are even more complicated than for the energy equa-
tion. In general, it is not possible to impose b.c. that are completely consistent
with the physics.

The outow boundary should be nearly normal to the ow direction, in a position
where the ow is nearly fully developed.

Examples of good and bad outow boundary positions

Reasons: the only mathematical b.c. that can be imposed without knowing the
solution are those corresponding to a fully developed ow.
There are dierent options, mainly related to the adopted numerical method:
1. Zero normal derivative of the normal velocity component (usually employed
with FDM and FVM)

∂un ∂ut
=0 and =0 or ut = 0
∂n ∂n
2. Zero normal stress (viscous stress + pressure, usually employed with FEM)
∂un ∂ut
µ −p=0 and =0 or ut = 0
∂n ∂n
If ut = 0 the orthogonality of the ow to the boundary is strictly enforced.
• Example

30
• Symmetry boundaries (ow parallel to the boundary and zero tangential stress)
∂ut
un = 0 =0
∂n

Obviously:

 on vertical boundaries, i.e., normal to the x axis


∂v
un = u ut = v −→ u=0 =0
∂x

 on horizontal boundaries, i.e., normal to the y axis


∂u
un = v ut = u −→ v=0 =0
∂y

• Pressure (deviation from hydrostatic p.): no equation for p −→ in principle, pres-


sure b.c. not required. However...

 only the pressure gradient appears in N-S equations −→ at least a value of


p must be specied somewhere, otherwise p could only be determined up to an
arbitrary constant and, possibly, the solution would not converge;
 with ∂un /∂n = ∂ut /∂n = 0 b.c. pressure must be specied at least in one
(arbitrary) point (usually p = 0);
 with ∂un /∂n = ut = 0 b.c. pressure should be specied on the entire outow
boundary;
 since zero normal stress b.c. contain pressure, p should not be specied any-
where else.

• Periodic boundaries: in corresponding points of bound. 1 and 2

u2 = u1 v2 = v1 p2 = p1 − ∆p

with ∆p (pressure drop) problem dependent for periodicity in the ow direction, ∆p =
0 for periodicity in the transverse direction.

Boundary Conditions for the Stream Function Equation


• Appropriate boundary must be imposed recalling that

 solid walls and symmetry axes are particular streamlines;


 the value of ψ increases to the left of the direction of ow in the xy -plane (left-side
convention);

 the volumetric ow rate per unit depth V̇1,2 between two streamlines 1 and 2
is equal to ψ2 − ψ1 ;

31
 the tangential velocity ut on a boundary is equal to ∂ψ/∂n.
Left-side convention

• Solid walls and symmetry boundaries:


 if V̇1,2 = ψ2 − ψ1 between two of such boundaries is known, Dirichlet conditions
can be used:

ψ = ψ1 = ψref on one boundary (usually ψref = 0) and

ψ = ψ2 = ψ1 + V̇1,2 on the other;

 if V̇1,2 is not known


a Dirichlet conditions ψ = ψref can be imposed on one solid or symmetry bound-
ary and

a Neumann condition ∂ψ/∂n = 0 can be imposed on all the other solid walls
where ut = 0 (not on symmetry boundaries because ut 6= 0).

• Inow and outow boundaries:


 if the ow is normal to the boundary (ut = 0) a Neumann condition ∂ψ/∂n = 0
can be imposed;

 if not, things are more complicated...

32
4 Finite Dierence Method (FDM)
4.1 Basic Concepts
Type of Approximation
• The nite dierence method implies a pointwise approximation (at nodes) of the
dierential equation to be solved.

• Derivatives are replaced by ratios of nite dierences. Example:

dt ∆t ∼ ∆t
= lim =
dx ∆x→0 ∆x ∆x

• Very simple method if domains are geometrically simple (1-D or 2-D rectangular).
• In 2-D, nodal positions determined using orthogonal uniform grids (constant ∆x
and ∆y , but ∆x 6= ∆y ).

Example of 2-D domain discretization

Node Identication
• Nodes identied by an index i (increasing in the + direction of the x axis) in 1-D and
by a couple of indexes i, j (corresponding to row and column) in 2-D.
• In 2-D, two node identication methods can be adopted:

 rst index increasing in the + direction of the x axis, second index increasing in
the + direction of the y axis, with node (1, 1) at the bottom left (most common);

 indexes assigned as for matrix elements, with node (1, 1) at the top left (seldom
adopted).

Stencils to illustrate node identication methods


i increasing

i,j+1 i−1,j

i−1,j i,j i+1,j i,j−1 i,j i,j+1


j increasing

i,j−1 i+1,j

i increasing j increasing

33
Approximation of Derivatives
• Two approaches can be used to obtain the approximation formulas:
1. direct approach (very simple);
2. Taylor series expansion.
• The two methods yield equivalent results, but the Taylor series expansion method
also yields the truncation error.

• Truncation error (TE): dierence between the derivative and its approximation.
• Basic 1-D approximation formulas obtained for a generic node i, with xi − xi−1 =
xi+1 − xi = ∆x =cost;

• For partial derivatives in 2-D (nodes identied by two indexes) same formulas but
one index remains constant.

• More accurate, but more complicated, formulas can also be obtained (not covered
in this course).

4.2 Direct Approach


Approximation of a First Order Derivative
Graphical representation of rst derivative approximations

• Backward dierence scheme (2 nodes involved)


 
dt ∼ ti − ti−1 ti − ti−1
= =
dx i xi − xi−1 ∆x

• Forward dierence scheme (2 nodes involved)


 
dt ∼ ti+1 − ti ti+1 − ti
= =
dx i xi+1 − xi ∆x

34
• Central dierence scheme (3 nodes involved)
 
dt ∼ ti+1 − ti−1 ti+1 − ti−1
= =
dx i xi+1 − xi−1 2 ∆x

• Interpretations of the central dierence scheme:


 average of backward and forward dierences;
 
ti+1 − ti−1 1 ti+1 − ti ti − ti−1
= +
2 ∆x 2 ∆x ∆x
 central dierence scheme with reference to the midpoints between nodes i e i + 1
and i−1 e i at a distance ∆x
ti+ 1 − ti− 1
 
ti+1 − ti−1 1 ti+1 + ti ti + ti−1
= − = 2 2

2 ∆x ∆x 2 2 ∆x

Approximation of a Second Order Derivative


• The second order derivative is the rst derivative of the rst derivative
  #
"
d2 t
     
d dt dt ∼ 1 dt
= = −
dx2 i dx i dx ∆x
dx i+ 1 dx i− 1
2 2
 
∼ 1 ti+1 − ti ti − ti−1 ti+1 − 2 ti + ti−1
= − =
∆x ∆x ∆x ∆x2

• The approximations of the rst derivatives can be interpreted as central dierence


1 1
formulas with reference to points i+ 2
and i− 2
.

• The term in parentheses is not the dierence between the forward and backward
dierence schemes.

4.3 Taylor-Series-Based Approximations


Taylor Series Expansions About Node i
• For node i+1
∆x2 d2 t ∆x3 d3 t ∆x4 d4 t
       
dt
ti+1 = ti + ∆x + + +
dx i 2! dx2 i 3! dx3 i 4! dx4 i+ξ
| {z }
remainder

• For node i−1


∆x2 d2 t ∆x3 d3 t ∆x4 d4 t
       
dt
ti−1 = ti − ∆x + − +
dx i 2! dx2 i 3! dx3 i 4! dx4 i−ξ 0
| {z }
remainder

with 0 ≤ ξ, ξ 0 ≤ 1 (Lagrange's form of the remainder term).

35
Approximation of a First Derivative
• From the Taylor series expansion for node i+1 truncated at the second order term:
forward dierence
d2 t
   
dt ti+1 − ti ∆x
= −
dx i ∆x 2 dx2 i+ξ

• From the Taylor series expansion for node i−1 truncated at the second order term:
backward dierence
d2 t
   
dt ti − ti−1 ∆x
= +
dx i ∆x 2 dx2 i−ξ 0

• By subtracting the two expansions truncated at the third order term: central
dierence
" #
ti+1 − ti−1 ∆x2 d3 t d3 t
    
dt
= − +
dx i 2 ∆x 12 dx3 i+ξ dx3 i−ξ 0

Approximation of a Second Derivative


• By summing the two expansions truncated at the fourth order term
" #
d2 t ti+1 − 2 ti + ti−1 ∆x2 d4 t d4 t
    
= − +
dx2 i ∆x2 24 dx4 i+ξ dx4 i−ξ 0

• Note: the truncation errors are proportional to

∆x for forward and backward dierence schemes


∆x2 for the central dierence scheme and in the approximation of the second deriva-
tive.

Order of the Truncation Error


• It is equal to the exponent of the grid size ∆x in the expression of the truncation
error.

• Notation: O(∆x) indicates rst order approximations, O(∆x2 ) second order approx.
and O(∆xn ) n-th order approximations.

• Importance order of the TE: it indicates the rate at which the numerical
of the
approximation tends towards the exact derivative when the grid size is reduced.

• Example: if ∆x is halved the TE becomes one half with a O(∆x) scheme one
fourth with a O(∆x2 ) scheme.
36
• It is not a direct measure of accuracy, while the truncation error is. Dierent
schemes can be of the same order, but have dierent accuracies.

• The forward and backward dierence schemes are O(∆x).


• The central dierence scheme and the approximation of the second derivative are
2
O(∆x ).
Graphical representation of the order of the truncation error

Example: Solution of the 1-D Heat Conduction Equation


• Governing equation
d2 t
λ + q̇ = 0
dx2
• Dirichlet boundary conditions: t(0) = t0 and t(L) = tL .
• Domain discretization

Discretized Equation
• Discretized equation for node i, with i increasing in the positive direction of the x axis
ti+1 − 2 ti + ti−1
λ + q̇i = 0
∆x2
• After reordering
λ λ λ
2
ti−1 −2 2 ti + ti+1 = −q̇i
∆x ∆x } ∆x2 |{z}
d
|{z} | {z |{z}
a b c

a ti−1 + b ti + c ti+1 = d

37
System of Linear Equations
• System of linear equations in matrix notation.

• Note 1 : the matrix is tridiagonal.


• Note 2 : the rst and the last equation are are obtained from the application of the
Dirichlet boundary conditions.

4.4 2-D Problems


Partial Derivatives in 2-D

• Stencil (computational molecule)

• First derivatives (central dierence scheme)


   
∂t ti+1,j − ti−1,j ∂t ti,j+1 − ti,j−1
= =
∂x i,j 2 ∆x ∂y i,j 2 ∆y

• Second derivatives
∂ 2t ∂ 2t
   
ti+1,j − 2 ti,j + ti−1,j ti,j+1 − 2 ti,j + ti,j−1
= =
∂x2 i,j ∆x2 ∂y 2 i,j ∆y 2

Example: Solution of the 2-D Heat Conduction Equation


• Governing equations
∂ 2t ∂ 2t
λ + λ + q̇ = 0
∂x2 ∂y 2
• Physical domain: rectangle of sides Lx and Ly .

38
• Details of the i, j notation

Discretized Equation
• Discretized equation for node (i, j ), with i and j increasing in the positive direction of
the x and y axes

ti+1,j − 2 ti,j + ti−1,j ti,j+1 − 2 ti,j + ti,j−1


λ 2
+λ + q̇i,j = 0
∆x ∆y 2
• After reordering
 
λ λ λ λ
2
ti,j−1 + ti−1,j − 2 + ti,j
∆y ∆x2 ∆x 2 ∆y 2
|{z} |{z}
ay ax
λ λ
+ 2
ti+1,j + ti,j+1 = −q̇i,j
∆x ∆y 2

ay ti,j−1 + ax ti−1,j − 2 (ax + ay ) ti,j + ax ti+1,j + ay ti,j+1 = −q̇i,j

Node Numbering
• Global numbering (by rows)

• k -th equation of the linear system

ay tk−nx + ax tk−1 − 2 (ax + ay ) tk + ax tk+1 + ay tk+nx = −q̇k

• Note: other numbering schemes are possible (e.g.: by columns, starting from the top
left node).

39
Structure of the System Matrix

FD with Complex Domains


• The discretization of complex domain is not possible with grids of orthogonal straight
lines.Curvilinear grids must be used.
• Problem: FD formulas cannot be used with curvilinear grids.
• Solution: coordinate transformation to map the irregular physical domain into a
regular computational domain, discretized using a rectangular grid.

• Curvilinear coordinates are are associated with the grid lines in the physical domain
(boundary-tted coordinate method).

• Requirement: each line in the computational domain must correspond to a line in


the physical domain and vice versa.

• Analytical or numericalmapping techniques can be used.


• The dierential equation is modied to include the metrics of the transformation,
i.e., f (x, y) = f [x(ξ, η), y(ξ, η)].
• The modied equation is solved in the computational domain using standard FD
techniques.

Illustration of the principle

• The FD method looses its original simplicity because the modied PDEs are com-
plicated.

• Other methods (e.g., nite volume or nite element methods) are preferred for the
solution of PDEs in complex domains.

40
Other Examples of Mapping

L-shaped with gross shaped preserved

L-shaped transformed into a rectangle

O-grid C-grid

41
5 Accuracy of Numerical Solutions
5.1 Errors
Types of Errors
• Numerical solutions are aected by an error E which is the sum of two contributions:
modeling error and numerical error
φreal − φcalc = E = Emod + Enum

• Modeling error: due to approximations in the denitions of the physical model (e.g.,
inappropriate domain) and mathematical model (e.g., oversimplied equations and/or
b.c.).

• Numerical error: due to the solution of approximate (discretized) forms of the gov-
erning equations.

• Validation: making sure that the adopted physical and mathematical models are
correct, i.e.,  solving the right eqs. (mostly done by comparisons with experimental
data).

• Verication: (i) making sure that the model equations have been correctly imple-
mented (verication of a code); (ii) making sure that the numerical error is within
acceptable limits (verication of a calculation), i.e.,  solving the eqs. right.

Numerical Error
• The numerical error is the sum of three contributions: iteration error Ei , round-o
error Er and discretization error Ed
Enum = Ei + Er + Ed

• Iteration error: dierence between iterative and exact solutions; small, but never
zero.
• Round-o error: due to the computer representation of real numbers with a limited
number of signicant digits (single precision (4 bytes): 6÷7; double precision (8 bytes):
14 ÷ 15; very small, but could become signicant after billions of operations.
• Discretization error: dierence between approximate and exact solution of a dier-
ential equation; the most signicant contribution to the numerical error.

Round-O Error
• Example : given a = 8888888, b = −8888887 and c = 0.3333341, compute D = a+b+c
and E = a+c+b using 7 signicant digits (single precision); in theory, a+b+c = a+c+b,
but computers perform sums sequentially

42
• Note : round-o errors accumulate over million of operations, but they are usually
small if compared to discretization errors.

Discretization Error
• The discretization error stems from the replacement of dierential equations with dis-
cretized equations.
• It depends on the truncation errors (TE) in the approximations of the terms of
dierential equations and boundary conditions.

• It should always be estimated, as with the uncertainty of experimental data.


• In general, an a priori evaluation is impossible, but an a posteriori assessment is
Richardson extrapolation.
possible, based on the so-called

• In practice, grid independence test are preferred: the same problem is solved using
ner and ner grids until the solution stops changing signicantly.

Dissipation and Dispersion Errors


• The discretization error is a combination of

 dissipation (diusion) errors (reduced amplitude), due to even-order deriva-


tives in the leading terms of the TEs;
 dispersion errors (non-physical oscillations), due to odd-order derivatives in
the leading terms of the TEs.

∂φ ∂φ
• With reference to the linear advection equation: +u =0
∂ϑ ∂x

dissipation dispersion

43
Local and Global (Accumulated) Discretization Errors
• Example :  
dφ φn+1 − φn
= + O(∆t)
dt n ∆t

• Note : The smaller the step, the smaller the errors.

Properties of Numerical Methods


1. Consistency: the discretization error tends to zero when the grid size tends to zero.

2. Stability: errors arising during the solution procedure are not amplied by the
method.

3. Convergence: the numerical solution tends to the solution of the PDE when the grid
size tends to zero.

Lax-Richtmyer Equivalence Theorem (Fundamental Theorem of Numerical Anal-


ysis) (only valid for well-posed, linear partial dierential equations)

consistency + stability ⇐⇒ convergence

4. Conservation: there are no articial (numerical) sinks/sources.


5. Boundedness: the solution is within the physically meaningful limits for the problem
and free of spurious wiggles.

• Example of instability: time dependent problem with unstable solution if ∆ϑ is too


large.

initial data stable solution unstable solution


(∆ϑ small) (∆ϑ too large)

44
5.2 Order of Accuracy
Order of Accuracy of Numerical Methods and Solutions
• The concept of order of the TE can be extended to the approximation of an entire
DE by appropriately dening an order of accuracy (order of convergence).
• Two orders of accuracy are actually dened:
(i) the order of accuracy of a numerical solution, which can be computed from the
results of numerical tests;
(ii) the formal order of accuracy of a numerical method, which is determined by
the lowest order of the TE of the dierent terms of the DE.

• They indicate how rapidly (i) the approximate solution and (ii) the approximate
equation tend to their exact counterparts when the grid size is reduced.
• They are not always coincident.

Convergence Properties of Numerical Solutions


• Order of accuracy (order of convergence) of a numerical solution: it indicates the
rate at which the numerical solution converges to the exact solution when the grid
size is reduced.
• With reference to a characteristic grid size h (e.g.: ∆x, ∆y, ∆ϑ) the discrete solution
φ can have a series representation
φ = φ0 + g1 h + g2 h2 + g3 h3 + g4 h4 + ...

(φ0 : exact solution, gi : functions containing the derivative of the unknown, but inde-
pendent of h).
• By denition the order of accuracy is equal to p if
φ = φ0 + gp hp + O(hp+1 )

with gi = 0 for 0 ≤ i ≤ p − 1.
• It coincides with the exponent of h in the rst nonzero term of the series.

Asymptotic Range of Convergence


• It can be shown that, if the grid is suciently ne, for k ≥ 1

|gp+k hp+k | < |gp hp |

• All O(hp+k ) terms are negligible → the discretization error Ed is proportional to


hp
and decreases with h at a constant rate,

45
i.e., |Ed | = C hp , with C = const (slope in a log-log plot: p).
• If so, the solution φ is in the asymptotic range of convergence.

Determination of the Order of Accuracy p


• If the exact solution φ0 is known, only 2 approximate solutions φ1 and φ2 are necessary,
obtained using two similar grids of sizes h1 < h2 within the asymptotic range
of convergence .
• Given h1 = h and h2 = rh1 = rh, where r > 1 is the renement ratio, the errors are

Ed,1 = φ0 − φ1 ∝ hp1 = hp Ed,2 = φ0 − φ2 ∝ hp2 = rp hp


 p
Ed,2 h2
• Dividing the two equations −→ = = rp
Ed,1 h1
 
Ed,2
ln
Ed,1
p=
ln r
• If the exact solution φ0 is not known, 3 approximate solutions φ1 , φ2 and φ3 are
necessary, obtained using three similar grids of sizes h1 < h2 < h3 within the
asymptotic range of conv.

• Given h1 = h, h2 = rh1 = rh and h3 = rh2 = r2 h

φ1 = φ0 + gp hp φ2 = φ0 + gp (rh)p φ3 = φ0 + gp (r2 h)p

• Subtracting the equations −→ φ3 − φ2 = gp rp hp (rp − 1) φ2 − φ1 = gp hp (rp − 1)


φ3 − φ2
• Dividing the two equations −→ = rp
φ2 − φ1
 
φ3 − φ2
ln
φ2 − φ1
p=
ln r

46
Remarks
• Optimal values of r: 1.3 ÷ 2.
• The order of accuracy p can be determined with reference to

 local values of the solution (temperature, velocity, etc.),


 local derived quantities (uxes, convection coe., etc.),
 integral or mean quantities (average temperatures, velocities, uxes, convec-
tion coe., friction factors, etc.),
 error norms (Euclidean norm, innite norm, etc.),
provided that methods of order equal to or higher than p are used in the evaluation
of derived and/or integral quantities.

• Solutions obtained with dierent methods can have the same order of accuracy, but
dierent discretization errors.
• If φ is not within the asymptotic range of convergence, higher order methods are not
always better than lower order methods.

Check for Grids in Asymptotic Range of Convergence


• If φ is within the asymptotic range of conv. and h is reduced by a factor r, Ed and
|φk − φk−1 | decrease by a factor rp = const.
• To check if grids are within the asymptotic range of conv., at least three (if φ0 is
known) or four (if φ0 is not known) additional simulations are required with grids
such that hk = rhk−1 .
• The condition is satised if :
Ed,k φk − φk−1
= const = const
Ed,k−1 or φk−1 − φk−2
(with φ0 known) (with φ0 not known)
• In a log-log plot of Ed (or of |φk − φk−1 |) vs. h all points must be aligned (with
slope p). If it is not so, φ is not within the asymptotic range of convergence.

Convergence Properties of Numerical Methods


• Formal order of accuracy of a numerical method: rate at which the discretized
equation approaches the original PDE when the grid is rened.
• Meaning similar to that of the order of the TE of a derivative.
• The formal order of accuracy can be obtained from a truncation error analysis of
the terms of the discretized equation.

• high p −→ more accuracy, but less stability, low p −→ less accuracy, but
In general,
more stability. Good compromise: p = 2, as in most commercial codes.
• Often the observed (actual) order of accuracy of the solution is lower than the
formal (theoretical) order of accuracy of the method.

47
• They can coincide only if (i) the equation is linear, (ii) the b.c. are appropriately
imposed, (iii) the grid is orthogonal (Cartesian) and uniform (all cells are equal).

• If the grid is distorted and/or is not uniform, the observed order of accuracy of the
solution is lower than the theoretical one and the discretization error is larger.

• In practice, however:
 nonuniform grids are always used; if they are ner where larger variations of φ
are expected (Ed = gp hp depends on h and on derivatives of φ contained in gp )
−→ the desired accuracy can be achieved with a lower computational eort.
 distorted grids are required to discretize complex domains.
• The reduction of p is acceptable if the cell distortion is not too severe and the size
dierence between adjacent cells is not too large.
• Often mesh quality parameters are used to asses the grid quality (e.g.: cell skewness,
aspect ratio, non-orthogonality).

• Some softwares allow adaptive mesh renements: grids are dynamically regener-
ated during the simulations to achieve error control.

Example of Adaptive Mesh Renement

6 Grids
6.1 Types of Grids
Grid Classication
• Grids are used to identify thenodal positions in the solution domain and apply the
equation discretization methods.

• Classication based on cell shape

 triangular (tetrahedral in 3-D);


 quadrilateral (hexahedral in 3-D);
 polygonal (polyhedral in 3-D).

48
• Classication based on structure
 structured (only quadrilateral grids)
- Cartesian: uniform or nonuniform;
- curvilinear (or body tted or boundary tted): orthogonal or non-orthogonal;
 unstructured (triangular, quadrilateral, polygonal grids).

• Note: mesh ≡ grid

Structured Cartesian Grids


uniform grid nonuniform grid

block-structured

Structured Curvilinear Grids


non-orthogonal orthogonal

block-structured

49
Unstructured Grids
triangular cells
quadrilateral cells

hybrid

polygonal cells quadtree grid

3-D Cells

Possible shapes of 3-D cells

Summary
• Structured grid: formed by families of lines where each line never intersects a line
of the same family and intersects only once each line of the other families. Features:

 each point (e.g.: a node) is identied by 2 indexes (i, j ) in 2-D, and by 3 indexes
(i, j, k ) in 3-D.
 each interior cell is surrounded by a xed numbers of neighboring cells.
50
• Cartesian grid: the lines of each family are straight lines and are perpendicular
to all the lines of the other families.

• Uniform grid: same spacing for all points in a given dimension.


• Nonuniform grid: nonuniform spacing within any given dimension.
• Curvilinear grid: same structure of Cartesian grids, but with curved lines (greater
exibility).

• Orthogonal curvilinear grid: the grid is locally orthogonal, i.e., lines are orthog-
onal at their intersection (required by some methods, good for accuracy);

• Non-orthogonal curvilinear grid: the cells are skewed (greater exibility, but
larger numerical error).

• Block-structured grid: dierent structured grids are used in dierent parts of the
domain.

• Unstructured grid: not dened by families of lines (cells of any polygonal shapes,
points not identied by indexes, greater complexity, but maximum exibility).

• Hybrid grid: unstructured grid with cells of more than one shape.

6.2 Practical Aspects


Tips for a Good Grid
• Grids should be ner where variables have the largest variations, in particular near
solid walls where boundary layers develop.

• With quadrilateral meshes: cells should be elongated in the ow direction since
gradients are steeper in transverse direction (only where the ow is nearly fully devel-
oped).

• Grid lines should be as aligned (or as orthogonal) as possible to the main ow
direction to minimize the dissipation error (only for quadrilateral meshes).

51
• Sizes of adjacent cells should not be too dierent (expansion (stretching) ratio
< 1.4, better < 1.2) to limit the reduction of the actual order of accuracy.

• Cell shapes should be as close as possible to an equilateral triangle in triangular


meshes and as close as possible to a rectangle in quadrilateral meshes.

• Cell aspect ratio AR (max over min cell length): AR < 5 (except in boundary layer
regions) with quadrilateral meshes. AR much smaller with triangular cells.

Final Remarks
• It is the user's responsibility
 to select appropriate computational domains, forms of the governing equations
and boundary conditions to minimize the modeling errors;
 to generate optimal grids to minimize the discretization errors (great attention
must be paid).

• To achieve the above aims, experience is not sucient if it is not supported by the
knowledge of at least the basic theoretical aspects of CFD methods and procedures.

• This will help the user recognize whether a numerical solution is acceptable or just
another example of  colorful uid dynamics.

52
Part III
Finite Volume Method (FVM)
7 Preliminaries
7.1 Basic Concepts
Why FVM?
• commercial CFD software is based on the FVM.
Most of the

• Commercial codes:
 ANSYS Fluent (Europe);
 CD-adapco STAR-CCM+ (U.S.A.).

• Open source codes:


 OpenFOAM.

Type of Approximation
• Purpose of the method: derive a system of linear algebraic equations whose
solution is the approximate solution to the PDE.

• With the FDM, the terms of the PDE are approximated pointwise, at nodes (grid
used to identify nodal positions).

• With the FVM,


 rst the domain is divided, by means of a grid, into a nite number of cells
(nite volumes ≡ control volumes), without holes or overlaps,
conservation principle at the base of the PDE
 then the fulllment of the is
imposed in each control volume (CV).

• The FVM is locally conservative since it is based on a local balance approach.

• If the method is applied consistently, uxes at interior boundaries cancel out −→ the
FVM is also globally conservative.

The General Transport Equation


• Transport equations in conservative forms (const. prop. uid)


(ρcp t) + ∇ · (ρwcp t) = ∇ · (λ∇t) + q̇
∂ϑ


(ρw) + ∇ · (ρww) = ∇ · (µ∇w) − ∇p − ρβ(t − t0 )g
∂ϑ

53
• Both of them can be represented by the following general form

(ρφ) + ∇ · (ρwφ) = ∇ · (Γ∇φ) + s
∂ϑ

with φ = cp t, u, v and Γ = λ/cp , µ; s: generalized source term.

• In other words:

Accumulation + Convection = Diusion + Source

• The method can thus be described with reference to the solution of the general trans-
port equation.

The Basic Idea


• Integral formulation for the generic control volume V
Z  

(ρφ) + ∇ · (ρwφ) − ∇ · (Γ∇φ) − s dV = 0
V ∂ϑ

• The application of the Gauss theorem yields


Z Z Z Z

(ρφ) dV + ρφw · n dA − Γ∇φ · n dA = s dV
V ∂ϑ A A V

or, in a more compact form


Z Z Z
∂ 00
(ρφ) dV + J · n dA = s dV
V ∂ϑ A V

where
J00 = J00c − J00d = ρφw − Γ∇φ

J 00 = J00 · n = ρφw · n − Γ∇φ · n

• Each term of the integral equation must be approximated.

Computational Grids
• Both structured and unstructured grids can be used with the FVM to dene the
control volumes (CVs).

• While the steps for the application of the method are the same in all cases, their
implementation is much easier if structured Cartesian grids are used (as in this
course).

• Two alternative types of grids can be adopted

 vertex-centered grid: grid used to dene nodal positions (as in FDM), while
CV faces are located midway between grid points.

54
 cell-centered grid: grid used to dene CVs, while nodes are placed at the
geometric center of each CV.

• For uniform grids the two types of grids become identical.

• In all nite volume grids there is only one node in each CV.

Vertex-centered grid - internal CV Cell-centered grid - internal CV

Vertex-centered grid - boundary CV Cell-centered grid - boundary CV

Discussion
• For nonuniform grids, the two methods lead to dierent orders of accuracy in the
approximations of the PDE terms.

• Vertex-centered grid: faces midway between nodes, but nodes o CV centers −→


order 2 in the approximation of rst derivatives on CV faces, but order < 2 in the
approximation of integrals over faces and CV.

• Cell-centered grid: nodes in CV centers, but faces not midway between nodes −→
order < 2 in the approximation of rst derivatives on CV faces, but order 2 in the
approximation of integrals over faces and CV.

• sizes of adjacent CVs are not too dierent.


The loss of accuracy is acceptable if the

• Order 2 in all approximations only with uniform grids (for both methods).

• In practice: the two methods are nearly equivalent. The cell-centered method is
easier with composite domains.

Notation (2-D)
• The generic node is identied by the letter P and the other nodes by capital letters
corresponding to the points of the compass.

• Faces are identied by the pertinent small case letters.

55
Identications of generic nodes and faces of CVs

Form of the Final Algebraic Equation


• For the generic CV (node) P

AW φW + AN φN + AP φP + AS φS + AE φE = SP
| {z } |{z}
lhs rhs

• Together with the equations for all the other CVs of the discretization it forms a
system of linear algebraic equations.
• Note 1: approximate equations yield physically meaningful results only if AP >0
and AW , AN , AS , AE < 0.
• Note 2: AP will be on the diagonal of the system matrix.
• For steady-state conditions the coecients can be computed by discretizing the gen-
eral transport equation in the form
Z Z Z
J00c ·
n dA − J00d ·
n dA = s dV
A A V
| {z } | {z } | {z }
Fc,P Fd,P SP

(Fc,P , Fd,P : convective, diusive uxes on CV boundaries).

Generic 2-D Control Volume

56
Structure of a FVM Program

8 Space Integration
8.1 Source Term
Source Term Independent of φ
• The integral of s over the control volume P yields the coecient SP
Z
SP = s dV = s V ' sP V = sP ∆x ∆y
V

with sp equal to the value of s at node P .


• If s constant in the CV the approximation is exact.
is

• If s varies linearly in the CV the approximation is exact only if P is at the center


of the CV (cell-centered grid).

• Otherwise, if the grid is cell-centered, the approximation is second order accurate,


if not, the order of accuracy is lower.

57
Nonlinear Source Term s = s(φ)
• An iterative procedure must be adopted and the source term must be linearized
using a Taylor-like series expansion.

• Linearization of S = S(φ) at the beginning of iteration k+1 (values of terms at


iteration k are known)

 k  k  k
dS dS dS
SP = S(φkP ) + (φP − φkP ) = φP + S(φkP ) − φkP
dφP dφP dφP

• lhs and rhs terms


 k  k
dS dS
SPlhs = SPrhs = S(φkP ) − φkP
dφP dφP

• Final algebraic equation

AW φW + AN φN + AP − SPlhs φP + AS φS + AE φE = SPrhs


 if SPlhs ≤ 0, no problems ;
if SP > 0, instabilities or divergence of solution −→
lhs
 assume: SPlhs = 0 and
SP = S(φkP ).
rhs

8.2 Diusion Term


Diusive Fluxes on CV Boundaries
• Diusive ux Fd,P on the boundaries of control volume P: sum of the uxes at faces
w, n, s, e Z X
Fd,P = J00d · n dA = Fd,k (k = w, n, s, e)
A k

• Diusive ux Fd,e at face e (similar procedure for faces w, n, s)


Z
Fd,e = J00d · n dA = Jd,e
00 00
Ae ' Jd,e 00
Ae = Jd,e ∆y
Ae

00
• Jd,e intersection of face e and the line connecting nodes P and E .
evaluated at the

• Accuracy of the approximation of the integral:

 if the intersection is at the midpoint of the face (cell-centered grid) −→ second


order accuracy;
 if not (vertex-centered grid) −→ lower order.

• Specic ux at face e


 
00 ∂φ φE − φP
Jd,e = (Γ∇φ · n)e = Γe ' Γe
∂x e xE − xP

58
• Accuracy of the approximation of the derivative:
 if face e is midway between nodes P and E (vertex-centered grid) −→ second
order accuracy;
 if not (cell-centered grid) −→ lower order.

• Approximation of the diusive ux Fd,e

φE − φP
Fd,e ' Γe ∆y
x E − xP

• Second order accuracy only with uniform grids.

Interface Diusion Coecient Γe


• If a domain is made of one material with a molecular transport property Γ, then
ΓP = Γ, ΓE = Γ −→ Γe = Γ
• If a domain is made of more than one material, each CV must be made of only one
material −→ material interfaces must coincide with CV faces.

• Problem: choosing the appropriate value of Γ.


• A linear interpolation between ΓP and ΓE would yield unphysical results.

• Correct choice: a value of Γe that allows a good representation of the interface


ux in the composite slab between points P and E
00 φE − φP φE − φP
Jd,e ' Γe = 00
xE − xP Req

• Equivalent resistance

00 xE − xP x e − xP xE − xe
Req = = +
Γe ΓP ΓE

• Dividing by xE − xP
xe − x P xE − xe
1 x − xP x − xP
= E + E
Γe ΓP ΓE
• Equivalent diusion coecient on face e
 −1
λe,P E (1 − λe,P E )
Γe = +
ΓP ΓE

xe − xP
where λe,P E = .
xE − xP
1 2 ΓP ΓE
• With a uniform grid: λe,P E = −→ Γe = ( harmonic mean).
2 ΓP + ΓE

59
8.3 Advection Term
Convective Fluxes on CV Boundaries
• Advective ux Fc,P on the boundaries of control volume P: sum of the uxes at faces
w, n, s, e Z X
Fc,P = J00c · n dA = Fc,k (k = w, n, s, e)
A k

• Convective ux Fc,e at face e (similar procedure for faces w, n, s)


Z
Fc,e = J00c · n dA = Jc,e
00 A ' J 00 A = J 00 ∆y
e c,e e c,e
Ae

00
• Jc,e evaluated at the intersection between face e and the line connecting nodes P and
E.
• Accuracy of the approximation of the integral:
 if the intersection is at the midpoint of the face (cell-centered grid) −→ second
order accuracy;
 if not (vertex-centered grid) −→ lower order.

• Specic ux at face e


00
Jc,e = (ρ φ w · n)e = ρ φe ue

• The normal velocity component ue = (w · n)e is assumed known, φe must be approxi-


mated.

Central Dierence Scheme (CDS)


• It is so called because it corresponds to the central dierence scheme in the FDM
discretization (on a uniform grid) of the rst derivative in the advection term.

• Approximation of φe by linear interpolation

φe = φE λe,P E + φP (1 − λe,P E )

• Second order accuracy even with nonuniform grids.


• Specic ux at face e (CDS)

00

Jc,e CDS
' ρ ue [φE λe,P E + φP (1 − λe,P E )]

• Approximation of the convective ux Fc,e (CDS)

Fc,e ' ρ ue [φE λe,P E + φP (1 − λe,P E )] ∆y

• Second order accuracy only with uniform or cell-centered grids, but not with
vertex-centered grids.

60
Spatial Oscillations of the CDS
• 1-D dimensionless advection-diusion eq. Pe = 3, Pe∆ = 1

dφ 1 d2 φ  x
− =0 x̂ =
dx̂ Pe dx̂2 L

• b.c.: φ(0) = 0, φ(1) = 1


ρuL uL
• Peclet number: Pe = =
Γ a
• cell Peclet number:
u ∆x ∆x
Pe∆ = = Pe
a L

Pe = 9, Pe∆ = 3 Pe = 9, Pe∆ = 1

u ∆x
• Particular cases for the cell Peclet number Pe∆ =
a
 in thermal problems (energy equation): a = λ/ρ cp (thermal diusivity).
 in ow problems (Navier-Stokes equations): a = ν = µ/ρ (kinematic viscosity)
−→ Pe∆ ≡ Re∆ (cell Reynolds number).
• Pe∆ > 2, some
If of thecoecients of the nal algebraic equation may change sign
−→ unphysical spatial oscillations.
• Solutions to the problem:

 use a ner grid so that Pe∆ < 2 (sometimes too computationally intensive,
especially in 3-D);
upwind approximations.
 use 

• Note: oscillations may arise if Pe∆ > 2, but whether they appear or not depends on
the downstream b.c.

First Order Upwind Dierence Scheme (UDS)


• Approximations of φe using the value at the upstream node:
 if ue > 0 −→ φe = φP
 if ue < 0 −→ φe = φE
• It is a rst order accurate approximation of φe .
61
• Specic ux at face e for ue > 0:
00

Jc,e U DS
' ρ ue φP

• Specic ux at face e for ue < 0:


00

Jc,e U DS
' ρ ue φE

• Approximation of the convective ux Fc,e (UDS)

Fc,e ' ρ ue φP ∆y for ue > 0

Fc,e ' ρ ue φE ∆y for ue < 0

Numerical (Articial) Diusion


• Taylor series expansion about point e
 
∂φ
+ O (xe − xP )2
 
φP = φe − (xe − xP )
∂x e

• Specic (convective (UDS) + diusive) ux at face e (ue > 0)


   
∂φ ∼ ∂φ
Je00 = ρ ue φe − Γe = (Je00 )U DS = ρ ue φP − Γe
∂x e ∂x e

• Substituting the expression for φP


   
∂φ ∂φ
(Je00 )U DS + O (xe − xP )2
 
= ρ ue φe − ρ ue (xe − xP ) − Γe
| {z } ∂x e ∂x e
Γnum

• Reordering

 
∂φ
(Je00 )U DS + O (xe − xP )2
 
= ρ ue φe − (Γnum + Γe )
∂x e

• Thus, (Je00 )U DS = Je00 + O(xe − xP ) is rst order accurate and the TE contains a
numerical (articial) diusion term.

62
Convection of a Step Prole
β = 0◦ - UDS and CDS
∂φ ∂φ
u +v =0
∂x ∂y

β = 30◦ - UDS β = 30◦ - CDS

Prole of φ along a sampling line normal to the ow


β = 30◦ β = 45◦

• For β = 0◦ (ow aligned with the grid): CDS and UDS give nearly the same solution.
• For β = 30◦ : UDS solution smeared by numerical diusion (second order derivatives
in the TE −→ dissipation error), CDS solution unbound due to oscillations (third
order derivatives in the TE −→ dispersion error)

• For β = 45◦ : even larger numerical diusion with UDS (the worst case in terms of
grid-to-ow alignment), smaller oscillations with CDS.

Other Upwind Schemes


• To reduce numerical diusion of the UDS (rst order), use
 hybrid schemes: CDS if Pe∆ < 2 and UDS if Pe∆ ≥ 2;
 higher order schemes (SOUDS, QUICK, etc.).

63
SOUDS: Second Order Upwind Dierence Scheme (linear extrapolation)

QUICK: Quadratic Upstream Interpolation for Convectice Kinematics (parabolic


interp.)

Remarks on Higher Order Schemes


Computational molecules (stencils)

• They require a larger computational molecule (stencil) −→ more unknowns per


equation −→ computational eort.
larger

• They are more dicult to implement (introduction of b.c., loss of conservation


properties, extension to unstructured grids).

• Thenumerical diusion is lower than with UDS, but not zero!


• Unphysical oscillations are still possible −→ a good grid is still a must!

9 Final Algebraic Equation (1)


9.1 Steady-State Problems
Equation for the Generic Control Volume P
• Integral form Z Z Z
J00c · n dA − J00d · n dA = s dV
A A V

• Discretized form (Aw = Ae = ∆y , An = As = ∆x)


X X X X
00 00
Jc,k Ak − Jd,k Ak = Fc,k − Fd,k = sp V (k = w, n, s, e)
k k k k

64
Example: Discretization Using CDS
P
uk = (w · n)k ṁk = ρ uk Ak k ṁk = 0 (for mass conservation)

ρ ue [φE λe,P E + φP (1 − λe,P E )] ∆y + ρ uw [φW λw,P W + φP (1 − λw,P W )] ∆y


+ ρ un [φN λn,P N + φP (1 − λn,P N )] ∆x + ρ us [φS λs,P S + φP (1 − λs,P S )] ∆x
 
φE − φP φP − φW φN − φP φP − φS
− Γe ∆y − Γw ∆y + Γn ∆x − Γs ∆x = sP ∆x∆y
xE − xP xP − xW yN − yP yP − yS

ṁe λe,P E φE + ṁe φP − ṁe λe,P E φP + ṁw λw,P W φW + ṁw φP − ṁw λw,P W φP
+ ṁn λn,P N φN + ṁn φP − ṁn λn,P N φP + ṁs λs,P S φS + ṁs φP − ṁs λs,P S φP
Γe ∆y Γe ∆y Γw ∆y Γw ∆y
− φE + φP − φW + φP
xE − xP xE − xP xP − xW xP − xW
Γn ∆x Γn ∆x Γs ∆x Γs ∆x
− φN + φP − φS + φP = sP ∆x∆y
yN − yP yN − yP yP − yS yP − yS

AcE = ṁe λe,P E AcW = ṁw λw,P W AcN = ṁn λn,P N AcS = ṁs λs,P S
Γe ∆y Γw ∆y Γn ∆x Γs ∆x
AdE = − AdW = − AdN = − AdS = −
xE − xP xP − xW yN − yP yP − yS

AcE φE − AcE φP + ṁe φP + AcW φW − AcW φP + ṁw φP


+ AcN φN − AcN φP + ṁn φP + AcS φS − AcS φP + ṁs φP
+ AdE φE − AdE φP + AdW φW − AdW φP + AdN φN − AdN φP + AdS φS − AdS φP = SP

AcE φE + AcW φW + AcN φN + AcS φS + AdE φE + AdW φW + AdN φN + AdS φS


− (AcE + AcW + AcN + AcS ) φP −(AdE + AdW + AdN + AdS ) φP
| {z } | {z }
AcP AdP
+ (ṁe + ṁw + ṁ + ṁs ) φP = Sp
| {z n }
=0

AE = AcE + AdE AW = AcW + AdW AN = AcN + AdN AS = AcS + AdS


AP = AcP + AdP = − (AE + AW + AN + AS ) SP = sP ∆x ∆y

AW φW + AN φN + AP φP + AS φS + AE φE = SP

X
AP φP + Anb φnb = SP
nb

65
The System of Linear Algebraic Equations
Matrix representation (for properly ordered CVs)

System Matrix Yielded by a FVM Discretization


• Structured grid with lexicographic ordering of the nodes

• Example: system matrix for Ni × Nj = 4 × 3 = 12

66
Boundary Conditions
• The stencils for the CVs along the boundaries are smaller −→ the equations for those
CVs have a smaller number of unknowns and coecients.

• The equations for the boundary CVs must be modied to include boundary condi-
tions.
• Boundary conditions must be approximated using methods of order equal to or
higher than those used for the other terms of the equations.
• In fact, the lowest order among all the approximations of the various terms of the
PDE determines the order of accuracy of the whole method and of the solutions.

• The particular technique to be employed depends on the type of the boundary con-
dition (Dirichlet, Neumann, Robin).

• Several options are available (not covered in this course).

10 Time Integration
10.1 Preliminaries
Problem Specication
• PDE to be solved

(ρφ) + ∇ · (ρwφ) = ∇ · (Γ∇φ) + s
∂ϑ
• In a more compact form

(ρφ) = F (ϑ, φ(ϑ))
∂ϑ
where
F = −∇ · (ρwφ) + ∇ · (Γ∇φ) + s
• It resembles an ODE describing an initial value problem
dφ(ϑ)
= f (ϑ, φ(ϑ)) with φ(ϑ0 ) = φ0

• The time integration procedure is illustrated with reference to this equation.

Time Marching Procedure


• parabolic in time −→ it must be solved in an open
The general transport equation is
domain (in time) using a marching procedure starting from an initial condition.
• The time domain of interest is divided into a nite number of time intervals ∆ϑ
(time step).

• From the initial condition φ(ϑ0 ) = φ0 , φ1 is found at time ϑ1 =


rst the solution
2
ϑ0 + ∆ϑ, then the solution φ is found at time ϑ2 = ϑ1 + ∆ϑ, and so on...

the generic time level ϑn+1 , the unknown solution φ


n+1
• With reference to is found
from the solution atprevious time levels.
• The marching procedure may require the knowledge of the solution at
 just the previous time level ϑn (two-level methods);
 more time levels (ϑn ,ϑn−1 ,ϑn−2 ,...) (multilevel methods);

67
10.2 Two-Level Methods
Time Integration Schemes
• Equation to be solved

dφ(ϑ)
= f (ϑ, φ(ϑ)) with φ(ϑ0 ) = φ0

• General time integration method (from time level n to n + 1)
Z ϑn+1 Z ϑn+1
dφ(ϑ)
dϑ = φn+1 − φn = f (ϑ, φ(ϑ)) dϑ
ϑn dϑ ϑn

• The integral at the rhs cannot be evaluated analytically.


• Dierent methods use dierent approximations of the integral; this inuences their
accuracy and their stability.
• The two-level methods most commonly used are the
 Forward Euler method (explicit);
 Backward Euler method (implicit);
 Crank-Nicolson method.

Forward Euler Method


• Integrand function f (ϑ, φ) sampled at the beginning of the time interval
φn+1 = φn + f (ϑn , φn ) ∆ϑ

• φn = φ (ϑn ) is known −→ f (ϑn , φn ) can be computed −→ the method is explicit.


• Order of accuracy: O(∆ϑ) (i.e., rst order).
• Stability: conditionally stable.
• Example: stability limits for the 1-D energy equation discretized using the UDS
a ∆ϑ 1 u ∆ϑ
Fo∆ = ≤ CF L = ≤1
∆x2 2 ∆x
CF L: Courant-Friedrichs-Lewy number; Fo∆ : cell Fourier number.

• Diusive stability implies that ∆ϑ ∼ ∆x2 . Thus, ne grids −→ very small time
steps (e.g., ∆x/2 −→ ∆ϑ/4).
• Convective stability implies that ∆ϑ ∼ ∆x (less restrictive for low Pe).
• Obviously, the CF L condition does not apply to pure diusion (like heat conduc-
tion) problems.

• In general, limits for the 2-D or 3-D energy equations are even more restrictive.

68
Backward Euler Method
• Integrand function f (ϑ, φ) sampled at the end of the time interval
φn+1 = φn + f ϑn+1 , φn+1 ∆ϑ


• φn+1 = φ (ϑn+1 ) isnot known −→ f (ϑn+1 , φn+1 ) cannot be computed directly −→


the method is fully implicit.

• Order of accuracy: O(∆ϑ) (i.e., rst order).

• Stability: unconditionally stable (even for large ∆ϑ).

Crank-Nicolson Method
• Integrand function f (ϑ, φ) sampled both at the beginning and at the end of the time
trapezoidal rule)
interval (

1
φn+1 = φn + f (ϑn , φn ) + f ϑn+1 , φn+1 ∆ϑ

2

• φn+1 = φ (ϑn+1 ) isnot known −→ f (ϑn+1 , φn+1 ) cannot be computed directly −→


the method is implicit.

Order of accuracy: O(∆ϑ ) (i.e., second order).


2

• Stability: unconditionally stable (oscillations for ∆ϑ too large).

69
Discussion
• The Crank-Nicolson method can be thought of as the average of the forward and
backward Euler schemes.

• The oscillations of the Crank-Nicolson method for large ∆ϑ remain bounded (i.e.,
no divergence).

• Implicit methods require, at each time step, the solution of an equation (if applied
to an ODE) or of a system of linear algebraic equations (if applied to a discretized
PDE), but

 the time steps ∆ϑ can be large (limited by accuracy and not by stability require-
ments).

• Explicit methods are much simpler and calculations at each time step are much
faster, but

 stability limits impose very small time steps ∆ϑ;


 as a consequence, a very large number of time steps is required to solve a prob-
lem;
 therefore, usually they are not convenient.

General Form of Two-Level Methods


• With reference to a weighting parameter γ ∈ [0, 1]

φn+1 = φn + γf ϑn+1 , φn+1 + (1 − γ) f (ϑn , φn ) ∆ϑ


  

γ=0 −→ Forward Euler method (FE);

γ = 1/2 −→ Crank-Nicolson method (CN);

γ=1 −→ Backward Euler method (BE).

φn+1 − φn
= γf ϑn+1 , φn+1 + (1 − γ) f (ϑn , φn )

∆ϑ

• Note 1: the FE, CN and BE methods correspond to approximations of the time


derivative in the ODE with the forward, central and backward FD schemes, re-
spectively.

• Note 2 : consistently, the FE, CN and BE methods are O(∆ϑ), O(∆ϑ2 ) and O(∆ϑ),
respectively.

• γ = 2/3: compromise between accuracy and stability.


good

• Avoid γ < 1/2: methods are implicit, but conditionally stable.

70
10.3 Multilevel Methods
Adams-Bashfort Method
• Integrand function f (ϑ, φ) sampled at beginning of the current and of the previous
time interval.
1
φn+1 = φn + 3 f (ϑn , φn ) − f ϑn−1 , φn−1 ∆ϑ

2

• φn−1 = φ (ϑn−1 ) and φn−1 = φ (ϑn ) are known −→ f (ϑn−1 , φn−1 ) and f (ϑn , φn ) can
be computed −→ the method is explicit.

• Accuracy: O(∆ϑ2 ) second order).


(i.e.,

• Stability: conditionally stable.

Remarks
• Many other multilevel methods of order equal to or higher than 2 are available (not
covered in this course).

• Also high order predictor-corrector methods exist, such as the Runge-Kutta method
(not covered in this course).

• Adaptive (variable) time steps ∆ϑ can be used to control the time discretization error.
• Pseudo-transient solution: the time evolution from an arbitrary initial condi-
tion can be interpreted as an iterative solver for a stationary nonlinear problem.
• In iterative solutions, relaxation is usually necessary to avoid divergence; in pseudo-
transient solutions, ∆ϑ is like a relaxation parameter.

• Since the evolution details are not important, the Backward Euler method with
as large ∆ϑ as possible is recommended.

11 Final Algebraic Equation (2)


11.1 Time-Dependent Problems
Equation for the Generic Control Volume P
• Integral form, letting F = −∇ · (ρwφ) + ∇ · (Γ∇φ) + s
Z Z

(ρφ) dV = F (ϑ, φ (ϑ)) dV
V ∂ϑ V

• Time discretization (for ρ = const)


φn+1 − φn
Z Z
γ F ϑn+1 , φn+1 + (1 − γ) F (ϑn , φn ) dV
  
ρ dV =
V ∆ϑ V

71
• The space discretization of the lhs yields
φn+1 − φn φn+1 − φnP
Z
P
∆x ∆y = CP φn+1 − φnP

ρ dV ≈ ρ P
V ∆ϑ ∆ϑ

where
ρ
CP = ∆x ∆y
∆ϑ

• The space discretization of the rhs yields the coecients AP , AW , AN , AS , AE , SP .


• Linear algebraic equation corresponding to the steady-state general tranport equation
∇ · (ρwφ) − ∇ · (Γ∇φ) = s

AW φW + AN φN + AP φP + AS φS + AE φE = SP

• Linear algebraic equation corresponding to the form F = −∇·(ρwφ)+∇·(Γ∇φ)+s = 0

− (AW φW + AN φN + AP φP + AS φS + AE φE ) + SP = 0

• Approximation of the rhs of the time discretized equation


Z
γ F ϑn+1 , φn+1 + (1 − γ) F (ϑn , φn ) dV
  
V
≈ − γ AW φn+1 n+1
+ AP φn+1 + AS φn+1 + AE φn+1

W + AN φN P S E
− (1 − γ) (AW φnW + AN φnN + AP φnP + AS φnS + AE φnE ) + SP

since, if s = const, γSP + (1 − γ)SP = SP .

Space and Time Discretized Equation (Two-Level Methods)


• Denition of coecients

ρ
CP = ∆x ∆y AP = − (AE + AW + AN + AS ) SP = sP ∆x ∆y
∆ϑ

• Application of the Forward Euler method


CP φn+1 − φnP = − AW φnW + AN φnN + AP φnP + AS φnS + AE φnE + SP
 
P

• After reordering, φn+1


P can be computed explicitly

SP 1 
φn+1 AW φnW + AN φnN + (AP − CP )φnP + AS φnS + AE φnE

P = −
CP CP

72
• Application of the Backward Euler method
φn+1 n n+1 n+1 n+1 n+1 n+1
 
CP P − φP = − AW φW + A N φN + AP φP + AS φS + AE φE + SP

• After reordering, an equation with 5 unknowns is obtained

AW φn+1 n+1
W + AN φN + (AP + CP ) φn+1
P + AS φn+1
S + AE φn+1
E = SP + CP φnP
| {z } | {z }
AP n
SP

• Application of the Crank-Nicolson method


1
CP φn+1 n n+1 n+1 n+1 n+1 n+1
 
P − φP = − AW φW + A N φN + A P φP + AS φS + AE φ E
2
n n n n n

+ AW φW + AN φN + AP φP + AS φS + AE φE + SP

• After reordering, an equation with 5 unknowns is obtained


 
AW n+1 AN n+1 AP AS n+1 AE n+1
φ + φ + + CP φn+1 + φ + φ
2 W
|{z} 2 N
|{z} 2 P
2 S
|{z} 2 E
|{z}
| {z }
AW AN AP AS AE
   
AW n AN n AP n AS n AE n
= SP − φ + φ + − CP φP + φ + φ
2 W 2 N 2 2 S 2 E
| {z }
n
SP

• Note: after redening the coecients at the lhs and rhs, the equations for the
(implicit) BE and CN methods can be cast in exactly the same form of that for
steady-state problems, i.e.,

AW φn+1 n+1
W + AN φN + AP φn+1
P + AS φn+1
S + AE φn+1
E = SPn

• A system of equations must be solved at each time step.

Final Remarks on the FVM


• Only very simple domains can be discretized with Cartesian grids.
• Greater exibility can be achieved by using structured (or block-structured) curvi-
linear grids.
• A coordinate transformation is required to go from the complex domain to a simpler
one that can be discretized using a Cartesian grid (as with the FDM).

• The discretized equations become more complicated because they must include
all the terms of the coordinate transformation.

• For maximum exibility, most modern commercial codes allow the use of unstruc-
tured grids, with polygonal cells.
• All principles and concepts at the basis of the procedure illustrated in these lectures
remain valid.
• Even if no coordinate transformation is required, the computation of areas, vol-
umes, uxes, etc., is more complicated (not covered in this course).

73
Part IV
Incompressible Navier-Stokes Equations
12 Solution Methods
12.1 Possible Approaches
2-D Incompressible Navier-Stokes and Continuity Equations

∂ ∂ ∂
(ρu) + (ρuu) + (ρvu)
∂ϑ ∂x ∂y
   
∂ ∂u ∂ ∂u ∂p
= µ + µ − − ρβ(t − t0 )gx
∂x ∂x ∂y ∂y ∂x

∂ ∂ ∂
(ρv) + (ρuv) + (ρvv)
∂ϑ ∂x ∂y
   
∂ ∂v ∂ ∂v ∂p
= µ + µ − − ρβ(t − t0 )gy
∂x ∂x ∂y ∂y ∂y

∂u ∂v
+ =0
∂x ∂y

Relevant Aspects
• The solution of the Navier-Stokes equations in terms of pressure and velocity is
called: primitive variable solution.
• Each of the momentum equations has the same form general transport
as the
equation −→ they could be discretized exactly in the same way.
• Problems: the Navier-Stokes equations are
 nonlinear because of the advection term (even if the thermophysical properties
are assumed constant);
 coupled because pressure and velocity components appear in both momentum
equations;
 pressure does not appear in the continuity equation −→ no pressure equation;
moreover only the pressure gradient appears in the momentum equations.

• Note: in natural convection problems, the Navier-Stokes equations are also coupled
with the energy equation.

74
Handling Nonlinearity
• The nonlinear terms must be linearized and the equations must be solved iteratively,
possibly using relaxation.
• Iterations must continue until a suitable convergence criterion is satised.
• In the generic k+1 iteration (solution computed from that of the previous iteration
k ),
 the advection term is linearized as (Picard method) ∇ · (ρww) ≈ ∇ · (ρwk w)
(other choices are possible);
 relaxation must be used for all updated variables (φk+1 )
∆φcalc = φk+1
calc − φ
k
−→ φk+1 = φk + ω ∆φcalc

with φ = u, v, p and ω≤1 ( relaxation coecient).


• ω can be assumed constant or (better) small in the rst iterations and closer to 1 when
approaching convergence.

Handling the Pressure-Velocity Coupling


• Two approaches are possible: (i) fully-coupled (monolithic) solution; (ii) segregated
solution.

• Fully-coupled solution: the Navier-Stokes and the continuity equations are consid-
ered a system of PDE.

• With reference to space discretization comprising N nodes, the equations are dis-
cretized using standard methods, yielding a system of 3N algebraic equations,
with 3N unknowns (in 2-D).

N
X N
X
(Auu )i,j Aup pj = Siu

uj + i,j
with i = 1, N
j=1 j=1

N
X N
X
(Avv )i,j vj + Avp pj = Siv

i,j
with i = 1, N
j=1 j=1

N
X N
X
(Acu )i,j uj + (Acv )i,j vj = 0 with i = 1, N
j=1 j=1

• Segregated solution: p and w calculations are decoupled.

 Pressure is assumed known in momentum equations.


 The continuity equation is replaced by a pressure equation obtained from the
mass conservation constraint.
 The systems corresponding to each of the PDEs are solved separately, one after
the other.

75
Structures of systems of linear algebraic equations:
fully-coupled approach segregated approach

(submatrix dimensions: N × N)

Discussion
• Pros and cons of the fully-coupled approach:
⊕ stability, especially for high Reynolds numbers;
⊕ faster convergence, i.e., fewer iterations, compared to other approaches;
high computer memory requirements limit the size of the problems that can
be solved with given comp. resources;
zero diagonal components in the lower right submatrix because pressure does
not appear in the continuity eq. −→
problems with the solution of the system of eqs. since
(i) all solution methods work better when the matrix is diagonally dominant,
P
i.e., |Ai,i | ≥
j6=i |Ai,j | for all i;
(ii) some methods do not work at all if diagonal elements are zero (pivoting,
i.e., equation reordering, is necessary).

• Note: the fully-coupled approach is more frequently adopted in solvers based on the
Finite Element Method (FEM).
• Pros and cons of the segregated approach:
⊕ smaller systems of algebraic equations (matrix dimensions: N × N ) −→ lower
computer memory requirements −→ larger problems can be solved;
⊕ no zero diagonal elements in the system matrices −→ easier selection of the
solution method for the linear systems of algebraic equations.
slower convergence, i.e., more iterations, compared to the fully-coupled ap-
proach.

• Note 1 : most FVM solvers are based on the segregated approach.


• Note 2 : the segregated approach cannot be adopted for the solution of the com-
pressible Navier-Stokes equations because pressure must satisfy an equation of
state −→
fully-coupled approaches are adopted with formulations based on the so-called con-
servation variables ρ, ρu, ρv, ρût (with ût : total energy per unit mass).

76
12.2 Segregated Solution Algorithms
Basic Ideas
• Vector eld: a vector-valued function f that assigns to each point x in Rn a vector
n
in R given by V = f (x).
• Property : ∇ × ∇ϕ = 0 for any scalar function ϕ.
• Helmholtz decomposition (HD) theorem: a vector eld V can be uniquely
decomposed into the sum of a solenoidal (divergence-free) vector eld Vsol and an
irrotational (curl-free) vector eld Virr = ∇ϕ since ∇ × ∇ϕ = 0
V = Vsol + Virr = Vsol + ∇ϕ ∇ · Vsol = 0

with

• Moreover, the elds Vsol and ∇ϕ are orthogonal.

• Relevance of HD: it implies that for any given vector eld V a scalar potential ϕ
exists that projects V onto a divergence-free vector eld Vsol
Vsol = V − ∇ϕ

• Given V, the scalar potential ϕ can be obtained by solving

∇ · ∇ϕ = ∇ · V − 
∇ sol
·V


−→ ∇2 ϕ = ∇ · V

• Vsol is the divergence-free vector eld closest to V.


• The HD theorem provides the theoretical foundation of projection methods
for the solution of the incompressible Navier-Stokes equations, which consist of two
phases:

(i) nd an approximate velocity eld w∗ that might not satisfy the continuity
constraint;
(ii) nd a correction to w∗ that yields a eld w such that ∇ · w = 0.

• In incompressible ows, pressure is not a thermodynamic variable (no equation of


state to be satised).

• Role of pressure: pressure must be such that the continuity equation is satised,
i.e., ∇ · w = 0.
• It can be shown that only the irrotational component (gradient of a scalar potential)
of the w eld can be inuenced by p.

77
• On these bases, several projection type algorithms have been developed to decouple
pressure from velocity.

• However, most of them are formulated with reference to the space discretized equa-
tions (SIMPLE, SIMPLER, SIMPLEC, PISO, etc.) dicult to understand.
−→
• Other methods have been developed starting from the equations discretized in time,
but not in space −→ independent of the space discretization method and much
easier to understand.
• All variants of segregated algorithms share the same basic philosophy, i.e., they are
based on Helmholtz decomposition.

A Projection Method
• Aim: to solve the steady-state incompressible Navier-Stokes equations by a pseudo-
transient procedure.
• Equations (isothermal ow, ρ = const, µ = const)


(ρw) + ∇ · (ρww) = µ∇2 w − ∇p
∂ϑ

∇·w =0

• Time discretization: integration from time level n to n+1 to nd wn+1 and pn+1
from known wn and pn , Backward Euler scheme, linearization of the advection term
as ww ≈ wn w
wn+1 − wn
+ ρ∇ · wn wn+1 = µ∇2 wn+1 − ∇pn+1

ρ
∆ϑ

• Procedure: at each time step, nd a tentative velocity eld that satisfy momentum
but not mass conservation and, then, correct it to recover a divergence-free velocity
eld.

• The unknown velocity and pressure are expressed as sums of tentative (∗) and cor-
rection 0
( ) values
n+1 ∗ 0 n+1 ∗ 0
w =w +w p =p +p

• The time step is split into two parts: a predictor step (from level n to (∗)) and a
corrector step (from level (∗) to n + 1).
• For this reason, projection methods are also called fractional step methods.
• Assuming p∗ = pn and substituting

w∗ − wn w0
ρ +ρ + ρ∇ · (wn w∗ ) + ρ∇ · (wn w0 )
∆ϑ ∆ϑ
= µ∇2 w∗ + µ∇2 w0 − ∇pn − ∇p0

78
• Associating the tentative part of the acceleration to the (∗) terms
w∗ − wn
ρ + ρ∇ · (wn w∗ ) = µ∇2 w∗ − ∇pn
∆ϑ

• Associating the correction 0


part of the acceleration to the ( ) terms and dropping
negligible terms
w0
(·((w w0 ) = 
n ( 20
− ∇p0
(
ρ +(
ρ∇ (( µ∇ w
∆ϑ

w0 wn+1 − w∗
ρ =ρ = −∇p0
∆ϑ ∆ϑ
• velocity (and pressure correction)
Neglecting the slashed terms is reasonable since
are always small and vanish when convergence is reached.

• Rearranging, taking the divergence and imposing ∇ · wn+1 = 0


ρ
∇ · ∇p0 = − n+1 − ∇ · w∗
=0 
∇
 ·w
∆ϑ

ρ
∇ 2 p0 = ∇ · w∗
∆ϑ
• Once p0 has been computed by solving the above Poisson equation

∆ϑ 0
w0 = − ∇p
ρ

• Finally

wn+1 = w∗ + w0 pn+1 = pn + p0
• Then it is possible to proceed to the next step.

Summary of the Method


• At each time step of the pseudo-transient procedure
1. a tentative pressure eld is assumed equal to that at the end of the previous

time step (p = pn );
2. momentum equations are solved to nd a tentative velocity

eld w which is
n
not divergence-free because p is not the correct pressure eld;
3. a pressure correction 0
eld p is found by solving an appropriate pressure Poisson
equation;
4. a velocity correction eld that allows to recover mass conservation is computed
from the pressure correction eld.

• At convergence 0
(steady-state): p and w0 vanish −→ pn approaches the correct
pressure −→ momentum and mass conservation.
wn+1 ≈ w∗ satises both
• Note: methods of this type are called projection methods because a correction
potential (pressure) projects a tentative velocity eld onto a divergence-free ve-
locity eld.

79
Helmholtz Decomposition vs. Projection of w∗

• HD: w∗ = wsol + ∇ϕ −→ wsol = w∗ − ∇ϕ .


• Projection: w
n+1
= w∗ + w0 .
• Since w
n+1
is divergence-free, w
n+1
≡ wsol and w0 = −(∆ϑ/ρ)∇p0 = −∇ϕ −→ w0
irrotational.
is equal to the gradient of a scalar potential and, thus, is

• The HD theorem guarantees that: (i) the projection is orthogonal and unique and
is the best div-free approximation to w (which satises momentum
n+1 ∗
(ii) w
conservation).

Boundary Conditions
• Boundary conditions for the time discretized N-S equations can be obtained from
those for the PDEs:
 inow boundaries: Dirichlet b.c.

w∗ = wn+1 = we −→ w0 = 0
 solid walls: Dirichlet b.c.

w∗ = wn+1 = 0 −→ w0 = 0
 outow boundaries: Neumann b.c.

∂w∗
= 0 −→ w0 6= 0, but small
∂n
• Boundary conditions for the pressure Poisson equation must be consistent with
the denition of the pressure correction:
 inow boundaries and solid walls (w0 = 0): Neumann b.c.

∂p0 ρ 0 ∂p0
= ∇p0 · n = − w ·n=0 −→ =0
∂n ∆ϑ ∂n
 outow boundaries (w0 6= 0, but are small and vanish at convergence): Neumann
b.c.
∂p0
=0
∂n
• Note: Neumann b.c. on the whole boundary are not sucient to solve a Poisson
equation −→ a Dirichlet condition
p0 = 0

must be specied at least in one (arbitrary) point.

80
True Transient Problems
• If the problem is really time dependent, the details of the ow evolution are impor-
tant −→
 projection based on an accurate time integration scheme;
 iterations within each time step until convergence.
wn+1 − wn
+ ρ∇ · γ w̃n+1 wn+1 + (1 − γ)wn wn
 
ρ
∆ϑ
= µ∇2 γwn+1 + (1 − γ)wn − ∇ γpn+1 + (1 − γ)pn
   

• w̃n+1 is a known approximation to wn+1 (e.g., the value computed at the end of the
last iteration).

• Alternatively, toavoid iterations while preserving the formal order of accuracy of


computed by extrapolation of values at previous
n+1
the time integration method: w̃
time steps −→ possible stability problems.

Natural Convection Problems


• In natural convection problems, the N-S equations are also coupled to the energy
equation because the buoyancy term −ρβ(t − t0 )g cannot be neglected.

• Equations must be decoupled by setting t = tn or using other suitable types of


linearization.

• At each time step the discretized energy equation


tn+1 − tn
+ ρcp ∇ · γwn+1 tn+1 + (1 − γ)wn tn
 
ρcp
∆ϑ
= λ∇2 γtn+1 + (1 − γ)tn
 

must be solved using appropriate boundary conditions.

• γ=1 should be used in pseudo-transient simulations.

13 FVM Implementation of the Projection Algorithm


(concepts only, no detailed math)

13.1 Predictor Step


Time Discretization
• General transport equation

φn+1 − φn
+ γ ∇ · ρwn+1 φn+1 + (1 − γ) ∇ · (ρwn φn )

ρ
∆ϑ
= γ ∇ · Γ∇φn+1 + (1 − γ) ∇ · (Γ∇φn ) + s


81
• N-S eqs. in the predictor step of the projection algorithm
u∗ − un
+ γ ∇ · ρw̃n+1 u∗ + (1 − γ) ∇ · (ρwn un )

ρ
∆ϑ
∂pn
= γ ∇ · (µ∇u∗ ) + (1 − γ) ∇ · (µ∇un ) − − ρβ (tn − t0 ) gx
∂x
v∗ − vn
+ γ ∇ · ρw̃n+1 v ∗ + (1 − γ) ∇ · (ρwn v n )

ρ
∆ϑ
∂pn
= γ ∇ · (µ∇v ∗ ) + (1 − γ) ∇ · (µ∇v n ) − − ρβ (tn − t0 ) gy
∂y

Colocated Grids
• All unknowns (u, v, p) are dened in the same points (nodes).

N
n
W w P e E
s
S

(u : →, v : ↑, p : ◦)

• Each of the two N-S equations can be discretized in space using the same techniques
valid for the general transport equation:

for each CV, integration of all terms over the volume V , followed by the application
of the divergence theorem.

Pressure Term
• Note: the volume integral does not contain the divergence of a vector
R 
V
∇p dV
eld, but the gradient of a scalar.

• However, a surface integral can still be obtained from the pressure term.
• Given the vector eld P(x, y) = p(x, y) c, where c 6= 0 is a constant vector eld, since
∇ · (p c) = c · ∇p + p 
∇ c =0
·
Z Z Z Z
∇ · P dV = P · n dA −→ c·
 ∇p dV = 
c· p n dA
V A V A
| {z }
divergence theorem

Z Z
∇p dV = p n dA −→
V A
Z Z Z Z
∂p ∂p
dV = p nx dA dV = p ny dA
V ∂x A V ∂y A

82
Integration over a CV (Colocated Grid)

Z Z Z
ρ ∗ ∗
u dV + γ ρ u w̃ n+1
· n dA − γ µ∇u∗ · n dA
V ∆ϑ AZ A Z
= − (1 − γ) ρ u w · n dA + (1 − γ) µ∇un · n dA
n n

Z A Z A Z
n n ρ n
− p nx dA − ρβgx (t − t0 ) dV + u dV
A V V ∆ϑ

Z Z Z
ρ ∗ ∗
v dV + γ ρ v w̃ n+1
· n dA − γ µ∇v ∗ · n dA
V ∆ϑ AZ A Z
= − (1 − γ) ρ v w · n dA + (1 − γ) µ∇v n · n dA
n n

Z A Z A Z
n n ρ n
− p ny dA − ρβgy (t − t0 ) dV + v dV
A V V ∆ϑ

(two systems of N equations with N unknowns each must be solved)

• Problem: if linear interpolation is used to approximate p at CV faces, the calcu-


lated pressure is aected by an unphysical checkerboarding eect (checkerboarded
pressure eld).

2-D example

1-D example

• Cause: weak coupling between pressure and velocity elds.


• E.g.: approximation of the pressure term in the x-momentum equation for the generic
to node P
Z Z Z 
n n
− p nx dA = − p dA − p dA ≈ (pnw − pne ) ∆y
n
A Ae Aw

83
• If the grid is uniform
pnW + pnP pn + pnE pnW − pnE
   
(pnw − pne ) ∆y ≈ − P ∆y = ∆y
2 2 2

• Remark 1 : pressure at node P does not appear in the momentum equations for node
P −→ pressure at node P cannot inuence velocity at node P !
• Similar results are obtained with reference to the y-momentum equation −→ pressure
at node P is decoupled from pressure at neighboring nodes.

• Remark 2 : the pressure term is computed on a coarse grid of size twice that of the
grid for velocity, i.e., 2∆x × 2∆y .
• Remark 3 : the representation of the pressure gradient is physically meaningful,
but not accurate (possible divergence).

• Cure: (i) use staggered grids or (ii) use Rhie-Chow interpolation.

Staggered Grids
• Dierent grids are used for dierent variables.
• Grids obtained by shifting the main grid to the right or up so that the velocity
nodes are on the faces of pressure CVs.

• The x-momentum equation is discretized using the CVs for u, the y -momentum equa-
tion discretized using the CVs for v, while the pressure equation is discretized using
themain grid.
• Note: ue , uw , vn , vs are face values in the grid for p and nodal values in the staggered
grids for u and v.

AN , y
N VC per p ed N
altri scalari
An vn
vn VC per u
AP , y
uw uw P ue E
P ue E Dy j
VC per v Aw
AP , x Ae AE , x
As vs
vs Dxi

Integration over a CV (Staggered Grids)


Z Z Z
ρ ∗ ∗
u dV + γ ρ u w̃ n+1
µ∇u∗ · n dA
· n dA − γ
Vu ∆ϑ Au Au
Z Z
n n
= − (1 − γ) ρ u w · n dA + (1 − γ) µ∇un · n dA
Au Au
Z Z Z
n n ρ n
− p nx dA − ρβgx (t − t0 ) dV + u dV
Au Vu Vu ∆ϑ

84
Z Z Z
ρ ∗ ∗
v dV + γ ρ v w̃ n+1
µ∇v ∗ · n dA
· n dA − γ
Vv ∆ϑ Av Av
Z Z
n n
= − (1 − γ) ρ v w · n dA + (1 − γ) µ∇v n · n dA
Av Av
Z Z Z
n n ρ n
− p ny dA − ρβgy (t − t0 ) dV + v dV
Av Vv Vv ∆ϑ

(two systems of N equations with N unknowns each must be solved)

• E.g., approximation of the pressure term in the x-momentum equation for the generic
to node ue
Z "Z Z #
− pn nx dA = − pn dA − pn dA ≈ (pnP − pnE ) ∆y
Au AE,x AP,x

• Remark: now the pressure at two adjacent nodes appears in the discretized momen-
tum equation.

• Similar results are obtained with reference to the y -momentum equation for node vn
−→ the nodal pressure is coupled with pressure at neighboring nodes −→ no more
checkerboarding.

• Note 1 : staggered grids yield accurate results, but their use iscomplicated and
cannot be extended to unstructured grids −→ Rhie-Chow interpolation is often
preferred in modern CFD codes (not covered in this course).

• Note 2 : the use of staggered grids with FVM corresponds to the use of elements of
dierent order for w and p (unequal order interpolation) in FEM discretizations.

13.2 Corrector Step


Discretization of the Pressure Poisson Equation
• Integration over a pressure CV (valid with any grid)
Z Z Z Z
2 0 ρ ρ ∗
∇ p dV = ∇ · w∗ dV −→ 0
∇p · n dA = w · n dA
V V ∆ϑ A A ∆ϑ

∂p0 ∂p0 ∂p0 ∂p0


Z Z Z Z
dy − dy + dx − dx
Ae ∂x Aw ∂x An ∂y As ∂y
ρ
= [u∗ ∆y − u∗w ∆y + vn∗ ∆x − vs∗ ∆x]
∆ϑ e

(uk are interpolated values with colocated grids and nodal values with staggered grids).

p0E − p0P p0P − p0W


 0
pN − p0P p0P − p0S
  
− ∆y + − ∆x
xE − xP xP − xW yN − yP yP − yS
 
ρ ∗ ∗ ∗ ∗
= [ue − uw ] ∆y + [vn − vs ] ∆x
∆ϑ
(a system of N equations with N unknowns must be solved)

85
Calculation of Velocity Corrections
• Integration over velocity CVs (only valid with staggered grids)
"Z #
∂p0
Z Z Z
ρ 0
u dV = − dV = − p0 dA − p0 dA
Vu ∆ϑ Vu ∂x AE,x AP,x

"Z #
∂p0
Z Z Z
ρ 0 0 0
v dV = − dV = − p dA − p dA
Vv ∆ϑ Vv ∂y AN,y AP,y

ρ 0  = − (p0 − p0 ) ∆y
u (xP − xE ) 
∆y 
∆ϑ e P E 

ρ 0  = − (p0 − p0 ) 
v (yP − yN ) 
∆x N ∆x

∆ϑ n P

∆ϑ p0P − p0E ∆ϑ p0P − p0N


u0e = − vn0 = −
ρ xP − xE ρ yP − yN
(explicit relations)

Finishing Touches
• Velocity and pressure at ϑn+1 (only valid with staggered grids)

pn+1
P = pnP + p0P
un+1
e = u∗e + u0e
vnn+1 = vn∗ + vn0

• Note: if required, the energy equation is integrated over the pressure CV (valid
with any grid)

Z Z Z
ρ cp n+1 n+1 n+1
t dV + γ ρ cp t w · n dA − γ λ ∇tn+1 · n dA
V ∆ϑ A A
Z Z
= − (1 − γ) ρ cp t w · n dA + (1 − γ) λ ∇tn · n dA
n n

Z A A
ρ cp n
+ t dV
V ∆ϑ

(a system of N equations with N unknowns must be solved)

86

You might also like