Fluid Animation from Simulation on Tetrahedral Meshes

Transcription

Fluid Animation from Simulation on Tetrahedral Meshes
Fluid Animation from Simulation on Tetrahedral
Meshes
Bryan Eric Feldman
Electrical Engineering and Computer Sciences
University of California at Berkeley
Technical Report No. UCB/EECS-2007-153
http://www.eecs.berkeley.edu/Pubs/TechRpts/2007/EECS-2007-153.html
December 17, 2007
Copyright © 2007, by the author(s).
All rights reserved.
Permission to make digital or hard copies of all or part of this work for
personal or classroom use is granted without fee provided that copies are
not made or distributed for profit or commercial advantage and that copies
bear this notice and the full citation on the first page. To copy otherwise, to
republish, to post on servers or to redistribute to lists, requires prior specific
permission.
Fluid Animation from Simulation on Tetrahedral Meshes
by
Bryan Eric Feldman
B.S. (University of California, Davis) 2000
M.S. (University of California, Berkeley) 2002
A dissertation submitted in partial satisfaction of the
requirements for the degree of
Doctor of Philosophy
in
Computer Science
in the
GRADUATE DIVISION
of the
UNIVERSITY OF CALIFORNIA, BERKELEY
Committee in charge:
Professor James F. O’Brien, Chair
Professor Jonathan Shewchuk
Professor Panayiotis Papadopoulos
Fall 2007
Fluid Animation from Simulation on Tetrahedral Meshes
Copyright 2007
by
Bryan Eric Feldman
1
Abstract
Fluid Animation from Simulation on Tetrahedral Meshes
by
Bryan Eric Feldman
Doctor of Philosophy in Computer Science
University of California, Berkeley
Professor James F. O’Brien, Chair
This thesis presents a simulation method for creating animations of gases and liquids that enhances the adaptability over current simulators within the computer graphics
community. The method achieves adaptability in element size and shape by discretizing
the domain with tetrahedra rather than regular hexahedra, the standard element shape in
computer graphics. I also describe a method which allows the discretization to adapt arbitrarily from time step to time step without computational or numerical smoothing penalty.
Additionally, I demonstrate a method to augment the fluid simulator with a rigid body
simulator such that the fluid and rigid body simultaneously effect one another. Together
these capabilities allow for complex scenarios to be simulated with a high level of detail
while maintaining practical computation time, memory use, and ease of implementation.
2
Professor James F. O’Brien
Dissertation Committee Chair
i
Contents
List of Figures
iii
1 Introduction
1.1 Background . . . . . . . . . . . . .
1.1.1 Accuracy and Adaptivity .
1.1.2 Reference Frames . . . . . .
1.1.3 Prior Methods . . . . . . .
1.2 Contributions of This Dissertation
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
1
3
4
6
8
8
2 Previous Work
2.1 Two-Dimensional Approximations
2.2 Basic Three-Dimensional Simulator
2.3 Alternative Discretizations . . . . .
2.4 Maintaining and Enhancing Detail
2.5 Extensions . . . . . . . . . . . . . .
2.6 Fluid Control . . . . . . . . . . . .
2.7 Fluid-Solid Coupling . . . . . . . .
2.8 Moving Meshes . . . . . . . . . . .
2.9 Particle Based Methods . . . . . .
2.10 Surface Tracking and Rendering . .
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
14
14
15
17
18
19
21
21
22
23
25
3 Meshing
3.1 Gas Meshing —Variational Tetrahedral Meshing
3.1.1 Overview . . . . . . . . . . . . . . . . . .
3.1.2 Modifications . . . . . . . . . . . . . . . .
3.1.3 Comments . . . . . . . . . . . . . . . . . .
3.2 Liquid Meshing —Isosurface Stuffing . . . . . . .
3.2.1 Overview . . . . . . . . . . . . . . . . . .
3.2.2 Modifications . . . . . . . . . . . . . . . .
3.2.3 Comments . . . . . . . . . . . . . . . . . .
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
27
28
28
30
31
33
33
35
36
ii
4 Simulation
4.1 Overview . . . . . . . . . . . . . . . . . . . . . . .
4.2 Equations of Motion . . . . . . . . . . . . . . . . .
4.3 Where to Store Things . . . . . . . . . . . . . . . .
4.4 Capabilities Required for Simulation . . . . . . . .
4.4.1 Velocity Interpolation . . . . . . . . . . . .
4.4.2 Derivative Operators . . . . . . . . . . . . .
4.5 Semi-Lagrangian Velocity Advection . . . . . . . .
4.5.1 Generalized Semi-Lagrangian Advection . .
4.6 External Forces . . . . . . . . . . . . . . . . . . . .
4.7 Mass Conservation . . . . . . . . . . . . . . . . . .
4.7.1 An Alternative Perspective . . . . . . . . .
4.7.2 Boundary Conditions . . . . . . . . . . . .
4.7.3 Coupling Between Fluids and Rigid Bodies
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
38
38
39
42
43
44
47
54
56
59
60
63
65
68
5 Multigrid
5.1 Multigrid Background . . . . . .
5.2 Algebraic Multigrid Background
5.3 Details of our Implementation . .
5.4 Multigrid Discussion and Results
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
74
74
77
78
81
.
.
.
.
83
83
84
88
96
6 Results and Discussion
6.1 Gas and Non Free Surface Liquid
6.1.1 Two-Way Coupling . . . .
6.2 Free Surface Liquid Animations .
6.3 Overall Conclusions . . . . . . .
Bibliography
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
Animations
. . . . . . .
. . . . . . .
. . . . . . .
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
97
iii
List of Figures
1.1
1.2
1.3
1.4
3.1
3.2
4.1
A one dimensional representation of discretization and simulation. On the left
a continuous function (dashed line) is represented by discrete values (dots)
∂s
and an interpolation function (solid line). The spatial derivative, ∂x
is estimated. On the right are the discrete values at a later time. The values
are changed by the partial differential equations of motion and the estimated
spatial derivative. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Figure showing the advantage of spatial adaptivity. The representation on
the right uses just as many data point but better approximates the continuous
function.. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
A comparison of a regular grid (left) and tetrahedral (right) discretization
of the same shape. Despite the fact that the tetrahedral mesh uses fewer
elements, it better represents the input boundary. . . . . . . . . . . . . . .
Two frames from different animations that took equivalent times to simulate. On the left, a single fixed grid was used throughout the simulation.
On the right, the mesh is dynamically updated to place small elements near
the smoke and regions of high vorticity. The right animation features substantially less numerical smoothing despite taking the same time to simulate
(including mesh generation) as the left animation. . . . . . . . . . . . . . .
Left: a visualization of the sizing field for a rectangular domain with an
irregular obstacle at the top and a plume of smoke at the bottom. Right:
the resulting simulation mesh. Obstacle faces are colored green. . . . . . .
This figure illustrates the two-dimensional version of isosurface stuffing. Yellow points are the vertices of the octree lattice. The green line is the fluid’s
surface. Blue points represent the warped locations of lattice vertices that
were near the surface. Red points are vertices created where the surface cuts
the lattice with no nearby vertices. . . . . . . . . . . . . . . . . . . . . . .
Two-dimensional representation of velocity interpolation. A velocity vector
is computed for each tetrahedron from the face normal velocities. These velocities are at the vertices of the Voronoi cell. The velocity at some arbitrary
location x can be computed by interpolating the Voronoi cell. . . . . . . .
5
6
10
13
32
35
45
iv
4.2
4.3
4.4
4.5
4.6
5.1
6.1
Divergence (left) is estimated by summing the outward-facing face normal
velocities. In the figure s2 is negative because n2 points inward; all other
s’s are positive. The gradient (right) is estimated by taking the difference
between the pressures in the tetrahedra adjoining the face. . . . . . . . . .
Top left: If pressures are stored at circumcenters, the line connecting two
adjacent pressures passes through the face circumcenter (the edge midpoint
in 2D) and is parallel to the face’s normal. Top right: Circumcenters may lie
outside of an element such that the line segment between adjacent circumcenters does not intersect the face. Bottom left: In 3D the face circumcenter
(dark triangle) is not necessarily in the face, making it a dubious place to locate the face normal velocity for divergence calculation. Bottom right: Storing quantities at barycenters. The line segment connecting adjacent tetrahedra barycenters does not necessarily pass through the face barycenter and is
not generally parallel to the face normal. . . . . . . . . . . . . . . . . . . .
A 2D representation of our generalized semi-Lagrangian method. We trace
back from the position where a velocity is stored in the new mesh x̄i = (x, y),
interpolate the velocity using the old mesh and update the velocity in the
new mesh. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
A comparison of simulation with the same initial conditions on a static (top)
and deforming (bottom) mesh. The deforming mesh is being stretched and
squashed in the vertical direction. As shown the simulations are qualitatively very similar, demonstrating that mesh deformation does not effect the
simulation. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Left) Pressure forces on rigid object create a force/torque couple. Right)
The acceleration on the boundary (and hence the fluid simulation mesh faces
at this boundary) of the rigid body can be computed from the linear and
angular acceleration of the body. . . . . . . . . . . . . . . . . . . . . . . . .
50
53
57
57
73
An example of variable classification where c indicates that a triangle is
labeled as coarse and f indicates a fine label. We have shown a geometry so
that neighbor information is clear. In practice, the non-zero entries in the
system matrix are used to determine neighborhood information. Subscripts
indicate the order in which the variables are classified. For example, c0 is
added first (selected at random), then its neighbors are added as f1 ’s. Next c2
is added and its neighbors are labeled as f3 . Note that due to the classification
algorithm each fine variable has at least one coarse neighbor and that there
are relatively few coarse variable (8 of a possible 21). . . . . . . . . . . . .
79
A paddle translates and rotates with scripted motion, stirring up the smoke
in a box shape. On the right, the mesh is shown for three frames for this
example. The domain is remeshed every time step so that it’s boundary
conforms to the paddle. The sizing function changes from time step to time
step so that smaller tetrahedra are created near the paddle, as this is where
the most interesting motion occurs. . . . . . . . . . . . . . . . . . . . . . .
85
v
6.2
The leftmost image shows smoke inside the Stanford Buddha. The remaining
images show the progression of green smoke as it is exhaled out. Smoke
motion is induced by the motion of Buddha’s belly, which determines the
boundary conditions of the simulation domain. . . . . . . . . . . . . . . . .
6.3 This image shows smoke in a tube spinning and rising around a rotating
blade. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
6.4 A series of frames from a high resolution example with a jet shooting smoke
up towards several obstacle rods . . . . . . . . . . . . . . . . . . . . . . . .
6.5 Two animations where jets of air are shot towards a rigid bunny. The top
sequence features a light bunny; the bottom features a heavier bunny. As
expected, the light bunny is more affected by the cannon than the heavier
one. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
6.6 The central bulb expands and contracts with causes the red particles to move
from the left tank to the right tank. The blue valves are coupled to the fluid
simulation and prevent backflow. . . . . . . . . . . . . . . . . . . . . . . .
6.7 Liquid initially in the shape of an angel falls under gravity, creating a splash.
6.8 Two nozzles spray liquid onto a dish with a hump shape in the middle. . .
6.9 Water, initially in the shape of a block, falls under the force of gravity. A
half-hemisphere obstacle on the floor interacts with the moving liquid, as do
the boundaries of the domain. . . . . . . . . . . . . . . . . . . . . . . . . .
6.10 The meshes used to generate the animation in Figure 6.9. In the upper corner
of the second, third, and forth panels a zoom in view is shown. Note that
the elements become larger as the distance to the surface increases and that
the mesh conforms well to that surface yet is highly structured. . . . . . .
6.11 Liquid is sprayed inside a transparent box. A thin sheet folds over after the
spray hits the back wall. . . . . . . . . . . . . . . . . . . . . . . . . . . . .
6.12 Red Liquid erupts from a mountain (left). On the right a close up of the
pool at the bottom where the liquid accumulates. . . . . . . . . . . . . . .
86
86
87
89
90
91
92
93
94
95
96
vi
Acknowledgments
I’d first like to thank my parents for supporting me through the many years of my education.
I know they’ve had to put up with countless questions of “So ...Bryan is STILL in school?”.
Hopefully, the rewards I have gained from this experience have been worth the annoyances
I have created for you.
Of course without my advisor James O’Brien finishing the Ph.D wouldn’t be possible. I mean that not only because without his signature, the university won’t let me finish
but of course because of the countless hours working with me on the details of projects and
more importantly for the big picture things that I think are the most important part of
what I’ve learned, for guiding me in how to think about solving problems. I also will always
appreciate him taking the risk to work with a Mechanical Engineering student that didn’t
(doesn’t?) know that much about computers. I am indebted for his guidance in my transformation from an ignorant young grad student to a slightly less ignorant and substantially
older graduate.
All of those in Berkeley Computer Graphics and Vision group have been an absolute joy to work with and to know. Without them the grad school experience wouldn’t be
the great one that it has been. I especially want to thank all those who have a co-authored
papers or worked on projects with me, I apologize if working on those deadlines with me
shaved years off your life, hopefully those were the bad years anyways.
1
Chapter 1
Introduction
Animating fluids is an important capability to those in the computer graphics
industry. Examples of fluid motions that might be animated include common, everyday,
phenomena such as pouring a glass of water or exhaling of cigarette smoke, and (thankfully) extraordinary occurrences such as large scale explosions or tidal waves crashing into
metropolises.
Animating the motion of fluids by hand would often require much time and labor by
a skilled artist and ad-hoc procedural methods for generating the motion do not generalize
well. The main reason for these methods inadequacies is that fluid motion is extraordinarily
complex. The complexity of a fluids motion contrasts with the simplicity of the equations
that describe the fluid behavior (see Equations (4.1) and (4.2)). As a result, simulation,
which is driven by these equations, has proven to be an extremely effective method to
generate animations. This being the case, simulation methods have been widely investigated
in academia and are commonly used in production.
2
Simulations that provide realistic and detailed motion are extremely resource intensive. Even as computers increase in speed and memory, fluid simulations continue to
push the limits of the available computational power. Accordingly, those who use the simulators are in need of simulation methods that can increase the level of realism and detail
for a given computational budget.
In this work I present techniques that increase the efficiency of simulating fluids
for the application of generating realistic animations. The method achieves this goal while
maintaining the stability and ease of use and ease of implementation that is desired by
practitioners of computer graphics.
To accomplish these goals I investigate the use of tetrahedra as the discretizing
element. Tetrahedral discretizations offer important advantages over regular grids, the
commonly used discretization within computer graphics. First, because the size of the
tetrahedra can vary over the domain, computational resources can be allocated efficiently
by placing many small tetrahedra in regions where they are needed to resolve features of
the flow, and few larger tetrahedra can be placed in the less important regions. Second, the
shape of a tetrahedron is more adaptable than a cube. This shape adaptability means that
for a fixed amount of computation resources, the discretization mesh can more accurately
match a simulation domain. and therefore can create a more realistic animation. For these
advantages to persist as the simulation progresses the discretization needs to adapt to the
changing shape of the domain and adapt the regions where high resolution elements are
located. To accomplish this adaptation, I present a method that allows the discretization
to change over time without performance degradation.
3
Creating a realistic-appearing animation of gas or water is the primary goal of a
simulator designed for use in computer graphics. This is a different goal than simulation in
an engineering context, where the goal of simulation is predictive accuracy of real world fluid
properties. The goals within computer graphics and those in engineering are not disjoint,
and it is no coincidence that many of the methods used in computer graphics were first
developed for use in the engineering field. That said, ultimately the purpose of a computer
graphics fluid simulator is to generate an animation that is visually plausible, this goal
and others such as speed, stability, and ease of implementation take precedence over strict
guarantees of numerical accuracy.
1.1
Background
To give perspective on the differences between previous methods and the methods
presented in this thesis, I briefly review fluid simulation from a high level. Much of this
review spells out the desirable properties of a simulation method and motivates the novel
methods presented in this thesis.
In a computer simulation the fluid state s (velocity, pressure, temperature, etc.)
is discretized, meaning that the continuous properties of a real fluid are approximated by
a discrete set of state values located at selected points throughout the simulation domain.
The discretized fluid state serves as a description of these relevant fluid properties at a
discrete moment in time t. The state at an arbitrary point in the domain can be computed
by interpolating the discrete values.
The simulator computes the states at the discrete data points for a series of times,
4
s(t1 ), s(t2 ), . . . , s(tN ) such that temporal evolution of the discretized fluid properties follow
the equations of motion for a fluid. The equations of motion relate the temporal derivative
∂s
∂t
of fluid properties to (among other things) the spatial derivative
∂s
∂x
of fluid properties.
Mathematically this can be expressed as
∂s
=f
∂t
∂s
∂x
.
(1.1)
Spatial derivatives can be estimated from the discrete values by, for example,
taking derivatives of the interpolation function or, in our case, by utilizing Stokes Theorem.
In plain English, Equation (1.1) expresses the idea that the way the fluid velocity,
pressure, and temperature change over time depends on how these properties vary in space.
The significance of this is that the fluid properties can be simulated over time given some
initial state by executing the following steps:
1. Calculate spatial derivatives.
2. Use the equations of motion to determine a temporal derivative.
3. Apply this change to the initial properties to yield new fluid properties.
The fluid state over time can be determined by repeating the steps using the updated fluid
properties from one step as the new initial state in the next step.
1.1.1
Accuracy and Adaptivity
There are several factors that affect the accuracy of a fluid simulation. One of the
most important factors is the number of discrete values used to estimate the fluid properties.
If more discrete values are available to estimate the fluid, the continuous properties of a
5
s
∂s
∂x
s
∂s
∂t
x
x
Figure 1.1: A one dimensional representation of discretization and simulation. On the
left a continuous function (dashed line) is represented by discrete values (dots) and an
∂s
is estimated. On the right
interpolation function (solid line). The spatial derivative, ∂x
are the discrete values at a later time. The values are changed by the partial differential
equations of motion and the estimated spatial derivative.
real fluid can be better approximated by the interpolation function. This results in better
spatial derivative estimates, yielding more accurate simulations. Of course the downside of
using more discrete values is that it requires more work to store and compute these values.
One way to improve performance in this inherent trade-off is to put more discrete values
where the fluid properties vary the most, and place fewer discrete values in areas where the
fluid does not require as many discrete values to accurately approximate.
An example of a beneficial use of spatial adaptivity is a discretization of the ocean.
It is sufficient to describe the velocity a body of water with the velocity at a few locations if
that water is moving with near constant velocity, such as would be found in the deep ocean.
On the other hand, the velocity at many locations are needed to accurately describe the
fluid velocity in the turbulent motion of a crashing wave. The motion of an ocean can be
best approximated given a fixed budget of data values by placing a high density of points
near the shore and a low density out in the deep ocean where the motion is less interesting.
The location of desired high/low density points are often not as simple as the ocean
example where dense points are generally always near the shore and sparse points far from
6
s
s
x
x
Figure 1.2: Figure showing the advantage of spatial adaptivity. The representation on the
right uses just as many data point but better approximates the continuous function..
shore. More often the location of regions where computation effort is desired varies over the
course of the simulation. This points to the importance of being able to alter the location
and even number of simulation data points over the simulation in order to maintain the
benefits of spatial adaptivity.
1.1.2
Reference Frames
If the discrete values that are used to estimate the fluid state are placed at locations
in space that don’t change over time the simulation is said to take an Eulerian view. A
second alternative is the Lagrangian view where the discrete values are associated with a
particular lump of fluid mass and therefore move with the fluid. Lastly, the locations of
fluid values can be placed and moved arbitrarily. This reference frame is known as the
Arbitrary Lagrangian-Eulerian (ALE) view.
As an analogy, the flow of a river can be described with a fixed number of data
points in a number of different ways. In the Eulerian way, assistants wade out into the
river, stand fixed on the river bottom and report the fluid velocity that is flowing past
them over time. In the Lagrangian way, they float down the river on innertubes. Each
assistant describes the velocity that they are moving at over time. Lastly, in an ALE view
7
the assistants could swim around in the river, perhaps moving to points of the flow that
are interesting, and report how quickly the fluid was moving past them, and how fast they
were swimming.
Probably the most widely used perspective for performing fluid simulation is the
Eulerian approach. The primary advantage of the Eulerian approach is that this method is
amenable to use of a simulation mesh. A simulation mesh is a geometric structure which
partitions the simulation domain into simple elements, typically squares or triangles in 2D
and cubes or tetrahedra in 3D. The mesh functions as an organizational structure for the
discrete fluid values. It is used to define convenient interpolation functions of the discrete
values, and provides a clear specification for the region of space that each discrete value is
responsible for. As a result, the mesh simplifies the operations required for performing a
simulation such as interpolating the discrete data points, and estimating derivatives.
It is difficult to use a mesh with a Lagrangian view because, in a Lagrangian
method the data points follow the complex motion of the fluid. As a result, the mesh is
altered into a configuration that would make simulation impossible. Elements are twisted
into shapes that are numerically unsuited to represent a function or to compute a derivative.
Furthermore, mesh elements can become inverted, creating the nonsensical situation that
these inverted elements represent a negative volumes of fluid. To avoid these problems when
simulating a fluid with Lagrangian view, meshless methods can be used. These method build
no explicit partitioning of the space into elements nor do they force elements to maintain
neighborhood relations over the simulation. Rather points are allowed to move freely and
neighborhood relations are determined for each time step. Interpolation is performed by
8
taking weighted averages of a time steps current local neighboring data.
1.1.3
Prior Methods
The majority of simulation methods developed for computer graphics application
use an Eulerian approach and discretize the domain with cube elements. An all cube element
discretization is also referred to as a regular grid. The advantage of a regular grid is that the
discretization is easy to generate, interpolation is straightforward, and accurate derivatives
can be estimated using a simple finite difference method. The main disadvantage is that
this discretization is very inflexible because all elements are the same size and shape. As
a consequence many cubical elements are required to accurately represent the shape of the
fluid being simulated, in particular at irregular boundaries such as at interface of fluid and
an irregularly shaped obstacle or at the free surface of liquids. Inaccuracies in the shape of
the discretization can result in noticeable artifacts such as stair-stepping. Another result of
a regular grid discretization’s lack of adaptability is that with fixed element size the data
points distribution is uniform and can not take advantage of spatial adaptivity to focus
computation where the fluid motion is most interesting.
1.2
Contributions of This Dissertation
This dissertation presents methods that increase the adaptability of simulation
methods used for computer graphics. Care is taken to maintain, as much as possible, the
desirable properties of many of the prior graphics simulation methods; speed, stability, and
ease of implimentation/use. The methods presented in this thesis increase adaptability over
9
the prior methods in two ways. First, we demonstrate use of tetrahedra for discretizing the
fluid simulation domain. Secondly, we allow the mesh discretization to change arbitrarily
from time step to time step. The following paragraphs elaborate on these points and their
effects on the animations.
This dissertation describes simulation methods where tetrahedra are used to discretize the domain as opposed to the standard computer graphic discretization, regular
cubical elements. Tetrahedra are more adaptable in their shape, and unlike a regular grid
of cubical elements, their size can vary over the domain. These factors together allow
a tetrahedral mesh to conform well to the desired discretization boundaries, and to take
advantage of spatial adaptivity.
Conforming well to boundaries is important because if the elements do not match
the intended boundary well, noticeable artifacts can be seen in the motion of the fluid. With
regular grids, accurate matching of the boundary is achieved by using many small elements,
increasing the cost of simulation. With tetrahedra, larger elements can be used to match
the boundary with the same accuracy as a much larger number of regular grid elements. In
Figure 1.3 the same shape has been discretized in one case using cubes and in another using
tetrahedra. As shown, even though more elements are used in the cubical discretization,
the tetrahedral discretization does a much better job of representing the object’s boundary.
Spatial adaptivity allows efficient use of available computations resources. It allows
effort to be focused where it is most needed. Small tetrahedra can be placed near the
boundary, where the fluid exhibits turbulent motion, or generally wherever the fluid exhibits
features that a user thinks necessitate more detail. Following the recommendation of the
10
Figure 1.3: A comparison of a regular grid (left) and tetrahedral (right) discretization of
the same shape. Despite the fact that the tetrahedral mesh uses fewer elements, it better
represents the input boundary.
work by Losasso et al. [43] I defining regions of interest based on where the visible smoke is,
regions of high vorticity, or near boundaries. Away from these regions the size of tetrahedra
can grade to larger sizes, thus saving computational effort and memory. In Figure 1.4 we
show an example comparing a simulation using a static mesh to one that adapts to use
small elements where smoke and vorticity are. As shown in this example, for the same
computation time, the adaptive discretization creates an animation with substantially more
detail and less numerical smoothing.
The second way that the methods presented in this thesis increase the adaptability
of the simulation is by allowing the mesh to change from time step to time step. Changing the mesh allows it to adapt to changes in the simulation such as the location of the
boundaries or the regions where simulation effort is desired. This capability is important
to maintain the advantages that tetrahedra offer over the progression of the simulation.
11
The approach I take does not fall neatly into the above three reference frames,
Eulerian, Lagrangian, or ALE. It perhaps most closely resembles an ALE view as the mesh
is neither fixed in world or material coordinates, but the method we use to accomplish this
differs substantially from previous ALE approaches. Furthermore, since the topology and
the number of discretization points may change arbitrarily between time steps, our method
is more general than typical ALE methods, where some limited mesh movement is used,
and topological changes and changes in the number of discrete points are not handled.
The adaptability of size and shape that comes with of tetrahedra does not, unfortunately, come without cost. Most of the costs can be attributed to the loss of the structure
that is inherent to a regular grid discretization. The structured nature of a regular grid
allows for optimizations of both execution time and memory. Furthermore, generation of a
regular grid is trivial. Generation of unstructured tetrahedral meshes with suitable quality
elements is a difficult problem and so even the initial step of creating the mesh is an obstacle using a tetrahedral based simulator. In this work I show that by choosing appropriate
meshing methods and by taking advantage of properties of the resulting meshes, many of
the problems typically associated with tetrahedral meshes are mitigated and I obtain a
viable simulator.
The method I use to alter the mesh between time steps, on the other hand, incurs
little cost. A standard part of fluid simulation for computer graphics is performing semiLagrangian advection. I show in Section 4.5.1 that by making a simple generalization of the
procedure, a mesh can be changed essentially arbitrarily as part of this step. Furthermore,
the generalization does not degrade the simulation performance. The method is applicable
12
to both tetrahedral grids or regular grids, although a tetrahedral mesh is needed to fully
exploit the adaptability that the method offers.
Fluid simulation, in particular on tetrahedral meshes, has been widely studied
outside of the computer graphics in the computational fluid dynamics (CFD) community.
However, the goals of practitioners within the CFD community are fundamentally different
from the ultimate goal of this thesis. Generally, researchers outside of computer graphics
are concerned with creating simulations that accurately predict numerical behavior of a
fluid.
In this work I present a simulation method that uses a tetrahedral discretization
to create animations of liquids and gases that is designed to meet the needs and desires
of those in computer graphics. In particular the method is meant to be stable, efficient in
execution and memory usage, and fairly straightforward to implement. It achieves these
goals by applying methods that are well established in computer graphics to tetrahedral
meshes. Furthermore, when applying the simulator to free-surface liquids I chose a meshing
technique, [41], that has properties that can be exploited to maintain some of the computational and memory efficiency of a regular grid, yet retains much of the adaptability of
general tetrahedra.
13
Figure 1.4: Two frames from different animations that took equivalent times to simulate.
On the left, a single fixed grid was used throughout the simulation. On the right, the mesh
is dynamically updated to place small elements near the smoke and regions of high vorticity.
The right animation features substantially less numerical smoothing despite taking the same
time to simulate (including mesh generation) as the left animation.
14
Chapter 2
Previous Work
Fluid simulation has been a popular subject in computer graphics for many years.
Outside computer graphics, fluid simulation has a long history within engineering. I only
mention the most relevant papers from these fields here as the literature is so vast. Even
within computer graphics a massive number of papers have been published on the subject.
The following sections discuss a selection of these papers that have been influential in the
development of this thesis.
2.1
Two-Dimensional Approximations
In computer graphics the end goal is to generate an animation, and for liquids the
animation is of the liquid’s surface. If the motion of the surface is simple enough that it
can be represented by a height field than the simulation can be simplified substantially by
representing the liquid as a height field over a 2D domain.
This idea was first used in computer graphics by [52] who used sinusoidal functions
15
to describe ocean waves and simulated their evolution over time by computing the change
due to gravity.
Other early work by Kass and Miller [38] represent the fluid as a 2D height field
and simulated the height field with a partial differential equation (PDE) developed from
an approximation to the shallow water equations. The shallow water equations are a simplification of the 3D equations for a fluid to a 2D height field representation that a linear
pressure variation in height columns of the fluid. The result was a simple, fast, stable system
for generating wave motion. To allow for more dynamic splashes O’Brien and Hodgins [50]
present a hybrid 2D column of fluid and particle method. The first use of the Navier-Stokes
equations in the graphics community appears in a 2D version of the equations [8] where the
height of the liquid surface is determined from pressures computed in the simulation.
2.2
Basic Three-Dimensional Simulator
The 2D methods discussed above describe a liquid by specifying the height of the
liquid surface over a 2D plane. This description of the liquid is somewhat limited. For
example, it can not model an overturning wave where the liquid surface exists at multiple
heights. Additionally, the 2D simplification is not appropriate for gasses because the motion
of the gas throughout the 3D domain is of visual interest. To handle general liquids, Foster
and Metaxas [24] perform a full 3D Navier-Stokes simulation. This work is based on the
pioneering work of Harlow and Welch [30] who present an effective and often used Eulerian
grid based 3D simulator in the engineering literature. Foster and Metaxas not only prove the
feasibility and usefulness of such an approach to fluid animation but also discuss a number
16
of useful ideas in their paper including a staggered storage scheme for the fluid velocity and
pressure variables. They also introduce preliminary work on simulating situations where
a fluid interacts with a solid and vice versa. Lastly, the authors present preliminary work
on fluid control. Fluid control is the manipulation of natural fluid motion through control
forces to achieve some desired properties of the motion. The authors followed up the next
year with an application of the method to gases [25].
The paper “Stable Fluids” by Jos Stam [62] presents a number of important improvements to fluid simulation for graphics application. First, this paper presents the semiLagrangian advection technique. (The method was known in other fields and rediscovered
by Stam.) Semi-Lagrangian advection is an unconditionally stable method for simulating
the fluids advection. Explicit advection techniques, such as the one used in [24], are subject
to the CFL (Courant, Friedrich, Levy) stability condition. This condition states that the
time step for which an explicit method will remain stable is related to the velocity and
element size. For stability, the time step must be small enough such that the velocity field
could not propagate material more than an element size. The semi-Lagrangian technique is
not subject to any such condition on it’s stability. The simulation time step may be arbitrarily large, and while the accuracy of the solution may suffer, the method is guaranteed
not to go unstable. Robustness of the simulator is typically considered more important
than accuracy in computer graphics applications and for this reason the method is popular within the field. Furthermore, the semi-Lagrangian method is important to this work
because the extension of the semi-Lagrangian method that we describe allows us to change
meshes between time steps efficiently and accurately. Secondly, Stam uses the projection
17
approach of Chorin [11] to conserve mass instead of the relaxation technique used by Foster
and Metaxas [24]. With this approach mass conservation can be abstracted to the problem
of solving a large sparse linear system. Years of work on developing fast linear system
solvers can be leveraged to obtain an efficient mass conservation procedure.
2.3
Alternative Discretizations
The efficiency of the early 2D methods has been revisited in more recent work.
For explosions that do not interact with obstacles, the motion of the explosion is radially
symmetric. Rasumssen et al. [55] exploit this symmetry and generate high resolution
explosions by simulating with several high resolution, 2D domains that are rotated about
the axis of symmetry. Irving et al. [36] present a hybrid shallow water and 3-D fluid
simulator is used to model deep bodies of water by placing a layer of 3D voxels atop the
column elements of a shallow water method . The method can simulate 3D effects like
splashing and overturning waves at a cost somewhere between a 2D and 3D method. Stam
[63] presents a method for animating flow on 2D manifolds in 3D space by projecting the
simulation onto a subdivision surface .
Most work within computer graphics has used regular hexahedral grids. Regular
grids have the advantages that they are easy to generate and taking derivatives and interpolating the grid values is straightforward. The disadvantage of regular grids is that their
elements lack adaptability in shape and size.
Some authors have investigated alternative discretizations of the simulation domain. Lossaso and colleagues [43] develop a method that uses octree decomposition of
18
the domain allowing adaptive resolution. Tetrahedra allow for adaptation of both size and
shape, and a number of works have investigated their use for computer graphics fluid simulation. Feldman et al. [21] simulates gases with a static discretization that uses cubical and
a tetrahedral elements. Cubical elements are used in open regions and tetrahedral elements
are used near the boundaries, so the mesh can conform to complex boundaries. Wendt
et al. [69] use an all-tetrahedral mesh and a finite volume method to simulate both gases
and liquids interacting with complex obstacles. Elcott et al. [16] simulated fluids using
a vortex approach on tetrahedral meshes. Vortex methods simulate using the curl of the
velocity field to describe the liquid’s motion. When the velocity field is needed for smoke
or liquid surface advection it can be solved for from the curl. Shi et al. [60] use a surface
triangulation discretization to simulate fluid motion on the surface of objects. They describe interpolation and derivative operators using a triangle mesh and perform projections
of velocity onto the surface manifold.
2.4
Maintaining and Enhancing Detail
Generating fluid animations with detailed turbulent motion is very important to
computer graphics practitioners. However, direct simulation of turbulent effects is prohibitively costly. The vorticity confinement method was introduced to the graphics community [19] to address this issue. The method enhances the vortices already present in the
field which would otherwise be damped out from numerical smoothing. The vortex particle
method, [56], presents a more flexible method which can add vortices to a fluid by associating vorticity with particles that are advected with the flow. Rasmussen and co-authors
19
[55] use Kolmogorov noise to enhance motion in explosions at a scale more finely resolved
than the simulation scale. The detail of flames is enhanced in work by Hong et al. [33]. In
this work the characteristic cellular patterns observed in flames are achieved by augmenting
motion of the flame with equations from detonation shock dynamics.
2.5
Extensions
The basic fluid simulator presented by Stam [62] has been extended in a number
of ways to increase the type of fluids that can be modeled and to allow for more general
interaction with other materials. The basic method is extended to apply to high viscosity
fluids in “Melting and Flowing” [7]. By adding this capability, materials such as melting
wax, wet sand, and squirting tubes of toothpaste may be simulated. Elastic materials exhibit
forces that try to restore the material from a deformed configuration back to the original
configuration. The forces can be computed from the deformation which is locally described
by a strain tensor. For solids, the material can be simulated using a Lagranian method and
strain tensors can be calculated directly. Fluid simulators typically use Eulerian methods.
To simulate viscoelastic liquids, liquids that exhibit elastic behavior, Goktekin et al. [28],
advects and integrates the strain rate tensor so that elastic behavior can be incorporated
to fluid simulation on an Eulerian grid. Sand is simulated [71] as a fluid by adding sand
friction forces to a standard fluid simulator.
Nguyen and co-authors [49] simulate flames by using a level set to track the reaction
front, and by modifying the semi-Lagrangian advection to account for the reaction process.
Fire animations are generated by using a mix of procedural and simulation methods [42]
20
with the goal of creating controllable flames. Explicit complex reaction processes have been
modeled for graphics by Ihm et al. [35]. This allows for generation of the complex behavior
of interacting fluids by adding some simple rules for the different fluids’ interaction. As
an example one fluid making contact with another can generate fire and reactive product
which are all three effected heat and expansion created by reaction.
Explosions have been investigated in a couple of different works. The first such
work by Yngve et al. [70] uses a compressible method instead of using the standard incompressible assumption and models the blast wave of the explosion. Since compressible
simulations are very stiff and the blast wave moves very fast, this method requires very
small time steps. Later work, by Feldman et al. [20] ignores the largely invisible blast wave
and instead focuses on the fireball, the most apparent visual phenomena of the explosion.
By ignoring the blast wave and focusing on the fireball an incompressible fluid simulator can
be used by modifying the simulator to account for expansion of the fireball. Additionally,
this work uses a hybrid particle/grid method is used to account for interaction of fuel and
air.
In some situations surface tension effects and the interaction of air with a liquid
has a noticeable effect on the fluid motion. The paper “Discontinuous Fluids” [32] focused
on simulating these cases by describing methods to properly simulate the large discontinutiy
in material properties at the liquid-air interface. More recent work has looked at foam [39]
and frothing liquids [12]
21
2.6
Fluid Control
In a production environment it is very important to be able to generate an anima-
tion that meets some specified goals or has a particular look and feel. For example a film
director might request that smoke form the shape of a dragon after it is blown. Finding
initial conditions that happen to move smoke into the desired configuration is unlikely or
impossible. So fluid control is used to help “nudge” the fluid with forces to influence its
motion.
One of the first works on fluid control in graphics, “Controlling fluid animations”,
[26] manipulates the flow by altering boundary conditions and the fluid velocities and pressure. A keyframe approach to control was first introduced by Treuille et al. [66]. This paper
uses an optimization procedure to solve for control forces which manipulate smoke into the
keyframes. The optimization is quite expensive so in later work the authors utilize the
adjoint method, a method from the control and optimization engineering literature, to improve efficiency [46]. A non-optimal keyframe method also has been introduced for smoke
[18] and water [61]. A more subtle approach to fluid control, which uses user animated
control particles was introduced by Rasmussen and colleagues [54].
2.7
Fluid-Solid Coupling
Early fluid simulation papers realized the need for interaction between fluids and
moving objects. One-way coupling, from fluid to solid, is achieved [24] by using the fluid
velocity to passively advect soda cans in the water.
Two-way coupling between explosions and fracturing solids was presented by Yn-
22
gve et al. [70] in the context of compressible fluid simulation. To obtain two way coupling
in an incompressible simulator, “Rigid Fluid” [6] simulates the solid as a fluid and then
projects all velocities within the solid to act rigidly. This method generates convincing
results in most situations and incurs relatively little overhead. One problem is that when
the velocities are altered to act rigidly, the divergence-free condition is broken in the cells
that surround the rigid body. This problem is addressed in this thesis by performing the
coupling simultaneously. A method for simulating the interaction of fluid and deformable
thin sheets is presented by Guendleman et al. by [29]. The interaction is achieved by alternating steps of simulating the fluid with fixed boundary conditions for the deformable
body, then performing the deformable body simulation fixing the pressure from the fluid
simulation. Alternatively, the coupling between fluid and deformable bodies and the fluid
can be performed simultaneously as is done in Chantenez et al. [10].
2.8
Moving Meshes
Prior work on moving meshes has been investigated in graphics albeit in a substan-
tially more limited fashion than what is presented in this thesis. The method by Rasmussen
et al. [54] translates the grid by cell size units so that the locations where velocities are
stored in the previous mesh overlap with the locations in the new mesh. This allows the
mesh to be moved without interpolating velocities on the new mesh and therefore avoids the
problem of numerical diffusion created by interpolation. The principle of Galilean Invariance
is used by Shah et al. [58] to allow meshes to translate with some moving reference frame
such that the grid can follow, for example, a plume of rising smoke. This prevents the need
23
for large simulation domains where much of the simulation domain contains velocity values
that do not effect the smoke. The method I present in this thesis which first appeared in
the paper “Fluid in Deforming Meshes” [22] allows for substantially more freedom in mesh
changes. This first paper has examples with affine transformations and simple deformation
of meshes while in later work with Klingner et al. [40] we demonstrate that the method
is applicable to meshes that move, deform, and alter topologically. In a related work by
Bargteil et al. [4] the idea of altering a mesh over the course of simulation is applied to
Lagrangian simulation of highly deformable plastic solids.
2.9
Particle Based Methods
The most common way fluids are simulated is by discretizing the domain with a
mesh and representing properties of the fluid using discrete values on that mesh that remain
fixed in world space, an Eulerian view. Alternatively, the fluid can be described by meshless
particles that are advected with the flow where each particle represents some lump of fluid
mass (Lagrangian). Smoothed Particle Hydrodynamics (SPH) defines continuous functions
of fluid values from the discrete particles by taking a weighted average of surrounding
particles. Weights are determined using densities that are attached to the particles and
smoothing kernels which fall off with distance. From these functions derivatives of the state
properties can be formulated. SPH was first introduced independently by Ginggold and
Monaghan [27] and Lucy [44]. The SPH method was introduced for use in graphics by
Desbrun and Cani, [14]. It has been used in a number of situations including lava, [64],
boiling water, [48], and soft bodies [13]. Mueller et al. [47] perform an SPH method with a
24
small number of particles (5̃000) achieving real time results. Adams et al. [1] use adaptively
sized particles in order to have a multi-resolution simulation. This allows computational
effort to be focused in areas that most benefit from the increased resolution. The results of
this work are visually compelling and are generated in times very competitive with regular
grid methods.
One draw back of the SPH method is that incompressibility is not enforced. As
a result, visible compression can be noticed unless the fluid is simulated with a very high
resistance to any compression. For the system to remain stable with this large compression
resistance very small time steps are required. An alternative approach introduced by Premoze et al. [53] uses of the Moving Particle Semi-Implicit method which is a particle based
method that explicitly enforces a divergence free velocity field. This work generated impressive results, and unlike previous particle methods, it rendered the surface using a level
set method, instead of defining the surface using an implicit function by the simulation
particles such as in Cani et al. [5].
Within academia at least, particle based implementations have yet to produce the
visual realism of grid based methods. Despite this they promise to be an interesting avenue
of future research. It is noteworthy that one of the most popular commercial software
packages “Real Flow”
1
is SPH based and has been used in production movies a number of
times although specific details of their implementation are unknown.
1
http://www.nextlimit.com/realflow/
25
2.10
Surface Tracking and Rendering
In order to simulate a liquid, the location of the liquid must be updated as it
moves over the duration of the simulation. Early methods, for example by Foster et al.
[24] advect particles to determine which computational elements contain liquid and assume
that the remaining elements contain air. The disadvantage is that it requires a storing
and advecting large number of particles because a dense collection of particles are needed
throughout the liquid. Another disadvantage is that the methods used to reconstruct the
liquid surface for rendering from particles tend to generate “blobby” or lumpy surfaces. A
new equation to generate an implicit function from the particles that helps alleviate this
problem is presented in a paper by Zhu and Bridson [71]. They also discuss a method
to filter away some of the remaining blobbyness, although this unfortunately also smooths
away some of the surface detail.
Level-Set methods [57] are a popular way to track the surface. They represent
the fluid surface as the zero set of a three-dimensional distance to the surface function.
The method works well because it naturally handles the complex topological changes in
the liquid surface and also generates high quality surfaces. One problem with a pure level
set method is that they suffer from noticeable mass loss. This problem arises because the
level set function is stored on a grid. When liquid features, such as thin sheets of liquid,
become smaller than the grid resolution, these features can not be represented by the grid
and are therefore lost. To help alleviate this problem Foster et al. [23] advects particles
that are initialized inside the liquid, near the surface. In thin regions, the particles are
used to reconstruct the surface instead of the level set, as it is known that the level set
26
methods lose mass in these regions. The following year, Enright et al. [17] showed that
by advecting particles initialized on the exterior of the surface in addition to the interior
particles improved results further. An alternative method, the semi-Lagrangian contouring
method [65] [3] corrects the level set function with a triangle mesh. Hierarchical Run
Length Encoded Level Sets [34] is a method to compactly represent the level set function,
conceptually similar to sparse matrix storage schemes for matrices. This enables very high
resolution level set functions to be stored, which means small features can be represented
thereby improving the mass loss problem.
27
Chapter 3
Meshing
In this chapter we describe the algorithms used to generate meshes for the gas and
liquid simulators. We adapt existing meshing algorithms, “variational tetrahedral meshing”
(VTM) [2] for the gas simulator and “isosurface stuffing” (ISS) [41] for our free surface liquid
simulator. We describe these methods only to a level of detail to provide an understanding
of the resulting meshes. Also we include details of the modifications or extensions we found
necessary for our application. For a thorough description of original implementation details,
analysis, and derivations the reader should refer to the original papers.
There are a number of differences between the two meshing techniques that determine which is the more appropriate choice for a particular application. The VTM method
creates unstructured Delaunay tetrahedral meshes while ISS creates semi-structured tetrahedral meshes. For a given number of tetrahedra, ISS is substantially faster at generating
the tetrahedralization. Furthermore, as discussed in Section 3.2.3, the semi-structured nature of the ISS can be exploited for memory and execution time optimizations. However,
28
for the same number of tetrahedra, VTM is more flexible in how it can distribute the tetrahedra. Of particular consequence is how adaptable it is in refining certain regions and how
well it can create a tetrahedralization that has boundaries of some shape. In our experience,
a gas simulator requires much less resolution than a free surface liquid simulator. Our gas
simulations use a relatively small number of elements (∼ 100, 000), and therefore we find
the VTM’s ability to better distribute the tetrahedra is required to ensure that the desired
refinement and matching of input boundaries is achieved. On the other hand our liquid
simulations use a large number of tetrahedra (∼ 1 − 3 million). In order to generate such
large meshes in an amount of time that does not dominate the overall simulation time we
require the ISS method. Furthermore, the semi-structured nature of the mesh allows for
optimizations in the simulation methods that are significant in speeding up simulation time.
3.1
Gas Meshing —Variational Tetrahedral Meshing
This section describes the high level properties of variational tetrahedral meshing
as well the modifications to make it work in the gas simulator.
3.1.1
Overview
Variational tetrahedral meshing takes as input 1) a surface mesh that specifies the
boundary, and 2) a sizing field that specifies the desired tetrahedral size throughout the
domain. It returns an unstructured Delaunay tetrahedral mesh with a boundary surface
that approximates the input surface mesh. To generate a tetrahedralization that has tetrahedra with shapes that are well suited for simulation, the method performs an iterative
29
procedure that minimizes an energy function by alternately improving the mesh topology
and improving the vertex positions.
The energy function is motivated by properties of the Delaunay triangulation. The
Delaunay triangulation of a set of vertices is the triangulation such no vertex is contained by
the circumsphere of any simplex of the triangulation. A related property is that the topology
the Delaunay triangulation is determined by the convex hull of the parabolic lifting map of
the set of vertices. The parabolic lifting map in 3D is
(x, y, z) → (x, y, z, x2 + y 2 + z 2 ).
Delaunay triangulations have a number of desirable properties. This motivates
defining an energy function which is minimized by a Delaunay triangulation. An energy
which meets this criterion and also is minimized by a uniform distribution of vertices is
the integral of distance between the piecewise linear convex hull of the lifted triangulation
and the continuous lifting parabola (x2 + y 2 + z 2 ). Specifically, the energy function can be
expressed as
p=
i=1...N
Ωi
||x − xi ||2 dx
where xi is a vertex position, Ωi is the union of tetrahedra adjoining vertex i and N is the
total number of vertices in the mesh.
The tetrahedron shapes are optimized by adjusting the vertices positions to minimize this energy given the current topology. The paper [2] shows that the energy function
is locally minimized by moving a vertex to the weighted average of the circumcenters of the
vertices adjoining tetrahedra. Alternate steps reduce the energy by improving the topology,
via Delaunay Tetrahedralization.
30
To adjust the tetrahedralization so that its boundary approximates the input surface, an additional step first seeds a large number of quadrature points on the surface. For
every quadrature point, the closest mesh vertex is found. Every mesh vertex that was found
to be closest to a quadrature point is moved to the average of quadrature points that it was
closest to.
3.1.2
Modifications
Our implementation differs from the original algorithm in a couple of details. As
in the original method, refinement of the mesh is controlled by a sizing function μ(x) that,
for any point x in the simulation domain, is the desired local edge length of the tetrahedra.
The original algorithm builds the sizing function based off of the boundary local feature
size and the distance to the mesh boundary. In our implementation we are concerned with
maintaining vorticies in the simulation, approximating obstacles well, and with making
sure that the simulation is has a lot of detail where the smoke is (since this is the visually
observable region). Given these priorities we formulate the sizing function at a point in
space x as:
μ(x) = k0 + min [kd d(x), ks (1 − s(x)) , kω (1 − ω(x))] .
(3.1)
In this equation, k0 is an offset value that controls the minimum value of the sizing field,
and hence the minimum local edge length of tetrahedra. The variable d(x) is the distance
to the closest obstacle or boundary that demands refinement, s(x) is a function of the
density of smoke particles, and ω(x) is the magnitude of the velocity field’s vorticity at
x. The parameters kd , ks , and kω respectively control the influence that each factor has
31
on the sizing field. These three factors are the same as those used for octree refinement
in [43]. Figure 3.1 shows an example of a sizing field and the resulting mesh. Figure 1.4
demonstrates the benefits of refinement near areas of high vorticity and smoke density.
One other modification we made to the algorithm is that, when optimizing the
vertex positions, we move vertices to the averages of the barycenters, instead of the circumcenters, of the surrounding tetrahedra. The primary motivation for this decision is that a
circumcenter position can be arbitrarily far from its tetrahedron. For tetrahedra near the
surface, it is not uncommon to have a circumcenter that is very far from the mesh, even
in a Delaunay mesh. In this case the optimization procedure described above will move a
vertex very far from its original position even moving it far outside the surface mesh. When
we use the barycenters, the behavior is much more stable. We have found that while this
slightly decreases the average quality of tetrahedra in the mesh, it often leads to substantial
improvements in the quality of the worst elements of the mesh, which are of more concern
for numerical simulation.
3.1.3
Comments
Overall, VTM works well for our purposes. It reliably generates meshes of suitable
quality for simulation in an acceptable amount of time. To take advantage of the fact that
the input surface and sizing field change very little from one frame to the next, we use
the mesh from the previous frame as an initialization for creating the new mesh. This
produces a good mesh within a few iterations. One area for improvement would be to take
advantage of the fact that in the vertex optimization step most of the vertices are moved
a very small distance. In our implementation, the Delaunay tetrahedralization ignores the
32
Figure 3.1: Left: a visualization of the sizing field for a rectangular domain with an irregular
obstacle at the top and a plume of smoke at the bottom. Right: the resulting simulation
mesh. Obstacle faces are colored green.
topology from previous iterations, instead it regenerates the triangulation from scratch each
time. The star splaying algorithm [59] describes a method for quickly repairing a Delaunay
tetrahedralization after vertex positions have moved. Inclusion of this in our implementation
would no doubt improve the meshing time.
It is important to note that the procedure is not guaranteed to generate good
simulation tetrahedra. Delaunay tetrahedralizations are happy to admit sliver tetrahedra,
flat tetrahedra that in a Delaunay mesh have vertices lying on or near the equator of
the tetrahedra’s circumsphere. Sliver tetrahedra have a number of properties that make
them poor elements to perform simulation on (near zero volume, large and small dihedral
angles etc.). To get rid of sliver tetrahedra a post processing step is employed which jitters
boundary vertices of sliver tetrahedra and inserts a new vertex at the sliver tetrahedron’s
center. These steps were helpful, but they did not completely eliminate all the slivers.
Although in our simulations we occasionally ended up with meshes that contained poor
33
quality elements, we did not observe noticeable artifacts in the animations we generated.
One appealing feature of this algorithm is that it does not attempt to create a
tetrahedralization with vertices that lie exactly on the input surface mesh. Initially this
may sound like a disadvantage, but often the input surface mesh is only an approximation to
the surface that we want the tetrahedralization to conform to. Experience has shown that
often low quality tetrahedra appear on or very near the surface. Placing strict conformity
requirements on the tetrahedra near the surface only makes it more difficult to get rid of
the troublesome tetrahedra. We obtain a mesh whose boundary is an approximation of the
input surface, but has fewer bad tetrahedra near the surface.
3.2
Liquid Meshing —Isosurface Stuffing
This section describes the essential details of the isosurface stuffing meshing algo-
rithm. Furthermore, we discuss the particulars of our implementation and its application
for use in the liquid simulator.
3.2.1
Overview
Isosurface stuffing takes a level set function as an input and returns a body centered
cubical (BCC) lattice tetrahedral mesh that is modified such that its boundary conforms
well to the surface defined by the zero isocontour of the input function. The mesh has
guaranteed quality elements and can be generated “whip fast.”
The first step of the meshing algorithm is to build a balanced octree that covers
the volume to be meshed and that is refined to the levels desired by the user. In our
34
implementation the octree is refined to the finest level where the liquid surface is and
grades to the coarsest level as quickly as is allowed by a balanced octree requirement.
Alternatively, the user can specify whatever refinement criterion is desired, for example
the criteria described in Section 3.1. One current limitation is that the guarantees on the
mesh quality are severely degraded if the octree level varies over the cells that intersect the
isosurface. Cells of the octree that lie completely within the liquid surface are filled with
tetrahedra that have vertices at the corners and center of the cell. If a cell is adjacent to
another cell that is refined to a finer level than itself, then vertices will also appear at the
face and edge centers of the first cell. The tetrahedra are built from templates for each of
the possible relative refinement levels of a cells neighbors.
Tetrahedra in cells that are sliced by the zero set of the level set function are
modified so that they conform to the surface. We refer to the unmodified tetrahedra of
the BCC lattice as background tetrahedra. First, the locations are found where the surface
intersects the edges of the background tetrahedra. The location of an intersection can be
found by querying the implicit function in a binary search along the edge. If the distance
between a lattice vertex and an edge crossing is smaller than some fraction of the edge’s
length, the vertex is moved to the closest crossing. Otherwise new vertices are added at the
edge crossing locations, and the portion of each sliced background BCC tetrahedra that is
inside the surface is filled with smaller tetrahedra. These tetrahedra can also be built from
templates that depend on the number of vertices of the background tetrahedra that have
been warped to the surface and how many edge crossings there are.
For a description of each of the possible templates we refer the reader to [41].
35
Figure 3.2: This figure illustrates the two-dimensional version of isosurface stuffing. Yellow
points are the vertices of the octree lattice. The green line is the fluid’s surface. Blue points
represent the warped locations of lattice vertices that were near the surface. Red points are
vertices created where the surface cuts the lattice with no nearby vertices.
Figure 3.2 shows an example of how this approach can be applied to a two-dimensional
triangulation. We also refer the reader to [41] for a detailed discussion of how this meshing
algorithm is guaranteed to produce good-quality tetrahedra. Briefly, the strategy generates
good quality tetrahedra because in the interior it uses high quality tetrahedra generated
by the BCC lattice. Near the boundary it only moves the lattice vertices if the distance is
sufficiently small to prevent creating bad tetrahedra. Otherwise it adds a vertex to an edge
that is far enough away from existing vertices to avoid creating new thin tetrahedra.
3.2.2
Modifications
The algorithm works extremely well but as we use it in particular situation, a few
minor modifications are needed. In a simulation the zero-contour of the implicit function
which defines the liquid surface will typically not conform perfectly to an obstacle that the
fluid is interacting with. This is due to small errors in the surface advection and because
36
a grid with finite resolution is used to represent the implicit function. To avoid errors
that could lead to meshing inside the obstacle or artificial gaps between the obstacle and
fluid, we build a negative signed distance function for each obstacle, then intersect it with
the signed distance function for the liquid and use the result as the input of the meshing
algorithm. After the mesh is built, vertices that are within some small tolerance (we use
1/8 the edge length of the finest octree level) of an obstacle are moved along their normal
direction to snap to the obstacle. We have found that moving them this small distance does
not introduce bad quality tetrahedra.
A mesh face on the boundary of the mesh is classified as liquid-obstacle interface
if all of its vertices lie on the obstacle. All other boundary faces are classified as liquid-air
interface.
3.2.3
Comments
Isosurface stuffing makes it feasible to simulate liquid with a large number of
tetrahedra (in our examples ∼ 1 − 3 million). The main advantage of the isosurface stuffing
algorithm is its speed and quality guarantees. Because we use a different mesh every time
step (to have a mesh that always conforms well to the moving liquid surface) it is imperative
to generate meshes quickly. Good quality tetrahedra are needed because poor quality
tetrahedra create simulation errors that can result in noticeable unnatural motion in the
resulting animation.
A more subtle reason that isosurface stuffing makes the simulator feasible is that
the meshes it creates exhibit structure that I aggressively exploit. For one, the meshes
contain many tetrahedra that are identically shaped. Therefore, important geometric prop-
37
erties that are used in the simulator such as tetrahedra volumes, face areas, and face normals
are the same for a large number of elements, and much memory can be saved by only storing the geometric properties for the set of template shapes. When the geometric quantities
for a particular tetrahedron are needed they can be obtained by referencing its template
shape. In a typical simulation we find that, on average, approximately 2/3 of the tetrahedra
come from template shapes. Another aspect of the mesh’s structure that we exploit is the
spatial structure of each element’s location. As shown in Figure 6.10 the tetrahedra are
positioned relative to the background octree structure. We take advantage of this structure
when determining which tetrahedron contains some query point. First, we determine which
leaf of the octree the point is in. Then we determine which portion of that cell it is in to
efficiently find the appropriate tetrahedra.
The advantages offered by the structure inherent to isosurface stuffing allow for
similar optimizations used with regular grids to be applied to the more adaptable tetrahedral
mesh. While still not as memory or computationally efficient on a per-element basis as
regular grids, we feel that the features of isosurface stuffing that we exploit allow for a
very favorable compromise between the grading of tetrahedral meshes and the efficiency of
regular grids.
One disadvantage of isosurface stuffing is that there is not complete freedom in the
shape of the tetrahedra. For example, grading of the mesh is limited to octree refinement
which means that tetrahedra can only be a discrete set of sizes. Taken in consideration
with the numerous advantages that isosurface stuffing has to offer, we find this penalty
insignificant and a price we are happy to pay.
38
Chapter 4
Simulation
4.1
Overview
After a mesh is generated we can associate fluid properties such as velocity and
pressure with each mesh element. With these variables and an interpolation method, we can
describe the fluid properties everywhere within the domain using a finite number of variables.
Simulation is the process of determining these fluid property variables at instances in time
such that the evolution of the discrete fluid approximates the behavior of a real fluid.
Simulation starts with an initial state for the fluid. This includes specifying the
fluid domain (the volume of fluid we wish to simulate) and fluid properties within that
domain. From this initial description of the fluid, we evolve the fluid over time using the
following steps.
1. Mesh the fluid domain (as described in Chapter 3).
2. Alter the fluid properties according to the governing equations of motion of the fluid.
39
3. Alter the fluid domain by the fluid velocities, or by scripted motion of internal objects
or external boundaries.
The simulation repeats this process using the updated fluid properties (computed
by step 2) as initial fluid properties, and using the updated fluid domain (computed by step
3) as the initial domain in the next iteration through the steps. The simulation domain
of a liquid with a free surface is altered by the motion of the liquid. Accurately tracking
the domain is a difficult problem and the subject of much research. In our implementation
we use the semi-Lagrangian contouring technique of Bargteil et al.[3]. At the boundary
between a fluid and a solid object, the domain can change by either scripted motion of the
object or by the interaction of the fluid with the object. The first case is trivial since it is
a specified motion. We describe a method for simulating the two-way interaction between
a fluid and a rigid body in Section 4.7.3.
This chapter is mainly concerned with step 2 above, altering the fluid properties
such that they change according to the governing equations of motion of the fluid. In
this chapter I first describe the equations used in this work. Next, I discuss how to alter the discrete fluid variables on a tetrahderal mesh discretization such that they evolve
approximately according to the equations of motion.
4.2
Equations of Motion
The differential equations that describe the evolution of the fluid velocity are the
Navier-Stokes equations. They are the conservation of momentum for a fluid,
∂u
f
∇p
= − (u · ∇) u + −
∂t
ρ
ρ
(4.1)
40
subject to the conservation of mass for incompressible fluids,
∇ · u = 0.
(4.2)
In these equations, u is the fluid velocity vector field, t time, p pressure, ρ density and f
is a volume normalized external forces. The symbol ∇ denotes the vector of differential
operators ∇ = [∂/∂x, ∂/∂y, ∂/∂z]T .
The first term on the right side of Equation (4.1), − (u · ∇) u is the advection term
which accounts for the change in velocity due to transportation of the fluid momentum.
The second term, f /ρ, accounts for acceleration due to external forces applied to the fluid.
External forces include buoyancy, gravity, or other forces specified by the user such as a jet
or control forces. The last term accounts for acceleration due to pressure forces.
These equations incorporate the common simplification of modeling the fluid as
incompressible. In reality, no fluid is truly incompressible, but visually, most fluid motions
we are interesting in animating approximate ideal incompressible fluids. Air and water do
not exhibit visually significant compression except under somewhat extraordinary circumstances, for example an explosion. Furthermore, the effects of the compression propagate
very rapidly, meaning that they move across simulation domains at time scales that are
much smaller than typical time scales used in computer graphics animation. Lastly, the
pressure shock waves that occur in explosions also occur on very small spatial scales as well.
The fact that compressible effects are rare, and even when observed occur faster and smaller
than would be observed is fortunate as the equations that include the effects are very stiff,
requiring very small time steps and small meshes to accurately resolve. Modeling fluids as
if they were incompressible allows us to make significant simplifications to the simulation
41
method and to use much larger time steps.
To update the fluid properties from time step to time step we integrate the momentum equation, Equation (4.1), forward in time using the operator splitting technique.
Operator splitting integrates the state forward by considering one term of the differential
equation at a time. Specifically, for Equation (4.1) we alter the velocity first by the advection term, then by the external force term, and lastly by the pressure term. As part of the
pressure step, a pressure is solved for such that when the velocity field is altered by the
pressure term the resultant velocity conserves mass, (it obeys Equation (4.2)).
The advantage of using operator splitting is that one may choose the most appropriate method of integration for each term, instead of trying to devise a method that
works well for all parts of Equation (4.1). For graphics applications, the semi-Lagrangian
technique is an attractive choice for performing advection. In addition to its well-known
stability and simplicity advantages I introduce in Section 4.5.1 a simple generalization of
original semi-Lagrangian method that allows arbitrary changes in the discretization mesh
between time steps. Next, we integrate the external force term using forward Euler integration (described below). Lastly, we form and solve for pressure such that when we apply
forward Euler integration of the pressure term, mass is conserved.
Forward Euler integration is a commonly used temporal integration technique. Its
advantage is its simplicity. It is the method of choice in most graphics applications. The
method estimates the temporal derivative using the state at the beginning of the time step,
and then assumes that the derivative is constant over the entire step. The state s(t) is
42
updated by the formula
where
∂s ∂t s(t)
∂s s(t + Δt) = s(t) + Δt
∂t s(t)
is the derivative evaluated using the state at time t.
The following steps show the momentum integration steps as a whole;
uadv = semiLag(u(t), t)
f
ρ
−∇p
.
u(t + Δt) = uext + Δt
ρ
uext = uadv + Δt
4.3
(4.3)
(4.4)
(4.5)
Where to Store Things
The choice of mesh location to store the discrete pressure and velocity values is
important. The locations affect the accuracy of the solution, the simulation time, and the
memory use. I store a pressures variable at each tetrahedron, and a velocity component
variable on each face. This arrangement is analogous to the popular staggered grid arrangement on regular grids. As in the regular grid staggered arrangement, I do not store the
full velocity vector u at the faces, only the component of the velocity normal to the face. I
call this scalar quantity the face normal velocity, z. The choice of a tetrahedral staggered
grid allows for natural enforcement of boundary conditions and generates sparse discrete
derivative matrices. This arrangement, as opposed to one where velocity vectors are stored
at the tetrahedra’s vertices, does make it more difficult to interpolate the velocity field.
However, in Section 4.4.1 we demonstrate an interpolation method that is practical despite
being more expensive than standard barycentric interpolation. Furthermore, the arrangement works very well for the mass conservation step, typically the most difficult part of the
43
simulation.
The motivation for choosing the staggered grid is that it avoids a problem known as
checkerboard instability. This name refers to the oscillatory pattern of pressures that arises
when we solve for the pressures in the mass conservation step. This step involves solving for
pressure in a linear system, Lp = d where L is the discrete Laplacian matrix, p the vector
of unknown pressures and d is a vector of the velocities divergence. When using a collocated
scheme the derivative mask for the Laplacian skips neighboring values and instead uses the
neighbors of neighbors to estimate the derivative. This causes direct neighboring values
to be decoupled from one another resulting in spatially oscillating solutions. An excellent
description of the problem and how a staggered grid addresses it can be found in [51].
The arrangement we use has the beneficial feature that the discrete divergence
and gradient derivative operators have very small support. The divergence features just 4
non-zero entries per row and the gradient has just 2 non-zero entries. This yields a sparse
Laplacian matrix, which means that it is cheap to store, and it improves the speed to solve
the linear system. For more details see Section 4.7.
4.4
Capabilities Required for Simulation
Two important capabilities are needed to follow the basic simulation method pre-
sented in Stam’s Stable Fluid paper [62]. First a method is needed to interpolate a velocity
at any point in the domain from the discrete velocity values. This is used for the semiLagrangian velocity advection step and also to advect smoke particles or the fluid surface.
Secondly, discrete approximations for the gradient of pressure and divergence of the velocity
44
field are needed. In the following sections I describe the methods used to perform these
operations on a tetrahedral mesh.
4.4.1
Velocity Interpolation
The fluid state location scheme we use describes the fluid velocity field using
only the component of velocity normal to the face. For both the semi-Lagrangian velocity
advection step and to advect smoke particles or the liquid surface, a full velocity vector
must be found at any arbitrary position in the mesh. We interpolate velocity vectors from
face normal velocities using the two-step method developed by Elcott et al. [16]. First, a
velocity vector ut is computed at each tetrahedron circumcenter, then we interpolate within
Voronoi cells using ut values at the Voronoi cell vertices.
Velocity ut for tetrahedron t is found by first considering a face of the tetrahedron,
face i, to have a normal velocity that is the projection of ut onto the face normal,
nT
i ut = zi .
Then a small linear system,
Nt ut = zt
accounts for all faces of the tetrahedra simultaneously. Here Nt is a 4 × 3 matrix containing
4 rows of the face normals of t and zt is a vector concatenation of the 4 face normal velocities
associated with tetrahedra t. This system can be solved in a least squares sense to find ut .
In general, this system is overconstrained and the recovered velocity vector will not exactly
satisfy the linear system, but it will minimize the squared error. If u is divergence-free field,
the linear system is obeyed exactly due to the additional mass conservation constraint on
45
ut
ct
ut
x
ni, zi
Figure 4.1: Two-dimensional representation of velocity interpolation. A velocity vector is
computed for each tetrahedron from the face normal velocities. These velocities are at the
vertices of the Voronoi cell. The velocity at some arbitrary location x can be computed by
interpolating the Voronoi cell.
the face normal velocities.
To find a velocity at an arbitrary point we interpolate within the Voronoi cell using
the tetrahedra velocities ut which are located at the Voronoi cells’ vertices (the tetrahedra
circumcenters). Voronoi cell interpolation uses generalized barycentric coordinates of convex
polytopes from the paper of Warren et al. [68]. This paper presents barycentric interpolation
within general convex polytopes. They interpolate the value at the point x as a weighted
sum of the polytope’s vertices values. Vertex t’s unnormalized weight is computed as
wt (x) = |Nt |
.
n
f ∈σt f · x + df
(4.6)
Here, σt is the set of polytope faces that adjoin vertex t. The denominator is the product of
distances from x to the faces in σt computed using the face normals, nf , and plane offsets,
df . |Nt | is the determinant of a matrix of unit face normals in σt . The denominator is a
product of the distance from the evaluation point to each of the faces in σt . Weights from all
vertices are then normalized to sum to 1 before use in the weighted sum for interpolation.
46
To simplify this computation we take advantage of the fact that we are interpolating a particular convex polytope, the Voronoi cell of a Delaunay mesh. There are two
important properties of these cells: 1) in a Delaunay mesh, edges are in the direction of the
Voronoi cell’s face normals, and 2) the volume of tetrahedron t is |Et |/6 where Et is a matrix
formed from the three vectors of edges, e1 , e2 , e3 emanating from a common node of t. By
using these properties, Equation (4.6) can be manipulated into a much more convenient
form:
wt (x) =
|Nt |
f ∈σt nf · x + df
(4.7)
=
|Nt |
f ∈σt nf · (ct − x)
(4.8)
=
6 1 |e1 | |e2 | |e3 | |Nt |
6
f ∈σt |ef |nf · (ct − x)
=
6Vol(t)
f ∈σt ef · (ct − x)
(4.9)
(4.10)
where wt (x) is the weight associated with the node at tetrahedra t’s circumcenter, Vol(t)
is the volume of tetrahedron t, ef is vector of the edge from the node associated with the
Voronoi cell to the other vertices of t, ct the circumcenter of t, and x the interpolation
position. The advantage here is that all terms appearing in Equation (4.10) are properties
of the mesh, either available, or quickly computable. The terms in Equation (4.6), involve
more complex terms that would require either substantially more storage or computation.
With this simplification velocity interpolation is substantially more practical.
Finally, letting d denote the set of tetrahedra adjoining the vertex belonging to
the Voronoi cell that contains point x, the velocity at x is
1
wt (x)ut
n
d
u(x) =
t=1
(4.11)
47
where n =
d
t=1 wt (x).
For the semi-Lagrangian velocity advection step it is important to use as accurate
an interpolation method as is possible. This is because this step uses the interpolation to
update the velocity field itself. Therefore, any error in interpolation is accumulated over
every time step. For situations where error is not cumulative such as when advecting visualization particles we employ a quicker (albeit less accurate) method. First, as a preprocess,
velocities at the vertices of all tetrahedra for the new time step are found by interpolating
using Equation (4.10). Interpolation at a vertex is a special case of Equation (4.10) and
can be simplified to
6Vol(t)
wt (x) = 3
.
2
i=1 |ei |
(4.12)
Then interpolation of the velocity at any point inside the mesh can interpolated from these
vertex velocities using standard barycentric coordinates,
u(x)
4
bi (x)ui .
i=1
Here bi are the barycentric coordinates of x in the tetrahedra that contains x and ui are the
velocities at that tetrahedron’s vertices found using Equation (4.11) with weights computed
by Equation (4.12).
4.4.2
Derivative Operators
As discussed in the section on mass conservation, Section 4.7, we need discrete ver-
sions of the divergence and gradient operators. To develop these we utilize Stokes Theorem.
For a detailed description of this approach see [31].
Informally, Stokes’ Theorem relates the integral over a volume, Γ, of the derivative
48
of a quantity ω to the integral over the boundary ∂Γ of that quantity,
dω =
Γ
ω
(4.13)
∂Γ
Stokes’ Theorem is a general version of many well-known specific instances of the theorem
including the Fundamental Theorem of Calculus, the Divergence (Gauss) Theorem, and
the Curl (Kelvin-Stokes) Theorem. We compute discrete derivatives by finding an average
derivative in some discrete region, referred to as the control volume. Recall that the average
g of some quantity g(x) over a region Γ with volume V can be computed by
1
g=
V
g(x) dx.
(4.14)
Γ
Equation (4.13) and Equation (4.14) can be used together to estimate an average derivative
in some region by first using Equation (4.14) to estimate the average derivative over a control
volume Γ. Then the volume integral of the derivative can be converted to a surface integral
of the quantity using Stokes’ Theorem, Equation (4.13). To estimate this surface integral
we use the discrete values stored on our mesh and perform numerical quadrature. This last
step is the only approximation in the procedure. As is often done, in our implementation
we use only quadrature points located at the discrete variables locations and integrate over
the surface by assuming that this is a good average value of the function over the associated
portion of the boundary. One beneficial feature of this general method for computing
derivatives is that one could easy modify the implementation to improve the accuracy of
the estimation simply by using more quadrature points, interpolating the discrete field as
required.
49
Discrete Divergence
We now show how the generic procedure for deriving average derivatives is used to
find the divergence. The average divergence within a tetrahedra, ∇ · u is derived starting
from the Divergence (Gauss) theorem,
Γ
∇ · u dV
u · dn
=
∂Γ
V ∇·u =
u · dn
∂Γ
∇·u ≈
∇·u ≈
1 (ui · si ni )Ai
V
i
1 si zi Ai
V
i
where Γ is domain of the tetrahedron, ∂Γ is the boundary of the tetrahedron, V is the
tetrahedron volume, Ai is the area of the ith face, ni is the face normal, zi is the face
normal velocity, and si is ±1 to orient the face normal to point out of the tetrahedron.
Here we have approximated the surface integral over the boundary of the tetrahedra using
a single quadrature point on each of the tetrahedron’s four faces. The accuracy of this
estimate relies on the assumption that the face normal velocity associated with a face is a
good representative value for the average normal velocity of the face.
When performing the mass conservation we prefer to compute the volume-weighted
divergence, and enforce that it is 0, V (∇ · u) = 0 instead of Equation (4.2) ((∇ · u) = 0). If
the divergence-free condition is enforced exactly this would have no effect on the solution,
but since we use an iterative solver that is run to some tolerance, weighting by volume
encourages larger elements to better conserve mass. This means that a region that is
responsible for more mass will be encouraged to make sure that mass is conserved. For
50
n3
n2
v
n1
p1
p2
n
Figure 4.2: Divergence (left) is estimated by summing the outward-facing face normal
velocities. In the figure s2 is negative because n2 points inward; all other s’s are positive.
The gradient (right) is estimated by taking the difference between the pressures in the
tetrahedra adjoining the face.
cases where elements vary greatly in size over the mesh, this has the potential to create
ill-conditioned matrices, as rows are weighted by vastly different numbers. However, we
have not observed this problem.
Discrete Gradient
Since we only deal with the face normal velocity, the component of velocity in
the direction of the face normal we only need the component of the pressure gradient in
the normal direction. To compute this we use the potential theorem (another instance of
Stokes Theorem). Let L be the line segment which connects the pressure values p2 , p1 which
are adjacent to a face f . Let the vector from p1 to p2 be v and the unit length vector in
v’s direction is v. The potential theorum computes the component of the gradient in the
direction v at face f as
∇p · v dL = p2 − p1 .
(4.15)
51
See Figure 4.2 for these and other terms discussed in this section. The average gradient in
the line direction is
∇p · v =
=
1
∇p · vdL
|v|
p2 − p1
|v|
where |v| is the length of L. We are assuming that the average gradient over the segment
is a good approximation of the gradient at the face location. In a Delaunay mesh, the line
segment that connects the circumcenters of two adjacent tetrahedra is parallel to the normal
of the face that they share. Furthermore the segment passes through the circumcenter of
the face. See Figure 4.3, top left. This suggests that a good place for storing the pressure
variables is at the circumcenters of tetrahedra; and a good place for storing face normal
velocities is at the face circumcenters. This storage scheme was used by Klinger et al. [40]
and produced satisfactory results. Unfortunately, the circumcenters can be far from their
base object, i.e. a face circumcenter can be far outside the face (although still in the plane
defined by the face) and a tetrahedron circumcenter can be far outside the tetrahedron. This
has two deleterious effects. When the face circumcenter is far from the face, using the face
normal velocity as an average for the outward velocity over the face can be very inaccurate,
making the divergence estimate poor. Second, because the tetrahedron circumcenter can be
far from the tetrahedra the line segment between two circumcenters might not pass through
the face, even though the line does. As a result, the average gradient along the line will be
a poor estimate for the gradient at the face. Refer to Figure 4.3 for visual examples of these
problems. To alleviate these problems we store the pressures and face normal velocites at
the barycenters of the tetrahedra and faces respectively [9]. Barycenters are much better
52
behaved than circumcenters. The face barycenter is a good location to sample the average
quantity over the face and therefore is a good location for estimating the divergence with the
face normal velocities. Also, the line segment between two tetrahedra barycenters passes
through the shared face, so the average derivative over the line segment is a reasonable
estimate for the derivative at the face. Unfortunately, the segment connecting tetrahedra
barycenters will not, in general, be parallel to the normal of the shared face nor will it
intersect the face at its face barycenter. To compensate for the difference in direction, we
modify Equation (4.16) to be
∇p · v̄ ≈
p2 − p1
v·n
(4.16)
This estimate has works in the examples that we generate but it has errors due to the
difference in direction between v and n and the difference between the face barycenter and
the face-line segment intersection. One particularly troublesome effect of the error is that
the derivative estimate is not linearly consistent and therefore the mass conservation step
does not perfectly balance an applied gravity field. As a result a liquid in a container that
should remain static (because the gravity forces are perfectly balanced by pressure forces)
displays some visible artifacts, the liquid has a slight phantom motion due to the errors.
Discrete Gradient Improvement
To improve the accuracy of the derivative estimate researchers have investigated
augmenting the estimate in Equation (4.16) with correction terms [37]. Most methods
compute the gradient in the face direction as above and then additionally compute a gradient
vector for the face. They use the gradient vector to correct the normal direction gradient
based off of how different the line segment direction is from the face’s normal direction. The
53
Figure 4.3: Top left: If pressures are stored at circumcenters, the line connecting two
adjacent pressures passes through the face circumcenter (the edge midpoint in 2D) and is
parallel to the face’s normal. Top right: Circumcenters may lie outside of an element such
that the line segment between adjacent circumcenters does not intersect the face. Bottom
left: In 3D the face circumcenter (dark triangle) is not necessarily in the face, making
it a dubious place to locate the face normal velocity for divergence calculation. Bottom
right: Storing quantities at barycenters. The line segment connecting adjacent tetrahedra
barycenters does not necessarily pass through the face barycenter and is not generally
parallel to the face normal.
corrected equation is (from [15]):
∇p · d =
p2 − p1
1
+ ∇p · v 1 −
v·n
n·v
(4.17)
where ∇p is an estimate for the gradient vector at the face. To compute the gradient
vector at the face, the methods compute gradients vectors at the adjacent tetrahedra and
average them. One way that the full gradient for a tetrahedra can be found is by using the
54
Green-Gauss reconstruction,
∇pdV =
T
pndS.
(4.18)
∂T
With this the tetrahedra full gradient can be estimated as:
∇pj =
4
1 1
(pj + pi )nij
V
2
(4.19)
i=1
where pi is the pressure of j’s neighbor, i and nij is the normal of the face between tetrahedra i and j. We have obtained pressure values on the faces of the tetrahedra by averaging
values from the tetrahedra adjacent to the faces. We have experimented with this augmented gradient estimate but the results do not overcome the aforementioned problem
with phantom motion in a pool of water effected by gravity or appreciably improve the
visual appearance of the simulation. Furthermore, these changes significantly decrease the
sparsity of the gradient matrix, thereby increasing both memory use and simulation time.
As a result, in our default implementation we do not include this correction.
4.5
Semi-Lagrangian Velocity Advection
With these methods for interpolating values and computing discrete derivatives
on a staggered tetrahedral mesh, we are able to perform the steps of simulation, the first
of which is velocity advection. Advection, in general, accounts for the change of a quantity
at some fixed location due to transport of the quantity by the velocity field. For example,
the temperature of the water at a shower head increases because the hot water in the
water heater is transported by the fluid velocity from the water heater to the head 1 . In
1
Note that in this shower example we’re taking an Eulerian perspective, describing the fluid at locations
fixed in space. Were we taking a Lagrangian view there is no advection term because we follow the hot
water from the heater to the shower head.
55
our simulation we advect not temperatures but the velocities themselves. In general, the
velocity field is more complicated than the uasi-one-dimensional velocity field of the shower
example, but the principle of change at a fixed location due to transport by the velocity
field is the same.
The advection term − (u · ∇) u in the momentum equation (Equation (4.1)) accounts for the change in velocity due to the transport of velocity by the velocity field itself.
In other words there is a change in velocity because we are storing velocity at some location
in space, and because the fluid is moving through that space. While the idea that the velocity field is transporting itself may be conceptually more convoluted than the temperature
case, the principle is the same. In fact, each component of velocity may be treated just like
the scalar temperature quantity.
The semi-Lagrangian method approximates the velocity advection phenomenon by
directly attempting to find the velocity that would be transported to the velocity storage
location during a time step. Note that the advection term in the momentum equation
actually computes the change in velocity due to advection whereas the semi-Lagrangian
method computes the velocity itself.
To compute the velocity at some location after advection, one traces backwards
from the location through the flow for a time step. At the end of the path the velocity
is interpolated and this velocity is then used as the advected velocity. In our mesh we
store face normal velocities at the face barycenters, so we trace back from the faces, and
then project the interpolated velocity at the end of the path onto the face normal. The
intuition behind can be understood by comparing it to a similar way for accounting for
56
advection. To compute what fluid properties will advect to a certain location one could
advect forward through the flow starting from several different places until the forward
advected path happened to end up at where we locate the fluid properties. The properties
at the beginning of the path are those that will advect to where we want to know the updated
advected properties. Finding an initial location that happens to end up at a particular place
may require many traces so we instead trace backwards to find the location that would end
up at the proper place.
The semi-Lagrangian method is not new to this thesis, but for comparison with
the novel generalized semi-Lagrangian method, I describe the original algorithm in detail.
Let x̄ be the locations where velocities are stored, z̄(t) be a concatenation of the discrete
velocity values at time t, and U (x, z̄(t) , x̄) be a function that returns the velocity at some
general location x. This function naturally depends on the values of the discrete velocities
z̄(t) and their positions x̄. For a fixed mesh, the semi-Lagrangian method updates the
velocity value at the ith face center by first tracing backwards from x̄i to a location xi . To
trace backwards, we integrate a path by interpolation of U (x, z̄(t) , x̄). Then the discrete
(t+adv.)
velocity after advection, zi
, is
(t+adv.)
zi
4.5.1
= ni · U (xi , z̄(t) , x̄)
(4.20)
Generalized Semi-Lagrangian Advection
We generalize the above procedure to account for the change in x̄ as the mesh
changes. Let x̄(t) be the locations where velocities are stored at time t, and x̄(t+Δt) be the
new face locations. Since we want to compute the velocity for face i in the new mesh we
57
Previous Mesh
Current Mesh
y
x
ȳ(t+Δt)
ȳ(t+Δt)
x̄(t+Δt)
x
x̄(t+Δt)
Figure 4.4: A 2D representation of our generalized semi-Lagrangian method. We trace
back from the position where a velocity is stored in the new mesh x̄i = (x, y), interpolate
the velocity using the old mesh and update the velocity in the new mesh.
Figure 4.5: A comparison of simulation with the same initial conditions on a static (top)
and deforming (bottom) mesh. The deforming mesh is being stretched and squashed in the
vertical direction. As shown the simulations are qualitatively very similar, demonstrating
that mesh deformation does not effect the simulation.
(t+Δt)
trace a path backwards from the new face location, x̄i
to location xi . To integrate the
path backwards from this point we interpolate the velocity field from the previous steps
face normal velocities, which are located at the previous mesh’s locations. In other words,
58
the interpolated function is expressed as U x, z̄(t) , x̄(t) . We then set the velocity of the
face normals at the new location to be the interpolation of the velocity at the end of the
path. To find this velocity we interpolate old mesh velocities which are located at old mesh
locations,
(t+adv.)
zi
= ni · U xi , z̄(t) , x̄(t) .
(4.21)
Note that the only real difference between this method and the original semi-Lagrangian
method is where we start the paths, namely the face barycenters of the new mesh.
An alternative method for transferring information from different meshes would
be to first interpolate velocities from the old mesh onto the new locations of the new mesh.
Then the standard semi-Lagrangian step could be performed without modification, simply
by ignoring the fact that there ever was an old mesh. Mathematically, this can be expressed,
z¯i (t+pre.) = ni · U x̄(t+Δt) , z̄(t) , x̄(t)
(4.22)
and
(t+adv.)
zi
= ni · U xi , z̄(t+pre.) , x̄(t+Δt)
(4.23)
In addition to being more work, this additional step adds artificial viscosity, an unwanted
blurring of the velocities, due to the extra step of interpolation. Every time velocity variables
are updated by interpolation we are taking averages of existing velocities which is the
equivalent of applying a low pass filter to the velocity field.
In our procedure we combine the two steps into a single procedure. Therefore
in an entire pass through all simulation steps, we only update velocities using a single
interpolation step. As a result, our method incurs only the smoothing of standard semiLagrangian integration.
59
In Figure 4.5, we show frames from two simulations comparing a static mesh and
a mesh that is being deformed. Throughout the latter simulation the deformed mesh is
being stretched and squashed in the vertical direction. Despite this mesh deformation the
results of the two simulations are qualitatively very similar. We ran an additional simulation
where the mesh was rotated back and forth rapidly. The result is not shown in Figure 4.5
because mesh rotation is not clear in static images but the results are qualitatively similar to
those with the static mesh. These tests demonstrate that the generalized semi-Lagrangian
procedure presented in this section does not create any artifacts or additional numerical
smoothing over that seen in the standard semi-Lagrangian method.
4.6
External Forces
Application of external forces is just as easy on tetrahedral meshes as it is for
regular meshes. Forces may be directly specified by the user, be constant body forces
(for example gravity), or be dependant on fluid properties such as buoyancy forces which
typically depend upon the fluid density or temperature. Once a force is determined, it may
be projected into the face normal direction and used to accelerate the face normal velocity
using forward Euler integration
zi = z i +
Δt
(fi · ni ).
ρ
(4.24)
For gravity, all faces experience the same acceleration, so they may be set using Equation (4.24). Buoyancy forces typically depend on a local temperature or density which must
be advected with the velocity field. Typically these quantities are stored at the tetrahedron
barycenters. To compute the quantity at a face location we use a weighted average of the
60
values from the two tetrahedra adjacent to the face. The weighting depends on the volume
of the adjacent elements. To compute a quantity df at a face f with adjacent tetrahedra i
and j we use the following:
df =
d i Vi + d j V j
,
Vi + Vj
where Vi , Vj are the volume of tetrahedra i, j respectively. After the value at the face and
the force due to this value is computed, Equation (4.24) is applied to change the face’s
velocity.
4.7
Mass Conservation
The generic method we use to enforce mass conservation is the same as that found
in many previous works. It can be originally attributed to [11]. The implementation of mass
conservation in this work differs only in the discrete derivative operators we use, which are
described in Section 4.4.2. This difference arises because we use a tetrahedral mesh instead
of a regular grid discretization. Many papers gloss over some of the important details. To
make our extension to fluid-rigid body coupling more concrete, we describe the procedure
in some detail here. We note that much of the discussion is applicable to all element shapes
(cubes, tetrahedra, non-orthogonal bricks etc.).
Integrating the advection and external force terms of Equation (4.1) yields an
intermediate velocity u∗ which in general, does not obey the mass conservation condition,
Equation (4.2); in other words ∇ · u∗ = 0. We need to make sure that after pressure is
added, this velocity at the end of the time step, u(t+Δt) does meet the mass conservation
61
condition. The pressure changes u∗ according to
u(n+1) = u∗ − Δt
∇p
.
ρ
(4.25)
The condition we desire for the u(n+1) is
∇ · u(t+Δt) = 0,
(4.26)
where Δt is the time step. After altering u∗ by Equation (4.25) all terms of the momentum
conservation have been applied and satisfying Equation (4.26) enforces mass conservation.
In our simulator we do not work with a continuous system asd in Equations (4.25)
and (4.26), so these equations must be replaced with their discrete approximations. As
noted in Section 4.3, we represent the fluid velocity field u with the discrete velocity values
zi , and the pressure field is represented by the discrete pressure values pj . The discrete
values for the entire mesh are concatenated into the vectors z and p respectively. Next, we
need discrete equivalents of the divergence and gradient operators that act on the discrete
velocity and pressure. As derived in Section 4.4.2, the discrete operator for the divergence
of the velocity field is,
∇·u=
1 si zi Ai
V
i
and the discrete operator for the gradient of pressure is
∇p · v =
p2 − p 1
.
|v|
As these equations show, the discrete divergence and gradient are linear functions of the
face normal velocities and pressures. All other terms in these equations, e.g. tetrahedron
volume V , face area A, and distance between barycenters |v| depend on mesh properties.
62
The discrete derivative operators can be expressed as matrices D and G which are
multiplied by the discrete face normal velocities and pressure respectively. The elements of
the matrices are the terms that depend on the mesh.
If tetrahedron i has a face j, then
Dij =
1
sj Aj ;
Vi
(4.27)
otherwise Diq = 0. For a face k with adjacent tetrahedra m and n
Gkm =
Δtsmk
ρ|cm − cn |
(4.28)
where cm and cn are the centers of tetrahedra m and n. The variable smk = +1 if the vector
from cn to cm is in the same direction as the face normal of face k (nk · (cm − cn ) > 0)
and smk = −1 otherwise. For simplicity we have include multiplication by the time step,
Δt and division by density ρ as part of the matrix G. We do this because every time the
gradient operator is applied, this multiplication factor is applied as well.
When the matrix D is multiplied by a vector concatenation of all of the face normal
velocities z the result is a vector concatenation of the discrete divergence estimates for each
tetrahedron. When the matrix G is multiplied by a vector of the pressures in the tetrahedra,
the result is a vector concatenation of the accelerations of all face normal velocities due to
pressure. We therefore have discrete versions of Equations (4.25) and (4.26),
z(n+1) = z∗ − Gp
(4.29)
Dz(n+1) = 0,
(4.30)
and
63
where 0 is a column vector of all zeros. We substitute Equation (4.29) into Equation (4.30)
and shift around terms such that the pressure term is on the left-hand side and the intermediate velocity is on the right-hand side. This results in the matrix equation
DGp = Dz∗ .
(4.31)
The matrix DG is the discrete equivalent of a Laplacian operator and is denoted by L.
Equation (4.31) therefore is written as the linear system
Lp = Dz∗ .
(4.32)
Since the right-hand side of Equation (4.32) is a known vector, we rewrite Equation (4.32)
in standard linear system form,
Lp = dz ∗ .
(4.33)
where dz ∗ is the vector of the divergences of the intermediate velocity field for the tetrahedra.
This equation is a discrete version of the Poisson equation ∇2 ϕ = f , a partial
differential equation seen in a wide swath of fields including electrostatics, mechanical engineering, and theoretical physics. By solving this linear system for the vector of unknown
pressures p, we can use p to alter the vector of intermediate face normal velocities z∗ according to Equation (4.29) such that we obtain a vector of face normal velocities that obeys the
discrete divergence-free condition, Equation (4.30). The matrix L is sparse and symmetric,
so Equation (4.32) can be solved with preconditioned conjugate gradient (PCG).
4.7.1
An Alternative Perspective
This same method can be arrived at from a different perspective, where mass con-
servation is a projection procedure. This is the view taken in [11] and [62]. The projection
64
viewpoint starts with the Helmholtz-Hodge decomposition theorem, which states that any
sufficiently smooth vector field v can be decomposed into 3 orthogonal vector field components, a divergence-free component vd , a curl-free component vc , and a divergence and curl
free component (the harmonic component) vh . The vector fields vd and vc can be created
from the curl and gradient of vector and scalar potential fields φ and ψ respectively. So,
the decomposition can be written
v = vd + vc + vh
= ∇ × φ + ∇ψ + vh
(4.34)
(4.35)
To use this idea for mass conservation we make the velocity field divergence-free by finding
the component of the velocity field that has divergence, vc , and subtracting it away. The intuition is that advection and external forces change the fluid velocity but also “accidentally”
shift it away from its desired divergence-free state. By projecting back to a divergence-free
configuration, we correct the mistake by changing the velocity field as little as possible.
This is called a projection method because it takes a general field and projects it to the
nearest divergence-free field. To find the component of the velocity with divergence, vc , we
take the divergence of both sides of Equation (4.34).
∇ · v = ∇ · (∇ × φ) + ∇ · ∇ψ + ∇ · vh
= 0 + ∇ · ∇ψ + 0.
(4.36)
(4.37)
The first term of the right-hand side of Equation (4.36) is zero due the property that
∇ · (∇ × a) = 0 for any vector field a. This term represents the divergence-free component
of the field, so by design its divergence is zero. The same is true for vh , it is by construction
65
divergence-free. By solving this equation for the scalar potential that generates the curl-free
component of the vector field, we can recreate it and subtract it off, v̄ = v − ∇ψ. Note
that this projection is identical to that described in Section 4.7, with ψ replacing the role
of the pressure p. The insight gained by this perspective is that it is clear that the mass
conservation step should not change the curl of the velocity field. If it does, the projection
is not orthogonal and therefore energy is incorrectly being added or subtracted from the
system.
One place where this intuition has been useful is in rejecting the choice of storing
velocities at tetrahedron vertices and pressures at tetrahedron centers. The reason is that to
prevent altering the curl of a particular tetrahedron, the pressure should force the velocities
in a direction normal to the face opposite of the node. However, doing this will alter the
curl for some other tetrahedra attached to this node. With some inspection we see that the
curl is not altered by the pressure gradient in the storage scheme we use. As the pressure
rises in a tetrahedron, the change in curl due to acceleration of one of the faces is balanced
by the acceleration of another face.
4.7.2
Boundary Conditions
On the boundary of the simulation domain, two types of boundary conditions can
occur, open and closed, or more formally, Dirichlet and Neumann boundary conditions.
Open boundary conditions are regions on the simulation boundary where fluid is free to
enter or exit. At open boundaries, the pressure is a specified fixed value (in our case 0). At
closed boundaries the derivative of the pressure is set. In most situations it is set such that
the derivative is 0, hence there is no acceleration by pressure.
66
For a liquid we treat the regions of the liquid surface in contact with air as open
boundary conditions. In reality, the motion of air has an effect on the liquid behavior.
However, because the density of air is so much less than that of water (∼ 1000 times less),
the air has very little effect on the liquids motion. Therefore, as in most other works, we do
not simulate the air. The benefit is that we simulate a smaller system and we avoid creating
a poorly conditioned Laplacian matrix due to the large differences in the density of air and
water. In practice, this simplification usually has little effect on the resulting liquid motion.
One situation where it creates problems is when liquid completely encloses a region of air
such as in an air bubble. These regions are free to unrealistically expand or collapse the air.
However, because these regions are obscured by other surfaces and typically arise during
turbulent motion, the problem is often not noticeable. In our experience this problem has
not been observed. Should it be necessary, the implementation of the extension to our
simulation method is straightforward.
Closed boundary conditions occur where the fluid is bounded by some solid obstacle
that may be stationary or moving. To prevent fluid from penetrating into the solid obstacle,
a closed boundary condition is enforced by setting the normal velocity at the boundary to
be the same as the normal velocity of the obstacle. To prevent the pressure from changing
the velocity at the closed boundary, the pressure outside the boundary is set to be the same
as inside the boundary. This makes the pressure gradient zero, and therefore the pressure
term does not change the closed boundary velocity.
The open and closed boundary conditions manifest themselves in the gradient
matrix. Open boundary conditions are enforced by assuming that pressure opposite the
67
open face is zero. This can be implemented by using the standard gradient equation and
since the outside value is zero, the row of the gradient matrix corresponding to this face
will contain only the entry corresponding to the one tetrahedron adjacent to the open face.
Closed boundary faces are enforced by making sure that the gradient is always
zero regardless of the pressures. This way the face velocity is completely dictated by the
normal velocity of the obstacle. To have a gradient always return zero for these closed faces,
the row of the gradient matrix corresponding to the closed faces could be set to contain all
zeros. Doing this would create a singular Laplacian matrix L, which would create problems
for the linear system solver. In practice, the rows of G that correspond to closed faces are
simply not included in G to avoid creating singular matrices. Therefore, G is a Na × Nt
matrix where Na is the number of active (internal or open but not closed) mesh faces and
Nt is the number of tetrahedra. The matrix D is built to compute divergence due to active
faces, so its size is Nt × Na . For non-moving obstacles, the closed (inactive) faces make
no contribution to the divergence of each face’s adjacent element, therefore these faces
may be ignored in the mass conservation procedure. For closed faces that are associated
with moving objects, the velocity of these faces must be accounted for when computing
the divergence to obtain proper interaction with the obstacle. To implement this, a vector
dc is added to the right-hand side of Equation (4.32). Each row of dc contains the total
contribution of closed face velocities to the elements discrete divergence. Therefore, the
right-hand side of the linear system of equations is a vector of the discrete divergence for
each element due to both active and inactive face normal velocities,
Lp = dz ∗ + dc ,
(4.38)
68
where the ith element of d comes from the ith tetrahedron,
dc,i =
zj Aj sj ,
(4.39)
and the sum is taken over the closed faces j of tetrahedron i. The normal velocity zj in this
equation comes from the scripted motion of the obstacle.
4.7.3
Coupling Between Fluids and Rigid Bodies
In the description of closed boundaries, the velocities of the closed faces are as-
sumed to be known, either 0 for static obstacles or specified by the user through some
scripted motion of the obstacle. In coupling between fluids and rigid bodies the obstacles
behavior is affected by the fluid. As a result, the velocities at the associated mesh boundary
faces are unknown and cannot simply be added to the left-hand side of the linear system
as in Equation (4.38). The acceleration of these velocities at the fluid/rigid interface must
be solved for.
In our mass conservation step for two-way coupling we solve for both the fluid and
rigid body velocities such that
1. the fluid and rigid body conserve momentum,
2. the fluid conserves mass, and
3. the rigid body moves rigidly.
This is accomplished by following the steps for conserving mass in Section 4.7 with the
addition that mesh faces at the interface between the fluid and the rigid body are affected
by the pressure.
69
Effect of Pressure on a Rigid Body
In this section we derive the effect of fluid pressure on the velocity and rotation of
the rigid body, and hence on the boundary face velocities associated with the rigid body.
Refer to Figure 4.6 for a visual explanation of the following derivation.
A constant pressure pi will create a force fi on a planar body with normal ni ,
according to the equation
fi = −pi Ai ni
where Ai is the area that the pressure acts upon. By assuming a constant pressure within
each element (tetrahedron in our case) we can compute a net force fp and torque τp couple
on the rigid body due to pressure in all N elements surrounding the body as
fp =
N
−pi Ai ni ,
(4.40)
pi Ai (ri × ni ),
(4.41)
i=1
τp =
N
i=1
where ri is the vector from the center of gravity of the rigid body to the location of the
ith face. The net force and torque on the rigid body creates a linear acceleration ap , and
angular acceleration αp , on the body such that
ap = M−1 fp ,
(4.42)
αp = I−1 τp ,
(4.43)
where M and I are the mass and moment of inertia matrices. The mass matrix M is a
3 × 3 diagonal matrix with the mass of the rigid body on the diagonal elements. The inertia
matrix describes the distribution of the body’s mass, and we calculate it for an object by
70
treating the object as a collection of point masses. The inertia matrix for k point masses is
Iij =
mk rk2 δij − rki rkj
where i and j indicate directional dimension (x, y, or z), mk is the mass of the kth point,
rk is the distance from the center of mass to the kth point, δij is the Kronecker delta, and
rki is the distance to the kth point.
The acceleration of the rigid body at the location of the ith mesh face is
ai = ap + (αp × ri ).
(4.44)
Since we store only components of velocity in the face normal direction, we only care about
acceleration in the normal direction, which is computed by
ai · ni = a · ni + (α × ri ) · ni
= a · ni + α · (ri × ni ),
(4.45)
(4.46)
where we have taken advantage of a vector identity to obtain the more convenient form of
Equation (4.46).
The Rigid Matrix
Equations 4.40 through 4.46 show how to find the acceleration of the faces that
surround the rigid body from the pressures that surround the rigid body. The entire series
of operations only depends linearly on the pressures, so they can be combined into a single
matrix R which, when multiplied by a vector of pressures surrounding the body, yields
a vector of the accelerations of face normal velocities that surround the rigid body. The
71
matrix R can easily be formed by
⎤
⎡
⎡
⎢ b1 ⎥
⎥ M−1 0
⎢
⎢ . ⎥⎢
⎥⎢
R=⎢
⎢ .. ⎥ ⎣
⎥
⎢
0
I−1
⎦
⎣
bk
⎤
⎥
⎥
⎦
A1 bT
···
1
Ak bT
k
,
(4.47)
T
where bi = nT
i | (ri × ni ) . The rightmost matrix finds the net force-torque couple acting
on a rigid body by summing up the contribution due to pressure forces acting mesh faces that
lie on the boundary of the rigid body. The force-torque couple is converted to a linear and
angular acceleration of the body by the middle 6 × 6 block symmetric matrix that contains
the mass matrix M and the inertia matrix I. The leftmost matrix in the multiplication
returns the acceleration of the fluid-rigid faces in the direction of the face normal due to the
linear and angular acceleration of the rigid body. By construction, accelerations generated
by this matrix behave rigidly. The matrix R is symmetric, which can be seen from the fact
T , where M
is
that Equation (4.47) can be written as a product of matrices R = BMAB
the block symmetric mass/inertia matrix, and A is a diagonal, and therefore symmetric,
matrix of the face areas. This symmetry is important as it allows us to use a conjugate
gradient solver when we formulate the two-way coupling in the following section.
Putting it all together
In Section 4.7 we showed a matrix G can be created that, when multiplied by
a vector of the pressures, yields the acceleration of fluid velocity faces. Similarly, in Section 4.7.3 we showed a matrix R that when multiplied by a vector of the pressures yields
the acceleration of fluid-rigid interface velocity faces. By combining the operations of both
these matrices into a single matrix Ḡ we can compute the acceleration of both the fluid and
72
fluid-rigid faces due to pressure. The matrix Ḡ can be viewed as a generalization of the
gradient matrix G seen in Section 4.7. Just as G computed the change in the face normal
velocities of fluid faces, Ḡ computes the changes of both mesh faces inside the fluid and
mesh faces on the boundary with the rigid body. A row of Ḡ that corresponds to a face
with fluid on both sides contains the same entries as the standard gradient matrix. A row
of Ḡ that belongs to a face at the fluid-rigid interface has element values obtained from the
corresponding row of R. The elements of this row are placed at columns corresponding to
the pressures that surround the rigid body. With Ḡ built, mass conservation and two-way
coupling proceed as in the all-fluid case, with Ḡ replacing the role of the discrete gradient
matrix, G.
For a vector of pressures p, the intermediate velocity field z∗ is accelerated to the
end-of-step velocity
z(t+Δt) = z∗ + Ḡp.
(4.48)
Fluid components of z∗ are found as before, by applying all terms of Equation (4.1) except
the pressure term. In particular, fluid-rigid interface components, z∗ are found using a
rigid body simulator without pressure forces applied. Components of z∗ corresponding to
all fluid on the interior of the mesh are found as before, doing semi-Lagrangian integration
then adding external forces. To find a particular pressure that accelerates z∗ such that z is
divergence free we solve the linear system
DḠp = Dz∗ .
(4.49)
This linear system can be solved efficiently using PCG since the the matrix DḠ, which
replaces the discrete Laplacian L from the all fluid case, is also a positive-definite, sparse,
73
fi
α
τ
f
a
r
ai
Figure 4.6: Left) Pressure forces on rigid object create a force/torque couple. Right) The
acceleration on the boundary (and hence the fluid simulation mesh faces at this boundary)
of the rigid body can be computed from the linear and angular acceleration of the body.
symmetric matrix. Once the pressure is found, all active faces are updated using Equation (4.48).
Using the same machinery, we can also interact with constrained rigid bodies.
This simply requires finding an R matrix that correctly computes face accelerations due
to pressure. For example, one could easily alter R such that the body was constrained
to just rotate about the objects center of mass by replacing bi in Equation (4.47) with
bi = (ri × ni )T and using only the I−1 block for the center matrix. This idea could be
extended further to include even articulated bodies.
This same idea has also been extended to fluid and deformable body coupling
[10]. The only change required is determining the new, and somewhat more complicated
relationship between the pressure surrounding the deformable body and the acceleration of
the fluid-deformable body faces.
74
Chapter 5
Multigrid
As discussed in Section 4.7, the procedure for enforcing the incompressibility of the
fluid involves solving the discrete Poisson’s equation, Lp = dz ∗ . This linear system is large,
sparse, and symmetric. In this chapter we describe how this linear system can be solved
efficiently using a multigrid method. A detailed background description of the multigrid
method is beyond the scope of this thesis but we briefly describe the relevant high level
concepts and refer the interested reader to the excellent books, “Multigrid Methods”, [45]
and “Multigrid” [67] for more details. We will focus instead on details of our implementation
that we found useful.
5.1
Multigrid Background
Suppose the linear system we wish to solve is Ax = b, where x is unknown.
Assume that we can construct a hierarchy of linear systems, Ak xk = bk , with k ranging
from q to 1 where q is the original, finest resolution system, and 1 corresponds to the
75
coarsest version of the original linear system. Here each Ak in some sense approximates
the finest system matrix Aq . Multigrid works by computing a quick, inaccurate solution
to this system, then correcting the error in this approximate solution with help from an
approximate solution to a coarser version of the problem, which can be solved more quickly.
The coarser version is recursively solved by using an even coarser version of the problem.
The base case is a linear system small enough to solve quickly with a direct method.
Multigrid uses a sequence of linear prolongation operators Pk,k−1 that upsample
a coarse solution (with few unknowns) to a finer one (with more), and a sequence of linear
restriction operators Rk−1,k that reduce a fine solution to a coarser one (with some loss of
information). Since these are linear operators, they can be expressed as matrices. In the
original, geometric formulation of multigrid, the fine and coarse solutions are nodal values
on regular grids of two different resolutions, prolongation is done (exactly) by interpolating,
and restriction is done (approximately) by projection. The matrices for the coarser levels,
Ak are formed by applying the discretization stencils on the coarsened meshes.
The motivation for the multigrid method can be conceptually understood at a high
level. Local iterative methods are very good at removing high-frequency error in the solution
estimate. By themselves, the local iterative methods fail to be effective solvers because they
are very bad at removing the low-frequency error. The remaining low-frequency error can
be well represented on a coarser system and furthermore it will appear as higher frequency
error on this coarser system. Therefore, iterations of the local solver on the coarser system
will be able to more effectively reduce this error. As an added benefit, each iteration on the
coarser system takes less time since it is performed on a smaller system.
76
The idea is similar to multiresolution methods which start from a solution on a very
coarse system and then repeatedly use an approximate solution on the coarser system to
initialize iterations on a refined system until ultimately solving the problem on the original
resolution. When solving a large linear system, it is more effective to make several cycles
through all levels of resolution.
V-cycle multigrid begins by applying a relaxation operator S(Ak , xk , bk ), which
returns an approximation solution (usually with poor accuracy) to the system Ak xk = bk .
We use two Gauss-Seidel iterations. Next, it computes the residual of the system, restricts it
to the next coarser grid, and recursively solves the coarse problem on the restricted residual.
It prolongs the coarse solution and adds it, as a corrective term, to the fine solution. Finally,
the relaxation operator is applied again. We use full-cycle multigrid, which uses V-cycle
multigrid as a subroutine as follows.
FullCycleMultigrid(x, b)
rq ← b − mathbf Ax
for k ← q to 2
rk−1 ← mathbf Rk−1,k rk
z1 ← A−1
1 r1
for k ← 2 to q
zk ← Pk,k−1 zk−1
VCycleMultigrid(zk , rk , k)
x ← x + zq
VCycleMultigrid(xk , bk , k)
if k = 1
77
xk ← A−1
1 bk
else
xk ← S(Ak , xk , bk )
rk−1 ← Rk−1,k (bk − Ak xk )
wk−1 ← 0
VCycleMultigrid(wk−1 , rk−1 , k − 1)
xk ← xk + Pk,k−1 wk−1
xk ← S(Ak , xk , bk )
5.2
Algebraic Multigrid Background
Often there is no obvious way to construct a coarse version of the problem by
geometrically coarsening the mesh, then applying the discrete differential operators to the
coarsened mesh. In our case, this is because grouping together tetrahedra will generally
not create larger tetrahedra. A similar problem occurs for regular hexahedral grids in the
common case when the coarse levels of the grid cannot capture the simulation domain
adequately, due to an irregularly shaped domain. Irregular domains occur, for example,
at a liquid free surface or at the boundary with interesting obstacles. We circumvent
this geometric problem with algebraic multigrid, which uses only A matrices, and not the
geometry, to construct the prolongation and restriction operators. From the prolongation
and restriction operators the system matrices can be defined by Ak−1 = Rk−1,k Ak Pk,k−1 .
The series of matrices on the right hand side first interpolates a course solution up to the
finer level by Pk,k−1 , then the finer level matrix, Ak , operates on the interpolated solution,
and finally, the solution is restricted back down to the coarser level by Rk−1,k .
78
5.3
Details of our Implementation
To form the restriction and prolongation operators, we partition the level k vari-
ables into coarse and fine variables. Coarse variables survive into the coarser level k − 1;
fine variables do not. Pk,k−1 is a matrix that prolongs a level k − 1 solution by assigning
each fine level k variable the average of the values of its coarse neighbors from the level
k − 1 solution. (Variables i and j are neighbors if Aij is non-zero.) Some researchers advocate using weighted averages based on matrix coefficients [45], but we found that simple
averages converged faster. They also save memory and time by obviating the need to compute weights. For restriction, we use the popular Galerkin projection method [67], in which
Rk−1,k = PT
k,k−1 .
To determine the partitioning of variables into coarse and fine we are guided by
a few considerations. Each level k variable must have at least one neighbor labeled coarse
(possibly itself) so that all variables can be interpolated from the coarser level. A good
partition has coarse variables that support good interpolation of values from the coarser
to the finer level, but also keep the number of coarse variables modest, so that the coarser
linear system is as small as possible. The following greedy algorithm for labeling variables,
though not optimal, strikes a good balance between simplicity and effectiveness in practice.
1. Assign each variable a counter that stores its number of neighbors.
2. Select a variable at random; label it coarse.
3. Label the neighbors of the new coarse variable fine.
4. For each unlabeled neighbor of each new fine variable, decrement the count of its
79
f11
f3
f13
f13
c14
f5
f3
c2
c12
f11
c10
f1
f5
c0
f7
c4
f1
f1
f9
c8
c6
f7
Figure 5.1: An example of variable classification where c indicates that a triangle is labeled as coarse and f indicates a fine label. We have shown a geometry so that neighbor
information is clear. In practice, the non-zero entries in the system matrix are used to
determine neighborhood information. Subscripts indicate the order in which the variables
are classified. For example, c0 is added first (selected at random), then its neighbors are
added as f1 ’s. Next c2 is added and its neighbors are labeled as f3 . Note that due to the
classification algorithm each fine variable has at least one coarse neighbor and that there
are relatively few coarse variable (8 of a possible 21).
number of unlabeled neighbors.
5. Select the unlabeled variable that neighbors a fine variable and has the most unlabeled
neighbors. Label it coarse.
6. Repeat steps 3 to 5 until every variable is labeled.
An example of this procedure worked through for a simple mesh is shown in Figure 5.1.
One concern with the use of an algebraic multigrid solver is the additional memory
80
burden it can impose. We have attempted to minimize memory usage in the following two
ways. First of all, as mentioned before, for the prolongation matrix we use simple averages
instead of weighted averages. This allows for memory savings as the elements of the matrix
need not be stored since their values are determined by the number of entries per row. The
value for each row can be computed on the fly quickly since it is an integer divide which we
store in a lookup table.
A second way which we have experimented with to reduce the memory usage is by
“skipping” the first coarsened level. That is, as part of the multigrid procedure of solving
on multiple resolutions of the system we never solve the system that is directly coarsened
from the original system. To implement this we create a temporary first coarsened level,
Aq−1 (which is directly coarsened from the original) and some temporary prolongation
matrices, Pq,q−1 , Pq−1,q−2 . The operator Pq,q−1 is a prolongation matrix built from the
neighborhood information contained in Aq and Pq−1,q−2 is a prolongation matrix built
from the neighborhood information in Aq−1 . Then Aq−1 is built as
T
Aq−1 = Pq,q−1 Aq Pq,q−1
and the first coarsened system matrix that is used is,
T
Aq−1 = Pq−1,q−2 Aq−1 Pq−1,q−2
with prolongation matrix
Pq,q−1 = Pq−1,q−2 Pq,q−1
To our pleasant surprise this addition not only saved on memory but also saved on execution
time. We believe the reason for this is that although each cycle through Full Multigrid has a
81
slower convergence factor than using the complete set matrices (due to worse approximations
in interpolation), the execution time per cycle is less because it omits iteration on the second
to largest system (see Table 5.1).
5.4
Multigrid Discussion and Results
Although the basics multigrid scheme we are using is not novel, we are not aware of
it’s prior use within graphics for fluid animations. Furthermore, the specific implementation
details outlined in Section 5.3 have been important in making a practical and effective
implementation. The simulations we used contained between 0.8 million and 1.3 million
tetrahedra. For these systems our algebraic multigrid solver varied between 1.8× and 2.1×
faster than a preconditioned conjugate gradient solver. We also tested our solver on a larger
5 million tetrahedra mesh, that was not used for one of our fluid simulations, and observed
a 3× speed up over preconditioned conjugate gradient. We expect that this multigrid solver
would also be useful for fluid simulations on other discretizations and that the performance
benefit will continue to grow as systems become larger. In particular, regular grids require a
larger number of elements and furthermore the mass conservation step is generally a larger
percent of simulation time (since velocity interpolation and hence the semi-Lagrangian step
is easier on a regular grid). Therefore not only is the linear system larger, which as we have
seen makes multigrid more useful, but also the significance of this step is greater. While
we have not yet experimented with applying the multigrid solver to regular grids we see no
reason for the results to not carry over to this setting.
82
Approx. #
Elements
1.5 Million
2 Million
3 Million
4 Million
5 Million
P.C.G
29.56 sec
67.27 sec
97.74 sec
162.43 sec
223.14 sec
Multigrid
standard
16.67 sec (1.77)
31.28 sec (2.15)
48.78 sec (2.04)
68.91 sec (2.36)
86.93 sec (2.57)
Multigrid
w/ skipping
16.15 sec (1.83)
28.05 sec (2.39)
41.74 sec (2.34)
63.28 sec (2.56)
70.94 sec (3.15)
Table 5.1: This table shows a timing comparison for different methods of solving the
mass conservation linear system. A variety of different sized meshes are compared. For
the Multigrid standard and Multigrid with skipping columns the speedup factor over the
equivalently sized PCG system is shown in parenthesis.
83
Chapter 6
Results and Discussion
I have used the methods described in this thesis to generate several example animations of both liquids and gases. This section features sample frames from several of the
animations and a discussion of these results.
6.1
Gas and Non Free Surface Liquid Animations
The first set of examples are of gasses and liquids that do not have a free surface.
These simulations used a tetrahedral discretization generated using the variational tetrahedral meshing algorithm with the modifications described in Section 3.1. For all examples,
the number of tetrahedra used in the discretization was ∼ 100, 000 with the exception of
the example shown in Figure 6.4, which used ∼ 500, 000. This number of tetrahedra suffices
to represent the complex boundaries with adequate resolution so that no artifacts appear
in the animations and the animations featured enough detail. Timings for these results
can be found in Table 6.1. Some of the examples feature complex boundaries that change
84
throughout the simulation. The results demonstrate that the methods described in this
thesis can handle complex, moving boundaries in a natural manner and generate visually
plausible results.
In the examples, the spatial resolution is graded over the simulation domain to
focus computational effort where it is most needed. See for example Figure 6.4, which
shows the mesh at several frames in the simulation. Computation is focused on the most
visually interesting portions of the flow. Careful inspection reveals that in regions where
the mesh is less refined, the simulation is less capable of maintaining detail. For example,
in Figure 6.1 diffusion is apparent at the corners of the box that are away from the paddle.
Often this is not a problem, as the users attention is focused on the visually interesting
portions. However, should the diffusion of fluid motion be a problem, the mesh regions can
be further refined at the expense of run time.
One important issue is visible in the high-resolution example in Figure 6.4. In this
example, a larger percentage of time is spent in the remeshing step —39.3% as opposed to
∼ 20% for the lower-resolution examples. This suggests that this meshing technique would
not be feasible when a large number of tetrahedra are needed, for example for free surfaces,
because the meshing time would dominate simulation time.
6.1.1
Two-Way Coupling
The following examples feature the two-way coupling method described in Sec-
tion 4.7.3. The method is successful at generating animations in which the fluid is affected
by the rigid body, and vice versa. In Figure 6.5, the method is demonstrated in two different
simulations featuring cannons that shoot smoke with the same force at bunnies of different
85
Figure 6.1: A paddle translates and rotates with scripted motion, stirring up the smoke
in a box shape. On the right, the mesh is shown for three frames for this example. The
domain is remeshed every time step so that it’s boundary conforms to the paddle. The
sizing function changes from time step to time step so that smaller tetrahedra are created
near the paddle, as this is where the most interesting motion occurs.
densities. As expected, the heavier bunny (right column of images) is less affected by the
jets.
Figure 6.6 shows an animation which demonstrates that the fluid rigid coupling
method proposed in this thesis does not suffer from the mass conservation problems of
previous work. (For a description of this problem, refer to Section 2.7.) In the example,
fluid/rigid coupling is used to simulate valves such that fluid is pumped from the left chamber to the right via the expansion and contraction action of the center spherical chamber.
The example demonstrates that no leakage occurs when simultaneous coupling is used since
86
Figure 6.2: The leftmost image shows smoke inside the Stanford Buddha. The remaining
images show the progression of green smoke as it is exhaled out. Smoke motion is induced by
the motion of Buddha’s belly, which determines the boundary conditions of the simulation
domain.
Figure 6.3: This image shows smoke in a tube spinning and rising around a rotating blade.
87
Figure 6.4: A series of frames from a high resolution example with a jet shooting smoke
up towards several obstacle rods
88
Paddle
Valves
Bunnies
Cylinders
Figure
number
6.1
6.6
6.5
6.4
Meshing time
(mean)
13.2 sec
8.33 sec
5.76 sec
313 sec
Sim time
(mean)
51.6 sec
36.2 sec
30.0 sec
483 sec
Percent
remeshing
20.3%
18.7%
16.1%
39.3%
Table 6.1: Simulation times for the gas and non-free surface liquid examples. Meshing is
the time required for mesh generation and determination of the topological and geometrical
information. Sim denotes the time used for numerical integration and pressure correction.
the mass conservation is not broken by a later rigid body projection.
6.2
Free Surface Liquid Animations
This series of examples features animations of liquids with free surfaces. To dis-
cretize the simulation domain these animations use the isosurface stuffing method. Typical
mesh sizes vary from ∼ 1.5 − 3.0 million tetrahedra. The number of tetrahedra varies
over the course of the simulation and depends on the liquid’s surface area because small
tetrahedra are placed near the surface (see Figure 6.10).
Timings for each of the animations are shown in Table 6.2. The meshing time
includes the time it took to determine topological relations and geometrical information.
Topological information includes, for example, determining the nodes of each face in the
mesh, which faces a tetrahedron is made of, and which tetrahedra are adjacent to a face.
Geometric information includes tetrahedra volumes and barycenter positions, face areas,
face barycenters, and face normals. These computations are a significant portion of the
meshing time. In our implementation, the mesh is regenerated from scratch each time step.
It is conceivable that by reusing portions of previous meshes, the mesh generation time
89
Figure 6.5: Two animations where jets of air are shot towards a rigid bunny. The top
sequence features a light bunny; the bottom features a heavier bunny. As expected, the
light bunny is more affected by the cannon than the heavier one.
90
Figure 6.6: The central bulb expands and contracts with causes the red particles to move
from the left tank to the right tank. The blue valves are coupled to the fluid simulation
and prevent backflow.
could be reduced appreciably.
91
Figure 6.7: Liquid initially in the shape of an angel falls under gravity, creating a splash.
92
Figure 6.8: Two nozzles spray liquid onto a dish with a hump shape in the middle.
93
Figure 6.9: Water, initially in the shape of a block, falls under the force of gravity. A
half-hemisphere obstacle on the floor interacts with the moving liquid, as do the boundaries
of the domain.
In some of the animations, artifacts on the free surface appear. I think that the
likely cause is errors in the gradient computation described in Section 4.4.2. Due to errors
in the estimate for the gradient, the pressure field is unable to perfectly counteract the force
of gravity.
On the positive side, the animations feature liquids with a level of detail rarely
observed in results from other state-of-the-art simulators. We believe the ability to conform
to and focus computation near the free surface is the primary reason for this detail.
94
Figure 6.10: The meshes used to generate the animation in Figure 6.9. In the upper corner
of the second, third, and forth panels a zoom in view is shown. Note that the elements
become larger as the distance to the surface increases and that the mesh conforms well to
that surface yet is highly structured.
95
Figure 6.11: Liquid is sprayed inside a transparent box. A thin sheet folds over after the
spray hits the back wall.
96
Figure 6.12: Red Liquid erupts from a mountain (left). On the right a close up of the pool
at the bottom where the liquid accumulates.
Chutes
Spray
Angel
Dam Break
Volcano
Figure
number
6.8
6.11
6.7
6.9
6.12
Meshing time
(mean)
59 sec
53 sec
24 sec
42 sec
26 sec
Sim time
(mean)
61 sec
37 sec
30 sec
49 sec
64 sec
SLC time
(mean)
350 sec
169 sec
276 sec
196 sec
276 sec
Table 6.2: Simulation times for the free surface liquid examples. Meshing is the time
required for mesh generation as well as determination of topological and geometrical information. Sim denotes the time used for numerical integration and pressure correction. SLC
is the time used by the semi-Lagrangian contouring surface tracker. All times are for one
frame of animation.
6.3
Overall Conclusions
The methods presented in this thesis accomplish the goals set forth in the intro-
duction. Our method increases the adaptability of fluid simulation for use in computer
graphics. Overall simulation times are on par with the state of the art. The adaptability
has allowed for the creation of animations involving complex scenarios with highly dynamic
boundary conditions and interaction with interesting shapes.
97
Bibliography
[1] Bart Adams, Mark Pauly, Richard Keiser, and Leonidas J. Guibas. Adaptively sampled
particle fluids. ACM Transactions on Graphics, 26(3):48.1–48.7, August 2007. Special
issue on Proceedings of SIGGRAPH 2007.
[2] Pierre Alliez, David Cohen-Steiner, Mariette Yvinec, and Mathieu Desbrun. Variational tetrahedral meshing. ACM Transactions on Graphics, 24(3):617–625, August
2005. Special issue on Proceedings of SIGGRAPH 2005.
[3] Adam W. Bargteil, Tolga G. Goktekin, James F. O’Brien, and John A. Strain. A semiLagrangian contouring method for fluid simulation. ACM Transactions on Graphics,
25(1):19–38, Jan 2005. Special issue on Proceeding of SIGGRAPH 2006.
[4] Adam W. Bargteil, Chris Wojtan, Jessica K. Hodgins, and Greg Turk. A finiteelement method for animating large viscoplastic flows. ACM Transactions on Graphics,
26(3):16.1–16.8, August 2007. Special issue on Proceedings of SIGGRAPH 2007.
[5] Marie-Paule Cani and Mathieu Desbrun. Animation of deformable models using implicit surfaces. IEEE Transactions on Visualization and Computer Graphics, 3(1):39–
50, January 1997.
98
[6] Mark Carlson, Peter J. Mucha, and Greg Turk. Rigid fluid: Animating the interplay
between rigid bodies and fluid. ACM Transactions on Graphics, 23(3):377–384, August
2004. Special issue on Proceedings of SIGGRAPH 2004.
[7] Mark Carlson, Peter J. Mucha, R. Brooks Van Horn III, and Greg Turk. Melting and
flowing. ACM Transactions on Graphics, 21(3):167–174, July 2002. Special issue on
Proceedings of SIGGRAPH 2002.
[8] J. X. Chen and N. da Vitoria Lobo. Towards interactive rate simulation of fluids
with moving obstacles using Navier-Stokes equations. Graphical Models and Image
Processing, 57:107–116, 1995.
[9] Nuttapong Chentanez, Bryan E. Feldman, James F. O’Brien, Jonathan R. Shewchuk,
and François Labelle. Liquid simulation on lattice-based tetrahedral meshes. In ACM
SIGGRAPH 2007 Symposium on Computer Animation, pages 219–228, September
2007.
[10] Nuttapong Chentanez, Tolga G. Goktekin, Bryan E. Feldman, and James F. O’Brien.
Simultaneous coupling of fluids and deformable bodies. In ACM SIGGRAPH 2006
Symposium on Computer Animation, pages 83–89, September 2006.
[11] A.J. Chorin. Numerical solutions of Navier-Stokes equations. Mathmatics of Computation, 22(104):745–762, 1968.
[12] Paul Cleary, Soon Hyoung Pyo, Mahesh Prakash, and Bon Ki Koo. Bubbling and
frothing liquids. ACM Transactions on Graphics, 26(3):97.1–97.6, August 2007. Special
issue on Proceedings of SIGGRAPH 2007.
99
[13] Gilles Debunne, Mathieu Desbrun, Marie-Paule Cani, and Alan Barr. Adaptive simulation of soft bodies in real-time. In Computer Animation 2000, pages 15–20, May
2000.
[14] Mathieu Desbrun and Marie-Paule Cani. Smoothed particles: A new paradigm for
animating highly deformable bodies. In Computer Animation and Simulation 1996,
pages 61–76, August 1996.
[15] W. J. Minkowycz (Editor), E. M. Sparrow (Editor), and J. Y. Murthy. Handbook of
Numerical Heat Transfer. John Wiley & Sons Inc., New York, second edition, 2006.
[16] Sharif Elcott, Yiying Tong, Eva Kanso, Peter Schröder, and Mathieu Desbrun. Stable, circulation-preserving, simplicial fluids. ACM Transactions on Graphics, 26(1),
January 2007.
[17] Douglas P. Enright, Stephen R. Marschner, and Ronald P. Fedkiw. Animation and
rendering of complex water surfaces. ACM Transactions on Graphics, 21(3):736–744,
July 2002. Special issue on Proceedings of SIGGRAPH 2002.
[18] Raanan Fattal and Dani Lischinski. Target-driven smoke animation. ACM Transactions on Graphics, 23(3):441–448, August 2004. Special issue on Proceedings of
SIGGRAPH 2004.
[19] Ronald Fedkiw, Jos Stam, and Henrik Wann Jensen. Visual simulation of smoke. ACM
Transactions on Graphics, 20(3):15–22, August 2001. Special issue on Proceedings of
SIGGRAPH 2001.
100
[20] Bryan E. Feldman, James F. O’Brien, and Okan Arikan. Animating suspended particle
explosions. ACM Transactions on Graphics, 22(3):708–715, July 2003. Special issue
on Proceedings of SIGGRAPH 2003.
[21] Bryan E. Feldman, James F. O’Brien, and Bryan M. Klingner. Animating gases with
hybrid meshes. volume 24, pages 904–909, August 2005. Special issue on Proceedings
of SIGGRAPH 2005.
[22] Bryan E. Feldman, James F. O’Brien, Bryan M. Klingner, and Tolga G. Goktekin. Fluids in deforming meshes. In ACM SIGGRAPH/Eurographics Symposium on Computer
Animation 2005, pages 255–259, July 2005.
[23] Nick Foster and Ronald Fedkiw. Practical animation of liquids. ACM Transactions
on Graphics, 20(3):23–30, August 2001. Special issue on Proceedings of SIGGRAPH
2001.
[24] Nick Foster and Dimitri Metaxas. Realistic animation of liquids. In Graphics Interface
1996, pages 204–212, May 1996.
[25] Nick Foster and Dimitri Metaxas. Modeling the motion of a hot, turbulent gas. In the
Proceedings of ACM SIGGRAPH 1997, pages 181–188, August 1997.
[26] Nick Foster and Dimitris Metaxas. Controlling fluid animation. In CGI ’97: Proceedings
of the 1997 Conference on Computer Graphics International, page 178, Washington,
DC, USA, 1997. IEEE Computer Society.
[27] R. A. Gingold and J. J. Monaghan. Smoothed particle hydrodynamics —theory and
101
applications to non-spherical stars. In Royal Astronomical Society, Monthly Notices
181, pages 375–389, 1977.
[28] Tolga G. Goktekin, Adam W. Bargteil, and James F. O’Brien. A method for animating viscoelastic fluids. ACM Transactions on Graphics, 23(3):463–468, August 2004.
Special issue on Proceedings of SIGGRAPH 2004.
[29] Eran Guendelman, Andrew Selle, Frank Losasso, and Ronald Fedkiw. Coupling water and smoke to thin deformable and rigid shells. ACM Transactions on Graphics,
24(3):973–981, August 2005. Special issue on Proceedings of SIGGRAPH 2005.
[30] F. Harlow and J. Welch. Numerical calculation of time-dependent viscous incompressible flow of fluid with a free surface. The Physics of Fluids, 8:2182–2189, 1965.
[31] Anil N. Hirani. Discrete exterior calculus. PhD thesis, Caltech, 2003.
[32] Jeong-Mo Hong and Chang-Hun Kim. Discontinuous fluids. ACM Transactions on
Graphics, 24(3):915–920, August 2005. Special issue on Proceedings of SIGGRAPH
2005.
[33] Jeong-Mo Hong, Tamar Shinar, and Ron Fedkiw. Wrinkled flames and cellular patterns. ACM Transactions on Graphics, 26(3):47.1–47.6, August 2007. Special issue on
Proceedings of SIGGRAPH 2007.
[34] Ben Houston, Michael B. Nielsen, Christopher Batty, Ola Nilsson, and Ken Museth.
Hierarchical RLE level set: A compact and versatile deformable surface representation.
ACM Trans. Graph., 25(1):151–175, 2006.
102
[35] Insung Ihm, Byungkwon Kang, and Deukhyun Cha.
gaseous fluids through chemical kinetics.
Animation of reactive
In Proceedings of the 2004 ACM SIG-
GRAPH/Eurographics Symposium on Computer Animation, pages 203–212, Aire-laVille, Switzerland, 2004. Eurographics Association.
[36] Geoffrey Irving, Eran Guendelman, Frank Losasso, and Ronald Fedkiw. Efficient simulation of large bodies of water by coupling two- and three-dimensional techniques.
August 2006.
[37] P. A. Jayantha and I. W. Turner. A comparison of gradient approximations for use in
finite-volume computational models for two-dimensional diffusion equations. Numerical
Heat Transfer, Part B, 40, 2001.
[38] Michael Kass and Gavin Miller. Rapid, stable fluid dynamics for computer graphics.
In Proceedings of ACM SIGGRAPH 90, pages 49–57, August 1990.
[39] Byungmoon Kim, Yingjie Liu, Ignacio Llamas, Xiangmin Jiao, and Jarek Rossignac.
Simulation of bubbles in foam with the volume control method. ACM Transactions on
Graphics, 26(3):98.1–98.10, August 2007. Special issue on Proceedings of SIGGRAPH
2007.
[40] Bryan M. Klingner, Bryan E. Feldman, Nuttapong Chentanez, and James F. O’Brien.
Fluid animation with dynamic meshes. ACM Transactions on Graphics, 25(3):820–825,
August 2006. Special issue on Proceedings of SIGGRAPH 2006.
[41] François Labelle and Jonathan R. Shewchuk. Isosurface stuffing: Fast tetrahedral
103
meshes with good dihedral angles. ACM Transactions on Graphics, 26(3):57.1–57.10,
August. Special issue on Proceedings of SIGGRAPH 2007.
[42] Arnauld Lamorlette and Nick Foster. Structural modeling of flames for a production
environment. ACM Transactions on Graphics, 21(3):729–735, August. Special issue
on Proceedings of SIGGRAPH 2002.
[43] Frank Losasso, Frederic Gibou, and Ronald Fedkiw. Simulating water and smoke with
an octree data structure. ACM Transactions on Graphics, 23(3):457–462, August 2004.
Special issue on Proceedings of SIGGRAPH 2004.
[44] L. B. Lucy. A numerical approach to the testing of the fission hypothesis. The Astronomical Journal 82, 12:1013–1024, 1977.
[45] Stephen F. McCormick. Multigrid Methods. SIAM, Philidelphia, 1987.
[46] Antoine McNamara, Adrien Treuille, Zoran Popovic, and Jos Stam. Fluid control
using the adjoint method. ACM Transactions on Graphics, 23(3):449–456, August
2004. Special issue on Proceedings of SIGGRAPH 2004.
[47] M. Müller, D. Charypar, and M. Gross. Particle-based fluid simulation for interactive
applications. In the ACM SIGGRAPH 2003 Symposium on Computer Animation,
pages 154–159, August 2003.
[48] M. Müller, Barbara Solenthaler, Richard Keiser, and Markus Gross. Point based fluidsolid interaction. In the ACM SIGGRAPH 2005 Symposium on Computer Animation,
pages 273–244, July 2005.
104
[49] Duc Nguyen, Ronald Fedkiw, and Henrik Jensen. Physically based modeling and
animation of fire. ACM Transactions on Graphics, 21(3):721–728, August 2002. Special
issue on Proceedings of SIGGRAPH 2002.
[50] J. F. O’Brien and J. K. Hodgins. Dynamic simulation of splashing fluids. In Symposium
on Computer Animation 95, pages 198–205, April 1995.
[51] S. V. Patankar. Numerical Heat Transfer and Fluid Flow. McGraw-Hill, New York,
1980.
[52] Darwyn R. Peachey. Modeling waves and surf. In SIGGRAPH ’86: Proceedings of the
13th annual conference on computer graphics and interactive techniques, pages 65–74,
New York, NY, USA, 1986. ACM Press.
[53] Simon Premože, Tolga Tasdizen, James Bigler, Aaron Lefohn, and Ross Whitaker.
Particle-based simulation of fluids. Computer Graphics Forum, 22(3):401–410, September 2003.
[54] N. Rasmussen, D. Enright, D. Nguyen, S. Marino, N. Sumner, W. Geiger, S. Hoon, and
R. Fedkiw. Directable photorealistic liquids. In ACM SIGGRAPH 2004 Symposium
on Computer Animation, pages 193–202, July 2004.
[55] Nick Rasmussen, Duc Quang Nguyen, Willi Geiger, and Ronald P. Fedkiw. Smoke
simulation for large-scale phenomena. ACM Transactions on Graphics, 22(3):703–707,
July 2003. Special issue on Proceedings of SIGGRAPH 2003.
[56] Andrew Selle, Nick Rasmussen, and Ronald Fedkiw. A vortex particle method for
105
smoke, water, and explosions. ACM Transactions on Graphics, 24(3):910–914, July
2005. Special issue on Proceedings of SIGGRAPH 2005.
[57] James Albert Sethian. Level Set Methods and Fast Marching Methods. Cambridge
Monograph on Applied and Computational Mathematics. Cambridge University Press,
Cambridge, U.K., 2nd edition, 1999.
[58] M. Shah, J. Cohen, S. Patel, P. Lee, and F. Pighin. Extended Galilean invariance
for adaptive fluid simulation. In 2004 ACM SIGGRAPH/Eurographics Symposium on
Computer Animation, pages 13–221, July 2004.
[59] Jonathan R. Shewchuk. Star splaying: An algorithm for repairing Delaunay triangulations and convex hulls. In Proceedings of the Twenty-First Annual Symposium on
Computational Geometry (Pisa, Italy), pages 237–246, June 2005.
[60] Lin Shi and Yizhou Yu. Inviscid and incompressible fluid simulation on triangle meshes.
Computer Animation and Virtual Worlds, 15(3-4):173–181, 2004.
[61] Lin Shi and Yizhou Yu. Taming liquids for rapidly changing targets. In Proceedings of
the 2005 ACM SIGGRAPH/Eurographics symposium on computer animation, pages
229–236, New York, NY, USA, 2005. ACM Press.
[62] Jos Stam. Stable fluids. ACM Transactions on Graphics, 18(3):121–128, August 1999.
Special issue on Proceedings of SIGGRAPH 1999.
[63] Jos Stam. Flows on surfaces of arbitrary topology. In SIGGRAPH ’03: ACM SIGGRAPH 2003, pages 724–731, New York, NY, USA, 2003. ACM Press.
106
[64] Dan Stora, Pierre-Olivier Agliati, Marie-Paule Cani, Fabrice Neyret, and JeanDominique Gascuel. Animating lava flows. In Graphics Interface 99, pages 203–210,
June 1999.
[65] John A. Strain. Semi-Lagrangian methods for level set equations. Journal of Computational Physics, 151(2):498–533, May 1999.
[66] Adrien Treuille, Antoine McNamara, Zoran Popovic, and Jos Stam. Keyframe control
of smoke simulations. In ACM SIGGRAPH 2003, pages 716–723, New York, NY, USA,
2003. ACM Press.
[67] U. Trottenberg, C. W. Oosterlee, and A. Schuller. Multigrid. Academic Press, London,
2001.
[68] Joe Warren, Scott Schaefer, Anil N. Hirani, and Mathieu Desbrun. Barycentric coordinates for convex sets. To appear in Advances in Computational and Applied Mathematics, 2004.
[69] Jeremy D. Wendt, William Baxter, Ipek Oguz, and Ming C. Lin. Finite volume flow
simulations on arbitrary domains. Graph. Models, 69(1):19–32, 2007.
[70] G. D. Yngve, J. F. O’Brien, and J. K. Hodgins. Animating explosions. ACM Transactions on Graphics, 19(3):29–36, July 2000. Special issue on Proceedings of SIGGRAPH
2000.
[71] Yongning Zhu and Robert Bridson. Animating sand as a fluid. ACM Transactions on
Graphics, 24(3):965–972, August 2005. Special issue on Proceedings of SIGGRAPH
2005.