Graphics Reference
In-Depth Information
-6-
Water
We, in fact, have most of the machinery in place now to simulate water
as well. Our starting point is treating water as a fluid with a free surface
boundary condition where it's in contact with air. The main new ingredient
is geometric: the free surface condition allows the water to change shape,
and thus we need to track or capture
1
that shape somehow. Along the
way, we'll also cover extrapolation, which until now we've hidden under the
rug.
Before jumping in, a note on terminology: the air-water surface or
boundary is also often called an
interface
. Most of this chapter is about
how to evolve this interface.
6.1 Marker Particles and Voxels
We'll begin with the simplest possible water simulator. Here we'll use the
voxelized pressure solve first covered in Chapter 4, which only required us to
classify each grid cell as being fluid (i.e., water), empty (i.e., air), or solid.
While the solid cells should be straightforward to identify, determining
when to switch a cell to fluid or empty as water moves in or out of it due
to advection under the velocity field is the tricky part.
This is where we introduce
marker particles
, used all the way back in
Harlow and Welch's seminal marker-and-cell paper, which also introduced
the MAC grid [Harlow and Welch 65]. We begin the simulation by filling
the volume of water with particles and viewing them as a sampling of the
water geometry (and if there are sources adding water during the course of
the simulation, we seed particles from them as well). Within each advection
step we move the particles according to the grid velocity field, so that they
naturally follow where the water should be going—using RK2 or better,
1
In some numerical contexts, tracking and capturing are technical terms referring
to different approaches to solving this problem: tracking loosely corresponds to meth-
ods using explicit descriptions of surfaces, such as meshes, whereas capturing refers to
methods built on implicit descriptions of surfaces.
83