Assignment
2: Smoke Simulation!
Due: March 5th, 2010
Starter code: For MSVC 2005, For MSVC 2008
Overview
The purpose of this assignment is to experiment with incompressible
fluid simulation implemented with a Semi-Lagrangian approach.
You will implement a 3D Smoke simulator using the techniques described in the
following resources:
- Class slides
- Fluid Simulation: SIGGRAPH 2007 Course Notes (Chpts 1-5) by
Bridson, Fedkiw, and Muller-Fischer

The startup code includes
an incomplete fluid animation system. Although rendering
and most of the necessary data structures have been written, this will
be a challenging assignment. You will need to implement the
following:
- (60 points) Air,
smoke density and temperature simulation (MACGrid.h)
- (25 points) Implement a Semi-Lagrangian approach to solve
the
advection step for air velocity, smoke desnity, and temperature
- Implement MACGrid::advectVelocity():
GriddedData for U,V,W components of the velocity have already been
setup for you See member variables MACGrid::mU, MACGrid::mV,
and MACGrid::mW.
- Implement MACGrid::advectTemperature(): GriddedData for
temperature has been setup for you. See member variable
MACGrid::mT.
- Implement MACGrid::advectDensity():
GriddedData for density has been setup for you. See member
variable MACGrid::mD. Additionally, values in mD will
automatically be rendered for you.
- Implement MACGrid::updateSources(): Initilialize a
smoke source, for example, have smoke come
up from the bottom of the container
- Implement buoyancy forces
- Look at MACGrid::addExternalForces()
- Implement MacGrid::computeBouyancy()
- (25 points) Solve the poisson equation for pressure
- Implement MACGridd::project(). Use the
function cg_solve() to solve a system of linear equations using the
conjugate gradient method described in class.
- (10 points) Add vorticity confinement forces
- ImplementMACGrid::computeVorticityConfinement()
- (30 points) Boundary
conditions and solid objects
- Smoke should be contained within a closed box (e.g.
boundary conditions with the sides of the grid should be correct -- see
the Bridson notes for details)
- Implement a solid object within the grid (any shape).
- (Extra Credit
- Up to 20 points)
- Implement a preconditioner for the conjugate gradient
step. Document which preconditioner you used, plus the
speedup you got
- Add dynamic objects, for example, an object that the user
can move with the mouse
- Add mouse interaction forces
- Implement a better numerical scheme to avoid numerical
dissapation, for example, cubic interpolation such as the one described
in "Visual Simulation of Smoke" by Fedkiw, Stam, and Wann Jensen.
- Implement fluid viscosity. Compare and show the
results with and without viscosity.
- Submission
- ZIP your .cpp, .mel, .h, .vcproj, and .sln files
and submit to
Blackboard. For
full credit, your application
must build without modifications for either msvc 2005 or 2008. Only complete submissions will be graded.
- Briefly write-up which questions you completed in
a file called
README.txt.
- If you used
any additional sources, you must include them in your writeup
- Include movies
showing off your work
IMPORTANT!
If
you used — or looked at — any source code you found somewhere else or
which someone else wrote, even a single line, you SHOULD describe that
in the writeup. You
are not allowed to use any fluid simulation code available on the web!
Please talk to us before using any existing code for this assignment
except for the code provided by us.
Questions for you to answer (10 points)
Notes
Dependencies
This project was built and tested with GLUT,
Boost 1.37 and Boost 1.42,
and Devil 1.6.7 on MSVC 2005. GLUT and DevIL are included these with the source, but you will need to download Boost.
We use Boost's
UBLAS library for its very effecient matrix data
structures and operations (especially
for sparse matrices). DevIL is an image library used to
implement screen capture.
Built in features
- Simulation controls
- Play: Press '>'
or right click to start the simulation
- Pause: Press '='
or right click to pause the simulation
- Reset: Press '<'
or right click to reset the simulation
- Camera controls
- Rotate: Left click, drag to rotate.
- Zoom: Middle click, drag to zoom.
- Rendering options
- Velocity display: Press 'v' or right click to
toggle the
drawing of velocity vectors.
- Render density as transparent, white cubes
- Render density as sheets with interpolation between
cells
(looks smoother)
- Recording mode
- Press 'r'
or right click to toggle screen
capture. Every frame will be saved to the /output directory
which you can assemble into a movie file with tools such as Adobe
AfterEffects or VirtualDub.
Alternatively, you can use FRAPS to create
- Configurable grid size
- Edit the global dimensions 'theDim' defined in
GriddedData.cpp
Important data
structures
- Gridded data: Gridded data is a low level data structure
for implementing any data stored in a grid. See GridData.h
for details.
- MAC Grid: MAC Grid implements a staggered
grid described in the Bridson fluid notes. X,Y,Z
components of the velocity are stored at each face. Other quanitites
such as density and temperature are stored in the cell centers.
Hints
- Start small! Carefully check your calculations with a tiny grid, say 2x2x1, in debug mode.
Then test in release mode with a larger grid.
- Release mode is much faster than debug mode
- Test your smoke with a 2D Grid, for example, set the grid dimensions to 10x10x1
- Don't forget you can visualize your velocities!
- If you find cg_solve does not converge, it's likely that your system of equations are not setup correctly.
- Make sure your A matrix is positive semi definite. You can check in matlab or write a function to test
- Checking
your projection step: remember that the projection step ensures
that the resulting fluid is non-divergent. Therefore, after
calling project, computing the velocity divergenceof each cell should
be zero. If this is not the case, there's a problem.