Computational Fluid Dynamics
CFD
Finite differences
H.O.T.
!
3
!
2
3 3 2 2 2 1−
∂
∂
∆
−
∂
∂
∆
−
∆
−
=
∂
∂
+ n j n j n j n j n jt
t
t
t
t
t
φ
φ
φ
φ
φ
( )
t
O
t
t
n j n j n j∆
+
∆
−
=
∂
∂
φ
φ
+1φ
Truncation errorFirst order forward difference, the truncation error is directly proportional to the time step.
Note that we can not from this say anything about the exact size of
Finite differences
H.O.T.
3
2
3 3 2 1 1+
∂
∂
∆
−
∆
−
=
∂
∂
+ − n j n j n j n jt
t
t
t
φ
φ
φ
φ
Second order central difference, the truncation error is proportional to the time step squared.
Finite differences
Dissipation error0
2 2=
∂
∂
−
∂
∂
x
x
c
φ
α
φ
Convection-diffusion equation1st order FD appoximation of the first derivative and 2nd order for the second derivative:
Finite differences
Dispersion error0
2 2=
∂
∂
−
∂
∂
x
x
c
φ
α
φ
Convection-diffusion equation2nd order FD appoximation of the first derivative and 2nd order for the second derivative:
( )
0
2
2
4 3 3 2 1 1+
∆
=
∂
∂
∆
+
∆
−
=
∂
∂
+ −x
O
x
x
x
x
j jφ
φ
φ
φ
( )
4 4 4 2 2 1 1 2 2O
4
2
x
x
x
x
x
j j j j+
∆
∂
∂
∆
−
∆
+
−
=
∂
∂
φ
φ
+φ
φ
−φ
Even derivatives are dissipative Odd derivatives are dispersive
Cell Reynolds number:
α
x
c
c∆
=
Re
Dispersive schemes are unstable if
2
Solution error: The difference between the exact solution of the governing PDEs and the exact solution to the system of
algebraic equations
(
)
n j n j n jφ
x
t
φ
ε
=
,
−
Convergence: The exact solution to the system of algebraic
equations will approach the exact solution of the governing PDEs when grid spacing and time step go to zero
Consistency: The system of algebraic equations will be equivalent to the
governing PDEs at each grid point when grid spacing and time step go to zero
Stability: If spontaneous perturbations in the solution to the system of
algebraic equations decay, we have stability
Convergence: The exact solution to the system of algebraic
Solving system of equations
P Domain of
dependence Region of influence Region of influence Domain of
dependence P
P
Every point influences all other points
Parabolic
Hyperbolic
Elliptic The flow situation the equations desides the character of the governing equations.
Solving system of equations
Parabolic Hyperbolic Elliptic
Different solution strategies can therefore be employed depending on the character.
Marching methods may be used since the solution only depends on previous data.
Has to be solved for the
whole domain simultaneously, since all points depend on each other. Relaxation techniques.
Examples:
•Inviscid supersonic flow
Examples:
•Steady incompressible flow
Marching methods
Lax-Wendroff scheme
Consider the inviscid Burger equation
=
0
∂
∂
+
∂
∂
x
u
u
t
u
Conserved form0
F
F
(
u
)
x
F
t
u
=
=
∂
∂
+
∂
∂
Start with a Taylor expansion around (x,t+∆t)
Marching methods
Lax-Wendroff scheme
The idea is to replace the time derivatives in the expansion by spacial ones, which gives a scheme that is 2nd order accurate in space and time.
First derivative:
x
F
t
u
∂
∂
−
=
∂
∂
∂
∂
∂
∂
−
=
∂
∂
∂
−
=
∂
∂
t
F
x
x
t
F
t
u
2 2 2 Second derivative:Since F is a function of u we can write
Marching methods
Lax-Wendroff scheme Hence,
∂
∂
∂
∂
=
∂
∂
x
F
A
x
t
u
2 2The Taylor expansion can now be written as:
Marching methods
Lax-Wendroff scheme
Apply 2nd order central differencing:
(
)
(
)
[
n]
j n j n j n j n j n j n j n j n j n jA
F
F
A
F
F
x
t
F
F
x
t
u
u
1/2 1 1/2 1 2 1 1 12
1
2
+ + − − − + +−
+
−
∆
∆
+
−
∆
∆
−
=
Sinceu
u
F
A
u
F
=
∂
∂
=
⇒
=
2
2the Jacobian is calculated as
2
1 2 / 1 j j ju
u
A
+=
++
A stability analysis gives
1
2
(
1
cos
θ
)
2
sin
θ
Marching methods
MacCormack scheme
Relaxation techniques
Basic techniques for solving a system of equations
Relaxation techniques
Basic techniques for solving a system of equations
Jacobi, easy but slow
Ax
=
b
∑
Relaxation techniques
Basic techniques for solving a system of equations
Gauss-Seidel
Ax
=
b
∑
==
N j i j ijx
b
a
1 ii i j k j ij i j k j ij i k ia
x
a
x
a
b
x
∑
∑
> − <−
−
=
1 In interation step k:Relaxation techniques
Basic techniques for solving a system of equations
Successive over-relaxation (SOR)
In interation step k:
Applying extrapolation to the Gauss-Seidel method
(
)
11
−
−+
=
k i k i k ix
x
x
ω
ω
Relaxation techniques
Point relaxation y x i i+1 i-1 j j+1 j-10
2 2 2 2=
∂
∂
+
∂
∂
y
x
φ
φ
0
2
2
2 1 , 1 , 2 , 1 , 1=
∆
+
−
+
∆
+
−
− + − +y
x
j i ij j i j i ij j iφ
φ
φ
φ
φ
φ
(
)
(
2)
1 1 , 1 , 2 1 , 1 , 1 11
2
β
φ
φ
β
φ
φ
φ
−
+
+
+
=
+ − + + − + + ikj k j i k j i k j i k ijExample: Potential flow
Gauss-Seidel, point relaxation:
Relaxation techniques
Line relaxation y x i i+1 i-1 j j+1 j-1(
)
(
2)
1 1 , 1 , 2 1 , 1 1 , 1 11
2
β
φ
φ
β
φ
φ
φ
−
+
+
+
=
+ − + + − + + + ikj k j i k j i k j i k ijGauss-Seidel, line relaxation in x:
Relaxation techniques
ADI, alternating direction implicit
y x i i+1 i-1 j j+1 j-1
(
)
(
2)
2 / 1 1 , 1 , 2 2 / 1 , 1 2 / 1 , 1 2 / 11
2
β
φ
φ
β
φ
φ
φ
−
+
+
+
=
+ − + + − + + + ikj k j i k j i k j i k ij Gauss-Seidel, ADIFurther improvement of numerical convergence speed. Computational time can be reduced with up to 20-40 % as compared to Gauss-Seidel with SOR
(
)
(
2)
1 1 , 1 1 , 2 1 , 1 2 / 1 , 1 11
2
β
φ
φ
β
φ
φ
φ
−
+
+
+
=
+ − + + + − + + + ikj k j i k j i k j i k ijFirst along x-direction
Relaxation techniques
Thomas algorithm Gauss elimination on a tridiagonal system
=
N N N N Nc
c
c
x
x
x
d
b
a
b
a
d
b
a
d
2 1 2 1 2 2 2 1 1 10
0
0
0
1 1 1 1 − − − −−
=
−
=
j j j j j j j j j jc
d
b
c
c
a
d
b
d
d
Put on upper triangular form:
Governing equations
Incompressible flow j j i j i j i j ix
x
u
x
p
f
x
u
u
t
u
∂
∂
∂
+
∂
∂
−
=
∂
∂
+
∂
∂
21
ν
ρ
0
=
∂
∂
i ix
u
Mass MomentumQuestions:
•Is there a difference between compressible and
incompressible flow that can cause problems? If so, which?
•Can we use our compressible code to solve incompressible
Pressure correction
Let’s use the MacCormack scheme, for example
Stable if 2 2
1
1
1
y
x
a
y
v
x
u
t
∆
+
∆
+
∆
+
∆
≤
∆
Pressure correction
pressure-velocity decoupling checker board errors
Multigrid methods
Multigrid methods are used to increase the computational efficiency of an implicit method
Consider the equation:
f
( )
x
dx
u
d
=
−
220
≤ x
≤
1
Periodic boundary conditionsMultigrid methods
von Neumann stability analysis
Use the numerical error
ξ
jm=
u
mj−
u
mj *1 1 1
2
− + −+
=
−
m j m j m jξ
ξ
ξ
to rewrite the equation
α θ α α
ξ
m n m ij j∑
c
e
− ==
2 1 0 Fourier modes of the error:n
πα
h
πα
θ
α=
=
2
Multigrid methods
von Neumann stability analysis
Multigrid methods
von Neumann stability analysis
( )
( )
4 1 2 1 12
1
1
θ
θ
θ
O
G
+
+
=
Useθ
1=
2
π
h
( )
1 2 2( )
44
1
1
h
O
h
G
+
+
=
π
θ
( )
1
lim
1 0=
→G
θ
hNote: What does this tell us?
( )
2 2( )
41
1
4
h
O
h
G
θ
=
−
π
+
Multigrid methods
( )
1
lim
1 0=
→G
θ
hThe longer the wave length of the error mode, the more effort one has to put in to converge the solution since the amplification factor will be closer to unity.
The basic idea of multigrid is to create a
Multigrid methods
Example of a linear problem, the Laplace equation
0
2 2 2 2=
∂
∂
+
∂
∂
y
u
x
u
2 1 , , 1 , 2 , 1 , , 1 ,2
2
y
u
u
u
x
u
u
u
Lu
i j i j i j i j i j i j i j∆
+
−
+
∆
+
−
=
− + − +On each grid, m, we solve:
Lu
im,j=
R
im,jProcedure for the Correction Storage (CS) scheme:
1. On the finest grid, M, do a few relaxations (iterations) of to reduce the short wave length error modes.
0
,=
M j iLu
2. Calculate the residual and transfer it to the next coarser grid, restriction: M
Multigrid methods
Example of a linear problem, the Laplace equation
3. On the coarser grid solve
6. Transfer the correction back to finer grid, prolongation,
and do a few relaxations on each grid until the finest grid is reached
0
, ,+
=
∆
m j i m j iR
u
L
m j i m j i m j iu
u
u
,=
ˆ −
, ,∆
4. Repeat steps 2 and 3 until the coarsest grid is reached
5. On the coarsest grid, solve the problem exactly.
Multigrid methods
Example of a non-linear problem
Multigrid methods
Example of a non-linear problem On each grid, m, we solve:
(
m)
i m m m i m i m m m i m iR
I
R
R
I
u
u
L
∆
−1=
−
−1−
−1+
−1 −1Similar procedure as for linear problems.
Differences:
1. Fine grid solution also restricted, i.e. and more complex residual term
m i m m m i
I
u
u
−1=
−1 Coarse grid residual Restricted fine grid residualCoarse grid residual
Discretisation and grid
Questions:
•How complex is the geometry?
•What accuracy is required? Grid quality? •What about stability?
Grid types
Unstructured grid
Grid types
Grid types
Grid types
Grid quality
Equilateral volume skew: