COMP 599 - Winter 2010 - Assignment 4
Fluid Simulation

Due 23:39 pm Thursday March 25

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 (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 simulation code.
  • 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.

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.

  1. 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.

  2. 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]).

  3. 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.

  4. 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).

  5. Velocity Step

    Implement a method to do the velocity update step as per GDC03. This will involves diffusion, transport, and a Poisson projection step.

  6. 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].

  7. Interesting Video

    Record a sequence of something interesting or amusing.

  8. 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 mass spring particle systems of Assignment 2?
    • 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

Written Questions

This assignment has no written questions.

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.