Smoke Simulation

What is it

This document is a description on the project, smoke simulation, that I did for cmps161 course. The latest version of this document can be found here

Project Description

For the final project, I have chose to do the smoke simulation. (Due to my (lack of) artisitic sense, I try to avoid anything that needs detailed texture.) After reading and researching for a bit, I believed that a fully-featured simulation can be written in two weeks, however, it didn't happen.

General background on fluid-dynamics simulation: After a bit more of researching, here's what I understand on the current trend on this field. There are two major type of simulations, particle-based and grid-based. The particle-based system keep track of each smoke molecule in the space, do calculation each one of them, and then render them on the screen. This approach is generally considered not a viable method to do for computer graphics, due to the large amount of particles needed to be rendered on the screen in order for it to be realistic; however this approach is often used by the _physics_peoploe_ due to it being more physically real.

The second approach, the grid-system, divides the space into a grid, and each grid element keeps track of amount of smoke molecules and the velocity in it, do calculation, and then use a texture to render that grid element. For my project, I have used the second approach.

For the grid-based system, there are thousands of papers and books published about it, and most of them covers the two main equations, Navier-Stokes, and Euler's equations of fluid dynamics. And among those two, Euler's equation is considered to be much faster. So naturally, I tried to use Euler's equation for my project, and for an overview of using Euler's in computer graphic, please refer to [2]. Here's the Euler's equation of fluid dynamics in the glory of ASCII, and what follows is the path that a physics-challenged computer programmer had to walk in order do a smoke simulation program in OpenGL..
     d(velocity_field)                                                       1
    -------------------  = - ( velocity_field dot del ) velocity_field - --------- del pressure + external_force
          d(time)                                                         density
From the equation above, please note the operator 'del' (which is represented as an inverted triangle). (Yeah, I had no idea of an 'operator' is either before this project, and definitely not 'del'.) After a very minimal amount of searching on the web, I found out that 'del' in the second term means _gradient_. However, what troubled me was the 'del' in the first term; I could not find any reference of what it means when "vector dot" comes _before_ it. During this step, I have consulted with my astro-physics-major roommate, (I hope this _consultation was not in violation of project rules, otherwise I'm going to regret spending hours typing up this detailed report.) and I found out in this context, I have to use velocity_field as an operator, to operate on the 'del' first, and then use the result to operate back on velocity_field.

After more researching, I have come to find a paper[3], which also provides some basic C codes, that I actually understand. What's different about this paper is that this approach uses Fourier Transformer, while others mostly use Lagrangian, Poissan and such. Also, when using this method, the result is much faster, however, with loss of realism that others approaches have. Again, please refer to [3] for detail.

Videos

Don't have one yet since there's no such video-capturing tools exist on Linux (please let me know if I'm wrong). I'll post one if I ever boot a Windows machine.

Binaries

x86 Linux binary
x86 Windows binary - not available yet
Sparc Solaris binary - not available yet

Screenshot

User Guide

(Please note that most of settings don't exist in a previous version, the one submitted and demonstrated in class.)

After you have started the program, you can do two things by dragging your mouse: one is to set the velocity fields, and another is injecting smoke. You can set them through the checkboxses on the right under "Mouse Control". The velocity is set by the direction that you're dragging your mouse.

There are also few other controls:

Velocity Field Damping: adjusting this amount will change the rate on fast the velocity grids slows down. When set to 0, the velocity grids won't decrease. When set to maximum, the velocity will stop immediately after you set it.

Smoke Disperse Rate: This settings changes how fast the smoke will vanish. At minimum, the smoke will never disappear; when at maximum, the smoke will disappear soon after it's created.

Integration Step: This setting sets the integration step increment.

Amount of smoke to inject: This sets the amount of smoke to inject when you click/drag your mouse, and the amount injected at center at each frame if "Inject Smoke At Center" is checked.

Viscosity: This sets the viscosity of smoke - how easy the smoke can move around. At minimum, the velocity grids will be effected much more by the grids next to it. After maximum, the velocity grids won't be effected by the velocity grids next to them.

Inject Smoke at Center: This option will inject the smoke constntly each frame at the center of opengl window.

Start Button: Clicking this button will start the simulation. This program does not do have much when it's in 'Stopped' stage, but this option was added mainly to save my laptop's battery power when I'm debugging the program.

Exit Button: Clicking this button will do all the necessary memory cleaning, and then exit the program.

References

[1] J. Stam. Stable Fluids. In SIGGRAPH 99 Conference Proceedings, Annual Conference Series, page 121-128, August 1999
[2] R. Fedkiw, J. Stam, and H. W. Jensen. Visual Simulation of Smoke. In SIGGRAPH 2001 Conference Proceedings, Annual Conference Series, pages 15-22, August August 2001
[3] J. Stam, "A Simple Fluid Solver based on the FFT", Journal of Graphics Tools, Volume 6, Number 2, 2001, 43-52