Professional Documents
Culture Documents
P - Computational Thermal Fluid Dynamics PDF
P - Computational Thermal Fluid Dynamics PDF
Contents
1 Introduction to CFD 3
1.1 Main Concepts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
1.2 Uses of CFD . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
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
1
6 Grids 48
6.1 Types of Grids . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48
6.2 Practical Aspects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51
8 Space Integration 57
8.1 Source Term . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 57
8.2 Diusion Term . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 58
8.3 Advection Term . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 60
10 Time Integration 67
10.1 Preliminaries . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 67
10.2 Two-Level Methods . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 68
10.3 Multilevel Methods . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 71
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 solution:
approximate and dened in a large but nite number of points;
can even be found for complex geometries and boundary conditions (engineering
applications).
3
Numerical Methods
• Finite dierence method
• Finite volume method (Control volume method)
Finite element method (FEM)
Boundary element method (BEM)
Spectral methods
Meshless methods
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.
• 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:
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).
Verication: making sure that the model equations have been correctly imple-
mented and solved (it concerns the computer program and the solution).
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
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
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
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
• In a symbolic form
Z Z Z Z Z
∂(...)
dV = n · (...)dA + (...)dV = ∇ · (...)dV + (...)dV
V ∂ϑ A V V V
Z
[(...) + (...) + (...)] dV = 0
V
• For ∆ϑ → 0 n
dm X X dm
= ṁe − ṁu d
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
Z
∂ρ
+ ∇ · (ρw) dV = 0
V ∂ϑ
8
• Continuity equation (general form)
∂ρ ∂ρ ∂(ρu) ∂(ρv)
+ ∇ · (ρw) = 0 + + =0
∂ϑ ∂ϑ ∂x ∂y
∂
(ρcp t) + ∇ · (ρwcp t) = ∇ · (λ∇t) + q̇
∂ϑ
• Non-conservative form
Dt ∂t
ρcp = ρcp + ρcp w · ∇t = ∇ · (λ∇t) + q̇
Dϑ ∂ϑ
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.
∂ ∂ ∂
(ρ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.
• 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.
• Denition in 2-D
" #
τxx τxy
T=
τyx τyy
Tensor Operations
• Scalar product of two vectors w · w or wT w (result: a scalar)
u
= u2 + v 2
w·w = u v
v
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.
∂
(ρ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
∇ · (ρww) = ρw · ∇w + w∇ · (ρw)
• If ρ = const −→ ∇ · w = 0 −→ ∇ · (ρww) = ρw · ∇w
• Non-conservative form
Dw ∂w
ρ =ρ + ρw · ∇w = −∇p + ∇ · T + ρg
Dϑ ∂ϑ
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).
∂ ∂
∂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
∇ · σ = ∇ · (−pI + T)
• 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
∂
(ρ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)
• 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.
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).
∂H ∂H g
∇H = i+ j=j and j=−
∂x ∂H g
ρ − ρ0 ∼
= −ρβ(t − t0 )
• Note 1: Since for a uid at rest p̃ = const and ∇p̃ = 0 −→ ∇p̃ 6= 0 is only a function
of the ow eld.
• Non-conservative form
Dw ∂w
ρ =ρ + ρw · ∇w = −∇p̃ + ∇ · (µ∇w) − ρβ(t − t0 )g
Dϑ ∂ϑ
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
Gr
• 1 −→ forced convection;
Re2
Gr
• 1 −→ natural convection;
Re2
Gr
• ∼1 −→ mixed convection.
Re2
• 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].
17
• Continuity equation automatically satised
∂u ∂v ∂ 2ψ ∂ 2ψ
+ = − ≡0
∂x ∂y ∂x∂y ∂y∂x
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).
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.
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).
∂t
ρcp + ρcp w · ∇t = λ∇2 t + q̇
∂ϑ
• 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).
• 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
• Note: often ω is not constant: ω << 1 in the rst iterations and then increased to
ω∼1 when aproaching to convergence.
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).
• 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).
• 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
∂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
ξ = 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
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
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.
• 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.
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 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
26
Remarks
• The normal derivative on the boundary can be expressed as
∂φ ∂φ ∂φ nx ∂φ ∂φ
= ∇φ · n = = nx + ny
∂n ∂x ∂y ny ∂x ∂y
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:
27
• Symmetry boundary conditions can be applied on the symmetry axis if there is:
geometrical symmetry and steady-state ow;
• 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
∂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
∂t
=0
∂n
t2 = t1 + ∆tbulk
with ∆tbulk problem dependent for periodicity in the ow direction, ∆tbulk = 0 for
periodicity in the transverse direction.
• 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.
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:
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.
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
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).
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.
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 ).
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).
i,j+1 i−1,j
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).
34
• Central dierence scheme (3 nodes involved)
dt ∼ ti+1 − ti−1 ti+1 − ti−1
= =
dx i xi+1 − xi−1 2 ∆x
2 ∆x ∆x 2 2 ∆x
• The term in parentheses is not the dierence between the forward and backward
dierence schemes.
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
• 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.
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.
• 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
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
Node Numbering
• Global numbering (by rows)
• Note: other numbering schemes are possible (e.g.: by columns, starting from the top
left node).
39
Structure of the System Matrix
• Curvilinear coordinates are are associated with the grid lines in the physical domain
(boundary-tted coordinate method).
• 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
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.
• In practice, grid independence test are preferred: the same problem is solved using
ner and ner grids until the solution stops changing signicantly.
∂φ ∂φ
• 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
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.
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.
(φ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.
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.
46
Remarks
• Optimal values of r: 1.3 ÷ 2.
• The order of accuracy p can be determined with reference to
• 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.
• 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.
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.
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).
block-structured
block-structured
49
Unstructured Grids
triangular cells
quadrilateral cells
hybrid
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.
• 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.
• 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 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.).
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).
• If the method is applied consistently, uxes at interior boundaries cancel out −→ the
FVM is also globally conservative.
∂
(ρ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
∂ϑ
• In other words:
• The method can thus be described with reference to the solution of the general trans-
port equation.
where
J00 = J00c − J00d = ρφw − Γ∇φ
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).
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.
• In all nite volume grids there is only one node in each CV.
Discussion
• For nonuniform grids, the two methods lead to dierent orders of accuracy in the
approximations of the PDE terms.
• 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.
• 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.
55
Identications of generic nodes and faces of CVs
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
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
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.
k k k
dS dS dS
SP = S(φkP ) + (φP − φkP ) = φP + S(φkP ) − φkP
dφP dφP dφP
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
00
• Jd,e intersection of face e and the line connecting nodes P and E .
evaluated at the
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.
φE − φP
Fd,e ' Γe ∆y
x E − xP
• 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
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.
φe = φE λe,P E + φP (1 − λe,P E )
00
Jc,e CDS
' ρ ue [φE λe,P E + φP (1 − λe,P E )]
• 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
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.
• 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
• 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.
63
SOUDS: Second Order Upwind Dierence Scheme (linear extrapolation)
64
Example: Discretization Using CDS
P
uk = (w · n)k ṁk = ρ uk Ak k ṁk = 0 (for mass conservation)
ṁ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
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)
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).
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
dϑ
• The time integration procedure is illustrated with reference to this equation.
67
10.2 Two-Level Methods
Time Integration Schemes
• Equation to be solved
dφ(ϑ)
= f (ϑ, φ(ϑ)) with φ(ϑ0 ) = φ0
dϑ
• 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
• 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 ∆ϑ
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
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
φn+1 − φn
= γf ϑn+1 , φn+1 + (1 − γ) f (ϑn , φn )
∆ϑ
• Note 2 : consistently, the FE, CN and BE methods are O(∆ϑ), O(∆ϑ2 ) and O(∆ϑ),
respectively.
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.
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.
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
∆ϑ
AW φW + AN φN + AP φP + AS φS + AE φE = SP
− (AW φW + AN φN + AP φP + AS φS + AE φE ) + SP = 0
ρ
CP = ∆x ∆y AP = − (AE + AW + AN + AS ) SP = sP ∆x ∆y
∆ϑ
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
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
• 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
• 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
• 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
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.
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
• 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 − ∇ϕ
∇ · ∇ϕ = ∇ · V −
∇ sol
·V
−→ ∇2 ϕ = ∇ · V
(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.
• 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
∆ϑ
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.
ρ
∇ 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.
• 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∗
• 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
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).
φ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 ∆ϑ
2-D example
1-D example
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).
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
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 ∆ϑ
• 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.
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
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 ∆ϑ
86