WS 04/05
Motivation Outline
n introduction
n pre-requisites
n governing equations
n continuity equation
n momentum equation
n summary
n solution techniques
D. Enright, S. Marschner, R. Fedkiw, n Lax-Wendroff
“Animation and Rendering of
n MacCormack
Complex Water Surfaces,”
Siggraph 2002, ACM TOG, n numerical aspects
vol. 21, pp. 736-744, 2002. n recent research in graphics
University of Freiburg - Institute of Computer Science - Computer Graphics Laboratory University of Freiburg - Institute of Computer Science - Computer Graphics Laboratory
•1
Introduction Numerical Solution - Overview
University of Freiburg - Institute of Computer Science - Computer Graphics Laboratory University of Freiburg - Institute of Computer Science - Computer Graphics Laboratory
n x, y, z – 3D coordinate system
n t – time
n ρ ( x,y,z,t ) – density
n v ( x,y,z,t ) – velocity
v (x,y,z,t ) v (x,y,z,t+∆t )
ρ (x,y,z,t ) ρ (x,y,z,t+∆t )
University of Freiburg - Institute of Computer Science - Computer Graphics Laboratory University of Freiburg - Institute of Computer Science - Computer Graphics Laboratory
•2
Outline Substantial Derivative of ρ
University of Freiburg - Institute of Computer Science - Computer Graphics Laboratory University of Freiburg - Institute of Computer Science - Computer Graphics Laboratory
•3
Divergence of v Outline
n momentum equation
n summary
n solution techniques
n Lax-Wendroff
n MacCormack
n numerical aspects
n recent research in graphics
University of Freiburg - Institute of Computer Science - Computer Graphics Laboratory University of Freiburg - Institute of Computer Science - Computer Graphics Laboratory
n mass is conserved
n infinitesimally small fluid element moving with the flow
Dρ
n fixed mass δm, variable volume δV, variable density ρ + ρ∇ ⋅ v = 0
δm = ρ ⋅ δV Dt
n time rate of change of the mass of the moving fluid substantial derivative – divergence of velocity -
element is zero time rate of change of time rate of change of volume
D δm D (ρ ⋅ δ V ) Dρ D δV density of a moving of a moving fluid element per
= = δV +ρ =0 fluid element volume
Dt Dt Dt Dt
Dρ 1 D δV Dρ
+ρ =0 → + ρ∇ ⋅ v = 0
Dt δ V Dt Dt
University of Freiburg - Institute of Computer Science - Computer Graphics Laboratory University of Freiburg - Institute of Computer Science - Computer Graphics Laboratory
•4
Continuity Equation Continuity Equation
University of Freiburg - Institute of Computer Science - Computer Graphics Laboratory University of Freiburg - Institute of Computer Science - Computer Graphics Laboratory
University of Freiburg - Institute of Computer Science - Computer Graphics Laboratory University of Freiburg - Institute of Computer Science - Computer Graphics Laboratory
•5
Body Force Pressure Force
dy
fluid
element n net pressure force in x direction
∂p ∂p
dz p − p + ∂ dx dy dz = − dx dy dz
x ∂x
dx
University of Freiburg - Institute of Computer Science - Computer Graphics Laboratory University of Freiburg - Institute of Computer Science - Computer Graphics Laboratory
Stress Stress
n normal stress – related to the time rate of change of volume n normal stress is related to pressure orthogonal to surface
n shear stress – related to the time rate of change n shear stress is related to friction parallel to surface
of the shearing deformation n friction and pressure are related to the velocity gradient
n τjk – stress in k direction applied to a surface perpendicular n friction (shear stress) models viscosity (viscous flow)
to the j axis n in contrast to inviscid flow, where friction is not considered
n τxx – normal stress in x direction
friction
n τzx , τyx – shear stresses in x directions
pressure normal shear velocity
τyx
stress stress
y
velocity
τxx
x
University of Freiburg - Institute of Computer Science - Computer Graphics Laboratory University of Freiburg - Institute of Computer Science - Computer Graphics Laboratory
•6
Surface Forces in x Momentum Equation in x
(τyx + ∂ τyx / ∂y dy) dx dz
dz
m a x = Fx
p dy dz ( p + ∂p/ ∂x dx ) dy dz
Du ∂p ∂τ xx ∂τ yx ∂τ zx
τxx dy dz (τxx + ∂ τxx / ∂x dx) dy dz ρ dx dy dz = − + + + dx dy dz + ρ f x dx dy dz
dx Dt ∂x ∂x ∂y ∂z
dy
τyx dx dz τzx not illustrated mass acceleration surface force body force
∂p ∂τ time rate of change pressure gravity
Fx = p − p + dx dy dz + τ xx + xx dx − τ xx dy dz
∂ x ∂x of velocity of a normal stress
∂τ ∂τ moving fluid element shear stress
+ τ yx + yx dy − τ yx dx dz + τ zx + zx dz − τ zx dy dz
∂y ∂z
Du ∂p ∂τ ∂τ yx ∂τ zx
ρ = − + xx + + + ρ fx
∂p ∂τ xx ∂τ yx ∂τ zx Dt ∂x ∂x ∂y ∂z
Fx = − + + + dx dy dz
∂x ∂x ∂y ∂z
University of Freiburg - Institute of Computer Science - Computer Graphics Laboratory University of Freiburg - Institute of Computer Science - Computer Graphics Laboratory
University of Freiburg - Institute of Computer Science - Computer Graphics Laboratory University of Freiburg - Institute of Computer Science - Computer Graphics Laboratory
•7
Momentum Equation Newtonian Fluids
∂(ρ w ) ∂p ∂τ ∂τ yz ∂τ zz ∂v ∂u ∂u ∂w ∂w ∂v
τ xy = τ yx = µ + τ xz = τ zx = µ + τ yz = τ zy = µ +
+ ∇ ⋅ (ρ w v ) = − + xz + + + ρ fz ∂x ∂y
∂z ∂x ∂y ∂z
∂t ∂z ∂x ∂y ∂z
n µ is the molecular viscosity coefficient
n λ is the second viscosity coefficient with λ = -2/3 ⋅ µ
University of Freiburg - Institute of Computer Science - Computer Graphics Laboratory University of Freiburg - Institute of Computer Science - Computer Graphics Laboratory
n T – temperature
n termal equation of state p = ρ R T n now,
p can be expressed using density and
τ can be expressed using velocity gradients,
fx is user-defined (e. g. gravity)
University of Freiburg - Institute of Computer Science - Computer Graphics Laboratory University of Freiburg - Institute of Computer Science - Computer Graphics Laboratory
•8
Governing Equations –
Outline
Viscous Compressible Flow
n introduction n thus, four equations and four unknowns ρ, u, v, w
pre-requisites ∂ρ
+ ∇ ⋅ (ρ v ) = 0
n
continuity equation
n governing equations ∂t
n continuity equation
∂(ρ u ) ∂p ∂τ ∂τ yx ∂τ zx
n momentum equation
+ ∇ ⋅ ( ρ u v ) = − + xx + + + ρ fx
∂t ∂x ∂x ∂y ∂z
momentum equation
n summary
n solution techniques
∂ (ρ v ) ∂p ∂τ xy ∂τ yy ∂τ zy
n Lax-Wendroff + ∇ ⋅ (ρ v v) = − + + + + ρ fy
n MacCormack ∂t ∂y ∂x ∂y ∂z
n numerical aspects
∂(ρ w ) ∂p ∂τ ∂τ yz ∂τ zz
n recent research in graphics + ∇ ⋅ (ρ w v ) = − + xz + + + ρ fz
∂t ∂z ∂x ∂y ∂z
University of Freiburg - Institute of Computer Science - Computer Graphics Laboratory University of Freiburg - Institute of Computer Science - Computer Graphics Laboratory
∂(ρ w ) ∂p
+ ∇ ⋅ (ρ w v ) = − + ρ f z
∂t ∂z
University of Freiburg - Institute of Computer Science - Computer Graphics Laboratory University of Freiburg - Institute of Computer Science - Computer Graphics Laboratory
•9
Governing Equations in
Generic Form
Conservation Form
n can be obtained directly from a control volume fixed in n viscous flow
space ρ ρu ?v ?w 0
n consider flux of mass, momentum (and energy) into and ρu
U=
F=
ρ u u + p − τ xx ? u v − t yx
G =
H =
? u w − t zx
J =
? fx
? v w + p − t zy ? f
out of the volume
ρv
ρ v u − τ xy
? v v + p − t yy
y
ρ w ρ w u −τ ? wv − t ? ww + p − t ? f
n have a divergence term which involves the flux of xz yz zz z
mass (ρv), momentum in x, y, z (ρu v, ρv v, ρw v)
n inviscid flow
n can be expressed in a generic form
ρ ρu ?v ?w 0
ρu ρ uu + p ?u v ?u w ? fx
∂U ∂F ∂G ∂H U= F = = H = J =
+ + + =J ρv ρ vu ?v w + p
G ?v v + p ? f
y
∂t ∂x ∂y ∂z ρ w ρ wu ?w w + p ? f
?w v z
University of Freiburg - Institute of Computer Science - Computer Graphics Laboratory University of Freiburg - Institute of Computer Science - Computer Graphics Laboratory
•10
Outline Lax-Wendroff Technique
University of Freiburg - Institute of Computer Science - Computer Graphics Laboratory University of Freiburg - Institute of Computer Science - Computer Graphics Laboratory
Lax-Wendroff
Taylor Series Expansions
Example
n 2D, inviscid flow, no body force, in non-conservation form n ρti,j – density at position (i, j ) and time t
n ρti,j , u ti,j , v ti,j are known
(∆ t )2
t
∂ρ ∂2ρ
t
∂ρ ∂u ∂ρ ∂v ∂ρ
= − ρ +u +ρ +v ρ it,+j ∆ t = ρ it, j + ∆ t + + ...
∂t ∂ ∂ ∂ ∂ y ∂t i , j ∂t
2
x x y i, j 2
∂u ∂u ∂u R T ∂ρ
(∆ t )
t
∂u ∂ 2u
t 2
= − u +v +
∂t ∂x ∂y ρ ∂x
u it ,+j ∆ t = u it, j + ∆ t + 2 + ...
∂t i , j ∂t i , j 2
∂v ∂v ∂v R T ∂ρ
= − u +v + ∂ 2 v (∆ t )2
t
ρ ∂ y ∂v
t
∂t ∂ x ∂y v it,+j ∆ t = v it, j + ∆ t + 2 + ...
∂ t i , j ∂t i, j 2
University of Freiburg - Institute of Computer Science - Computer Graphics Laboratory University of Freiburg - Institute of Computer Science - Computer Graphics Laboratory
•11
Taylor Expansion - Density Taylor Expansion - Density
(∆ t )
t
∂ρ ∂ 2ρ
t 2
∂ρ ∂u ∂ρ ∂v ∂ρ
= − ρ +u +ρ +v n mixed second derivatives can be obtained by differentiating
∂t ∂x ∂x ∂y ∂y the governing equations with respect to a spatial variable,
using second-order central differences e. g.
n 2
∂ u 2
∂ u ∂u
2 2
∂ u
2
∂ u ∂v R T ∂ ρ
2
R T ∂ ρ
= −u + +v + − 2 +
∂ x ∂t ∂ x 2 ∂ x ∂ x ∂ y ∂ y ∂ x ρ ∂ x ρ ∂ x 2
t u it+ 1, j − u it −1, j ρt − ρ it− 1, j − vit −1, j ρt − ρ it− 1, j
∂ρ
t
vt
= − ρ i , j + u it, j i + 1, j + ρ it, j i + 1, j + v it, j i + 1, j
∂t i , j 2 ∆x 2∆ x 2 ∆y 2∆ y n brackets missing on pp. 219, 220 in Anderson’s book!
University of Freiburg - Institute of Computer Science - Computer Graphics Laboratory University of Freiburg - Institute of Computer Science - Computer Graphics Laboratory
∂ x i, j
2
n summary
t
n solution techniques
∂ 2u ut + ut − ut − ut Lax-Wendroff
= i+1, j +1 i −1, j−1 i −1, j +1 i +1, j −1 n
University of Freiburg - Institute of Computer Science - Computer Graphics Laboratory University of Freiburg - Institute of Computer Science - Computer Graphics Laboratory
•12
MacCormack Technique MacCormack Technique
ρ it,+j ∆ t = ρ it, j + ∆t
n illustrated for density ∂ t i , j
av
∂ρ
ρ it,+j ∆ t = ρ it, j + ∆t n u, v are predicted the same way
∂t i, j
∂u ∂v
t t
University of Freiburg - Institute of Computer Science - Computer Graphics Laboratory University of Freiburg - Institute of Computer Science - Computer Graphics Laboratory
n corrector step for density n Lax-Wendroff and MacCormack can be used for
∂ρ
t + ∆t
u t + ∆t
−u t + ∆t
ρ t + ∆t
−ρ t+∆ t
v t+∆ t
−v t + ∆t
ρ t + ∆t
−ρ t + ∆t
unsteady flow
= − ρ it,+j ∆ t
i +1 , j i −1 , j
+ u it,+j ∆ t
i +1 , j i −1 , j
+ ρ it,+j ∆ t
i +1 , j i −1 , j
+ v it,+j ∆ t
i +1 , j i − 1, j
∂t
i , j 2∆ x 2∆x 2∆ y 2∆ y n non-conservation form
n conservation form
1 ∂ ρ
t + ∆t
∂ρ ∂ρ
av t
ρ it,+j ∆ t = ρ it, j + ∆ t = ρ i, j +
t
+ ∆t n viscous flow
∂ i, j ∂ i , j ∂t
t 2 t i , j n inviscid flow
n higher-order accuracy required to avoid numerical
n corresponds to Heun scheme for ODEs dissipation, artificial viscosity, numerical dispersion
n other higher-order schemes, e. g. Runge-Kutta 2 or 4, n note, that viscosity is represented by second partial
could be used as well derivatives in the governing equations
University of Freiburg - Institute of Computer Science - Computer Graphics Laboratory University of Freiburg - Institute of Computer Science - Computer Graphics Laboratory
•13
Outline Numerical Effects
University of Freiburg - Institute of Computer Science - Computer Graphics Laboratory University of Freiburg - Institute of Computer Science - Computer Graphics Laboratory
n artificial viscosity compromises the accuracy, but n governing equations for compressible flow
improves the stability of the solution n continuity equation, momentum equation
n adding artificial viscosity increases the probability of n Navier-Stokes (viscous flow) and Euler (inviscid flow)
making the solution less accurate, but improves n discussion of conservation and non-conservation form
the stability n explicit time-marching techniques
n similar to iterative solution schemes for implicit integration n Lax-Wendroff
schemes, where a smaller number of iterations introduces n MacCormack
“artificial viscosity”, but improves the stability n numerical aspects
n recent research in graphics
University of Freiburg - Institute of Computer Science - Computer Graphics Laboratory University of Freiburg - Institute of Computer Science - Computer Graphics Laboratory
•14
Recent Research Recent Research
M. Carlson, P. J. Mucha, G. Turk, “Rigid Fluid: Animating the T. G. Goktekin, A. W. Bargteil, J. F. O’Brien,
Interplay Between Rigid Bodies and Fluid,” Siggraph 2004. “A Method for Animating Viscoelastic Fluids,” Siggraph 2004.
University of Freiburg - Institute of Computer Science - Computer Graphics Laboratory University of Freiburg - Institute of Computer Science - Computer Graphics Laboratory
•15