0% found this document useful (0 votes)
17 views51 pages

Solving System of Equations

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
17 views51 pages

Solving System of Equations

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 51

Computational Fluid Dynamics

CFD
Solving system of equations,
Grid generation
Basic steps of CFD
Problem •Discretization •Result

•Gov. Eq. •OK?


•BC •Solution
•Init. Cond.

? ui ,t + uij , j + ...

2
Solving system of equations
The type of equations decides solution strategy

Marching problems Equilibrium problems


Parabolic

P
Domain of
dependence Region of influence
Elliptic

Hyperbolic P

Every point influences all other points

Domain of P
dependence Region of influence
Solving system of equations

Parabolic Hyperbolic Elliptic

Marching methods may be Has to be solved for the


used since the solution only whole domain simultaneously,
depends on previous data. since all points depend on
each other. Relaxation
techniques.

Examples: Examples:
•Inviscid supersonic flow •Steady incompressible flow

Note! Time dependent incompressible flow


has a mixed character: elliptic in space and
parabolic in time.
Marching methods
1st order

∂u ∂u
Consider the inviscid Burger equation +u = 0
∂t ∂x
u1,n+1 ui-1,n+1ui,n+1 ui+1,n+1 uN,n+1 ∂u ∂F
∆t

Conserved form + =0 F = F (u )
∂t ∂x
u1,n ui-1,n ui,n ui+1,n uN,n
Start with a Taylor expansion around (x,t+∆t)
∆x
 ∂u 
u (x, t + ∆t ) = u ( x, t ) + ∆t   + HOT
u1,1 ui-1,1 ui,1 ui+1,1 uN,1  ∂t  x ,t
Marching methods
1st order

The idea is to replace the time derivatives in the expansion by spacial ones

∂u ∂F
First derivative: =− u1,n+1 ui-1,n+1ui,n+1 ui+1,n+1 uN,n+1
∂t ∂x

∆t
Apply 2nd order central differencing: u1,n ui-1,n ui,n ui+1,n uN,n

∆t F n
− F n
uin +1 = uin − i +1 i −1
∆x
∆x 2

u1,1 ui-1,1 ui,1 ui+1,1 uN,1


Marching methods
Lax-Wendroff scheme

∂u ∂u
Consider the inviscid Burger equation +u = 0
∂t ∂x
∂u ∂F
Conserved form + =0 F = F (u )
∂t ∂x

Start with a Taylor expansion around (x,t+∆t)

 ∂u  ∆t 2
 ∂ 2
u
u ( x, t + ∆t ) = u ( x, t ) + ∆t   +  2
+ HOT
 ∂t  x ,t 2  ∂t  x ,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.

∂u ∂F
First derivative: =−
∂t ∂x
∂ 2u ∂2F ∂  ∂F 
Second derivative: = − = −  
∂t 2
∂t∂x ∂x  ∂t 
Since F is a function of u we can write

∂u ∂F ∂F ∂u ∂u ∂F ∂F ∂u ∂u
=− =− = −A = =A
∂t ∂x ∂u ∂x ∂x ∂t ∂u ∂t ∂t
Jacobian
Marching methods
Lax-Wendroff scheme

∂ 2u ∂  ∂F 
Hence, = A 
∂t 2
∂x  ∂x 

The Taylor expansion can now be written as:

 ∂F  ∆t 2  ∂  ∂F 
u ( x, t + ∆t ) = u ( x, t ) − ∆t   +   A  + HOT
 ∂x  x ,t 2  ∂x  ∂x  x ,t
Marching methods
Lax-Wendroff scheme

Apply 2nd order central differencing:


[ ( ) ( )]
n n
∆ ∆
2
+   Anj+1 / 2 F jn+1 − F jn + Anj−1 / 2 F jn − F jn−1
t F + F − 1 t
u nj +1 = u nj −
j 1 j 1
∆x 2 2  ∆x 
u2 ∂F u j +1 + u j
Since F = ⇒ A= =u the Jacobian is calculated as A j +1 / 2 =
2 ∂u 2
∆t ∆t
2
A stability analysis gives G = 1 − 2 A  (1 − cos θ ) − 2i A sin θ
 ∆x  ∆x
u∆t
Stable if ≤1 the CFL-condition
∆x
Marching methods
MacCormack scheme

This is a two step version of the L-W with the advantage that
no Jacobians are needed. Otherwise it has identical properties
to the L-W

u nj+1 = −
∆t n
u nj
∆x
(
F j +1 − F jn )
Predictor

n +1 1 n
2
n +1
u j = u j + u j −
∆x
(
∆t n +1
)
F j − F jn−+11 

Corrector
Solving system of equations

Marching problems Equilibrium problems


Parabolic

P
Domain of
dependence Region of influence
Elliptic

Hyperbolic P

Every point influences all other points

Domain of P
dependence Region of influence
Relaxation techniques
∂ 2T
=S
Ti +n1+1 − 2Ti n +1 + Ti −n1+1
+ O ( ∆x 2
) = S n
∂x 2
∆x 2
i

Ti +n1+1 − 2Ti n +1 + Ti −n1+1 = ∆x 2 Sin

T3n +1 − 2T2n +1 + T1n +1 = ∆x 2 S 2n


T1,n+1 Ti-1,n+1 Ti,n+1 Ti+1,n+1 TN,n+1 T4n +1 − 2T3n +1 + T2n +1 = ∆x 2 S3n
∆t

T5n +1 − 2T4n +1 + T3n +1 = ∆x 2 S 4n


T1,n Ti-1,n Ti,n Ti+1,n TN,n

13
Relaxation techniques
Basic techniques for solving a system of equations

System of equations Ax = b
Direct methods
 a11 a12 a1N   x1   b1  •Cramer
a  x   b  •Gauss elimination
•Heavy
 21  2   2  •Error accumulation
    
  =  
•Thomas algorithm
 •Tri-diagonal systems
    
     Iterative methods
    
a N 1 a NN   x N  bN 
Thomas algorithm
bj
dj = dj − a j −1
Put on upper triangular form: d j −1
bj
cj = cj − c j −1
d j −1
Unknowns computed using j = 2,3,.......N
back-substitution:
d1 a1 0 0   x1   c1 
xN =
cN b d2 a2  x   c 
dN  2  2   2 
0 b3    
cj − d jxj    =  
x j −1 =     
a j −1  a N −1     
j = N − 1, N − 2.........1     
 0 bN d N   x N  c N 
Jacobi
N

Ax = b ∑a x = b
j =1
ij j i

b −∑a x
i
k −1
ij j
j ≠i
In interation step k: xik =
aii

Ti +n1+1 − 2Ti n +1 + Ti −n1+1 = ∆x 2 Sin


T1,k+1 Ti-1,k+1 Ti,k+1 Ti+1,k+1 TN,k+1
∆t

T k
+ T k
− ∆x 2 n
Si
T1,k Ti-1,k Ti,k Ti+1,k TN,k Ti k +1 = i +1 i −1
2

Easy but slow


Gauss-Seidel
N

Ax = b ∑a x = b
j =1
ij j i

bi − ∑j <i
aij x kj −∑a x
j >i
k −1
ij j
In interation step k: xik =
aii

Ti +n1+1 − 2Ti n +1 + Ti −n1+1 = ∆x 2 Sin


T1,k+1 Ti-1,k+1 Ti,k+1 Ti+1,k+1 TN,k+1
∆t

k +1
T k
+ T − ∆x 2 n
Si
T1,k Ti-1,k Ti,k Ti+1,k TN,k Ti k +1 = i +1 i −1
2
Always uses the best value available, gives faster solution
Successive Over-Relaxation (SOR)
• Accelerate convergence
Ti k +1 = Ti k + ω (Ti k +1 − Ti k ) k +1 Ti +k1 + Ti −k1+1 − ∆x 2 Sin
Ti =
T
2
T
Texact Texact

Ti k +1 = Ti k +
Tk+1 T*k+1
∆T
ω∆T Ti +k1 + Ti −k1+1 − ∆x 2 Sin − 2Ti k
Tk T*k ω
2

k k+1 k k+1 • ω > 1 overrelaxation


• ω < 1 underrelaxation
(for stability) 18
Residuals
When should we stop
R the iterations?

Lu = Rm
i, j
m
i, j

Jacobi

SOR Gauss-Seidel

Iteration Nr.
Relaxation techniques
Point relaxation
Example: Potential flow

∂ 2φ ∂ 2φ φi +1, j − 2φij + φi −1, j φi , j +1 − 2φij + φi , j −1


+ 2 =0 + =0
∂x 2
∂y ∆x 2
∆y 2

y
Gauss-Seidel, point relaxation:

k +1
φij =
φ k
i +1, j + φ k +1
i −1, j + β (φ
2 k
i , j +1 + φi , j −1 )
k +1

2(1 − β 2 )
j+1
2
 ∆x 
β = 
2
j
 ∆y  j-1

i-1 i i+1 x
Relaxation techniques
Line relaxation

In line relaxation a whole line is solved at once using a


direct method, for example the Thomas algoritm.

y
Gauss-Seidel, line relaxation in x:

k +1
φij =
φ k +1
i +1, j + φ k +1
i −1, j + β (φ
2 k
i , j +1 + φi , j −1 )
k +1

2(1 − β 2 )
j+1

j
j-1

i-1 i i+1 x
Relaxation techniques
ADI, alternating direction implicit

Further improvement of numerical convergence speed.


Computational time can be reduced with up to 20-40 %
as compared to Gauss-Seidel with SOR
Gauss-Seidel, ADI
y
First along x-direction
φik++11,j/ 2 + φik−+11,j/ 2 + β 2 (φik, j +1 + φik, +j −11/ 2 )
φijk +1 / 2 =
2(1 − β 2 )
then along y-direction
j+1
k +1
φij =
φ k +1 / 2
i +1, j + φ k +1
i −1, j + β (
2 k +1
φi , j +1 + φi , j −1 )
k +1

2(1 − β 2 )
j
j-1

i-1 i i+1 x
Multigrid methods
• Accelerate convergence
Multigrid methods
• Accelerate convergence
Multigrid methods
• Accelerate convergence
Multigrid methods
• Accelerate convergence
Multigrid methods
Multigrid methods are used to increase the
computational efficiency of an implicit method

d 2u
Consider the equation: − 2 = f (x) 0 ≤ x ≤1
dx
Periodic boundary conditions u (1) = u (0 )

x j = jh 1
Create a grid: 0 ≤ j ≤ 2n + 1 h=
2n
− u j −1 + 2u j − u j +1 1 ≤ j ≤ 2n
Discretise
2
= fj
h

Gauss-Seidel − u mj−1 + 2u mj = u mj+−11 + h 2 f j 1 ≤ j ≤ 2n


Multigrid methods
von Neumann stability analysis

Remember:
Use the numerical error ξ = u −u
m m m*
j j j
e a +ib = e a (cos(b) + i sin(b))

to rewrite the equation − ξ jm−1 + 2ξ jm = ξ jm+−11


2 n −1 πα
Fourier modes of ξ = ∑ cα e
m
j
m ijθα
θα = = 2παh
the error: α =0 n

lim G (θ1 ) = 1
What does this tell us?

h →0
Amplification factor
Multigrid methods
lim G (θ1 ) = 1
h →0

Short wavelength (high frequency) errors damps faster

Create grids with different resolutions

Low frequency errors on fine grids are high(er) frequency


errors on coarser grids (damps faster when relaxed on coarse
grids)
Multigrid methods
Example of a linear problem, the Laplace equation

∂ 2u ∂ 2u
+ 2 =0
∂x ∂y
2

ui −1, j − 2ui , j + ui +1, j ui , j −1 − 2ui , j + ui , j +1


Lui , j = +
∆x 2
∆y 2
On each grid, m, we solve: Luim, j = Rim, j Residual

Procedure for the Correction Storage (CS) scheme:

1. On the finest grid, M, do a few relaxations (iterations) of LuiM, j = 0


to reduce the short wave length error modes.

2. Calculate the residual and transfer it to the next


coarser grid, restriction: R M −1 = I M −1 R M
i, j M i, j
Multigrid methods
Example of a linear problem, the Laplace equation

3. On the coarser grid solve L∆uim, j + Rim, j = 0


∆uim, j = uˆim, j − uim, j

correction Previous solution on


grid m

4. Repeat steps 2 and 3 until the coarsest grid is reached

5. On the coarsest grid, solve the problem exactly.

6. Transfer the correction back to finer grid, prolongation, uˆim, j+1 = uim, j+1 + I mm+1∆uim, j
and do a few relaxations on each grid until the finest grid is reached
Multigrid methods
Multigrid cycles

V-cycle:
m=M

prolongation
restriction

m=1
= relaxation
Geometric multigrid
• Several grids
explicitly generated
• Suitable for structured
grids
• Several type of
cycles:
– V, W, ...

33
Algebraic multigrid

• Coarser levels built


’on-line’
• Can be used for
unstructured
meshes

• Mostly for elliptic


problems
• Too many/coarse
levels not 34

neccessarily help
Discretisation and grid

Questions:
•How complex is the geometry?
•What accuracy is required? Grid quality?
•What about stability?
•Grid refinement?
Grid generation-classification
Structured Unstructured

Number of Tetra- Poly-


blocks Hierarchy hedral hedral

Oct-
Mono Multi Cartesian tree

Shape Orthogonality

Orthog Body-
H C O onal fitted
36
Cell types

2-dimensional 3-dimensional

Triangular Tetrahedron
(tri) (tet)

Hexahedron
Quadrilateral
(hex)
(quad)

pyramid wedge
Grid types
Structured grid Unstructured grid
Grid types
Structured grid Unstructured grid
Multi-block
Grid types

Hybrid grid
Grid types
Hybrid grid
Structured Unstructured

• Easy to generate • Difficult to generate


• Inbuilt topology • Topology has to be
• Low memory stored
footprint • Lower mesh quality
• Fast solution • Slow algorythms
algorythms • Difficult for high-
• Easy to use high- order
order schemes • Suitable for
• Difficult for complex complex
geometries geometries

42
Mesh quality measures

• Stretching
α • dy2/dy1
dy2
• Best: 1
• Aspect ratio
dy1
• dy1/dx
• Best: 1
dx • Skewness
α
• Best: equi-angle
43
Efficient grids – grid stretching

Large
gradients

Fine
resolution

44
Efficient grids – grid stretching
 ∂T  ∆x  ∂ T  ∆x  ∂ T 
2 2 3 3
i+1 Ti −1 = Ti − ∆x  +  2  −  3  ...
 ∂x i 2  ∂x i 6  ∂x i

 ∂T  (r∆x)
2
 ∂ 2T  (r∆x) 3  ∂ 3T 
Ti +1 = Ti + r∆x  +  2  +  3  ...
i  ∂x i 2  ∂x i 6  ∂x i

i-1 ∂T Ti +1 − Ti −1 (r − 1)∆x  ∂ 2T 
= +  2  + O(∆x 2 )
∂x (r + 1)∆x 2  ∂x i

• Not second order any


more!
• Can be corrected
• Extra work 45
Grid stretching
Grid stretching
Efficient grids – local refinement

48
Efficient grids – adaptive
refinement
• Right marker parameter
• P, u, T, dt/dx, etc.
• Not too often
• Comp. Time
• Errors introduced
• Not too late
• Follow the flow
features

49
Refinement techniques

• Easier to implement • Neighbours affected


• Mesh quality • Better quality
decreases
50
Other grid related issues
• Grid generation strategies
• Moving boundaries

You might also like