First, there is the fact that everyone knows, namely, fire is hot, and heat rises. Heat rises because it is less dense than air, but the whole idea of Eulerian fluid simulation is to make things the density uniform at all points, that is, to make the fluid incompressible. So how do we account for temperature. I had no idea, so i cribbed the idea from someone else.

The basic method turned out to be to take the density (that's density of smoke or fire, or fog, or whatever, floating around in the fluid), and treat it as the temperature. Once you know that, adding buoyancy is trivial, just introduce an upward force on every point proportional to the density at that point. This gives much better results than my earlier method, that of shooting the fire upwards, as if out of a garden... um flamethrower.

The second problem is that, in most Eulerian, (read

*Jos*

*Stammian*) fluid simulation, the velocity field tends to be smooth, and vortexes tend to disappear almost immediately. This can be solved through grid-based vorticity confinement, which, I discovered is not actually that hard, and has to do with identifying and increasing curvature for all cells.

The only remaining problem is that simple fluid simulations like to diffuse their density, but hate to loose track of it. No color disappears. I had to make it go away manually. A fairly simple coefficient-based decay function solved this problem, and voila, a little bit of fire on my screen.

Here's the first stage of my solver, with, of course, the source code:

https://sites.google.com/site/stylustechnology/recent-stuff/eulerian-fluid-simulation

## No comments:

## Post a Comment