Simulating fluid flow over a heightmap

I am looking for a way to approximate a volume of fluid moving over a heightmap. The easiest solution I can think of is to approximate it as a large number of non-drawn spheres, of small diameter (<0.1m). I would then place a visible plane representing the surface of the water on "top" of the spheres, at the locations they came to rest. To my knowledge, no managed physics engines contain a built in fluid simulator, hence the question.

Implementation would consist of using a physics engine such as JigLibX, which is capable of simulating the motion of the spheres. To determine the height of the planes, I was thinking of averaging the maximum height of each sphere that is on the top layer of a grouping.

I dont expect performance to be great, but would it be approachable for real time? If not, could I use this simulation to pre-bake lines of flow?

I hope this makes sense, I really want opinions/suggestions as to whether this is feasible, or if there is a better way of approaching this.

Thanks for any help, Venatu

(If its relevant, my target platform is XNA 4.0, using C#. Windows only at this point in time, so PhysX/Havok are possibilities for the simulation, but I would prefer a managed solution)


I haven't seen realistic fluid dynamics in real time without using something like PhysX as of yet - probably because the calculations needed are so complicated! The problem with your approach as I see it would come with the resting contact of all those spheres as they settled down, which takes up a lot of processing power. Lots of resting contact points are notorious for eating into performance very quickly, even on the most powerful of desktops.

If you are going down this route then I'd recommend modelling the fluid as an elastic but solid body using spring based physics, where the force applied to one part of the water would use springs to propagate out to the rest. This gives you the option of setting a breaking point for the springs and separating the body into two or more bodies when that happens (and the reverse for coming back together.) This can give you the foundation for things like spray. It's also a more versatile approach in terms of performance, because you can choose the number of particles and springs you use to approximate your model.

It's a big and complicated topic, but I hope that provided at least some insight!


The most popular method to simulate fluids in real-time is Smoothed-particle hydrodynamics .

Several useful links:

http://en.wikipedia.org/wiki/Smoothed-particle_hydrodynamics

http://http.developer.nvidia.com/GPUGems/gpugems_ch38.html

http://www.plunk.org/~trina/thesis/html/thesis_toc.html

In addition to simulation itself you will also need some specialized broad-phase collision detection algorithms such as sweep-and-prune or hashing cells.

And you're right, there is no completed 2d solutions for the fluid dynamics.


看看这里:http://varunpant.com/demo/Silverlight/water.html和http://www.varunpant.com/posts/water-simulation,也许http://www.dhteumeuleu.com/multi-流体/

链接地址: http://www.djcxy.com/p/8812.html

上一篇: POSIX信号行为

下一篇: 在高度图上模拟流体流动