|
COMP 559 - Winter 2011 - Assignment 3 Fluid Simulation
Due noon Wednesday March 2
Getting Started
In this assignment you will implement a simple
yet stable Eularian fluid simulation, similar to the approach
described
in [Stam
et al. 2003]. You should read this link before starting the
assignment, and use it as a reference in completing the requirements
below.
Sample Code
Download the provided code from WebCT. The code has two main
packages, similar to the previous assignment. The setup for jars
and libraries is the same from the previous assignments.
The a4 package contains code to provide a mouse interface
and drawing interface to your fluid simulation code.
- A3App.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 A3App.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.
Steps and Objectives (7/7) * 100%
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
provided code.
Diffusion
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.
Transport
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]).
Scalar Step
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.
Poisson Solve
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).
Velocity Step
Implement a method to do the velocity update step as per GDC03.
This will involves diffusion, transport, and a Poisson projection step.
Buoyancy Forces
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
Metaxas 1997].
Interesting Video
Record a sequence of something interesting or amusing.
Optional: Extensions
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
calculations.
- 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 rigid bodies of Assignment 2?
- Consider adding a higher order integrator into the
advection step.
- 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.
References
-
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.
(vorticity confinement)
-
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.
Finished?
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.
|