Fluid dynamic simulation, with obstacles

7.3k views Asked by At

I'm trying to write a fluid dynamic simulator on the HTML5 canvas. I've found some real damn cool stuff on the internets that always look like a promising starting point, but they are all cell-based and use some crazy math.

I'd like to be able to add arbitrary obstacles (lines of any orientation, circles, etc) to make things more interesting, but I've no idea where do begin.

Does anyone know of some fairly simple equations for fluid simulation that include obstacles of any orientation? Alternatively, could anybody point me towards the math required to take one of the above examples and add obstacles?

I know that this question borders on something I should ask mathoverflow, but they seem more into the theory stuff. Apologies if I'm in the wrong area. I don't really know where to begin - if anyone's worked on fluid simulation with arbitrary obstacles before, I could use some pointers.

Accuracy takes a back seat to simplicity here.

Thanks!

5

There are 5 answers

0
duffymo On BEST ANSWER

Fluid dynamics isn't a simple topic. All that "theory" they like over at the other site is just the way this field works.

The simplest example of fluid flow is 2D, incompressible, irrotational, laminar flow. I'd start by looking into that.

But it's not an easy field. There's no "Teach Yourself Computational Fluid Dynamics In Ten Days" books out there.

1
simong On

If you don't care about real accuracy but just want something swooshy and cool, I developed a very simple pressure-based simulation that delivers a very fast interactive interface in Javascript. You can see it here.

1
Endre Simo On

Here is a pretty decent list of everything You need to know about fluid dynamics and simulation: http://www.dgp.toronto.edu/~stam/reality/Research/pub.html

Also you should check this site, where you can find the concrete source code written in Java and transported to Actionscript3. It's pretty documented, so shouldn't be a problem to transport to Javascript.

1
batty On

The best book to read for introduction to graphics-oriented fluid simulation is "Fluid Simulation for Computer Graphics" by Robert Bridson (disclaimer: he was my PhD advisor). http://www.cs.ubc.ca/~rbridson/fluidbook/

Ultimately, there is plenty of math involved, but there's also plenty of code examples to clarify things for the less math-inclined.

It covers mainly the cell-based approach you mentioned. The other main alternative is "Smoothed Particle Hydrodynamics" or SPH. Matthias Muller has some papers about this if you're looking to get started.

0
Ramin On

I have tried that and just to let you know there is an important part of Fluid simulation of any kind called Projection which is computationally extensive even on CPU it takes much and you might well know that Javascript is quite slow for many reasons.