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!
This is a simulation of a two-dimensional fluid. Initially the fluid is flowing from left to right, and a linear barrier (shown in black) diverts the fluid and creates vortices. The colors indicate the curl, or local rotational motion, of the fluid.
Fluid mechanics is difficult indeed. The primary reason is there seems to be more exceptions than rules. This subject evolves from observing behaviour of fluids and trying to put them in the context of mathematical formulation. Many phenomena are still not accurately explained.
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With