computational fluid dynamics (cfd) - sccswiki · pdf filetechnische universität...
TRANSCRIPT
Technische Universität München
Janos Benk: Computational fluid dynamics (CFD) www5.in.tum.de/wiki/index.php/Lab_Course_Computational_Fluid_Dynamics_-_Summer_10
9th SIMLAB Course, Belgrade, October 7, 2010
Computational fluid dynamics (CFD)9th SIMLAB Course
Janos Benk
October 3-9, 2010
Technische Universität München
Janos Benk: Computational fluid dynamics (CFD) www5.in.tum.de/wiki/index.php/Lab_Course_Computational_Fluid_Dynamics_-_Summer_10
9th SIMLAB Course, Belgrade, October 7, 2010
Overview
• Introduction
• Potential flow
• Stokes equation and discretization
• Boundary Conditions
• Navier-Stokes equation and its dicretization
• (Parallelization)
Technische Universität München
Janos Benk: Computational fluid dynamics (CFD) www5.in.tum.de/wiki/index.php/Lab_Course_Computational_Fluid_Dynamics_-_Summer_10
9th SIMLAB Course, Belgrade, October 7, 2010
Introduction
• What defines a flow?
• What are the quantities in such a incompressible flow field?
Velocity vector
pressure scalar
Technische Universität München
Janos Benk: Computational fluid dynamics (CFD) www5.in.tum.de/wiki/index.php/Lab_Course_Computational_Fluid_Dynamics_-_Summer_10
9th SIMLAB Course, Belgrade, October 7, 2010
Introduction
• We are looking for a relation between the velocity vector and the pressure
• We note vel = (u,v) the velocity vector in 2D
• The pressure is noted by p
• For the case of simplicity we consider only stationary scenarios though the whole
tutorial
• We use a regular structured grid (as the simplest grid)
• The cells form a mesh
x
y One cell
Technische Universität München
Janos Benk: Computational fluid dynamics (CFD) www5.in.tum.de/wiki/index.php/Lab_Course_Computational_Fluid_Dynamics_-_Summer_10
9th SIMLAB Course, Belgrade, October 7, 2010
Introduction
• Grid based method
• Finite difference (reuse some knowledge from the previous lecture)
• Other discretization techniques are more favorable in practice, due to the limitations
of the finite difference method.
• “Finite volume”
• “Finite element”
Technische Universität München
Janos Benk: Computational fluid dynamics (CFD) www5.in.tum.de/wiki/index.php/Lab_Course_Computational_Fluid_Dynamics_-_Summer_10
9th SIMLAB Course, Belgrade, October 7, 2010
Potential flow
• The first try is the “Potential flow”, the simples flow equation
• The velocity is directly derived from the pressure (potential) flow
• First we specify that per cell no matter can be gained or disappear.
( vel = (u,v) )
0
0
=∂∂+
∂∂
=⋅∇
y
v
x
u
vel
v1
v2
u1 u2
p
x
y
Technische Universität München
Janos Benk: Computational fluid dynamics (CFD) www5.in.tum.de/wiki/index.php/Lab_Course_Computational_Fluid_Dynamics_-_Summer_10
9th SIMLAB Course, Belgrade, October 7, 2010
Potential flow
• Replace the “?” with values
3
?
-2
p
x
y
0
0
=∂∂+
∂∂
=⋅∇
y
v
x
u
vel
?
X
-X+1
Technische Universität München
Janos Benk: Computational fluid dynamics (CFD) www5.in.tum.de/wiki/index.php/Lab_Course_Computational_Fluid_Dynamics_-_Summer_10
9th SIMLAB Course, Belgrade, October 7, 2010
Potential flow
• Replace the “?” with values
-2
4
3
p
x
y
0
0
=∂∂+
∂∂
=⋅∇
y
v
x
u
vel
?
-3
Technische Universität München
Janos Benk: Computational fluid dynamics (CFD) www5.in.tum.de/wiki/index.php/Lab_Course_Computational_Fluid_Dynamics_-_Summer_10
9th SIMLAB Course, Belgrade, October 7, 2010
Potential flow
• The potential is a Poisson equation, with zero right hand side.
• The velocity is directly derived from the pressure (potential) flow
• The different boundary conditions can be implemented through the potential
• To be the solution uniquely determined, we use a Dirichlet boundary condition for
0
0
02
==∇⋅=∇⋅=∇−
p
ppn
pn
p
out
Inlet
Outlet
Walls
Technische Universität München
Janos Benk: Computational fluid dynamics (CFD) www5.in.tum.de/wiki/index.php/Lab_Course_Computational_Fluid_Dynamics_-_Summer_10
9th SIMLAB Course, Belgrade, October 7, 2010
Potential flow
• Is the velocity still divergence free?
• Is the following equation still satisfied? vel=(u,v)
• With the following equations:
pvel ∇=
0=⋅∇ vel
02 =∇− p
02 =∇=⋅∇ pvel
Technische Universität München
Janos Benk: Computational fluid dynamics (CFD) www5.in.tum.de/wiki/index.php/Lab_Course_Computational_Fluid_Dynamics_-_Summer_10
9th SIMLAB Course, Belgrade, October 7, 2010
Potential flow
• How does the potential field looks for a channel flow?
• And the velocity field (u,v)
p=0
Inlet
p=-1
Outlet
Walls
pvu ∇=),(
02 =∇− p
x
y
p
u
Technische Universität München
Janos Benk: Computational fluid dynamics (CFD) www5.in.tum.de/wiki/index.php/Lab_Course_Computational_Fluid_Dynamics_-_Summer_10
9th SIMLAB Course, Belgrade, October 7, 2010
Stokes equation
• There is a “complete” new second equation:
0=⋅∇ vel
extfvelpt
vel +∇=∇+∂
∂ 2
Re
1
0=∂
∂t
vel
• Since we consider only stationary problems:
extfvelp +∇=∇ 2
Re
1
Technische Universität München
Janos Benk: Computational fluid dynamics (CFD) www5.in.tum.de/wiki/index.php/Lab_Course_Computational_Fluid_Dynamics_-_Summer_10
9th SIMLAB Course, Belgrade, October 7, 2010
Stokes equation
extfvelp +∇=∇ 2
Re
1
• What does the second equation mean ?
• This is the so called “impulse equation”, at each point the sum of the acting forces
must equal zero
Grad(p)
vel
Technische Universität München
Janos Benk: Computational fluid dynamics (CFD) www5.in.tum.de/wiki/index.php/Lab_Course_Computational_Fluid_Dynamics_-_Summer_10
9th SIMLAB Course, Belgrade, October 7, 2010
Stokes equation
• Reformulate the equation in terms of u,vand p instead of vel,p
• Vel=(u,v)0=⋅∇ vel
extfvelp +∇=∇ 2
Re
1
• The equations are
0=∂∂+
∂∂
y
v
x
u
xextfy
u
x
u
x
p,2
2
2
2
Re
1 +
∂∂+
∂∂=
∂∂
yextfy
v
x
v
y
p,2
2
2
2
Re
1 +
∂∂+
∂∂=
∂∂
Technische Universität München
Janos Benk: Computational fluid dynamics (CFD) www5.in.tum.de/wiki/index.php/Lab_Course_Computational_Fluid_Dynamics_-_Summer_10
9th SIMLAB Course, Belgrade, October 7, 2010
Stokes equation
• Calculate the parabolic profile of a channel flow:
0)( =Hu
02
2
Re
1c
y
u
x
p =
∂∂=
∂∂
32
20
2Re)( cycy
cyu ++=
xextfy
u
x
u
x
p,2
2
2
2
Re
1 +
∂∂+
∂∂=
∂∂
yextfy
v
x
v
y
p,2
2
2
2
Re
1 +
∂∂+
∂∂=
∂∂
x
y
10)( cxcxp +=
0)0( =u
x
pc
∆∆=0
Technische Universität München
Janos Benk: Computational fluid dynamics (CFD) www5.in.tum.de/wiki/index.php/Lab_Course_Computational_Fluid_Dynamics_-_Summer_10
9th SIMLAB Course, Belgrade, October 7, 2010
Stokes equation
• Finite difference discretization:
• “Cell wise” view of the cont. eq.
xextfy
u
x
u
x
p,2
2
2
2
Re
1 +
∂∂+
∂∂=
∂∂
yextfy
v
x
v
y
p,2
2
2
2
Re
1 +
∂∂+
∂∂=
∂∂
0=∂∂+
∂∂
y
v
x
u
• The operators in the velocity points, since the impulse is point wise satisfied (x and y).
Technische Universität München
Janos Benk: Computational fluid dynamics (CFD) www5.in.tum.de/wiki/index.php/Lab_Course_Computational_Fluid_Dynamics_-_Summer_10
9th SIMLAB Course, Belgrade, October 7, 2010
Stokes equation xextfy
u
x
u
x
p,2
2
2
2
Re
1 +
∂∂+
∂∂=
∂∂
yextfy
v
x
v
y
p,2
2
2
2
Re
1 +
∂∂+
∂∂=
∂∂
0=∂∂+
∂∂
y
v
x
u
Technische Universität München
Janos Benk: Computational fluid dynamics (CFD) www5.in.tum.de/wiki/index.php/Lab_Course_Computational_Fluid_Dynamics_-_Summer_10
9th SIMLAB Course, Belgrade, October 7, 2010
Stokes equation
Boundary conditions:
• No-Slip:
)0,0(),( =vu
• Free-Slip:
• Inflow:
• Outflow: 02
=+= iar
vvv
)0,(),( uvu = ),0(),( vvu =
),(),( 00 vuvu =
0/),( =∂∂ nvu
Technische Universität München
Janos Benk: Computational fluid dynamics (CFD) www5.in.tum.de/wiki/index.php/Lab_Course_Computational_Fluid_Dynamics_-_Summer_10
9th SIMLAB Course, Belgrade, October 7, 2010
Stokes equation
• Driven cavity
Technische Universität München
Janos Benk: Computational fluid dynamics (CFD) www5.in.tum.de/wiki/index.php/Lab_Course_Computational_Fluid_Dynamics_-_Summer_10
9th SIMLAB Course, Belgrade, October 7, 2010
Stokes equation
• Which are the unknowns?
1
1
Technische Universität München
Janos Benk: Computational fluid dynamics (CFD) www5.in.tum.de/wiki/index.php/Lab_Course_Computational_Fluid_Dynamics_-_Summer_10
9th SIMLAB Course, Belgrade, October 7, 2010
Stokes equation• What to do at the boundary?
Technische Universität München
Janos Benk: Computational fluid dynamics (CFD) www5.in.tum.de/wiki/index.php/Lab_Course_Computational_Fluid_Dynamics_-_Summer_10
9th SIMLAB Course, Belgrade, October 7, 2010
Stokes equation
p0 p1
p2 p3
v0
u0
v1
u1
• What to do at the boundary?
Technische Universität München
Janos Benk: Computational fluid dynamics (CFD) www5.in.tum.de/wiki/index.php/Lab_Course_Computational_Fluid_Dynamics_-_Summer_10
9th SIMLAB Course, Belgrade, October 7, 2010
Stokes equation
p0 p1
p2 p3
v0
u0
v1
u1
-v0
2-u0
-v1
-u1
Technische Universität München
Janos Benk: Computational fluid dynamics (CFD) www5.in.tum.de/wiki/index.php/Lab_Course_Computational_Fluid_Dynamics_-_Summer_10
9th SIMLAB Course, Belgrade, October 7, 2010
Stokes equation• Continuity equation:
0=∂∂+
∂∂
y
v
x
u
p0 p1
p2 p3
v0
u0
v1
u1
-v0
2-u0
-v1
-u1
v0 – u0 = 0
u0 + v1 = 0
-v0 - u1 = 0
-v1 + u1 = 0
1
1
Technische Universität München
Janos Benk: Computational fluid dynamics (CFD) www5.in.tum.de/wiki/index.php/Lab_Course_Computational_Fluid_Dynamics_-_Summer_10
9th SIMLAB Course, Belgrade, October 7, 2010
Stokes equation
p0 p1
p2 p3
v0
u0
v1
u1
-v0
2-u0
-v1
-u1
(1/Re)(5v0– v1)+p0-p2 = 0
(1/Re)(5u0-u1)-p0+p1 =(1/Re) 2
(1/Re)(-v0 +5v1)+p1-p3 = 0
(1/Re)(-u0 + 5u1)-p2+p3 = 0
1
1
0Re
12
2
2
2
=
∂∂+
∂∂−
∂∂
y
u
x
u
x
p
0Re
12
2
2
2
=
∂∂+
∂∂−
∂∂
y
v
x
v
y
p
Technische Universität München
Janos Benk: Computational fluid dynamics (CFD) www5.in.tum.de/wiki/index.php/Lab_Course_Computational_Fluid_Dynamics_-_Summer_10
9th SIMLAB Course, Belgrade, October 7, 2010
Stokes equation
v0 – u0 = 0
u0 + v1 = 0
-v0 - u1 = 0
-v1 + u1 = 0
(1/Re)(5v0– v1)+p0-p2 = 0
(1/Re)(5u0-u1)-p0+p1 =(1/Re) 2
(1/Re)(-v0 +5v1)+p1-p3 = 0
(1/Re)(-u0 + 5u1)-p2+p3 = 0
=
−−−−
−−−−
−−−
−
0
0
2
0
0
0
0
0
3
2
1
0
1
1
0
0
1151
1151
1115
1115
11
11
11
11
p
p
p
p
u
v
u
v
Write the system of equation with Re=1
With unknown vector [v0,u0,v1,u1,p0,p1,p2,p3] , first cont. eq. then momentum equation
Technische Universität München
Janos Benk: Computational fluid dynamics (CFD) www5.in.tum.de/wiki/index.php/Lab_Course_Computational_Fluid_Dynamics_-_Summer_10
9th SIMLAB Course, Belgrade, October 7, 2010
Stokes equation
• Due to the singularity we set p0=0 and delete the fourth line from the system
=
−−−−
−−−
−
0
0
2
0
0
0
0
3
2
1
1
1
0
0
1151
1151
115
115
11
11
11
p
p
p
u
v
u
v
• We calculate the solution with Octave
Technische Universität München
Janos Benk: Computational fluid dynamics (CFD) www5.in.tum.de/wiki/index.php/Lab_Course_Computational_Fluid_Dynamics_-_Summer_10
9th SIMLAB Course, Belgrade, October 7, 2010
Stokes equation
0 1.5
0.5
1.0
0.083
0.083 -0.083
-0.083
• The solution vector is:[0.083333 0.083333 - 0.083333 - 0.083333 1.5 0.5 1.0]
• “Visualize” these data on the grid
Technische Universität München
Janos Benk: Computational fluid dynamics (CFD) www5.in.tum.de/wiki/index.php/Lab_Course_Computational_Fluid_Dynamics_-_Summer_10
9th SIMLAB Course, Belgrade, October 7, 2010
Stokes equation
• 3D Example:
Technische Universität München
Janos Benk: Computational fluid dynamics (CFD) www5.in.tum.de/wiki/index.php/Lab_Course_Computational_Fluid_Dynamics_-_Summer_10
9th SIMLAB Course, Belgrade, October 7, 2010
Navier-Stokes equation
• Is the velocity still divergence free?
0=⋅∇ vel
( ) extfvelpvelvelt
vel +∇=∇+∇⋅+∂
∂ 2
Re
1
0=∂
∂t
vel
• Since we consider only stationary problems:
( ) extfvelpvelvel +∇=∇+∇⋅ 2
Re
1
Technische Universität München
Janos Benk: Computational fluid dynamics (CFD) www5.in.tum.de/wiki/index.php/Lab_Course_Computational_Fluid_Dynamics_-_Summer_10
9th SIMLAB Course, Belgrade, October 7, 2010
Navier-Stokes equation
• The new term in the equation is the so called “convective” or “transport” term
( )velvel ∇⋅
∂∂+
∂∂
∂∂+
∂∂
=
∂∂∂∂
⋅
y
vv
x
vu
y
uv
x
uu
v
u
y
x
v
u
• Which in more detailed form is (see the non-linearity)
• The velocity field transports the
“velocity”.
• The diffusion “spreads” the velocity in
each direction equally
• This transports in the flow direction
velocityGrad(p)
vel
Technische Universität München
Janos Benk: Computational fluid dynamics (CFD) www5.in.tum.de/wiki/index.php/Lab_Course_Computational_Fluid_Dynamics_-_Summer_10
9th SIMLAB Course, Belgrade, October 7, 2010
Navier-Stokes equation
• Which model to use when?
• Would you use Navier-Stokes for “slow” , viscous flow (diffusion term is dominant)?
• Would you use Navier-Stokes for non viscous flow?
• (Péclet number, is a good indicator for this)
Technische Universität München
Janos Benk: Computational fluid dynamics (CFD) www5.in.tum.de/wiki/index.php/Lab_Course_Computational_Fluid_Dynamics_-_Summer_10
9th SIMLAB Course, Belgrade, October 7, 2010
Navier-Stokes equation
• We reformulate the equation in terms
of u,v and p instead of vel,p
• Vel=(u,v)0=⋅∇ vel
• The equations are (the convection term is transformed slightly)
0=∂∂+
∂∂
y
v
x
u
( ) ( )xextf
y
uv
x
u
y
u
x
u
x
p,
2
2
2
2
2
Re
1 +∂
∂−∂
∂−
∂∂+
∂∂=
∂∂
( ) ( )yextf
y
v
x
uv
y
v
x
v
y
p,
2
2
2
2
2
Re
1 +∂
∂−∂
∂−
∂∂+
∂∂=
∂∂
( ) extfvelvelvelp +∇⋅−∇=∇ 2
Re
1
Technische Universität München
Janos Benk: Computational fluid dynamics (CFD) www5.in.tum.de/wiki/index.php/Lab_Course_Computational_Fluid_Dynamics_-_Summer_10
9th SIMLAB Course, Belgrade, October 7, 2010
Navier-Stokes equation
• Convection term, x component
Technische Universität München
Janos Benk: Computational fluid dynamics (CFD) www5.in.tum.de/wiki/index.php/Lab_Course_Computational_Fluid_Dynamics_-_Summer_10
9th SIMLAB Course, Belgrade, October 7, 2010
Navier-Stokes equation
• Convection term, y component
Technische Universität München
Janos Benk: Computational fluid dynamics (CFD) www5.in.tum.de/wiki/index.php/Lab_Course_Computational_Fluid_Dynamics_-_Summer_10
9th SIMLAB Course, Belgrade, October 7, 2010
Navier-Stokes equation
Outline of the solving method:
• Coupled approach:
Using non-linear solvers (fix point or Newton method)
• Partitioned approach only for time dependent problem
b
p
v
u
vuA =
),(
...2 =∇ p
...),(11 =++ tt
vu
Technische Universität München
Janos Benk: Computational fluid dynamics (CFD) www5.in.tum.de/wiki/index.php/Lab_Course_Computational_Fluid_Dynamics_-_Summer_10
9th SIMLAB Course, Belgrade, October 7, 2010
Navier-Stokes equation
• 2D Example:
Technische Universität München
Janos Benk: Computational fluid dynamics (CFD) www5.in.tum.de/wiki/index.php/Lab_Course_Computational_Fluid_Dynamics_-_Summer_10
9th SIMLAB Course, Belgrade, October 7, 2010
Parallelization
• Shared memory systems
• The basics of parallelization on the matrix level on distributed memory system
• Distribute the unknown vector to processes
• Distribute the corresponding lines of the matrix and the right hand side
bAx =
=
p0
p1
p2
p0
p1
p2
p0
p1
p2
Technische Universität München
Janos Benk: Computational fluid dynamics (CFD) www5.in.tum.de/wiki/index.php/Lab_Course_Computational_Fluid_Dynamics_-_Summer_10
9th SIMLAB Course, Belgrade, October 7, 2010
Parallelization
• Let’s think in terms of iterative processes
• How to divide among processors?
Technische Universität München
Janos Benk: Computational fluid dynamics (CFD) www5.in.tum.de/wiki/index.php/Lab_Course_Computational_Fluid_Dynamics_-_Summer_10
9th SIMLAB Course, Belgrade, October 7, 2010
Parallelization
• We need additional cells in the same way as we need boundary cells
Technische Universität München
Janos Benk: Computational fluid dynamics (CFD) www5.in.tum.de/wiki/index.php/Lab_Course_Computational_Fluid_Dynamics_-_Summer_10
9th SIMLAB Course, Belgrade, October 7, 2010
Parallelization
• (Ghost cells)
Technische Universität München
Janos Benk: Computational fluid dynamics (CFD) www5.in.tum.de/wiki/index.php/Lab_Course_Computational_Fluid_Dynamics_-_Summer_10
9th SIMLAB Course, Belgrade, October 7, 2010
Parallelization
• Communication needed (?)
Technische Universität München
Janos Benk: Computational fluid dynamics (CFD) www5.in.tum.de/wiki/index.php/Lab_Course_Computational_Fluid_Dynamics_-_Summer_10
9th SIMLAB Course, Belgrade, October 7, 2010
Thank you for your attention!