Fluid dynamics

Started by
17 comments, last by Inian 17 years, 11 months ago
Hey there. I'm currently working on a project in school where I want to simulate the internal workings of a fluid in a static environment. This is mainly for a submarine game where it will be used to add some extra feeling to the water without actually having any affect on the gameplay itself. Currently I have been looking at three different models for this type of simulation and have made very little progress deciding which one to go with. The models are: Navier-Stokes equations - Simulates everything perfectly but is slow to compute/implement. Lattice Boltzmann - Actually, I'm having trouble finding any info about this but I've heard it's heavy to implement/compute but it seems to be gaining ground in the simulation world. Cellular Automata - A very rough simulation that will need a lot of tweaking to make it look good, advanced behaviour (Coanda effect/turbulence) will be difficult to implement. But in general it's easy to get working on a rough scale and supposedly it's fast but somewhat memory consuming. I guess it's fairly obvious that CA is the one I feel is the most appropriate at the moment but I'd like to know if there are other ways of doing this that I have overlooked. Or if you think I am on the right track with CA. Cheers!
Advertisement
Quote:Original post by Inian
I'm currently working on a project in school where I want to simulate the internal workings of a fluid in a static environment. This is mainly for a submarine game where it will be used to add some extra feeling to the water without actually having any affect on the gameplay itself.


Since the fluid model is really icing on the cake, I don't think the models you are looking at a worth implementing. Don't get me wrong: if you are just interested in modelling the fluid for your own personal satisfaction, then full steam ahead! However, if you just want to convey the idea of fluid motion to the player these methods are overkill.

I'm really too sure though what you hope to convey to the user. I mean, the Coanda effect is hardly something that is going to affect a submarine, and even turbulence is generally going to be slight. Perhaps you could elaborate on what you want the user to experience?

--www.physicaluncertainty.com
--linkedin
--irc.freenode.net#gdnet

google for

fast stable fluids

there was a "pong" game a couple of weeks/months back on the gamedev image of the day - maybe you want to do something similar?

If you want to simulate the air/liquid interface as well then a particle method (e.g. smoothed particle hydrodynamics) might be appropriate.

2D or 3D is a big difference...
Maybe Real-Time Fluid Dynamics for Games is what you are looking for?
To jjd:

Well, the fluid modelling part is what I am working on, the fact that it's for a game is just to have someone to evaluate my results. In the said game the fluid won't affect the submarine at all, I'm not sure what my client really wants it for but he was talking about alien corpses floating around or something like that. Actually it began with me wanting to model an outdoor scene with some hills and tree's and having leaves blow over the terrain and just look awesome, but I wasn't allowed to do this so now I'm making something for alien corpses in a submarine game. The reason I got interested in all of this is because the usual way to fake wind is with some form of cheesy vertexshader and a sin function. And being me I want something a little different, everyone else is doing HDR, fur shading and similar boring pretentios brown-nose projects and I want to be different choosing something that is tough and uncommon.

To MrRowl:

I have googled ;) a lot. So did this pong have an internal fluid sovler of sorts? Otherwise I don't see it's relevance. No, I don't want to simulate the air/water interface, just the internals of one fluid (Water mainly but I'm going to use it for Air also since they are fairly much the same on a larger scale.) I haven't seen any good fast implementations of smoothed particle hydrodynamics out there, the fastest was a 4 hour rendering of a 10 second animation... not really real-time if you ask me. If you have any links to solutions like this I'd love to see em though.

To twanvl:

WOW!!! Perfect! This is exactly what I am looking for! Thank you very much!
Inian, Stam's papers are great, as is Mark Harris'.

I've converted Stam's source code from the paper into 3D, so if you are interested in that, I can pass you along a copy of it.
Using the Stam method in 3d, be very careful about memory. For instance, if you try to use a 128x128x128 space, storing each of density and 3 components of velocity as floats, that's 32 megs of memory. And you could do something like 80 passes over this memory to resolve all the gauss-seidel relaxations. You'll be memory-bound in a heartbeat.

Don't get me wrong... this is a fine method. But I would still advise you to see how far you get with 2D first. Either that, or try to shift the location of the grid with the submarine so you don't have to compute more than a 64x64x64 section of fluids.
I wrote my bachelor's thesis last semester based on Stam's article. Or specifically, on ways to optimize it. It's a great article, but don't just copy his code. It's horribly inefficient. [lol]

The very first fix should be to swap the loops when iterating through the array. His code does so column-major, which thrashes the CPU cache.

We made a bunch of other changes, and ended up with an 8x speedup.
Only problem is that we wrote our report in Danish, otherwise I'd send you a copy... [wink]

But PM me if you're interested in our code, or a description of what we changed.
Quote:Original post by jjd
However, if you just want to convey the idea of fluid motion to the player these methods are overkill.

I'm really too sure though what you hope to convey to the user. I mean, the Coanda effect is hardly something that is going to affect a submarine, and even turbulence is generally going to be slight. Perhaps you could elaborate on what you want the user to experience?


[imwithstupid] there's no 'I'm with' emoticon on GameDev.net; delete 'stupid'

here we go, grabbed some from CorvetteForum.com

Stam et al's methods are cool for smoke/turbulent-fluids-with-dye, etc., but for everything else, there are simpler + way (way*) faster methods. As jjd asked, what effect are you looking for?


*for example, a player caught in a whirlpool, simulated with advanced G.I.F (Generalized Inviscid Fluid) simulation:
Quote:Original post by Inian
I have googled ;) a lot.


I just gave the search terms because they not only result in the Jos Stam stuff (i.e. the twanvl link), but also comments on it.

Quote:So did this pong have an internal fluid sovler of sorts?


Of course, else I wouldn't have mentioned it! It's here

Quote:I haven't seen any good fast implementations of smoothed particle hydrodynamics out there, the fastest was a 4 hour rendering of a 10 second animation... not really real-time if you ask me. If you have any links to solutions like this I'd love to see em though.


It's only 2D, and probably not as fast as it could be, but there's mine. There's others too, some in 3D, some all on GPU etc (e.g. here). However, I suspect the grid-based approach is better for you.

This topic is closed to new replies.

Advertisement