Title: Simulating Smoke and Water in CG
1Simulating Smoke and Water in CG
- Introduction to Water Simulation
- and
- The Level Set Method
2Last Time
- Hypertexturing
- Cellular Texturing
- Vortex Particle Method
3This Lecture
- Introduction to Water Simulations
- The Level Set Method for Representing the fluid
surface
4Intro to Water Simulations
We want to be able to simulate water like this
In fact you have already learned how water moves
The Navier Stokes Equations
In the case where we are not interested in the
fluid surface you can just use the methods you
have already learned.
There are three main open questions
- How do we represent the fluid surface? (this and
next lecture) - How do we make the fluid surface move? (this
lecture and next Tuesday) - How do we confine the volumetric velocity field
to within the fluid (next Tuesday)
5How do we represent the surface?
- A water surface behaves in very complex ways
- It changes topology The surface merges and
breaks up. - It stretches and contracts.
6How do we represent the surface?
In an explict surface representation, the points
on the surface are specified explicitly. In this
example the representation is a surface mesh
consisting of connected triangles.
7How do we represent the surface?
- What happens when using an explicit surface
representation? - In an explicit representation, only the surface
is - maintained, not the inside and outside.
Loops are created and we have to remove them and
determine inside and outside. But what is inside
and what is outside? No general algorithm
proposed in 3D!
8How do we represent the surface?
- In an implicit surface representation, the
surface is represented implicitly as the
iso-contour (level set) of a higher dimensional
scalar function (the surface has co-dimension
one), and inside/outside information is
unambiguous.
The signed distance field (a scalar field) is
one such surface representation...
9How do we represent the surface?
gt0
lt0
0
The unsigned distance field
The surface S is defined as
The signed distance field
where sign(x) is -1 inside and 1 outside.
Inside and outside is unambiguous A scalar
value cannot be both postive and negative!
10How do we represent the surface?
- Dynamic Implicit Surfaces (the signed distance
field combined with a - framework for advecting and propagating implicit
surfaces) or Level Set Surfaces - are a good candidate for representing fluid
surfaces - Inside/outside information is unambiguous
(always a closed surface). - No stretching and contraction artifacts as
surface patches are not explicit. - Topological changes are easily handled by the
surface embedding (is just a - matter of changing scalar values in the right
way). - The level set framework provides the vanishing
viscosity solution with no loops - which is the visual solution we desire.
- As we know, differential properties are easy to
compute on a scalar grid.
11Intuition About Topology Change using Level Sets
Consider a 1D level set curve in 2D propagating
with time. We are solving the equation ?(x,y,t)
0 which in itself is a 2D iso-surface of a 3D
scalar function.
t
t2
t0
t0
t1
This means that the 1D curve is just the
intersection of a 2D Surface with a plane
orthogonal to the time, t, axis.
12Applications of Level Sets, 1
- Geometrical Modeling
- Morphing
- Medical Segmentation
13Applications of Level Sets, 2
- Water Simulations
- Fire Simulations
- Film production (Day after tomorrow, T3, Scooby
Doo 2, Peter Pan ...)
14The Level Set Method
- Given a surface as a signed distance field and a
velocity field (e.g. a fluid velocity field), how
do we move the surface in the velocity field?
The surface, S, is given by
Written more compactly as
Consider a particle on the surface as a function
of time, x(t) is its path. We differentiate with
t
This is a linear Partial Differential Equation
(PDE)
15The Level Set Method
- Some problems are easier to model by motion in
the normal direction Geometric Smoothing,
Morphing, Geometric Modeling. - How do we derive an equation for this?
Split V into its normal and tangential components
Insert it into the level set equation
Recall that
Which gives
This is a non-linear Partial Differential
Equation (PDE)
16The Level Set Method
- Let us develop some intuition about the level set
equation - How do we move a surface outwards in the
direction of the normal (dilation)?
17The Level Set Method
- Let us develop some intuition about the level set
equation - How do we move a surface inwards in the direction
of the normal (erosion)?
18The Level Set Method
- Let us develop some intuition about the level set
equation - How do we smooth a surface?
19The Level Set Method
- How do we do shape-metamorphosis between two
surfaces?
The Original
More Stable
20Numerical Solution of the Level Set Equations
- The two level set equations are identical
mathematically. But numerically we have to solve
them differently. - The linear equation
is solved using upwind or semi-lagrangian
methods. - The non-linear equation
is solved using the Godunov Scheme.
Today I will explain only the linear equation...
21Numerical Solution of the Level Set Equations
- Consider the following situation in 1D
V1
?
0.5
x
i
-0.5
We want to move the level set to the right, ie
V1. Assume we are at time n ?t, and we solve for
time (n1)?t. At position i at time (n1)?t, ?
-0.5.
We discretize this using a forward Euler
time-step
And re-arrange the terms
22Numerical Solution of the Level Set Equations
So we are looking at
How should we discretize the gradient at position
i? We have three standard ways
0.5
1
0
Computing these three in our case gives.
But which one is the right one? Recall that at
position i at time (n1)?t , ? -0.5. Inserting
into the equation
gives
-0.5
0.5
0
In general we should use the finite difference in
the direction opposite to The direction of the
velocity. This is called UPWIND DIFFERENCING.
23Numerical Solution of the Level Set Equations
- The numerical methods used for level set
advection are typically not unconditionally
stable (one exception is semi-Lagrangian
advection) - The CFL condition tells us the largest time-step
we are allowed to take in order for the solution
to remain stable. For the level set equation it
looks like this - You can also think of it as, the maximal distance
travelled in one time-step by the surface must be
less than the grid spacing
24Numerical Solution of the Level Set Equations
- It turns out that, in general, the signed
distance function does not remain a signed
distance function after advection. - The signed distance function behaves nicely
numerically (Lipschitz continous) and stability
conditions are derived under the assumption of a
signed distance field. - Consequence We need a way to reset the level set
function to a signed distance field
Re-Initialization.
25Numerical Solution of the Level Set Equations
- Re-initialization itself can be formulated as a
level set equation that is solved iteratively
until convergence. - Hint We have convergence when
- For outside (positive values)
- For inside (negative values)
- Values on the surface (zero) should not move!
- The combined equation
- Is solved numerically using the Gudonov Scheme.
-
26Numerical Solution of the Level Set Equations
- A loop for level set advection looks like this
- for (number of iterations)
- Advect(velocity field)
- Advect(level set, velocity field)
- Re-initialize(level set)
- end
27The Narrow Band Level Set Method
- The level set method as previously described
solves the level set method in the entire domain
of the embedding scalar function. - BUT we are only interested in the zero-crossing
of the scalar function. - Narrow band level set methods track a narrow band
of scalar values about the zero-crossing.
28The Narrow Band Level SetMethod
The narrow band of a circle. Outside of the
narrow band, values are clamped
29The Narrow Band Level Set Method
- The coordinates of the grid points inside the
narrow band are kept in arrays. - Advection is done in the gamma tube
- for (all (x,y) in gamma tube)
- Solve Level Set Equation
- End
- Re-initialization is done in the N tube (the
gamma tube one additional layer of grid points) - Computations at grid points in the gamma tube
(but not in the beta tube) are damped to avoid
oscillations/instabilities.
30The Narrow Band Level Set Method
- At each iteration the narrow band needs to be
rebuilt - Grid points are added to the narrow band in
regions where the surface moved closer to the
edge, and grid points are removed to the narrow
band in regions where the surface moved further
away from the edge (of the narrow band). - This is determined by looking at the values of
the grid points.
31Next Time
- Improving the accuracy of the level set method
(the particle level set method)