Navier-Stokes on a 2D plane of polys

Started by
6 comments, last by Jedaye 21 years, 11 months ago
Hi, I am looking at implementing the Navier-Stokes fluid dynamics equations on a flat grid of polys... Has anyone done this and has some source or good explanation (aimed at someone with a good(ish) math background)? Thanks in advance ** Ste
**Ste
Advertisement
"Modelling the motion of a hot turbulent gas" is one of the more straightforward papers I have read on the topic. You can find it here: http://www.cis.upenn.edu/~fostern/gas.html It is for 3D, but can be easily adapted for 2D.
There is already tonnes of code out there to do this. If you really must reinvent the wheel (since it is always a good way of learning), then you should consider that all of your polygons can be described as a set of triangles and as such you can implement a finite element method for your simulation. Alternatively, you could possibly work out a finite difference implementation... although mapping from the grid to your polygons might be a pain. I''d go with the Finite element implementation.

As for code/papers... google should be your first port of call. After that, check out any one of the thousand or so University departments that perform fluid dynamics research via DNS.

Cheers,

Timkin
Yeah, there''s lots of prior art on this. Search the web for the name "Jos Stam", for example. Jos, who works for Alias Wavefront, has a quite simple algorithm that is also quite fast to run and code up. He has 2D and 3D implementations, and has even demonstrated the 2D version on a Compaq iPaq handheld computer (SIGGRAPH 2001 session on simulating nature). Or you can look up the names Nick Foster and Ron Fedkiw who have also done quite a bit of fluids work. Their stuff is more sophisticate than Jos'', but also more difficult to implement and much slower running. But very very cool.

By the way, you most certainly be running a subset or approximation to the Navier-Stokes equations, rather than the full equations. Since the full equations are rather tricky indeed. (I''ve been through most of a Ph.D program in fluid dynamics for high speed aerodynamics, and never wrote a full NS simulator. The closest I came was a Thin Layer Navier Stokes simulator or "TLNS" for supersonic flows.)

Graham Rhodes
Senior Scientist
Applied Research Associates, Inc.
Graham Rhodes Moderator, Math & Physics forum @ gamedev.net
I know all this But that is a good thing as if I didnt I would be about to fail!

I am writing an MSc on the potential use of fluid dynamics in a gaming environment. Have been in touch with Foster and Chen regarding their work (both were very helpfull). Stam's solver does indeed look the way forward with regards my case study implementation altho I wanna slip in chen and lobo's pressure->height map theory as well I think.

Anyway, thanks again for your input guys and gals


**
Ste

Oh ye, Fosters latest model takes in the region of 3 to 7 minutes to render each frame depending upon the effect you are simulating...just incase people were wondering how much more sophisticated his work is!

[edited by - Jedaye on May 6, 2002 5:44:57 PM]
**Ste
Jeff Lander did a cool presentation at GDC back in March titled "Taming a Wild River" that you may want to look at. He has a pressure->height mapping as well, and the real-time results are fairly impressive.

See his GDC page here: www.darwin3d.com/confpage.htm

Graham Rhodes
Senior Scientist
Applied Research Associates, Inc.
Graham Rhodes Moderator, Math & Physics forum @ gamedev.net
Has anyone implemented Stams model using fixed boundaries??

I think the answer lies in this piece of code from (from his paper)

for(x=0.5f/n,i=0;i{
for(y=0.5f/n,j=0;j{
x0 = n*(x-dt*u0[i+n*j])-0.5f;
y0 = n*(y-dt*v0[i+n*j])-0.5f;

i0 = floor(x0);
s = x0-i0;
i0 = (n+(i0%n))%n;
i1 = (i0+1)%n;

j0 = floor(y0);
t = y0-j0;
j0 = (n+(j0%n))%n;
j1 = (j0+1)%n;

u[i+n*j] = (1-s)*((1-t)*u0[i0+n*j0]+t*u0[i0+n*j1])+ s *((1-t)*u0[i1+n*j0]+t*u0[i1+n*j1]);

v[i+n*j] = (1-s)*((1-t)*v0[i0+n*j0]+t*v0[i0+n*j1])+ s *((1-t)*v0[i1+n*j0]+t*v0[i1+n*j1]);
}
}

Anyone familiar with his model and point me in the right direction?!?

Cheers
**Ste
Call me a fool, but if you''re just wanting to do fluid dynamics in a game, have a look at the lattice boltzmann methods, pretty easy to code (much easier than traditional CFD) and in 2D it''s really fast too, another benefit is boundary conditions are trivial while in tradional CFD they aren''t, only problem may be if you really want to use an untructured grid you can''t use LB (yet).
Ignorance is bliss but some people are just stupid.

This topic is closed to new replies.

Advertisement