In this assignment you will implement a simple
yet stable Eularian fluid simulation, similar to the approach
et al. 2003]. You should read this link before starting the
assignment, and use it as a reference in completing the requirements
Download the provided code from WebCT (do not distribute). The
code has two main packages, similar to the previous assignment. Note
that the tools
package has minor updates, so you will want to
make sure you use this one. The a4
package contains code
to provide a mouse interface and drawing interface to your fluid
- A4App.java contains the mouse interface and drawing code.
Left click creates a source, while right click will delete
it. Sources can be dragged using the left button, while
dragging while holding the right button will apply forces to
your fluid simulation. The mouse wheel, while hovering over
a source, can be used to adjust the heating/cooling rate of a
source. Clicking with the middle button will create a
horizontal filament. There are keyboard controls similar to
previous assignments (space to toggle the simulation, R to
reset, S to step, enter to record, C to create filaments);
see the code for full details, and feel free to adjust the
interface to suit your needs.
- Filament.java contains simple code for creating, advecting, and refining
thin filaments. This is provided purely as an additional visual
aid in determining if your fluid is behaving correctly.
- Source.java contains code representing a heating or cooling source.
A list of sources is maintained by the fluid, and is editable using
the mouse with the code in A4App.java.
- Fluid.java contains the fluid simulation framework. This should
be the only place where you need to add code.
You do not need to change
anything except Fluid.java. However, you are free to edit
everything as you please, and you are certainly encouraged to
explore and understand the rest of the provided code as it is
small in size. Be sure to leave a comment in your readme.txt on
any additional test cases you add, or other modifications outside
of the Fluid.java code.
The setup for jars and libraries
is the same from the previous assignments. Consult the
A1 page for more information. Likewise, you may also
want to visit the previous assignment specification for
instructions on making videos.
You will find that there is already a fair bit of provided code in
the Fluid class. There are forces applied to the velocity field
when mouse dragging while right button is held. With the velocity
field visualization turned on you can implement and test many
parts of the assignment. Implementing in this case will often
mean taking code directly from the GDC03 code examples. Note that
in your final step method, there are three main components: apply
forces, update velocities, update scalar fields (temperature,
density, etc.). Most steps should be trivial to implement and you
should be able to test each using the functionality of the
Implement stable diffusion as per GDC03. Test it on the
velocity field. Use the DoubleParameters in the Fluid code
to select the diffusion rate and the number of iterations
to use with the Gauss Seidel method.
Implement a method to advect quantities in a scalar field
based on a velocity field. You can follow the advect code
example in GDC03, but you should probably use
the traceParticle (already provided) to find what goes
where. Note that you might want to change traceParticle be
higher order or adaptive (see also [Stam 1999]).
Implement a method to do the scalar step which will diffuse
and advect scalar quantities in the temperature field. Note
that you'll also want to apply the heating / cooling effects
of different sources to test your method. Recall that you
want to left click and then use the mouse wheel to create
some sources for your test.
Implement a method to do fix the velocity field so that it
is divergence free. Use a Gauss Seidel solve as per GDC03,
and use the DoubleParameter in the diffusion step. Note that
as an extension you may want to consider a better solver
(e.g., Conjugate Gradients).
Implement a method to do the velocity update step as per GDC03.
This will involves diffusion, transport, and a Poisson projection step.
Use the temperature scalar field to compute buoyancy forces
to apply to the scalar field. Use the buoyancy
DoubleParameter to scale the response. Thus, the velocity
update (vertical direction only) is buoyancy times step size
times temperature delta (comparing the temperature with the
reference temperature). For more details, see [Foster and
Record a sequence of something interesting or amusing.
There are a vast number of possible extensions. Here are
a few you might like to think about:
- Change the domain size, e.g., allow it to be a rectangle.
Change the width and height of cells. How does this change
the divergence and Laplacian and other computations? Would
it be difficult to use an arbitrary triangular grid?
- Extend the code to work in 3D. How would you visualize
the different scalar fields?
- Staggered grids. Many people prefer to define
velocities at cell boundaries. This makes for a trickier
interpolation problem while simplifying some of the other
- Add obstacles to fluid flow using geometry. How might
you make these obstacles dynamic and have fluid forces
move these objects? What would be necessary to combine
this fluid code with the 2D mass spring particle systems of
- The projection step could use a number of different
fast solvers. Note that [Stam 1999] used FISHPAK.
- Use vorticity confinement to combat numerical dissipation
(see [Fedkiw et al. 2001]).
- See also the extensions listed at the end of the GDC03 article.
J. Stam, Real-Time Fluid Dynamics for Games, GDC 2003.
J. Stam, Stable Fluids, SIGGRAPH 1999.
R. Fedkiw, J. Stam, and H. W. Jensen, Visual Simulation of Smoke, SIGGRAPH 2001.
R. Bridson, and M. Müller-Fischer, Fluid Simulation for Computer Animation, SIGGRAPH 2007 Course Notes.
N. Foster and D. Metaxas, Modeling the motion of a hot, turbulent gas, SIGGRAPH 1997.
A. Bargteil, Physical Simulation for Computer Animation
Assignment 3, CMU, Fall 2007.
This assignment has no written questions.
Great! Submit your source code and xvid encoded videos as a zip
file via webCT. Include a readme.txt file with any specific
comments. Your readme should provide a list of people with which
you discussed the assignment, or state that you did discuss the
assignment with anyone.