Download - Introduction to Fluid Simulation
![Page 1: Introduction to Fluid Simulation](https://reader036.vdocuments.mx/reader036/viewer/2022062520/56815e6b550346895dccea81/html5/thumbnails/1.jpg)
The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL
Introduction to Fluid Simulation
Jacob Hicks4/25/06UNC-CH
![Page 2: Introduction to Fluid Simulation](https://reader036.vdocuments.mx/reader036/viewer/2022062520/56815e6b550346895dccea81/html5/thumbnails/2.jpg)
2The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL
Different Kind of Problem• Can be particles, but lots of
them• Solve instead on a uniform
grid
![Page 3: Introduction to Fluid Simulation](https://reader036.vdocuments.mx/reader036/viewer/2022062520/56815e6b550346895dccea81/html5/thumbnails/3.jpg)
3The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL
No Particles => New StateParticle• Mass• Velocity• Position
Fluid• Density• Velocity Field• Pressure• Viscosity
![Page 4: Introduction to Fluid Simulation](https://reader036.vdocuments.mx/reader036/viewer/2022062520/56815e6b550346895dccea81/html5/thumbnails/4.jpg)
4The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL
No Particles => New EquationsNavier-Stokes equations for
viscous, incompressible liquids.
fuuuu
u
pt 1
0
2
![Page 5: Introduction to Fluid Simulation](https://reader036.vdocuments.mx/reader036/viewer/2022062520/56815e6b550346895dccea81/html5/thumbnails/5.jpg)
5The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL
What goes in must come outGradient of the velocity field= 0
Conservation of Mass
fuuuu
u
pt 1
0
2
![Page 6: Introduction to Fluid Simulation](https://reader036.vdocuments.mx/reader036/viewer/2022062520/56815e6b550346895dccea81/html5/thumbnails/6.jpg)
6The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL
Time derivativeTime derivative of velocity field
Think acceleration
fuuuu
u
pt 1
0
2
au
t
![Page 7: Introduction to Fluid Simulation](https://reader036.vdocuments.mx/reader036/viewer/2022062520/56815e6b550346895dccea81/html5/thumbnails/7.jpg)
7The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL
Advection termField is advected through itself
Velocity goes with the flow
fuuuu
u
pt 1
0
2
![Page 8: Introduction to Fluid Simulation](https://reader036.vdocuments.mx/reader036/viewer/2022062520/56815e6b550346895dccea81/html5/thumbnails/8.jpg)
8The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL
Diffusion termKinematic Viscosity times Laplacian of u
Differences in Velocity damp out
fuuuu
u
pt 1
0
2
![Page 9: Introduction to Fluid Simulation](https://reader036.vdocuments.mx/reader036/viewer/2022062520/56815e6b550346895dccea81/html5/thumbnails/9.jpg)
9The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL
Pressure termFluid moves from high pressure to low pressureInversely proportional to fluid density, ρ
fuuuu
u
pt 1
0
2
![Page 10: Introduction to Fluid Simulation](https://reader036.vdocuments.mx/reader036/viewer/2022062520/56815e6b550346895dccea81/html5/thumbnails/10.jpg)
10The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL
External Force TermCan be or represent anythying
Used for gravity or to let animator “stir”
fuuuu
u
pt 1
0
2
![Page 11: Introduction to Fluid Simulation](https://reader036.vdocuments.mx/reader036/viewer/2022062520/56815e6b550346895dccea81/html5/thumbnails/11.jpg)
11The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL
Navier-StokesHow do we solve these equations?
fuuuu
u
pt 1
0
2
![Page 12: Introduction to Fluid Simulation](https://reader036.vdocuments.mx/reader036/viewer/2022062520/56815e6b550346895dccea81/html5/thumbnails/12.jpg)
12The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL
Discretizing in space and time• We have differential
equations• We need to put them in a
form we can compute
• Discetization – Finite Difference Method
![Page 13: Introduction to Fluid Simulation](https://reader036.vdocuments.mx/reader036/viewer/2022062520/56815e6b550346895dccea81/html5/thumbnails/13.jpg)
13The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL
Discretize in Space
X VelocityY VelocityPressure
Staggered Grid vs Regular
![Page 14: Introduction to Fluid Simulation](https://reader036.vdocuments.mx/reader036/viewer/2022062520/56815e6b550346895dccea81/html5/thumbnails/14.jpg)
14The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL
Discretize the operators• Just look them up or derive
them with multidimensional Taylor Expansion
• Be careful if you used a staggered grid
![Page 15: Introduction to Fluid Simulation](https://reader036.vdocuments.mx/reader036/viewer/2022062520/56815e6b550346895dccea81/html5/thumbnails/15.jpg)
15The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL
Example 2D Discetizations
-1 0 1
1
-1
1 -4 1
1
1
Divergence Operator Laplacian
Operator
![Page 16: Introduction to Fluid Simulation](https://reader036.vdocuments.mx/reader036/viewer/2022062520/56815e6b550346895dccea81/html5/thumbnails/16.jpg)
16The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL
Make a linear systemIt all boils down
to Ax=b.
dddd nnxnnx
bb
x
xx
2
1
2
1
??
?????
![Page 17: Introduction to Fluid Simulation](https://reader036.vdocuments.mx/reader036/viewer/2022062520/56815e6b550346895dccea81/html5/thumbnails/17.jpg)
17The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL
Simple Linear System• Exact solution takes O(n3)
time where n is number of cells
• In 3D k3 cells where k is discretization on each axis
• Way too slow O(n9)
![Page 18: Introduction to Fluid Simulation](https://reader036.vdocuments.mx/reader036/viewer/2022062520/56815e6b550346895dccea81/html5/thumbnails/18.jpg)
18The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL
Need faster solver• Our matrix is symmetric and
positive definite….This means we can use♦ Conjugate Gradient
• Multigrid also an option – better asymptotic, but slower in practice.
![Page 19: Introduction to Fluid Simulation](https://reader036.vdocuments.mx/reader036/viewer/2022062520/56815e6b550346895dccea81/html5/thumbnails/19.jpg)
19The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL
Time Integration• Solver gives us time
derivative• Use it to update the system
stateU(t+Δt)
U t
U(t)
![Page 20: Introduction to Fluid Simulation](https://reader036.vdocuments.mx/reader036/viewer/2022062520/56815e6b550346895dccea81/html5/thumbnails/20.jpg)
20The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL
Discetize in Time• Use some system such as
forward Euler.• RK methods are bad because
derivatives are expensive • Be careful of timestep
![Page 21: Introduction to Fluid Simulation](https://reader036.vdocuments.mx/reader036/viewer/2022062520/56815e6b550346895dccea81/html5/thumbnails/21.jpg)
21The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL
Time/Space relation?• Courant-
Friedrichs-Lewy (CFL) condition
• Comes from the advection term
uxt
![Page 22: Introduction to Fluid Simulation](https://reader036.vdocuments.mx/reader036/viewer/2022062520/56815e6b550346895dccea81/html5/thumbnails/22.jpg)
22The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL
Now we have a CFD simulator• We can simulate fluid using
only the aforementioned parts so far
• This would be like Foster & Metaxas first full 3D simulator
• What if we want it real-time?
![Page 23: Introduction to Fluid Simulation](https://reader036.vdocuments.mx/reader036/viewer/2022062520/56815e6b550346895dccea81/html5/thumbnails/23.jpg)
23The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL
Time for Graphics Hacks• Unconditionally stable
advection♦ Kills the CFL condition
• Split the operators♦ Lets us run simpler solvers
• Impose divergence free field♦ Do as post process
![Page 24: Introduction to Fluid Simulation](https://reader036.vdocuments.mx/reader036/viewer/2022062520/56815e6b550346895dccea81/html5/thumbnails/24.jpg)
24The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL
Semi-lagrangian Advection
CFL Condition limits speed of information travel forward in time
Like backward Euler, what if instead we trace back in time?
p(x,t) back-trace
![Page 25: Introduction to Fluid Simulation](https://reader036.vdocuments.mx/reader036/viewer/2022062520/56815e6b550346895dccea81/html5/thumbnails/25.jpg)
25The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL
Divergence Free Field• Helmholtz-Hodge Decomposition
♦ Every field can be written as
• w is any vector field• u is a divergence free field• q is a scalar field
quw
![Page 26: Introduction to Fluid Simulation](https://reader036.vdocuments.mx/reader036/viewer/2022062520/56815e6b550346895dccea81/html5/thumbnails/26.jpg)
26The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL
Helmholtz-Hodge
STAM 2003
![Page 27: Introduction to Fluid Simulation](https://reader036.vdocuments.mx/reader036/viewer/2022062520/56815e6b550346895dccea81/html5/thumbnails/27.jpg)
27The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL
Divergence Free Field• We have w and we want u
• Projection step solves this equation
q
q
q
2
2
wuw
uw
qwu
![Page 28: Introduction to Fluid Simulation](https://reader036.vdocuments.mx/reader036/viewer/2022062520/56815e6b550346895dccea81/html5/thumbnails/28.jpg)
28The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL
Ensures Mass Conservation• Applied to field before
advection• Applied at the end of a step
• Takes the place of first equation in Navier-Stokes
![Page 29: Introduction to Fluid Simulation](https://reader036.vdocuments.mx/reader036/viewer/2022062520/56815e6b550346895dccea81/html5/thumbnails/29.jpg)
29The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL
Operator Splitting• We can’t use semi-lagrangian
advection with a Poisson solver• We have to solve the problem
in phases
• Introduces another source of error, first order approximation
![Page 30: Introduction to Fluid Simulation](https://reader036.vdocuments.mx/reader036/viewer/2022062520/56815e6b550346895dccea81/html5/thumbnails/30.jpg)
30The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL
Operator Splitting
0 u
uu u2 p1 ftu
![Page 31: Introduction to Fluid Simulation](https://reader036.vdocuments.mx/reader036/viewer/2022062520/56815e6b550346895dccea81/html5/thumbnails/31.jpg)
31The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL
Operator Splitting1. Add External
Forces
2. Semi-lagrangian advection
3. Diffusion solve
4. Project field
f
uu
u20 u
![Page 32: Introduction to Fluid Simulation](https://reader036.vdocuments.mx/reader036/viewer/2022062520/56815e6b550346895dccea81/html5/thumbnails/32.jpg)
32The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL
Operator Splitting
u2f
uu
W0 W1 W2 W3 W4
u(x,t)
u(x,t+Δt)
0 u
![Page 33: Introduction to Fluid Simulation](https://reader036.vdocuments.mx/reader036/viewer/2022062520/56815e6b550346895dccea81/html5/thumbnails/33.jpg)
33The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL
Various Extensions• Free surface tracking• Inviscid Navier-Stokes• Solid Fluid interaction
![Page 34: Introduction to Fluid Simulation](https://reader036.vdocuments.mx/reader036/viewer/2022062520/56815e6b550346895dccea81/html5/thumbnails/34.jpg)
34The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL
Free Surfaces• Level sets
♦ Loses volume♦ Poor surface detail
• Particle-level sets♦ Still loses volume♦ Osher, Stanley, & Fedkiw, 2002
• MAC grid♦ Harlow, F.H. and Welch, J.E., "Numerical
Calculation of Time-Dependent Viscous Incompressible Flow of Fluid with a Free Surface", The Physics of Fluids 8, 2182-2189 (1965).
![Page 35: Introduction to Fluid Simulation](https://reader036.vdocuments.mx/reader036/viewer/2022062520/56815e6b550346895dccea81/html5/thumbnails/35.jpg)
35The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL
Free Surfaces
+
-
+ +
+ +
+
+
+
+
+ +
+
+
+
+
+
+
+
+
+
+ +
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
+
0
0
-
-
-
-
-
-
-
-
--
-
-
-
-
-
-
-
-
-
-
-
--
-
-
-
-
-
-
-
-
--
--
-
MAC Grid Level Set
![Page 36: Introduction to Fluid Simulation](https://reader036.vdocuments.mx/reader036/viewer/2022062520/56815e6b550346895dccea81/html5/thumbnails/36.jpg)
36The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL
Inviscid Navier-Stokes• Can be run faster• Only 1 Poisson Solve needed• Useful to model smoke and
fire♦ Fedkiw, Stam, Jensen 2001
![Page 37: Introduction to Fluid Simulation](https://reader036.vdocuments.mx/reader036/viewer/2022062520/56815e6b550346895dccea81/html5/thumbnails/37.jpg)
37The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL
Solid Fluid Interaction• Long history in CFD• Graphics has many papers on
1 way coupling♦ Way back to Foster & Metaxas, 1996
• Two way coupling is a new area in past 3-4 years♦ Carlson 2004
![Page 38: Introduction to Fluid Simulation](https://reader036.vdocuments.mx/reader036/viewer/2022062520/56815e6b550346895dccea81/html5/thumbnails/38.jpg)
38The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL
Where to get more info• Simplest way to working fluid
simulator (Even has code)♦ STAM 2003
• Best way to learn enough to be dangerous♦ CARLSON 2004
![Page 39: Introduction to Fluid Simulation](https://reader036.vdocuments.mx/reader036/viewer/2022062520/56815e6b550346895dccea81/html5/thumbnails/39.jpg)
39The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL
ReferencesCARLSON, M., “Rigid, Melting, and Flowing Fluid,” PhD Thesis, Georgia Institute of Technology, Jul. 2004.
FEDKIW, R., STAM, J., and JENSEN, H. W., “Visual simulation of smoke,” in Proceedings of ACM SIGGRAPH 2001, Computer Graphics Proceedings, Annual Conference Series, pp. 15–22, Aug. 2001.
FOSTER, N. and METAXAS, D., “Realistic animation of liquids,” Graphical Models and Image Processing, vol. 58, no. 5, pp. 471–483, 1996.
HARLOW, F.H. and WELCH, J.E., "Numerical Calculation of Time-Dependent Viscous Incompressible Flow of Fluid with a Free Surface", The Physics of Fluids 8, 2182-2189 (1965).
LOSASSO, F., GIBOU, F., and FEDKIW, R., “Simulating water and smoke with an octree data structure,” ACM Transactions on Graphics, vol. 23, pp. 457–462, Aug. 2004.
OSHER, STANLEY J. & FEDKIW, R. (2002). Level Set Methods and Dynamic Implicit Surfaces. Springer-Verlag.
STAM, J., “Real-time fluid dynamics for games,” in Proceedings of the Game Developer Conference, Mar. 2003.