A Simple fluid solver implementation in javascript. A live demo can be found here.
The demo uses dat.gui for the GUI (included in the vendors
folder).
Simulates the Navier–Stokes equations for incompressible fluids.
Largely based on Jos Stam's paper Real-Time Fluid Dynamics for Games.
The density field is rendered on an off-screen bitmap and blit'ed to the canvas for performance reasons.
The code is commented as best I could where ever I felt it was necessary.
If you want to understand this code I suggest you read the original paper (You will need a good background in math and physics).
Other implementations I've looked at while making this.
- http://www.multires.caltech.edu/teaching/demos/java/stablefluids.htm
- http://blog.inspirit.ru/fluidsolver-as3-port-of-msafluid/
- http://http.developer.nvidia.com/GPUGems/gpugems_ch38.html
Just open index.html
in your browser.