Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

pickups

fluid dynamics - projection step.

This topic is 5615 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

hello. im working on a fluid solver, and i implemented it in 2D successfuly. but, when i try it in 3D, every thing works except for the projection step, what practically means the flui''s velocity explodes. i tried to fix it, but i dont know what to do next. did anybody of you ever try this stuff, or even succeeded? i would really appriciate your help, thanx.

Share this post


Link to post
Share on other sites
Advertisement
First of all, you didn''t really tell how you''re solving the projection step. Do you use a relaxation scheme (as in Foster&Metaxas and Stam''s GDC paper) or a (much better) sparse linear system solver (Stam and Fedkiw papers)?

Furthermore something needs to be known about the boundary conditions you''re using. Periodic or solid walls, perhaps?

Something needs to be known about your discretization, too. Are you using a MAC staggered grid or a cell-centered grid?

- Mikko Kauppila

Share this post


Link to post
Share on other sites
On the other hand, the fact that your solver actually did work in 2D suggests of some bug or a misinterpreted formula in the 3D version.

If you''re forming a sparse linear system, what kind of linear equation are you using in 3d?

- Mikko Kauppila

Share this post


Link to post
Share on other sites
all right, ill fill the details.

im using a relaxation solver, gauss-seidel solver. i tried to find some info about the conjugate gradient method but couldnt find anything, and i dont have access to university books.

i use a cell centerd grid, and my boundary conditions are fixed walls, i think it is called free-slip, becuase on the horizonal walls i keep the horizonal velocity and on the vertical walls i keep the vertical velocity.
i used the code from stams GDC 2003 paper, and turned it to 3D.
i compute the velocity divergent with the following code, from stams paper:

Div[i,j,k] = 0.5*h*(U[i+1,j,k] - U[i-1,j,k] +
V[i,j+1,k] - V[i,j-1,k] + W[i,j,k+1] - W[i,j,k-1])

altough it should be: 0.5*(...)/h. stams doesnt do it like this, so i followed him.

then, i compute the pressure filed like this:

P[i,j,k] = (P[i+1,j,k] + P[i-1,j,k] +
P[i,j+1,k] + P[i,j-1,k] + P[i,j,k+1] + P[i,j,k-1])-Div[i,j,k])/6

this is what stam does, although in the math it should be :
....-h*h*Div[])/6.

what do you think?

Share this post


Link to post
Share on other sites

"An Introduction to the Conjugate Gradient Method Without the Agonizing Pain" by Jonathan Richard Shewchuk

http://www-2.cs.cmu.edu/~jrs/jrspapers.html

Share this post


Link to post
Share on other sites
Get ghostscript and GSView here, for reading .PS files:
http://www.cs.wisc.edu/~ghost/doc/AFPL/get800.htm

The "canned algorithms" section in Shewchuk''s paper gives straight pseudocodes for implementing the methods, so it is only a few minutes'' job.

I really suggest implementing a version with periodic boundary conditions at first if you''re doing the CG method for solving Poissons''s equation on a cell-centered grid.

- Mikko Kauppila

Share this post


Link to post
Share on other sites
allright thank you.
i will read this paper, im sure ill understand it, it looks good.
but what do you mean periodic boundary conditions? why is it better?
and one more thing, what should i expect after implementing CG, visually speaking? i mean, i actually have a working 3D solver, with a gauss-seidel solver for the projection. it works nice, but i can bearly see small scale swirls. will CG improve it, or i should implement vorticity confinement?

thanks for your help.

Share this post


Link to post
Share on other sites
>but what do you mean periodic boundary conditions?

Periodic boundary conditions is when the fluid wraps around...
In semi-Lagrangian integration this means that if your particle "escapes" the fluid domain, it enters from the opposite side.

Also when constructing the Poisson linear equation it means that you should wrap your coordinates... it should be quite trivial, really.

>why is it better?

It''s not better. It''s just easy to implement (on a cell-centered grid).

You see, if your matrix in the Poisson equation (Ax=b when discretized) is singular, as it usually is, the sum of the nodes in the vector b should be zero. That is most easy to achieve with periodic boundary conditions. In a MAC staggered grid it''s also easy to achieve even with solid walls.

>and one more thing, what should i expect after implementing
>CG, visually speaking?

You should see more turbulence, that''s for sure. Computationally speaking you''ll also see a huge speedup, as only 20 iterations produces a near-perfect solution.

- Mikko Kauppila

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!