computational fluid dynamics cfd - strömningsteknik · 2013-03-25 · computational fluid dynamics...
TRANSCRIPT
Computational Fluid Dynamics CFD
Solving system of equations, Grid generation
2
Basic steps of CFD
Problem
?
•Gov. Eq. •BC •Init. Cond.
...,, ++ jijti uu
•Discretization •Result
•Solution •OK?
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 type of equations decides solution strategy
Marching problems Equilibrium problems
Solving system of equations
Parabolic Hyperbolic Elliptic
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
Note! Time dependent incompressible flow has a mixed character: elliptic in space and parabolic in time.
Marching methods
1st order
Consider the inviscid Burger equation 0=∂∂
+∂∂
xuu
tu
Conserved form )( 0 uFFxF
tu
==∂∂
+∂∂
Start with a Taylor expansion around (x,t+∆t)
( ) ( ) HOT,,,
+
∂∂
∆+=∆+txt
uttxuttxuu1,1 ui,1 ui+1,1 ui-1,1 uN,1
u1,n+1 ui,n+1 ui+1,n+1 ui-1,n+1 uN,n+1
u1,n ui,n ui+1,n ui-1,n uN,n
∆t
∆x
Marching methods
1st order
The idea is to replace the time derivatives in the expansion by spacial ones
First derivative: xF
tu
∂∂
−=∂∂
Apply 2nd order central differencing:
2111
ni
nin
ini
FFxtuu −++ −
∆∆
−=
u1,1 ui,1 ui+1,1 ui-1,1 uN,1
u1,n+1 ui,n+1 ui+1,n+1 ui-1,n+1 uN,n+1
u1,n ui,n ui+1,n ui-1,n uN,n
∆t
∆x
Marching methods
Lax-Wendroff scheme
Consider the inviscid Burger equation 0=∂∂
+∂∂
xuu
tu
Conserved form )( 0 uFFxF
tu
==∂∂
+∂∂
Start with a Taylor expansion around (x,t+∆t)
( ) ( ) HOT2
,,,
2
22
,+
∂∂∆
+
∂∂
∆+=∆+txtx t
uttuttxuttxu
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: xF
tu
∂∂
−=∂∂
∂∂
∂∂
−=∂∂
∂−=
∂∂
tF
xxtF
tu 2
2
2Second derivative:
Since F is a function of u we can write
xuA
xu
uF
xF
tu
∂∂
−=∂∂
∂∂
−=∂∂
−=∂∂
Jacobian
tuA
tu
uF
tF
∂∂
=∂∂
∂∂
=∂∂
Marching methods
Lax-Wendroff scheme
Hence,
∂∂
∂∂
=∂∂
xFA
xtu2
2
The Taylor expansion can now be written as:
( ) ( ) HOT2
,,,
2
,+
∂∂
∂∂∆
+
∂∂
∆−=∆+txtx x
FAx
txFttxuttxu
Marching methods
Lax-Wendroff scheme
Apply 2nd order central differencing:
( ) ( )[ ]nj
nj
nj
nj
nj
nj
nj
njn
jnj FFAFFA
xtFF
xtuu 12/112/1
2111
21
2 −−++−++ −+−
∆∆
+−
∆∆
−=
Since uuFAuF =
∂∂
=⇒=2
2the Jacobian is calculated as
21
2/1jj
juu
A+
= ++
A stability analysis gives ( ) θθ sin2cos1212
AxtiA
xtG
∆∆
−−
∆∆
−=
Stable if 1≤∆∆xtu the CFL-condition
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
( )
( )
−
∆∆
−+=
−∆∆
−=
+−
+++
++
11
111
11
21 n
jnj
nj
nj
nj
nj
nj
nj
nj
FFxtuuu
FFxtuu Predictor
Corrector
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
Marching problems Equilibrium problems
13
Relaxation techniques
SxT
=∂∂
2
2ni
ni
ni
ni SxO
xTTT
=∆+∆
+− +−
+++ )(2 2
2
11
111
T1,n+1 Ti,n+1 Ti+1,n+1 Ti-1,n+1 TN,n+1
T1,n Ti,n Ti+1,n Ti-1,n TN,n
∆t
ni
ni
ni
ni SxTTT 21
111
1 2 ∆=+− +−
+++
nnnn SxTTT 221
11
21
3 2 ∆=+− +++
nnnn SxTTT 321
21
31
4 2 ∆=+− +++
nnnn SxTTT 421
31
41
5 2 ∆=+− +++
Relaxation techniques Basic techniques for solving a system of equations
bAx =System of equations
=
NNNNN
N
b
bb
x
xx
aa
aaaa
2
1
2
1
1
21
11211
Direct methods •Cramer •Gauss elimination
•Heavy •Error accumulation
•Thomas algorithm •Tri-diagonal systems
Iterative methods
Thomas algorithm
=
−
NNNN
N
c
cc
x
xx
dba
badb
ad
2
1
2
1
1
3
222
11
0
0
00
11
11
−−
−−
−=
−=
jj
jjj
jj
jjj
cdb
cc
adb
ddPut on upper triangular form:
Unknowns computed using back-substitution:
11
−−
−=
=
j
jjjj
N
NN
axdc
x
dcx
Nj ,.......3,2=
1.........2,1 −−= NNj
Jacobi
Easy but slow
bAx = ∑=
=N
jijij bxa
1
ii
ij
kjiji
ki a
xab
x∑
≠
−−
=
1
In interation step k:
ni
ni
ni
ni SxTTT 21
111
1 2 ∆=+− +−
+++
2
2111
ni
ki
kik
iSxTTT ∆−+
= −++
T1,k+1 Ti,k+1 Ti+1,k+1 Ti-1,k+1 TN,k+1
T1,k Ti,k Ti+1,k Ti-1,k TN,k
∆t
Gauss-Seidel bAx = ∑
=
=N
jijij bxa
1
ii
ij
kjij
ij
kjiji
ki a
xaxab
x∑∑
>
−
<
−−
=
1
In interation step k:
Always uses the best value available, gives faster solution
ni
ni
ni
ni SxTTT 21
111
1 2 ∆=+− +−
+++
2
21111
ni
ki
kik
iSxTTT ∆−+
=+
−++
T1,k+1 Ti,k+1 Ti+1,k+1 Ti-1,k+1 TN,k+1
T1,k Ti,k Ti+1,k Ti-1,k TN,k
∆t
18
Successive Over-Relaxation (SOR) • Accelerate convergence
• ω > 1 overrelaxation • ω < 1 underrelaxation
(for stability)
k
T Texact
∆T
k+1
Tk
Tk+1
k
T Texact
ω∆T
k+1
T*k
T*k+1
)( 11 ki
ki
ki
ki TTTT −+= ++ ω
2
21111
ni
ki
kik
iSxTTT ∆−+
=+
−++
2221
11
1
ki
ni
ki
ki
ki
ki
TSxTTTT
−∆−+
+=+
−+
+
ω
Residuals When should we stop the iterations?
mji
mji RLu ,, =
Iteration Nr.
R
Jacobi
Gauss-Seidel SOR
Relaxation techniques Point relaxation
y
x i i+1 i-1
j
j+1
j-1
02
2
2
2=
∂∂
+∂∂
yxφφ
022
21,1,
2,1,1 =
∆
+−+
∆
+− −+−+
yxjiijjijiijji φφφφφφ
( )( )2
11,1,
21,1,11
12 βφφβφφ
φ−
+++=
+−+
+−++
kji
kji
kji
kjik
ij
Example: Potential flow
Gauss-Seidel, point relaxation:
22
∆∆
=yxβ
Relaxation techniques Line relaxation
y
x i i+1 i-1
j
j+1
j-1
( )( )2
11,1,
21,1
1,11
12 βφφβφφ
φ−
+++=
+−+
+−
+++
kji
kji
kji
kjik
ij
Gauss-Seidel, line relaxation in x:
In line relaxation a whole line is solved at once using a direct method, for example the Thomas algoritm.
Relaxation techniques ADI, alternating direction implicit
y
x i i+1 i-1
j
j+1
j-1
( )( )2
2/11,1,
22/1,1
2/1,12/1
12 βφφβφφ
φ−
+++=
+−+
+−
+++
kji
kji
kji
kjik
ij
Gauss-Seidel, ADI
Further improvement of numerical convergence speed. Computational time can be reduced with up to 20-40 % as compared to Gauss-Seidel with SOR
( )( )2
11,
11,
21,1
2/1,11
12 βφφβφφ
φ−
+++=
+−
++
+−
+++
kji
kji
kji
kjik
ij
First along x-direction
then along y-direction
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
Consider the equation: ( )xfdx
ud=− 2
2
10 ≤≤ x
Periodic boundary conditions
Create a grid: jhx j = 120 +≤≤ njn
h21
=
Discretise j
jjj fh
uuu=
−+− +−
211 2
Gauss-Seidel jmj
mj
mj fhuuu 21
11 2 +=+− −+−
nj 21 ≤≤
nj 21 ≤≤
( ) ( )01 uu =
Multigrid methods von Neumann stability analysis
Use the numerical error *m
jmj
mj uu −=ξ
111 2 −
+− =+− mj
mj
mj ξξξto rewrite the equation
αθ
ααξ ij
nmm
j ec∑−
=
=12
0
Fourier modes of the error:
hn
παπαθα 2==
( ) 1lim 10=
→θG
h
What does this tell us?
Amplification factor
Remember:
))sin()(cos( bibee aiba +=+
Multigrid methods ( ) 1lim 10
=→
θGh
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
02
2
2
2
=∂∂
+∂∂
yu
xu
21,,1,
2,1,,1
,
22y
uuux
uuuLu jijijijijiji
ji ∆+−
+∆
+−= +−+−
On each grid, m, we solve: mji
mji RLu ,, =
Procedure 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, =MjiLu
2. Calculate the residual and transfer it to the next coarser grid, restriction: M
jiMM
Mji RIR ,
11,
−− =
Residual
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,, =+∆ mji
mji RuL
mji
mji
mji uuu ,,, ˆ −=∆
4. Repeat steps 2 and 3 until the coarsest grid is reached
5. On the coarsest grid, solve the problem exactly.
correction Previous solution on grid m
mji
mm
mji
mji uIuu ,
11,
1,ˆ ∆+= +++
Multigrid methods Multigrid cycles
V-cycle:
= relaxation
restriction prolongation
m=M
m=1
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 neccessarily help
34
Discretisation and grid
Questions:
•How complex is the geometry?
•What accuracy is required? Grid quality?
•What about stability?
•Grid refinement?
Grid generation-classification
36
Structured
Number of blocks
Mono Multi
Hierarchy
Cartesian
Shape
H C O
Orthogonality
Orthogonal
Body-fitted
Oct-tree
Unstructured
Tetra-hedral
Poly-hedral
Cell types
2-dimensional 3-dimensional
Triangular (tri)
Quadrilateral (quad)
Tetrahedron (tet)
Hexahedron (hex)
pyramid wedge
Grid types Structured grid Unstructured grid
Unstructured grid
Grid types Structured grid Multi-block
Grid types
Hybrid grid
Grid types Hybrid grid
42
Structured
• Easy to generate • Inbuilt topology
• Low memory footprint
• Fast solution algorythms
• Easy to use high-order schemes
• Difficult for complex geometries
Unstructured
• Difficult to generate • Topology has to be
stored • Lower mesh quality • Slow algorythms • Difficult for high-
order • Suitable for
complex geometries
Mesh quality measures
43
• Stretching • dy2/dy1 • Best: 1
• Aspect ratio • dy1/dx • Best: 1
• Skewness �α • Best: equi-angle
α
dx
dy1
dy2
Efficient grids – grid stretching
44
Large gradients
Fine resolution
Efficient grids – grid stretching
45
i
i+1
i-1
...62 3
33
2
22
1iii
ii xTx
xTx
xTxTT
∂∂∆
−
∂∂∆
+
∂∂
∆−=−
...6
)(2
)(3
33
2
22
1iii
ii xTxr
xTxr
xTxrTT
∂∂∆
+
∂∂∆
+
∂∂
∆+=+
)(2
)1()1(
22
211 xO
xTxr
xrTT
xT
i
ii ∆+
∂∂∆−
+∆+
−=
∂∂ −+
• Not second order any more!
• Can be corrected • Extra work
Grid stretching
Grid stretching
Efficient grids – local refinement
48
Efficient grids – adaptive refinement
49
• Right marker parameter • P, u, T, dt/dx, etc.
• Not too often • Comp. Time • Errors introduced
• Not too late • Follow the flow
features
Refinement techniques
50
• Easier to implement • Mesh quality
decreases
• Neighbours affected • Better quality
Other grid related issues
• Grid generation strategies • Moving boundaries