1. Dr Patrick Geoghegan
Book: H. Versteeg and W. Malalasekera An Introduction to
Computational Fluid Dynamics: The Finite Volume Method
FEA/CFD for
Biomedical
Engineering
Week 10: CFD
3. Lets demonstrate this through an example
We will solve this matrix equation using the iterative Jacobi Method
Residuals
4 2 0
1 2 1
1 1 2
𝑢𝑢1
𝑢𝑢2
𝑢𝑢3
=
10
5
4
}
{
}
]{
[ F
u
K =
}
{
]
[
}
{ 1
F
K
u −
=
Using the Excel Function
=MMULT(MINVERSE(B2:D4),(F2:F4))
𝑢𝑢1
𝑢𝑢2
𝑢𝑢3
=
1.8
1.4
0.4
5. • Residuals tell us whether or not the values u1, u2 and u3 satisfy the
matrix equation
Residuals
4𝑢𝑢1 + 2𝑢𝑢2 + 0𝑢𝑢3 = 10
1𝑢𝑢1 + 2𝑢𝑢2 + 1𝑢𝑢3 = 5
1𝑢𝑢1 + 1𝑢𝑢2 + 2𝑢𝑢3 = 4
4 2 0
1 2 1
1 1 2
𝑢𝑢1
𝑢𝑢2
𝑢𝑢3
=
10
5
4
𝑅𝑅1 = 10 − 4𝑢𝑢1 − 2𝑢𝑢2
𝑅𝑅2 = 5 − 1𝑢𝑢1 − 2𝑢𝑢2 − 1𝑢𝑢3
𝑅𝑅3 = 4 − 1𝑢𝑢1 − 1𝑢𝑢2 − 2𝑢𝑢3
They are calculated as follows
The equations are satisfied
when these equal zero
6. Iterative Method
1.Guess u1, u2, u3
2.Calculate new values for u1, u2, u3 Based on these
equations using latest guess
3.Repeat 2. until u1, u2, u3 don't change between
iterations
Residuals
𝑢𝑢1 = ⁄
10 − 2𝑢𝑢2 4
𝑢𝑢2 = ⁄
5 − 1𝑢𝑢1 − 1𝑢𝑢3 2
𝑢𝑢3 = ⁄
4 − 1𝑢𝑢1 − 1𝑢𝑢2 2
𝑢𝑢1
𝑢𝑢2
𝑢𝑢3
=
0
0
0
Initial Guess: If you don’t know start
with Zero
The residual is a measure of this change
Simulations Speed can be increases if you can
predict an initial condition value closer to the
solution – This requires some knowledge of the
flow physics - You did this in the tutorial
8. -1
-0.5
0
0.5
1
1.5
2
2.5
3
0 5 10 15 20 25 30 35
Velocity
Iteration
U1
U2
U3
Residuals
The Jacobi Method gives a solution of
in 35 iterations
Excel gives a solution of [1.8,1.4,0.4]
𝑢𝑢1
𝑢𝑢2
𝑢𝑢3
=
1.801
1.401
0.4
9. -6
-4
-2
0
2
4
6
8
10
12
14
0 5 10 15 20 25 30 35
Residuals
Iteration
R1
R2
R3
Rt
Residuals
The total residual is decreasing towards a value of zero, showing convergence of
the solution
10. • Convergence refers to how close the numerical solution is to the
exact solution of the equations
• Residuals are a measure of convergence
– the closer to zero, the more converged the solution
Convergence and Residuals
12. • Imagine a geometry as shown below that is divided into discrete control
volumes with nodes at centre
Residuals
13. Φ=1 for conservation of mass
Φ =u for conservation of x-momentum
Φ =v for conservation of y-momentum
Φ =w for conservation of z-momentum
Φ =i for conservation of internal energy
• Any terms that are not in the common form have been hidden within the source
terms
• For example Γ diffusive term represents μ for the momentum equations
The General Transport Equation
𝜕𝜕 𝜌𝜌𝛷𝛷
𝜕𝜕𝜕𝜕
+ 𝑑𝑑𝑑𝑑𝑑𝑑 𝜌𝜌𝜌𝜌𝐮𝐮 = 𝑑𝑑𝑑𝑑𝑑𝑑 𝛤𝛤
𝛷𝛷𝜇𝜇𝑔𝑔𝑔𝑔𝑔𝑔𝑔𝑔Φ + 𝑆𝑆Φ
14. • In the “Solver” of many commercial CFD packages, a similar iterative
solution of matrix equations is carried out
– More complex though since A and B are usually functions of Φ
Residuals
1) Discretise each partial
differential equation at
each node
2) Form matrix equation
3) Solve matrix equation
𝜕𝜕 𝜌𝜌𝛷𝛷
𝜕𝜕𝜕𝜕
+ 𝑑𝑑𝑑𝑑𝑑𝑑 𝜌𝜌𝜌𝜌𝐮𝐮 = 𝑑𝑑𝑑𝑑𝑑𝑑 𝛤𝛤
𝛷𝛷𝜇𝜇𝑔𝑔𝑔𝑔𝑔𝑔𝑔𝑔Φ + 𝑆𝑆Φ
𝑎𝑎𝑃𝑃𝛷𝛷𝑃𝑃 = 𝑎𝑎𝑊𝑊𝛷𝛷𝑊𝑊 + 𝑎𝑎𝐸𝐸𝛷𝛷𝐸𝐸 + 𝑆𝑆𝑢𝑢
15. • One such matrix equation for each variable (u, v, w, p etc)
• A and B are usually functions of velocity, pressure, temperature etc
need iterative solution
(1)Use estimates of u, v, w, p, T to calculate A and B
(2)Solve matrix equations for new u, v, w, p, T
(3)Iterate until convergence is achieved
Residuals
17. • In CFD simulations (FLUENT) you select a maximum allowable
residual
• The smaller R, the more accurate the solution, but longer the run time
• Typically R ≈ 1x10-5 or 1x10-6
• Dependent upon the nature of the problem
• notice how iterative solutions ‘converge’ (on the correct answer) – don’t
stop it too soon
• some methods converge quickly
• initial condition (guess at values) affect the number of iterations needed
• notice the decimal places? Rounding errors are a real concern (double
precision is available)
Residuals
18. Residuals
• Ansys looks at global
residuals
• Residuals might flat
line or exhibit a
periodic pattern
• Periodic pattern is
evidence of a
transient phenomena
like vortex shedding
Global residuals