Programming Assignment 2: Smoke Simulation

(submit by 14/06/2005)

Your second assignment is to experiment with smoke simulation (in 2D): you will simulate a circular object following a sinusoidal path while emitting smoke and leaving a wispy trail of smoke behind it.

To aid you in this assignment you are provided with code that implements Jos Stam's method (described in the paper "A Simple Fluid Solver Based on the FFT", available here). This is a very simple fluid solver for simulating 2D flow with periodic boundary conditions. The code is available under ~danix/atcg2005/smoke.

Part I:

To begin with, you will need to implement a function which tracks a circular shape across the simulation domain, generates forces and new smoke in the grid cells covered by the shape, and perform smoke decay across the entire domain. More specifically, the function is:

void track(int n, fftw_real *u, fftw_real *v, fftw_real *rho, fftw_real dt, fftw_real t)

where:

The trajectory of the moving circle is cyclic across the computational domain, and is given by:

x(t) = 0.15 * t (%n)

y(t) = n * (1/2 + 1/4 * sin(0.01 * M_PI * t))

The circle (which has the radius sqrt(20)) should generate smoke according to the following equation: rho_t = 0.1 * (1 - rho), and exert a force on the fluid that is given by 0.001 times the circle's velocity.

The smoke decays across the entire simulation domain at a rate of 1/100, and the velocities also decay at a rate of 1/250. To mimic buoyancy, you should also add exert a force along the y axis with magnitude (1/10000)*rho.

Raanan's school solution for this part of the assignment consists of fewer than 20 lines of code!

Part II:

As you'll undoubtedly notice, the evolving smoke density is very smooth, lacking interesting detail. To make things more interesting you will implement the vorticity confinement idea described in Section 3 of the paper "Visual Simulation of Smoke" by Fedkiw et al. (available here) . Also, rather than using bi-linear interpolation when advecting the smoke (in the advect_matter function), you should implement the monotonic cubic interpolation described in Appendix B of the same paper.

Bonuses: will be given for a nice GUI enabling experimentation with different simulation parameters, other interesting extensions.

Files: Under ~danix/public/atcg2005/smoke you'll find a Makefile and a source file (fluids.cc) which lacks the implementation of the track function, and a school solution executable (sim). Note that the school solution only implements Part I.