Sign in to follow this  
wyrzy

Resources on Smoothed Particle Hydrodynamics (SPH)

Recommended Posts

Does anyone know of any good resources on Smoothed Particle Hydrodynamics (SPH)? I know of the book (http://www.worldscibooks.com/engineering/5340.html), does anyone know if that is pretty good? It looks rather helpful, and the text says its focused on the computational and implementation issues, which is what I'm looking for. They have the first chapter on the web site, and I read it, it seems pretty good so far. I also heard that Game Programming Gems 6 has an article on "Real-Time Particle-Based Fluid Simulation". Has anyone read that, and, if so, would you say that the gem gives one a good start to implement real-time fluids? I was looking for some resource (book or web reference) that gives a good explanation behind the theory behind SPH and also goes into how one would begin the implementation in code. Does anyone know of any good resources for SPH?

Share this post


Link to post
Share on other sites
Smoothed Paricle Hydrodynamics by JJ Monaghan is an excelent resource

This code is an ok rendition of a SPH system that runs in real time. As pointed out in another thread, this could be improved masively with
good sse code

Time stepping N-body simulations by Thomas Quinn, Neal Katz, Joachim Stadel, and George Lake is a good resource for understanding SPH with a variable timestep.



[Edited by - KulSeran on June 12, 2006 7:49:12 PM]

Share this post


Link to post
Share on other sites
I edited that fluids chapter for the book Game Programming Gems 6 (GPG6), and tweaked some of the chapter text prior to publication. Its an okay-but-not-great chapter, and I wouldn't suggest buying the book just for any one chapter. The GPG6 chapter references another article that is more of a solid background in SPH. The chapter discusses how to implement fluid interaction with rigid bodies that might be affected by---and affect---the fluid. And the author had intended this idea to be the focal point of the chapter. The code referenced by KulSeran is exactly the same code from that chapter---maybe a slightly later version. Its kind of university-quality/quick-and-dirty code---not professional quality and not necessarily easy to read (students don't often have time to make the most polished code), but does work as advertised for at least some test cases.

I actually would suggest that the other fluids chapter in GPG6 is a very good chapter, Erin Catto's discussion of exact buoyancy for polyhedra. You can get some really neat fluid-like effects---arbitrary objects bobbing around and floating as though they were in a pool or bathtub or the ocean---without doing any actual fluid simulation. And Erin's presentation is very straightforward.

Share this post


Link to post
Share on other sites
grhodes:

Thanks for the confirmation that Catto's article is pretty good. I thought his GDC presentation was pretty good, so I'll definetly check out the article. The Gems series has enough other useful information in it (I looked at the index, and there's a few other articles I thought looked interesting anyways).

I was also interested in level set methods for simulating fluids, but from the information I've seen, those methods are not yet real-time, whereas low-scale SPH simulations are.

Share this post


Link to post
Share on other sites
You can do visual level set fluids in real-time, at least for the 2D case. The idea is this. Use a traditional gridded method of some sort to run the fluid simulation, such as Jos Stam's famous stable fluids approach. The results, say the scalar density, can be stored in a texture---immediately ready to draw on the surface of a quad. Now...the way you do the real-time "level set" extraction is to first choose an appropriate tone mapping approach. Make sure you color the texture to something meaningful and interesting for your visual. Next, use a texture with alpha. Set alpha to 0 every except where density is around a certain value. In that case, set alpha to 1. Do this per-pixel while you are storing off the result. A low-cost addition. That'll get you an image-space isocurve with arbitrary topology, which is what you get from traditional level-set methods. You don't get actual mesh geometry, but perhaps you don't need the geometry anyway? If time, you might want to post-process to smooth the resulting image---avoiding having an aliased isocurve.

Share this post


Link to post
Share on other sites
Quote:
Original post by grhodes_at_work
You can do visual level set fluids in real-time, at least for the 2D case. The idea is this. Use a traditional gridded method of some sort to run the fluid simulation, such as Jos Stam's famous stable fluids approach. The results, say the scalar density, can be stored in a texture---immediately ready to draw on the surface of a quad. Now...the way you do the real-time "level set" extraction is to first choose an appropriate tone mapping approach. Make sure you color the texture to something meaningful and interesting for your visual. Next, use a texture with alpha. Set alpha to 0 every except where density is around a certain value. In that case, set alpha to 1. Do this per-pixel while you are storing off the result. A low-cost addition. That'll get you an image-space isocurve with arbitrary topology, which is what you get from traditional level-set methods. You don't get actual mesh geometry, but perhaps you don't need the geometry anyway? If time, you might want to post-process to smooth the resulting image---avoiding having an aliased isocurve.


Thanks for the info. I've already implemented Stam's fluid solver (he gives a pretty good explanation), so I'll think I try the level set route. Sounds like parts of the computations would be suited for the GPU, but I'll would worry about that after I have a CPU version working.

I'm thinking of using the marching cubes algorithm for rendering the fluid. That should take care of problem of not having the mesh geometry, right?

Share this post


Link to post
Share on other sites
Quote:
Original post by wyrzy
Quote:
Original post by grhodes_at_work
You can do visual level set fluids in real-time, at least for the 2D case. The idea is this. Use a traditional gridded method of some sort to run the fluid simulation, such as Jos Stam's famous stable fluids approach. The results, say the scalar density, can be stored in a texture---immediately ready to draw on the surface of a quad. Now...the way you do the real-time "level set" extraction is to first choose an appropriate tone mapping approach. Make sure you color the texture to something meaningful and interesting for your visual. Next, use a texture with alpha. Set alpha to 0 every except where density is around a certain value. In that case, set alpha to 1. Do this per-pixel while you are storing off the result. A low-cost addition. That'll get you an image-space isocurve with arbitrary topology, which is what you get from traditional level-set methods. You don't get actual mesh geometry, but perhaps you don't need the geometry anyway? If time, you might want to post-process to smooth the resulting image---avoiding having an aliased isocurve.


Thanks for the info. I've already implemented Stam's fluid solver (he gives a pretty good explanation), so I'll think I try the level set route. Sounds like parts of the computations would be suited for the GPU, but I'll would worry about that after I have a CPU version working.

I'm thinking of using the marching cubes algorithm for rendering the fluid. That should take care of problem of not having the mesh geometry, right?


i believe using surface particles (surfels) is a more common technique.

Share this post


Link to post
Share on other sites
Quote:
Original post by Eelco
i believe using surface particles (surfels) is a more common technique.


Thanks, I'll look into it. From some quick looking around on the internet, it seems surfels are more suited for real-time applications. Do you happen to know of any introductory papers / web resources on surfels. Wikipedia doesn't seem to have a page on it, so I'm guessing the technique is new/slighly undocumeted.

Share this post


Link to post
Share on other sites
Quote:
Original post by wyrzy
Quote:
Original post by Eelco
i believe using surface particles (surfels) is a more common technique.


Thanks, I'll look into it. From some quick looking around on the internet, it seems surfels are more suited for real-time applications. Do you happen to know of any introductory papers / web resources on surfels. Wikipedia doesn't seem to have a page on it, so I'm guessing the technique is new/slighly undocumeted.


google 'Point Based Animation of Elastic, Plastic and Melting Objects' for a start. its an interesting read anyway.

Share this post


Link to post
Share on other sites
Quote:
Original post by wyrzy
Thanks for the info. I've already implemented Stam's fluid solver (he gives a pretty good explanation), so I'll think I try the level set route. Sounds like parts of the computations would be suited for the GPU, but I'll would worry about that after I have a CPU version working.

Be wary of his actual code though. It's *horribly* unoptimized. You can quadruple the performance of the solver without changing more than a few lines of code. Using a few more advanced tricks, you can probably double performance again on top of that. (And yes, these numbers are based on my own results)

Share this post


Link to post
Share on other sites
Quote:
Original post by wyrzy
I'm thinking of using the marching cubes algorithm for rendering the fluid. That should take care of problem of not having the mesh geometry, right?


Hmmmm...well, "level set" kind of refers to the idea of extracting isosurfaces/isocurves out of a continuous field solution. "Level set" does not refer to the actual fluid simulation technique, e.g., it is not the underlying method of solving for the continuous fluid field. So, the gridded result is the discretized continuous field solution. I'm rambling here, to may be clarify things for some people in the audience.

Yes, marching cubes is one way to extract a surface. Effectively....marching cubes gives you the mesh geometry even if you always compute on-the-fly and never actually store the mesh to cached data structures. So, that would work. And the marching cubes patent expired last year, I believe, so you could even use it in a commercial game without having to pay royalties (though I'm no lawyer).

The idea I gave, using a specialized alpha channel...was meant to completely replace the need to do something like marching cubes. And is quite truly simple in the 2D case---quite a bit simpler than marching cubes, but with potentially dirtier results. Could be done in 3D (volume fluids) too, but wouldn't be nearly as successful due to limited texture memory for volume textures... More rambling.

Share this post


Link to post
Share on other sites
Quote:
Original post by grhodes_at_work

Hmmmm...well, "level set" kind of refers to the idea of extracting isosurfaces/isocurves out of a continuous field solution. "Level set" does not refer to the actual fluid simulation technique, e.g., it is not the underlying method of solving for the continuous fluid field. So, the gridded result is the discretized continuous field solution. I'm rambling here, to may be clarify things for some people in the audience.

...

The idea I gave, using a specialized alpha channel...was meant to completely replace the need to do something like marching cubes. And is quite truly simple in the 2D case---quite a bit simpler than marching cubes, but with potentially dirtier results. Could be done in 3D (volume fluids) too, but wouldn't be nearly as successful due to limited texture memory for volume textures... More rambling.


Ok, thanks for the clarification. I'm still rather new to most of this, so I'll need to do some more reading / researching for a while. I was a little confused by this book (http://www.amazon.com/gp/product/0387954821/sr=8-1/qid=1150526071/ref=pd_bbs_1/104-3668688-5749521?%5Fencoding=UTF8) and associated papers refrencing it. This is actually for a university project in the fall, so I still have a few months to figure out how to approach the problem.

But now that I look at one of my books (Game Physics), it does have a few sections on using level set extraction to render an implicit surfaces. I'm actually quite interested in the Surfels technique for rendering implicit surfaces that Eelco mentioned. I saw it used in a 2D fluid simulation at http://www.rowlhouse.co.uk/water/ which I believe uses Surfels to render the water (though I could be mistaken) and smoothed particle hydrodynamics for simulation.

Thanks everyone for the help, I think I have enough info to get started.

[Edited by - wyrzy on June 17, 2006 7:40:31 PM]

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this