Download as pdf or txt
Download as pdf or txt
You are on page 1of 83

4.

The Scalar-Transport Equation


Structured Grid; Cell-Centred Storage

t
W N
w
n
s P e

S E
b
k
j
B
i
Cell Indexing

Local Global

NN i,j+2

N i,j+1

n
WW Ww P e E EE i-2,j i-1,j i,j i+1,j i+2,j

s
i,j-1
S
i,j-2
SS
Generic Scalar-Transport Equation
u
V un
A

TIME DERIVATIVE ADVECTION + DIFFUSION SOURCE


+ =
𝑜𝑓 𝑎𝑚𝑜𝑢𝑛𝑡 𝑖𝑛 𝑉 𝑡ℎ𝑟𝑜𝑢𝑔ℎ 𝑏𝑜𝑢𝑛𝑑𝑎𝑟𝑦 𝑜𝑓 𝑉 𝑖𝑛𝑠𝑖𝑑𝑒 𝑉

ϕ = concentration (amount per unit mass of fluid)

d 𝜕ϕ
(𝑚𝑎𝑠𝑠 × ϕ) + ෍ ( 𝑚𝑎𝑠𝑠 𝑓𝑙𝑢𝑥 × ϕ −Γ 𝐴 ) = 𝑆
d𝑡 𝜕𝑛
𝑓𝑎𝑐𝑒𝑠
𝑡𝑖𝑚𝑒 𝑑𝑒𝑟𝑖𝑣𝑎𝑡𝑖𝑣𝑒 𝑎𝑑𝑣𝑒𝑐𝑡𝑖𝑜𝑛 𝑑𝑖𝑓𝑓𝑢𝑠𝑖𝑜𝑛 𝑠𝑜𝑢𝑟𝑐𝑒
1-d Advection-Diffusion Equation

• Simple analysis

• Hand solution

• Straightforward generalisation to 2D/3D

• Coordinate-wise discretisation in practice

• Many important theoretical problems


Steady 1-d Advection-Diffusion Equation
area A

flux w source flux e


Conservation: 𝑓𝑙𝑢𝑥𝑒 − 𝑓𝑙𝑢𝑥𝑤 = 𝑠𝑜𝑢𝑟𝑐𝑒

dϕ x
Flux: 𝑓𝑙𝑢𝑥 = ρ𝑢𝐴 ϕ −Γ𝐴
d𝑥
𝑎𝑑𝑣𝑒𝑐𝑡𝑖𝑜𝑛
𝑑𝑖𝑓𝑓𝑢𝑠𝑖𝑜𝑛

Source: 𝑠Δ𝑥

Conservative differential equation:


d
(𝑓𝑙𝑢𝑥) = 𝑠𝑜𝑢𝑟𝑐𝑒 𝑝𝑒𝑟 𝑢𝑛𝑖𝑡 𝑙𝑒𝑛𝑔𝑡ℎ
d𝑥
d dϕ
(ρ𝑢𝐴ϕ − Γ𝐴 ) = 𝑠
d𝑥 d𝑥
Discretising Diffusion and Source
Example
A thin rod has length 1 m and cross-section T = 20 C
o

8
1 cm  1 cm. The left-hand end is kept at
o
T=100 C
100 C, whilst the right-hand end is insulated.
dT
Rod dx =0
The heat flux across any section of area 𝐴 is
given by
d𝑇 s = -c (T-T )

8
x=0 1
−𝑘𝐴
d𝑥
where the conductivity 𝑘 = 1000 W m−1 K −1 . The rod loses heat along its length at a rate
proportional to the temperature excess over ambient (Newton’s law of cooling); i.e. the
heat source per unit length is:
𝑠 = −𝑐(𝑇 − 𝑇∞ )
where the ambient temperature 𝑇∞ = 20 °C and the coefficient 𝑐 = 2.5 W m−1 K −1.

(a) Write down and solve the differential equation for temperature along the rod.

(b) Divide the rod into 5 control sections, with nodes at the centre of each section, and
carry out a finite-volume analysis to find the temperature along the rod.
Differential Equation and Exact Solution
𝑓𝑙𝑢𝑥𝑒 − 𝑓𝑙𝑢𝑥𝑤 = 𝑠𝑜𝑢𝑟𝑐𝑒
flux w source flux e

d𝑇 d𝑇
−𝑘𝐴 − −𝑘𝐴 = −𝑐(𝑇 − 𝑇∞ )Δ𝑥
d𝑥 𝑒
d𝑥 𝑤

d𝑇 d𝑇
−𝑘𝐴 − −𝑘𝐴
d𝑥 𝑒 d𝑥 𝑤
= −𝑐(𝑇 − 𝑇∞ )
Δ𝑥

d d𝑇
( −𝑘𝐴 ) = −𝑐(𝑇 − 𝑇∞ ) 𝑇(0) = 100, 𝑇 ′ (1) = 0
d𝑥 d𝑥

d2 𝑇 𝑐 𝑐
− 𝑇=− 𝑇
d𝑥 2 𝑘𝐴 𝑘𝐴 ∞

d2 𝑇
− 25𝑇 = −500
d𝑥 2

𝑇 = 𝐴e5𝑥 + 𝐵e−5𝑥 + 2ด
0 𝐴 = 0.0036 , 𝐵 = 79.9964
𝑐𝑜𝑚𝑝𝑙𝑒𝑚𝑒𝑛𝑡𝑎𝑟𝑦 𝑝𝑎𝑟𝑡𝑖𝑐𝑢𝑙𝑎𝑟
𝑓𝑢𝑛𝑐𝑡𝑖𝑜𝑛 𝑖𝑛𝑡𝑒𝑔𝑟𝑎𝑙
Finite-Volume Decomposition

-4
A = 10
1 2 3 4 5
TL = 100 flux R= 0

 x = 0.2
Discretisation of Fluxes
T
TE
e

TW TP TE T
w e TP
x
x

d𝑇 𝑇𝐸 − 𝑇𝑃
𝑓𝑙𝑢𝑥𝑒 = − 𝑘𝐴 ቤ
d𝑥 𝑒 → −𝑘𝐴
Δ𝑥
Finite-Volume Discretisation
Conservation: 𝑓𝑙𝑢𝑥𝑒 − 𝑓𝑙𝑢𝑥𝑤 = 𝑠𝑜𝑢𝑟𝑐𝑒 flux w source flux e

Fluxes:
d𝑇 𝑇𝐸 − 𝑇𝑃 TW TP TE
interior faces: 𝑓𝑙𝑢𝑥𝑒 = − 𝑘𝐴 ቤ → −𝑘𝐴 w e
d𝑥 𝑒 Δ𝑥
𝑘𝐴
→ −𝐷(𝑇𝐸 − 𝑇𝑃 ) 𝐷= = 0.5
Δ𝑥

d𝑇 TL TP
𝑇𝑃 − 𝑇𝐿
left boundary: 𝑓𝑙𝑢𝑥𝐿 = − 𝑘𝐴 ቤ → −𝑘𝐴
d𝑥 𝐿 1
2Δ𝑥
→ −2𝐷(𝑇𝑃 − 𝑇𝐿 )
TP
flux R = 0
right boundary: 𝑓𝑙𝑢𝑥𝑅 = 0

Source: 𝑠𝑜𝑢𝑟𝑐𝑒 = −𝑐(𝑇𝑃 − 𝑇∞ )Δ𝑥 → 𝑏𝑃 + 𝑠𝑃 𝑇𝑃

𝑏𝑃 = 𝑐𝑇∞ Δ𝑥 = 10 , 𝑠𝑃 = −𝑐Δ𝑥 = −0.5


Finite-Volume Discretisation
𝑓𝑙𝑢𝑥𝑒 − 𝑓𝑙𝑢𝑥𝑤 = 𝑠𝑜𝑢𝑟𝑐𝑒 flux w source flux e

TW w
TP e
TE

Interior cells: −0.5(𝑇𝐸 − 𝑇𝑃 ) + 0.5(𝑇𝑃 − 𝑇𝑊 ) = 10 − 0.5𝑇𝑃


−0.5𝑇𝑊 + 1.5𝑇𝑃 − 0.5𝑇𝐸 = 10

Left boundary: −0.5(𝑇𝐸 − 𝑇𝑃 ) + 1.0(𝑇𝑃 − 100) = 10 − 0.5𝑇𝑃


2.0𝑇𝑃 − 0.5𝑇𝐸 = 110

Right boundary: 0 + 0.5(𝑇𝑃 − 𝑇𝑊 ) = 10 − 0.5𝑇𝑃


−0.5𝑇𝑊 + 1.0𝑇𝑃 = 10
Assembled Equations

-4
A = 10
1 2 3 4 5
TL = 100 flux R= 0

 x = 0.2

2 −0.5 0 0 0 𝑇1 110
−0.5 1.5 −0.5 0 0 𝑇2 10
0 −0.5 1.5 −0.5 0 𝑇3 = 10
0 0 −0.5 1.5 −0.5 𝑇4 10
0 0 0 −0.5 1 𝑇5 10
2 −0.5 0 0 0 𝑇1 110
−0.5 1.5 −0.5 0 0 𝑇2 10
0 −0.5 1.5 −0.5 0 𝑇3 = 10
0 0 −0.5 1.5 −0.5 𝑇4 10
0 0 0 −0.5 1 𝑇5 10
4 −1 0 0 0 ∥ 220
−1 3 −1 0 0 ∥ 20
All 𝑅 × 2: 0 −1 3 −1 0 ∥ 20
0 0 −1 3 −1 ∥ 20
0 0 0 −1 2 ∥ 20
4 −1 0 0 0 ∥ 220
𝑅2 → 4𝑅2 + 𝑅1: 0 11 −4 0 0 ∥ 300
0 −1 3 −1 0 ∥ 20
0 0 −1 3 −1 ∥ 20
0 0 0 −1 2 ∥ 20
4 −1 0 0 0 ∥ 220
0 11 −4 0 0 ∥ 300
𝑅3 → 11𝑅3 + 𝑅2: 0 0 29 −11 0 ∥ 520 2620
𝑇5 = = 21.30
0 0 −1 3 −1 ∥ 20 123
0 0 0 −1 2 ∥ 20
1100 + 29𝑇5
4 −1 0 0 0 ∥ 220 𝑇4 = = 22.60
76
0 11 −4 0 0 ∥ 300
0 0 29 −11 0 ∥ 520 520 + 11𝑇4
𝑅4 → 29𝑅4 + 𝑅3: 0 0 0 76 −29 ∥ 1100 𝑇3 = = 26.50
29
0 0 0 −1 2 ∥ 20
300 + 4𝑇3
4 −1 0 0 0 𝑇1 220 𝑇2 = = 36.91
0 11 −4 0 0 𝑇2 300 11
0 0 29 −11 0 𝑇3 = 520 220 + 𝑇2
0 0 0 76 −29 𝑇4 1100 𝑇1 = = 64.23
𝑅5 → 76𝑅5 + 𝑅4: 4
0 0 0 0 123 𝑇5 2620
Points to Note

• Each control volume gives one equation

• Each equation is a linear equation connecting the central node


and nodes on either side:
−𝑎𝑤 ϕ𝑊 + 𝑎𝑃 ϕ𝑃 − 𝑎𝐸 ϕ𝐸 = 𝑏𝑃

• Boundary values are incorporated into the source term

• The resulting matrix is tri-diagonal


=b
Discretising Diffusion


E
e

P
x
x

dϕ ϕ𝐸 − ϕ𝑃
−Γ𝐴 ቤ → −(Γ𝐴)𝑒
d𝑥 𝑒 Δ𝑥
Discretising the Source Term

𝑠𝑜𝑢𝑟𝑐𝑒 = 𝑏𝑃 + 𝑠𝑃 ϕ𝑃 𝑠𝑃 ≤ 0

Examples:

𝑠𝑜𝑢𝑟𝑐𝑒 = 3 − 2ϕ 𝑏𝑝 = 3, 𝑠𝑝 = −2

2
𝑠𝑜𝑢𝑟𝑐𝑒 = 10 − 7ϕ3 𝑏𝑝 = 10, 𝑠𝑝 = −7ϕ∗

Solve iteratively
x
Example uN

A 2-d finite-volume calculation is to be undertaken for fully-developed,


laminar flow between stationary, plane, parallel walls. A streamwise u j+1
pressure gradient d𝑝/d𝑥 = −𝐺 is imposed and the fluid viscosity is μ. The
uj
depth of the channel, 𝐻, is divided into 𝑁 equally-sized cells of dimension H y
𝑥 × 𝑦 × 1 as shown, with the velocity 𝑢 stored at cell centres. uj-1

(a) What are the boundary conditions on velocity?


u1
(b) What is the net pressure force on a single cell?

(c) Using a finite-difference approximation for velocity gradient, find expressions for the viscous forces on
upper and lower faces of the jth cell in terms of the nodal velocities {𝑢𝑗 }. (Deal separately with interior
cells and the boundary cells 𝑗 = 1 and 𝑗 = 𝑁.)

(d) By balancing pressure and viscous forces set up the finite-volume equations for velocity.

(e) Solve for the nodal velocities in the case 𝑁 = 6, leaving your answers as multiples of 𝑈0 = 𝐺𝐻 2 /μ. (You
are advised to note the symmetry of the problem.)

(f) Using your numerical solution, find the volume flow rate (per unit span) 𝑞 in terms of 𝑈0 and 𝐻.

(g) Find the wall shear stress, τ𝑤

(h) Compare your answers to (e), (f), (g) with the exact solution for plane Poiseuille flow.
A 2-d finite-volume calculation is to be undertaken for fully-developed, laminar flow between stationary,
plane, parallel walls. A streamwise pressure gradient d𝑝/d𝑥 = −𝐺 is imposed and the fluid viscosity is μ.
The depth of the channel, 𝐻, is divided into 𝑁 equally-sized cells of dimension 𝑥 × 𝑦 × 1 as shown, with
the velocity 𝑢 stored at cell centres. x

(a) What are the boundary conditions on velocity? uN

𝑢 = 0 on upper and lower walls


u j+1
(b) What is the net pressure force on a single cell?
uj
𝑁𝑒𝑡 𝑝𝑟𝑒𝑠𝑠𝑢𝑟𝑒 𝑓𝑜𝑟𝑐𝑒 = 𝑝𝐿 × Δ𝑦 × 1 − 𝑝𝑅 × Δ𝑦 × 1 H y
uj-1
= (𝑝𝐿 − 𝑝𝑅 ) × Δ𝑦
d𝑝 u1
= − Δ𝑥 Δy = 𝐺Δ𝑥Δ𝑦
d𝑥

(c) Using a finite-difference approximation for velocity gradient, find expressions for the viscous forces
on upper and lower faces of the jth cell in terms of the nodal velocities {𝑢𝑗 }.
d𝑢 𝑢𝑗+1 − 𝑢𝑗
Interior faces: 𝑣𝑖𝑠𝑐𝑜𝑢𝑠 𝑓𝑜𝑟𝑐𝑒 𝑜𝑛 𝑢𝑝𝑝𝑒𝑟 𝑓𝑎𝑐𝑒 = μ × (Δ𝑥 × 1) ≈ μ Δ𝑥
d𝑦 Δ𝑦
𝑢𝑗 − 𝑢𝑗−1
𝑣𝑖𝑠𝑐𝑜𝑢𝑠 𝑓𝑜𝑟𝑐𝑒 𝑜𝑛 𝑙𝑜𝑤𝑒𝑟 𝑓𝑎𝑐𝑒 ≈ −μ Δ𝑥
Δ𝑦

0 − 𝑢𝑗
Boundary faces: 𝑣𝑖𝑠𝑐𝑜𝑢𝑠 𝑓𝑜𝑟𝑐𝑒 𝑜𝑛 𝑢𝑝𝑝𝑒𝑟 𝑓𝑎𝑐𝑒 𝑜𝑓 𝑡𝑜𝑝 𝑐𝑒𝑙𝑙 ≈μ 1 Δ𝑥
2
Δ𝑦
𝑢𝑗 − 0
𝑣𝑖𝑠𝑐𝑜𝑢𝑠 𝑓𝑜𝑟𝑐𝑒 𝑜𝑛 𝑙𝑜𝑤𝑒𝑟 𝑓𝑎𝑐𝑒 𝑜𝑓 𝑏𝑜𝑡𝑡𝑜𝑚 𝑐𝑒𝑙𝑙 ≈ −μ Δ𝑥
1
2
Δ𝑦
A 2-d finite-volume calculation is to be undertaken for fully-developed, laminar flow between stationary,
plane, parallel walls. A streamwise pressure gradient d𝑝/d𝑥 = −𝐺 is imposed and the fluid viscosity is μ.
The depth of the channel, 𝐻, is divided into 𝑁 equally-sized cells of dimension 𝑥 × 𝑦 × 1 as shown, with
the velocity 𝑢 stored at cell centres.
(d) By balancing pressure and viscous forces set up the finite-volume equations for velocity.
x
𝑢𝑗+1 − 𝑢𝑗 𝑢𝑗 − 𝑢𝑗−1
Interior cell: 𝐺Δ𝑥Δ𝑦 + μ Δ𝑥 − μ Δ𝑥 = 0 uN
Δ𝑦 Δ𝑦
𝐺Δ𝑦 2
= −𝑢𝑗−1 + 2𝑢𝑗 − 𝑢𝑗+1 u j+1
μ
uj
y
0 − 𝑢𝑗 𝑢𝑗 − 𝑢𝑗−1 H
Top cell (𝑗 = 𝑁): 𝐺Δ𝑥Δ𝑦 + μ 1 Δ𝑥 − μ Δ𝑥 = 0 uj-1
2
Δ𝑦 Δ𝑦
𝐺Δ𝑦 2
= −𝑢𝑗−1 + 3𝑢𝑗 u1
μ
𝑢𝑗+1 − 𝑢𝑗 𝑢𝑗 − 0
Bottom cell (𝑗 = 1): 𝐺Δ𝑥Δ𝑦 + μ Δ𝑥 − μ 1 Δ𝑥 = 0
Δ𝑦 2
Δ𝑦
𝐺Δ𝑦 2
= 3𝑢𝑗 − 𝑢𝑗+1
μ

(e) Solve for the nodal velocities in the case 𝑁 = 6, leaving your answers as multiples of 𝑈0 = 𝐺𝐻 2 /μ.
Symmetry: 𝑢1 = 𝑢6 , 𝑢2 = 𝑢5 , 𝑢3 = 𝑢4 Consider just 𝑗 = 1,2,3
2
𝐺Δ𝑦 2 𝐺𝐻 2 Δ𝑦 1
= = 𝑈
μ μ 𝐻 36 0
A 2-d finite-volume calculation is to be undertaken for fully-developed, laminar flow between stationary,
plane, parallel walls. A streamwise pressure gradient d𝑝/d𝑥 = −𝐺 is imposed and the fluid viscosity is μ.
The depth of the channel, 𝐻, is divided into 𝑁 equally-sized cells of dimension 𝑥 × 𝑦 × 1 as shown, with
the velocity 𝑢 stored at cell centres.
(e) Solve for the nodal velocities in the case 𝑁 = 6, leaving your answers as multiples of 𝑈0 = 𝐺𝐻 2 /μ.
x
1 1 1
𝑗 = 1: 3𝑢1 − 𝑢2 = 𝑈 𝑢1 = (𝑢2 + 𝑈 ) uN
36 0 3 36 0
1
𝑗 = 2: −𝑢1 + 2𝑢2 − 𝑢3 = 𝑈
36 0 u j+1
uj
1 1 1
H y
𝑗 = 3: −𝑢2 + 2𝑢3 − 𝑢4 = 𝑈 −𝑢2 + 𝑢3 = 𝑈 𝑢3 = 𝑢2 + 𝑈 uj-1
36 0 36 0 36 0
u1
1 1 1 1
− (𝑢2 + 𝑈0 ) + 2𝑢2 − (𝑢2 + 𝑈0 ) = 𝑈
3 36 36 36 0

2 7 1
𝑢2 = × 𝑈0
3 3 36

7
𝑢2 = 𝑈
72 0

3 7 9
𝑢1 = 𝑢6 = 𝑈 𝑢2 = 𝑢5 = 𝑈 𝑢3 = 𝑢4 = 𝑈
72 0 72 0 72 0
A 2-d finite-volume calculation is to be undertaken for fully-developed, laminar flow between stationary,
plane, parallel walls. A streamwise pressure gradient d𝑝/d𝑥 = −𝐺 is imposed and the fluid viscosity is μ.
The depth of the channel, 𝐻, is divided into 𝑁 equally-sized cells of dimension 𝑥 × 𝑦 × 1 as shown, with
the velocity 𝑢 stored at cell centres.
(f) Using your numerical solution, find the volume flow rate (per unit span) 𝑞 in terms of 𝑈0 and 𝐻.
3 7 9 x
𝑢1 = 𝑢6 = 𝑈0 𝑢2 = 𝑢5 = 𝑈0 𝑢3 = 𝑢4 = 𝑈0
72 72 72 u N

6 3
𝐻 𝐻 3 7 9 19 u j+1
𝑞 = ෍ 𝑢𝑗 Δ𝑦 = 2 ෍ 𝑢𝑗 = 𝑈0 ( + + ) = 𝑈 𝐻
𝑗=1 𝑗=1
6 3 72 72 72 216 0 H
uj
y
uj-1

u1

(g) Find the wall shear stress, τ𝑤

2 × τ𝑤 Δ𝑥 = (𝑝𝐿 − 𝑝𝑅 )𝐻

1 𝑝𝐿 − 𝑝𝑅 1
τ𝑤 = ( )𝐻 = 𝐺𝐻
2 Δ𝑥 2
A 2-d finite-volume calculation is to be undertaken for fully-developed, laminar flow between stationary,
plane, parallel walls. A streamwise pressure gradient d𝑝/d𝑥 = −𝐺 is imposed and the fluid viscosity is μ.
The depth of the channel, 𝐻, is divided into 𝑁 equally-sized cells of dimension 𝑥 × 𝑦 × 1 as shown, with
the velocity 𝑢 stored at cell centres.
(h) Compare your answers to (e), (f), (g) with the exact solution for plane Poiseuille flow.
x
𝑢 1𝑦 𝑦 𝐺𝐻 2
Exact solution: = 1− , 𝑈0 =
𝑈0 2 𝐻 𝐻 uN
μ

u j+1
Nodal values:
3 7 9 H
uj
y
(numerical) 𝑢1 = 𝑢6 = 𝑈 𝑢2 = 𝑢5 = 𝑈 𝑢3 = 𝑢4 = 𝑈
72 0 72 0 72 0 uj-1

2.75 6.75 8.75


(exact) 𝑢1 = 𝑢6 = 𝑈 𝑢2 = 𝑢5 = 𝑈 𝑢3 = 𝑢4 = 𝑈
72 0 72 0 72 0 u1

Flow rate:
19
(numerical) 𝑞= 𝑈 𝐻
216 0
𝐻
18
(exact) 𝑞 = න 𝑢 d𝑦 = 𝑈 𝐻
0 216 0

Wall stress:
1
(numerical) 𝜏𝑤 = 𝐺𝐻
2
𝜕𝑢 1
(exact) τ𝑤 = μ ቤ 𝜏𝑤 = 𝐺𝐻
𝜕𝑦 𝑦=0 2
Discretising Advection (Part 1)
Example
=0 d
u =0
dx
x=0 L

point
source

A pipe of cross-section 𝐴 = 0.01 m2 and length 𝐿 = 1 m carries water (density ρ =


1000 kg m−3 ) at velocity 𝑢 = 0.1 m s−1 .

A faulty valve introduces a reactive chemical into the pipe half-way along its length at a
rate of 0.01 kg s–1. The diffusivity of the chemical in water is Γ = 0.1 kg m−1 s−1 . The
chemical is subsequently broken down at a rate proportional to its concentration ϕ (mass
of chemical per unit mass of water), this rate amounting to – γϕ per metre, where γ =
0.5 kg m−1 s −1 .

Approximating the downstream boundary condition by dϕ/d𝑥 = 0, set up a finite-


volume calculation with 7 cells to estimate the concentration along the pipe using:
(a) Central
(b) Upwind
differencing schemes for advection.
Fluxes and Sources
=0 d
u =0
dx
x=0 L

point
source

Concentration ϕ (= mass of chemical per mass of water)

Flux (= rate of transport across a surface)


‒ advection: 𝐶ϕ 𝐶 = ρ𝑢𝐴 (mass flux)

‒ diffusion: −Γ𝐴
d𝑥

Source
‒ point source 𝑆𝑝𝑡 at 𝑥 = 0.5 m
‒ loss by chemical breakdown −γϕ per unit length
Finite-Volume Decomposition

loss - per metre

d
L = 0 1 2 3 4 5 6 7 =0
dx

S pt = 0.01 kg/s
Finite-Volume Discretisation
𝑓𝑙𝑢𝑥𝑒 − 𝑓𝑙𝑢𝑥𝑤 = 𝑠𝑜𝑢𝑟𝑐𝑒  W w
 P e
 E

dϕ 𝑓𝑙𝑢𝑥𝑒 = 𝐶ϕ𝑒 − 𝐷(ϕ𝐸 − ϕ𝑃 ) 𝐶 = ρ𝑢𝐴 = 1.0


𝑓𝑙𝑢𝑥 = 𝐶ϕ − Γ𝐴
d𝑥
Γ𝐴
𝑓𝑙𝑢𝑥𝑤 = 𝐶ϕ𝑤 − 𝐷(ϕ𝑃 − ϕ𝑊 ) 𝐷= = 0.007
Δ𝑥

𝑠𝑜𝑢𝑟𝑐𝑒 = 𝑆ด
𝑝𝑡 − 𝛾ϕ𝑃 Δ𝑥 𝑠𝑜𝑢𝑟𝑐𝑒 = 𝑏𝑃 + 𝑠𝑃 ϕ𝑃 𝑏𝑃 = 0.01 (cell 4)
𝑐𝑒𝑙𝑙 4 𝑠𝑃 = −0.071

𝐶ϕ𝑒 − 𝐶ϕ𝑤 −𝐷ϕ𝑊 + 2𝐷ϕ𝑃 − 𝐷ϕ𝐸 = 𝑏𝑃 + 𝑠𝑃 ϕ𝑃


𝑎𝑑𝑣𝑒𝑐𝑡𝑖𝑜𝑛 𝑑𝑖𝑓𝑓𝑢𝑠𝑖𝑜𝑛 𝑠𝑜𝑢𝑟𝑐𝑒

An approximation for cell-face values ϕe and ϕw is called an


advection scheme or advection-differencing scheme
Central Differencing

P
e
E
P E
e

1
ϕ𝑒 = (ϕ𝑃 + ϕ𝐸 )
2
Finite-Volume Discretisation:
Central Differencing For Advection

𝐶ϕ𝑒 − 𝐶ϕ𝑤 −𝐷ϕ𝑊 + 2𝐷ϕ𝑃 − 𝐷ϕ𝐸 = 𝑏𝑃 + 𝑠𝑃 ϕ𝑃 


W w

P e

E

𝑎𝑑𝑣𝑒𝑐𝑡𝑖𝑜𝑛 𝑑𝑖𝑓𝑓𝑢𝑠𝑖𝑜𝑛 𝑠𝑜𝑢𝑟𝑐𝑒

1 1
Central differencing: 𝐶ϕ𝑒 − 𝐶ϕ𝑤 = 𝐶 (ϕ𝑃 + ϕ𝐸 ) − 𝐶 (ϕ𝑊 + ϕ𝑃 )
2 2
𝐶
= (ϕ𝐸 − ϕ𝑊 )
2

𝐶 𝐶
−( + 𝐷)ϕ𝑊 + (2𝐷 − 𝑠𝑃 )ϕ𝑃 − (− + 𝐷)ϕ𝐸 = 𝑏𝑃
2 2

−0.507ϕ𝑊 + 0.085ϕ𝑃 + 0.493ϕ𝐸 = 0ถ


.01
𝑐𝑒𝑙𝑙 4 𝑜𝑛𝑙𝑦
Assembled Equations
Central Advection Scheme

0.592 0.493 0 0 0 0 0 ϕ1 0
−0.507 0.085 0.493 0 0 0 0 ϕ2 0
0 −0.507 0.085 0.493 0 0 0 ϕ3 0
0 0 −0.507 0.085 0.493 0 0 ϕ4 = 0.01
0 0 0 −0.507 0.085 0.493 0 ϕ5 0
0 0 0 0 −0.507 0.085 0.493 ϕ6 0
0 0 0 0 0 −0.507 0.578 ϕ7 0
Directional Bias

diffusion only

u advection
+
diffusion
Upwind Differencing

P e P
E e E
P E P E
e e

ϕ𝑒 = ϕ𝑃 (if 𝑢 > 0) ϕ𝑒 = ϕ𝐸 (if 𝑢 < 0)


Upwind Differencing

𝐶ϕ𝑒 − 𝐶ϕ𝑤 −𝐷ϕ𝑊 + 2𝐷ϕ𝑃 − 𝐷ϕ𝐸 = 𝑏𝑃 + 𝑠𝑃 ϕ𝑃 


W w

P e

E

𝑎𝑑𝑣𝑒𝑐𝑡𝑖𝑜𝑛 𝑑𝑖𝑓𝑓𝑢𝑠𝑖𝑜𝑛 𝑠𝑜𝑢𝑟𝑐𝑒

Upwind differencing: 𝐶ϕ𝑒 − 𝐶ϕ𝑤 = 𝐶(ϕ𝑃 − ϕ𝑊 )

−(𝐶 + 𝐷)ϕ𝑊 + (𝐶 + 2𝐷 − 𝑠𝑃 )ϕ𝑃 − 𝐷ϕ𝐸 = 𝑏𝑃

−1.007ϕ𝑊 + 1.085ϕ𝑃 − 0.007ϕ𝐸 = 0ถ


.01
𝑐𝑒𝑙𝑙 4 𝑜𝑛𝑙𝑦
Assembled Equations
Upwind Advection Scheme

1.092 −0.007 0 0 0 0 0 ϕ1 0
−1.007 1.085 −0.007 0 0 0 0 ϕ2 0
0 −1.007 1.085 −0.007 0 0 0 ϕ3 0
0 0 −1.007 1.085 −0.007 0 0 ϕ4 = 0.01
0 0 0 −1.007 1.085 −0.007 0 ϕ5 0
0 0 0 0 −1.007 1.085 −0.007 ϕ6 0
0 0 0 0 0 −1.007 1.078 ϕ7 0
Simple Advection Schemes Compared
−𝑎𝑊 ϕ𝑊 + 𝑎𝑃 ϕ𝑃 − 𝑎𝐸 ϕ𝐸 = 𝑏𝑃
 W w

P e

E

Central differencing Upwind differencing

𝑎𝑊 = 12𝐶 + 𝐷 𝑎𝑊 = 𝐶 + 𝐷
𝑎𝐸 = −12𝐶 + 𝐷 𝑎𝐸 = 𝐷 (if 𝐶 > 0)

𝑎𝑃 = 2𝐷 − 𝑠𝑃 𝑎𝑃 = 𝐶 + 2𝐷 − 𝑠𝑃

No “wiggles”  Pe ≤ 2

𝐶 ρ𝑢Δ𝑥
Pe = = Peclet number
𝐷 Γ

Theoretically, high accuracy ... Lower accuracy ...


... but unphysical “wiggles” ... but no “wiggles”
Finite-Volume Analysis: 1-d

Conservation: flux w source flux e 𝑓𝑙𝑢𝑥𝑒 − 𝑓𝑙𝑢𝑥𝑤 = 𝑠𝑜𝑢𝑟𝑐𝑒


𝑓𝑙𝑢𝑥 = 𝐶ϕ − Γ𝐴
d𝑥

W P E −𝑎𝑊 ϕ𝑊 + 𝑎𝑃 ϕ𝑃 − 𝑎𝐸 ϕ𝐸 = 𝑏𝑃
Discretisation:

Assembled matrix equation:

=b AΦ = b
Finite-Volume Analysis: 2-d
fluxn

Conservation: flux w source fluxe 𝑓𝑙𝑢𝑥𝑒 − 𝑓𝑙𝑢𝑥𝑤 + 𝑓𝑙𝑢𝑥𝑛 − 𝑓𝑙𝑢𝑥𝑠 = 𝑠𝑜𝑢𝑟𝑐𝑒


𝜕ϕ
𝑓𝑙𝑢𝑥𝑒,𝑤 = (ρ𝑢𝐴ϕ − Γ𝐴 )
fluxs 𝜕𝑥 𝑒,𝑤
𝜕ϕ
𝑓𝑙𝑢𝑥𝑛,𝑠 = (ρ𝑣𝐴ϕ − Γ𝐴 )𝑛,𝑠
𝜕𝑦
N

W P E −𝑎𝑆 ϕ𝑆 − 𝑎𝑊 ϕ𝑊 + 𝑎𝑃 ϕ𝑃 − 𝑎𝐸 ϕ𝐸 − 𝑎𝑁 ϕ𝑁 = 𝑏𝑃
Discretisation:

𝑎𝑃 ϕ𝑃 − ෍ 𝑎𝐹 ϕ𝐹 = 𝑏𝑃
S

Assembled matrix equation:

=b AΦ = b
General Discretisation Properties
Discretisation Properties

• Consistency

• Conservativeness

• Transportiveness

• Boundedness

• Stability

• Accuracy (“order”)
Consistency

Definition: an algebraic approximation is consistent if it tends to the


exact governing equation as the mesh size tends to zero

ϕ𝐸 − ϕ𝑃 dϕ
e.g. →
Δ𝑥 d𝑥
Conservativeness

Definition: flux out of one cell = flux into adjacent cell

flux

• Fluxes are worked out by face, not by cell

• Automatically built into the finite-volume method


Transportiveness

Definition: upstream-biased

P e
E
P E
e
Boundedness
Definition. For advection-diffusion without sources:

(1) ϕP must lie between minimum and maximum values at surrounding nodes

(2) ϕ = constant must be a possible solution (if the boundary conditions permit)

𝑎𝑃 ϕ𝑃 − ෍ 𝑎𝐹 ϕ𝐹 = 0 N

W P E
𝑎𝐹
If ϕ𝐹 is the only non-zero adjacent value, ϕ𝑃 = ϕ𝐹
𝑎𝑃
If ϕ is constant. (𝑎𝑃 − ෍ 𝑎𝐹 )ϕ = 0 S

Requirements for boundedness:

(1) Positive coefficients: 𝑎𝑃 , 𝑎𝐹 ≥ 0

(2) Sum of neighbouring coefficients: 𝑎𝑃 = ෍ 𝑎𝐹


Stability

Definition:

• Small errors do not grow in the course of the calculation

Requirement:

• Negative-slope linearisation of the source term (“negative feedback”)

𝑠𝑜𝑢𝑟𝑐𝑒 = 𝑏𝑃 + 𝑠𝑃 ϕ𝑃 , 𝑠𝑃 ≤ 0
Summary of Conditions on Matrix Coefficients
N
𝑠𝑜𝑢𝑟𝑐𝑒 = 𝑏𝑃 + 𝑠𝑃 ϕ𝑃
W P E

𝑎𝑃 ϕ𝑃 − ෍ 𝑎𝐹 ϕ𝐹 = 𝑏𝑃
S

Positive coefficients:
𝑎𝐹 ≥ 0 for all 𝐹

Negative-slope linearisation of the source term:


𝑠𝑃 ≤ 0

Sum of neighbouring coefficients:

𝑎𝑃 = ෍ 𝑎𝐹 − 𝑠𝑃
Accuracy (“Order”)

• General definition:
𝐨𝐫𝐝𝐞𝐫 𝒏 ⇔ 𝑒𝑟𝑟𝑜𝑟 ∝ Δ𝑥 𝑛 as Δ𝑥 → 0

• Determined by Taylor-series expansion (about a cell face)


x

P e E

• Common advection schemes:


‒ Upwind: 1st order
‒ Central: 2nd order
‒ LUD: 2nd order
‒ QUICK: 3rd order
x
Order of Accuracy P E
e

2 3 4
dϕ Δ𝑥 1 d2 ϕ Δ𝑥 1 d3 ϕ Δ𝑥 1 d4 ϕ Δ𝑥
ϕ𝐸 = ϕ𝑒 + + + + + ⋯
d𝑥 𝑒
2 2! d𝑥 2 𝑒
2 3! d𝑥 3 𝑒
2 4! d𝑥 4 𝑒
2
2 3 4
dϕ Δ𝑥 1 d2 ϕ Δ𝑥 1 d3 ϕ Δ𝑥 1 d4 ϕ Δ𝑥
ϕ𝑃 = ϕ𝑒 − + − + + ⋯
d𝑥 𝑒
2 2! d𝑥 2 𝑒
2 3! d𝑥 3 𝑒
2 4! d𝑥 4 𝑒
2

Subtract:
dϕ 2 d3 ϕ Δ𝑥 ϕ𝐸 − ϕ𝑃 dϕ
ϕ𝐸 − ϕ𝑃 = 0 + Δ𝑥 + 0 + ( )3 + ⋯ = + O(Δ𝑥 2 )
d𝑥 3! d𝑥 3 2 Δ𝑥 d𝑥 𝑒
𝑒 𝑒

2nd-order central differencing for diffusion


Add:
d2 ϕ Δ𝑥 1
ϕ𝑃 + ϕ𝐸 = 2ϕ𝑒 + 0 + ( )2 + ⋯
2(ϕ𝑃 + ϕ𝐸 ) = ϕ𝑒 + O(Δ𝑥 2 )
d𝑥 2 𝑒
2
2nd-order central differencing for advection
First term:
dϕ Δ𝑥
ϕ𝑃 = ϕ𝑒 − + ⋯ ϕ𝑃 = ϕ𝑒 + O(Δ𝑥)
d𝑥 𝑒
2
1st-order upwind differencing for advection
Example
W P e E EE

x
3 x

Consider the uniform, one-dimensional arrangement of nodes


shown. Face e lies half way between P and E nodes.

(a) Show that the central-differencing schemes


1 dϕ ϕ𝐸 − ϕ𝑃
ϕ𝑒 ≈ (ϕ𝑃 + ϕ𝐸 ) ቤ ≈
2 d𝑥 𝑒 Δ𝑥
are second-order approximations for ϕ𝑒 and dϕ/d𝑥 𝑒
respectively.

(b) Making use of the W and EE nodes also, find symmetric fourth-
order approximations for ϕ𝑒 and dϕ/d𝑥 𝑒 .
(b) Making use of the W and EE nodes also, find symmetric W P e E EE

fourth-order approximations for ϕ𝑒 and dϕ/d𝑥 𝑒 .


x
3 x
dϕ Δ𝑥 1 d2 ϕ Δ𝑥 2 1 d3 ϕ Δ𝑥 3 1 d4 ϕ Δ𝑥 4
ϕ𝐸 = ϕ𝑒 + + ( ) + ( ) + ( ) + ⋯
d𝑥 𝑒
2 2! d𝑥 2 𝑒
2 3! d𝑥 3 𝑒
2 4! d𝑥 4 𝑒
2
dϕ Δ𝑥 1 d2 ϕ Δ𝑥 2 1 d3 ϕ Δ𝑥 3 1 d4 ϕ Δ𝑥
ϕ𝑃 = ϕ𝑒 − + ( ) − ( ) + ( )4 + ⋯
d𝑥 𝑒
2 2! d𝑥 2 𝑒
2 3! d𝑥 3 𝑒
2 4! d𝑥 4 𝑒
2

Add:
2 d2 ϕ Δ𝑥 2 d4 ϕ Δ𝑥 4
ϕ𝑃 + ϕ𝐸 = 2ϕ𝑒 + 0 + ( ) +0 + ( ) +⋯
2! d𝑥 2 𝑒
2 d𝑥 4 𝑒
2

ϕ𝑃 + ϕ𝐸 1 d2 ϕ Δ𝑥 2
= ϕ𝑒 + ( ) + O(Δ𝑥)4
2 2! d𝑥 2 𝑒
2

ϕ𝑊 + ϕ𝐸𝐸 1 d2 ϕ 3Δ𝑥 2
= ϕ𝑒 + ( ) + O(Δ𝑥)4
2 2! d𝑥 2 𝑒
2

ϕ𝑃 + ϕ𝐸 ϕ𝑊 + ϕ𝐸𝐸 1 d2 ϕ Δ𝑥
α +β = (α + β)ϕ𝑒 + (α + 9β) ( )2 + O(Δ𝑥)4
2 2 2 d𝑥 2 𝑒
2

Require α + β = 1 8β = −1 9 ϕ𝑃 + ϕ𝐸 1 ϕ𝑊 + ϕ𝐸𝐸
1 9 − = ϕ𝑒 + O(Δ𝑥)4
α + 9β = 0 8 2 8 2
β=− α=
8 8
(b) Making use of the W and EE nodes also, find symmetric W P e E EE

fourth-order approximations for ϕ𝑒 and dϕ/d𝑥 𝑒 .


x
3 x
dϕ Δ𝑥 1 d2 ϕ Δ𝑥 2 1 d3 ϕ Δ𝑥 3 1 d4 ϕ Δ𝑥 4
ϕ𝐸 = ϕ𝑒 + + ( ) + ( ) + ( ) + ⋯
d𝑥 𝑒
2 2! d𝑥 2 𝑒
2 3! d𝑥 3 𝑒
2 4! d𝑥 4 𝑒
2
dϕ Δ𝑥 1 d2 ϕ Δ𝑥 2 1 d3 ϕ Δ𝑥 3 1 d4 ϕ Δ𝑥
ϕ𝑃 = ϕ𝑒 − + ( ) − ( ) + ( )4 + ⋯
d𝑥 𝑒
2 2! d𝑥 2 𝑒
2 3! d𝑥 3 𝑒
2 4! d𝑥 4 𝑒
2

Subtract:
dϕ 2 d3 ϕ Δ𝑥 3 2 d5 ϕ Δ𝑥
ϕ𝐸 − ϕ𝑃 = 0 + Δ𝑥 + 0 + ( ) +0+ ( )5 + ⋯
d𝑥 𝑒
3! d𝑥 3 𝑒
2 5! d𝑥 5 𝑒
2

ϕ𝐸 − ϕ𝑃 dϕ 1 d3 ϕ Δ𝑥 2
= + ( ) + O(Δ𝑥)4
Δ𝑥 d𝑥 𝑒
3! d𝑥 3 𝑒
2

ϕ𝐸𝐸 − ϕ𝑊 dϕ 1 d3 ϕ 3Δ𝑥 2
= + ( ) + O(Δ𝑥)4
3Δ𝑥 d𝑥 𝑒
3! d𝑥 3 𝑒
2

ϕ𝐸 − ϕ𝑃 ϕ𝐸𝐸 − ϕ𝑊 dϕ 1 d3 ϕ Δ𝑥
α +β = (α + β) + (α + 9β) 3
( )2 + O(Δ𝑥)4
Δ𝑥 3Δ𝑥 d𝑥 𝑒
3! d𝑥 𝑒
2

Require α + β = 1 8β = −1 9 ϕ𝐸 − ϕ𝑃 1 ϕ𝐸𝐸 − ϕ𝑊 dϕ
− = + O(Δ𝑥)4
1 9 8 Δ𝑥 8 3Δ𝑥 d𝑥
α + 9β = 0 β=− α= 𝑒
8 8
Discretising Advection (Part 2)
Exponential Scheme
Exact solution of the 1-d advection-diffusion equation

(with constant coefficients and without sources)

dϕ P E
𝑓𝑙𝑢𝑥 = 𝐶ϕ − Γ𝐴 = 𝑐𝑜𝑛𝑠𝑡𝑎𝑛𝑡 e
d𝑥

ePe ϕ𝑃 − ϕ𝐸 Γ𝐴 𝐶
𝑓𝑙𝑢𝑥𝑒 = 𝐶 𝐶 = ρ𝑢𝐴, 𝐷= , Pe =
ePe − 1 Δ𝑥 𝐷

𝐶ePe 𝐶
𝑎𝑊 = , 𝑎𝐸 =
ePe − 1 ePe − 1
𝑓𝑙𝑢𝑥𝑒 − 𝑓𝑙𝑢𝑥𝑤 = 𝑎𝑃 ϕ𝑃 − ෍ 𝑎𝐹 ϕ𝐹
𝑎𝑃 = 𝑎𝐸 + 𝑎𝑊
LUD (Linear Upwind Differencing)

• Extrapolates from the two upwind nodes e E


P
UU U D
W
face
W P E
1
ϕ𝑓𝑎𝑐𝑒 = ϕ𝑈 + (ϕ𝑈 − ϕ𝑈𝑈 ) e
2
u>0
3 1
ϕ𝑓𝑎𝑐𝑒 = ϕ𝑈 − ϕ𝑈𝑈
2 2
E EE
e
• 2nd-order accurate P

• Transportive, but not bounded P E EE


e
• Generalises to unstructured meshes:
u<0
ϕ𝑓𝑎𝑐𝑒 = ϕ𝑈 + (x𝑓𝑎𝑐𝑒 − x𝑈 ) • (∇ϕ)𝑈
QUICK

P e E

• 3-point, upwind-biased scheme W


UU U D W P E

face e
u>0
• Fits a quadratic through 3 nodes
ϕ𝑓𝑎𝑐𝑒 = −18ϕ𝑈𝑈 + 34ϕ𝑈 + 38ϕ𝐷 E EE
e
P
• 3rd-order accurate
P E EE
e
• Transportive, but not bounded u<0
Flux-Limited Schemes

● 3-point, upwind-biased schemes; solution-dependent limiters


UU U D
ϕ𝑓𝑎𝑐𝑒 = 𝑓𝑢𝑛𝑐𝑡𝑖𝑜𝑛(ϕ𝑈𝑈 , ϕ𝑈 , ϕ𝐷 )
face
● General form:

1 
ϕ𝑈 + 𝜓(𝑟)(ϕ𝐷 − ϕ𝑈 ) if monotonic
ϕ𝑓𝑎𝑐𝑒 =ቐ 2
ϕ𝑈 otherwise UU U D UU U D

ϕ𝑈 − ϕ𝑈𝑈
𝑟= monotonic non-monotonic
ϕ𝐷 − ϕ𝑈
● Non-linear ( iteration necessary)

● Total-Variation-Diminishing
Scheme 𝛙(𝒓) (for 𝒓 > 𝟎)

1 Upstream Monotonic Interpolation


UMIST min{ 2, 2𝑟, 14 1 + 3𝑟 , (3 + 𝑟)} for Scalar Transport (Lien and
4
Leschziner, 1993)

2𝑟
Harmonic Van Leer (1974)
1+𝑟

Min-mod min{ 𝑟, 1} Roe (1985)

𝑟 + 𝑟2
Van Albada et al. Van Albada et al., (1982)
1 + 𝑟2

In all cases ψ 𝑟 is taken as 0 if non-monotonic (𝑟 < 0)


Example
The figure shows a single line of cells in a structured mesh. The values of a transported
scalar ϕ at cell-centre nodes are given below the figure.
w e
WW W P E EE

x
ϕ𝑊𝑊 = 1, ϕ𝑊 = 4, ϕ𝑃 = 5, ϕ𝐸 = 7, ϕ𝐸𝐸 = 3

The Van Leer harmonic advection scheme is defined (for the immediate upstream and
downstream nodes, U and D respectively) by:
1
ϕ𝑓𝑎𝑐𝑒 = ϕ𝑈 + ψ(𝑟)(ϕ𝐷 − ϕ𝑈 )
2
2𝑟
if 𝑟 > 0 ϕ𝑈 − ϕ𝑈𝑈
ψ(𝑟) = ቐ 1 + 𝑟 𝑟=
0 otherwise ϕ𝐷 − ϕ𝑈

Calculate the values of ϕ on the cell faces marked e and w in the figure using the Van Leer
advection scheme if the velocity component 𝑢 is:
(i) positive;
(ii) negative.
w e 1
WW W P E EE ϕ𝑓𝑎𝑐𝑒 = ϕ𝑈 + ψ(𝑟)(ϕ𝐷 − ϕ𝑈 )
2
x 2𝑟
if 𝑟 > 0 ϕ𝑈 − ϕ𝑈𝑈
ϕ𝑊𝑊 = 1, ϕ𝑊 = 4, ϕ𝑃 = 5, ϕ𝐸 = 7, ϕ𝐸𝐸 = 3 ψ(𝑟) = ቐ 1 + 𝑟 𝑟=
ϕ𝐷 − ϕ𝑈
0 otherwise
Calculate the values of ϕ on the cell faces marked e and w in the figure using the Van Leer advection
scheme if the velocity component 𝑢 is (i) positive; (ii) negative.
𝑢 positive 𝑢 negative
w: ϕ𝑈𝑈 = 1, ϕ𝑈 = 4, ϕ𝐷 = 5 w: ϕ𝑈𝑈 = 7, ϕ𝑈 = 5, ϕ𝐷 = 4
4−1 5−7
𝑟= =3 𝑟= =2
5−4 4−5
2×3 3 2×2 4
ψ= = ψ= =
1+3 2 1+2 3
1 3 1 4
ϕ𝑓 = 4 + × (5 − 4) = 4.75 ϕ𝑓 = 5 + × (4 − 5) = 4.333
2 2 2 3

e: ϕ𝑈𝑈 = 4, ϕ𝑈 = 5, ϕ𝐷 = 7 e: ϕ𝑈𝑈 = 3, ϕ𝑈 = 7, ϕ𝐷 = 5
5−4 1
𝑟= =
7−5 2
Non-monotonic
2 × (1/2) 2
ψ= =
1 + (1/2) 3
1 2 ϕ𝑓 = ϕ𝑈 =7
ϕ𝑓 = 5 + × (7 − 5) = 5.667
2 3
Implementation of Higher-Order Schemes
𝜕ϕ
෍( 𝑚𝑎𝑠𝑠 𝑓𝑙𝑢𝑥 × ϕ −Γ 𝐴 )= 𝑆
𝜕𝑛
𝑓𝑎𝑐𝑒𝑠
𝑎𝑑𝑣𝑒𝑐𝑡𝑖𝑜𝑛 𝑑𝑖𝑓𝑓𝑢𝑠𝑖𝑜𝑛 𝑠𝑜𝑢𝑟𝑐𝑒
P f F
෍ [𝐶𝑓 ϕ𝑓 + 𝐷𝑓 (ϕ𝑃 − ϕ𝐹 )] = 𝑏𝑃 + 𝑠𝑃 ϕ𝑃
𝑓𝑎𝑐𝑒𝑠

෍ 𝐶𝑓 = 0 ෍ [𝐶𝑓 (ϕ𝑓 − ϕ𝑃 ) + 𝐷𝑓 (ϕ𝑃 − ϕ𝐹 )] = 𝑏𝑃 + 𝑠𝑃 ϕ𝑃


𝑓𝑎𝑐𝑒𝑠 𝑓𝑎𝑐𝑒𝑠

Write the cell-face value as upwind + correction: ϕ𝑓 = ถ


ϕ𝑈 + (ϕ𝑓 − ϕ𝑈 )
𝑢𝑝𝑤𝑖𝑛𝑑 𝑑𝑒𝑓𝑒𝑟𝑟𝑒𝑑 𝑐𝑜𝑟𝑟𝑒𝑐𝑡𝑖𝑜𝑛

The upwind part always gives positive coefficients and diagonal dominance
𝐶𝑓 (ϕ𝑓 − ϕ𝑃 ) = 𝐶𝑓 (ϕ𝑈 − ϕ𝑃 ) + 𝐶𝑓 (ϕ𝑓 − ϕ𝑈 )
𝑢𝑝𝑤𝑖𝑛𝑑 𝑐𝑜𝑟𝑟𝑒𝑐𝑡𝑖𝑜𝑛
= max( − 𝐶𝑓 , 0)(ϕ𝑃 − ϕ𝐹 ) +𝐶𝑓 (ϕ𝑓 − ϕ𝑈 )

The deferred correction is transferred to the source term and treated explicitly
(i.e. not updated until the next iteration):
෍ 𝑎𝐹 (ϕ𝑃 − ϕ𝐹 ) = 𝑏𝑃 + 𝑠𝑃 ϕ𝑃 − ෍ 𝐶𝑓 (ϕ𝑓 − ϕ𝑈 ) 𝑎𝐹 = max( − 𝐶𝑓 , 0) + 𝐷𝑓
𝐹 𝑓𝑎𝑐𝑒𝑠
𝑑𝑒𝑓𝑒𝑟𝑟𝑒𝑑 𝑐𝑜𝑟𝑟𝑒𝑐𝑡𝑖𝑜𝑛
Implementation of Boundary Conditions

boundary
boundary

2 3 4 NI-3 NI-2 NI-1

Boundary fluxes are transferred to the source term:


P B
෍ 𝑓𝑙𝑢𝑥 + 𝑓𝑙𝑢𝑥𝑏𝑜𝑢𝑛𝑑𝑎𝑟𝑦 = 𝑠𝑜𝑢𝑟𝑐𝑒
𝑛𝑜𝑡
𝑏𝑜𝑢𝑛𝑑𝑎𝑟𝑦
boundary

𝑎𝑃 ϕ𝑃 − ෍ 𝑎𝐹 ϕ𝐹 = 𝑏𝑃 − 𝑓𝑙𝑢𝑥𝑏𝑜𝑢𝑛𝑑𝑎𝑟𝑦
𝑛𝑜𝑡
𝑏𝑜𝑢𝑛𝑑𝑎𝑟𝑦
Matrix Solution Algorithms
Form of the Matrix Equations
𝑎𝑃 ϕ𝑃 − ෍ 𝑎𝐹 ϕ𝐹 = 𝑏𝑃
𝐹

1-d 2-d

W P E W P E

−𝑎𝑊 ϕ𝑊 + 𝑎𝑃 ϕ𝑃 − 𝑎𝐸 ϕ𝐸 = 𝑏𝑃 −𝑎𝑆 ϕ𝑆 − 𝑎𝑊 ϕ𝑊 + 𝑎𝑃 ϕ𝑃 − 𝑎𝐸 ϕ𝐸 − 𝑎𝑁 ϕ𝑁 = 𝑏𝑃

=b =b
Characteristics of the Equations

• Fluid-flow equations:
‒ non-linear
‒ coupled

• Matrix equations:
‒ sparse
‒ banded (for structured meshes)

• Solution methods:
‒ iterative
Common Solution Methods

• Gaussian elimination

• Gauss-Seidel

• Line Gauss-Seidel
Gaussian Elimination

• Direct, not iterative

• Sequence of row operations aiming to produce an upper-


triangular matrix

• Tends to “fill in” sparse matrices


=b
Important exception: tri-diagonal systems
(basis of the tri-diagonal matrix algorithm)
Gauss-Seidel

−𝑎𝑆 ϕ𝑆 − 𝑎𝑊 ϕ𝑊 + 𝒂𝑷 𝛟𝑷 − 𝑎𝐸 ϕ𝐸 − 𝑎𝑁 ϕ𝑁 = 𝑏𝑃

1
𝛟𝑷 = (𝑏𝑃 + 𝑎𝑆 ϕ∗𝑆 + 𝑎𝑊 ϕ∗𝑊 + 𝑎𝐸 ϕ∗𝐸 + 𝑎𝑁 ϕ∗𝑁 )
𝑎𝑃

W P E

S
direction of sweep

being updated
already updated
not yet updated
Gauss-Seidel Example (i)

4 −1 0 0 𝐴 2
−1 4 −1 0 𝐵 4
=
0 −1 4 −1 𝐶 6
0 0 −1 4 𝐷 13
4 −1 0 0 𝐴 2
−1 4 −1 0 𝐵 4
=
0 −1 4 −1 𝐶 6
0 0 −1 4 𝐷 13

A B C D
2+𝐵
4𝐴 − 𝐵 = 2 𝐴= 0 0 0 0
4
4+𝐴+𝐶 0.500 1.125 1.781 3.695
−𝐴 + 4𝐵 − 𝐶 = 4 𝐵=
4
6+𝐵+𝐷 0.781 1.641 2.834 3.959
−𝐵 + 4𝐶 − 𝐷 = 6 𝐶=
4 0.910 1.936 2.974 3.994
13 + 𝐶
−𝐶 + 4𝐷 = 13 𝐷=
4 --- --- --- ---

1.000 2.000 3.000 4.000


Gauss-Seidel Example (ii)
1 −4 0 0 𝐴 −7
−4 1 −4 0 𝐵 −14
=
0 −4 1 −4 𝐶 −21
0 0 −4 1 𝐷 −8

DIVERGES!
Gauss-Seidel Overview
• Iterative

• Simple to code

• Minimal storage requirements

• Can use for unstructured meshes

• Convergence slow for large matrices

• Constraints on matrix elements (e.g. diagonal dominance)


𝑎𝑖𝑖 ≥ ෍ 𝑎𝑖𝑗
𝑗≠𝑖
Line Gauss-Seidel
(Line-Iterative Procedures, LIP)

−𝑎𝑆 ϕ𝑆 − 𝒂𝑾 𝛟𝑾 + 𝒂𝑷 𝛟𝑷 − 𝒂𝑬 𝛟𝑬 − 𝑎𝑁 ϕ𝑁 = 𝑏𝑃

−𝒂𝑾 𝛟𝑾 + 𝒂𝑷 𝛟𝑷 − 𝒂𝑬 𝛟𝑬 = 𝑏𝑃 + 𝑎𝑆 ϕ∗𝑆 + 𝑎𝑁 ϕ∗𝑁

=b - 
*

of sweep
direction
W P E

S
Line Gauss-Seidel - Overview

• Iterative

• Repeated use of tri-diagonal solver:


‒ whole line updated in one go
‒ rapid propagation across domain

• Applicable to structured meshes only

• Basis of many research codes


Convergence Criteria
𝑎𝑃 ϕ𝑃 − ෍ 𝑎𝐹 ϕ𝐹 = 𝑏𝑃
𝐹

Single-cell error:
residual: 𝑟𝑒𝑠 = 𝑎𝑃 ϕ𝑃 − ෍ 𝑎𝐹 ϕ𝐹 − 𝑏𝑃
𝐹

Global error:
sum of absolute residuals: ෍ 𝑟𝑒𝑠
𝑐𝑒𝑙𝑙𝑠

1
root-mean-square error: ෍ (𝑟𝑒𝑠)2
𝑁
𝑐𝑒𝑙𝑙𝑠

Convergence criteria:
error < tolerance
or
error < fraction of initial error
Under-Relaxation

• The governing equations are coupled and non-linear

• The iterative solution method may be numerically


unstable

• Under-relaxation tries to stabilise an iterative


procedure by reducing the change in variables at each
iteration
Under-Relaxation in CFD
Standard linearised equation: 𝑎𝑃 ϕ𝑃 − ෍ 𝑎𝐹 ϕ𝐹 = 𝑏𝑃

σ 𝑎𝐹 ϕ𝐹 + 𝑏𝑃
Rearrange as the change in ϕ: ϕ𝑃 =
𝑎𝑃

𝑝𝑟𝑒𝑣 σ 𝑎𝐹 ϕ𝐹 + 𝑏𝑃 𝑝𝑟𝑒𝑣
ϕ𝑃 = ϕ𝑃 + − ϕ𝑃
𝑎𝑃

𝑝𝑟𝑒𝑣 σ 𝑎𝐹 ϕ𝐹 + 𝑏𝑃 𝑝𝑟𝑒𝑣
Under-relax the change: ϕ𝑃 = ϕ𝑃 +α − ϕ𝑃
𝑎𝑃

𝑝𝑟𝑒𝑣
Rearrange back: 𝑎𝑃 ϕ𝑃 − ෍ α𝑎𝐹 ϕ𝐹 = α𝑏𝑃 + (1 − α)𝑎𝑃 ϕ𝑃

𝑎𝑃 𝑎𝑃 𝑝𝑟𝑒𝑣
ϕ𝑃 − ෍ 𝑎𝐹 ϕ𝐹 = 𝑏𝑃 + (1 − α) ϕ𝑃
𝛼 𝛼

𝑎𝑃
Incorporate by modifying coefficients: 𝑎𝑃 → 𝑎𝑃′ =
α
𝑝𝑟𝑒𝑣
𝑏𝑃 → 𝑏𝑃′ = 𝑏𝑃 + (1 − α)𝑎𝑃′ ϕ𝑃
Summary (1)
• The generic scalar-transport equation for a control volume has the form
rate of change + net outward flux = source

• Flux ≡ rate of transport through a surface and consists of:


‒ advection: transport with the flow (other authors prefer convection)
‒ diffusion: net transport by random molecular or turbulent fluctuations

• Discretisation of the (steady) scalar-transport equation yields a linear equation


𝑎𝑃 ϕ𝑃 − ෍ 𝑎𝐹 ϕ𝐹 = 𝑏𝑃
𝐹
for each control volume.

• The collection of these simultaneous equations on a structured mesh yields a matrix


equation with limited bandwidth (i.e. few non-zero diagonals), typically solved by
iterative methods such as Gauss-Seidel or line-Gauss-Seidel
Summary (2)
• Source terms are linearised as
𝑏𝑃 + 𝑠𝑃 ϕ𝑃 , 𝑠𝑃 ≤ 0

• Diffusive fluxes are usually discretised by central differencing; e.g.


𝜕ϕ Γ𝐴
−Γ ቤ 𝐴 → − (ϕ − ϕ𝑃 )
𝜕𝑥 𝑒 Δ𝑥 𝐸

• Advection schemes are means of approximating ϕ on cell faces in order to compute


advective fluxes. They include Upwind, Central, Exponential, LUD, QUICK, and
various flux-limited schemes

• General desirable properties for a numerical scheme in CFD:


‒ consistency
‒ conservativeness
‒ transportiveness
‒ boundedness
‒ stability
‒ accuracy / order
Summary (3)

● Boundedness and stability impose certain constraints:


𝑎𝐹 ≥ 0 (“positive coefficients”)
𝑠𝑃 ≤ 0 (“negative feedback in the source term”)
𝑎𝑃 = σ 𝑎𝐹 − 𝑠𝑃 (“sum of the neighbouring coefficients”)

● To ensure positive coefficients (and implement non-linear schemes), advective


fluxes are often decomposed into
upwind + deferred correction
The latter is transferred to the source and treated explicitly

● Boundary conditions can be implemented by transferring boundary fluxes to the


source term

● Under-relaxation is usually required to solve coupled and/or non-linear equations

You might also like