Jump to content
  • Advertisement
Sign in to follow this  
tok_junior

Navier-Stokes and forces

This topic is 5135 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

Hi. I've managed to implement the NSE-solvers in Jos Stam's GDC03-paper "Real-Time Fluid Dynamics for Games" without too many problems, and managed to get rather interesting movements in te volumes by simply adding manual velocities to it. This is rather useless though, since the whole point of making this in the first place is to get a rater physically correct fluid. So i'm trying to figure out how to apply forces to this volume. When i'm thinking about it it doesn't seem that there's an easy way of sticking Newtons second into the system, and i can't really come up with any other alternatives :( So please, help? Edit: I think i've done it, although im not sure if it's correct. Wouldn't it be correct to simply add the forces to the velocity? I had totally missed the +F in the equation, just spotted it. And i surely get results when i add the forces. Tobias Karlsson Sweden [Edited by - tok_junior on September 1, 2004 7:35:59 AM]

Share this post


Link to post
Share on other sites
Advertisement
i dont completely understand what youre trying to say...

you managed to apply forces, but thats no good because you want to apply forces?

anyway, to make this usefull for games all youll have to do is set boundary conditions on the fluid according to your gameworld and objects, apply forces to your fluid according to moving objects, and optionally let the objects be influenced by the fluid flow.


experiment with setting arbitrary boundary conditions on the flow: i found this to be quite hard to get working quite right.

applying forces according to moving gameobjects shouldnt be that hard me thinks.

Share this post


Link to post
Share on other sites
If you're willing to keep it simple and not let the objects influence the flow, then this seems like an easy problem...I'm ignorant of NSE...let me see...oh mathworld has it...well, it seems that you're basically working with a differentiable vector field that defines your velocity...why not just compute accelerations by differentiating w/respect to time, then you can multiply by mass to get forces, if that's what you want. Just keep in mind, you're talking about acceleration of fluid parcels, so you might multiply by the mass of a fluid parcel, which you can probably set arbitrarily. If the fluid parcel is infintesmal, you can then compute net forces on an object by integrating over the surfaces of the object in the fluid.

I suppose a more challenging problem would be to start with a scalar pressure field and kinematic velocity, and solve the differential equation for the velocity, but I can't imagine why you should happen to know these things for a game...

Share this post


Link to post
Share on other sites
Yes, turned out to be very easy indeed.
Now the problem is my diffusion adds density to the system :(

EDIT:
Never mind, i really should start commenting out old lines before i insert the same lines in another place.
DOH!

Share this post


Link to post
Share on other sites
Quote:
Original post by tok_junior
Yes, turned out to be very easy indeed.
Now the problem is my diffusion adds density to the system :(


Which I suspect is because of numerical error? If so, either use a better integrator, or just renormalise your density every few iterations. If not, then you've incorrectly implemented the computation.

Cheers,

Timkin

Share this post


Link to post
Share on other sites
Tim is correct in saying that a better integrator may help. But, it will not eliminate the diffusion entirely. The added diffusion, known in engineering CFD circles as artificial dissipation, is pretty much impossible to eliminate entirely. Actually, only in special cases, when you can achieve what is known as "perfect shift," can you fully eliminate such errors that creep in. The extra diffusion (and in some cases dispersion) is simply the Taylor Series truncation error inherent in the finite differences. The perfect shift condition is a very special case when the truncation error is exactly zero. I can refer you to some excellent books that explain this in good detail, if you'd like.

Share this post


Link to post
Share on other sites
I've noticed there's a major difference, it even looks as if nothing's added, if i use a high diffusion, say about 100.0. As I'm totally new to everything fluid, i have no idea what a normal diffusion-rate would be.
If someone could point at somewhere i can find rates for say water and smoke, i'd be a happy camper indeed. Or well, just giving me some general pointers on diffusion would work aswell.

By the way, as a first-time poster in this forum, i must say it's by far the best one i've seen on gamedev. Clean posts, and accurate information, especially by grhodes. Cudos to all of you, and thanks for helping out :)

Share this post


Link to post
Share on other sites
>>If someone could point at somewhere i can find rates
>>for say water and smoke, i'd be a happy camper indeed.
>>Or well, just giving me some general pointers on diffusion
>>would work aswell.

Well, if you are after realworld physical parameters, you should first check two things:

1.) your timestep is realistic
2.) you take fluid density into account. meaning that if you have a force field F, you use the formula v += F/density to add forces to the velocities (these density parameters are easily found even in high school textbooks).

But diffusion rates are a different thing... as people have pointed out, fluid simulation (and especially the semi-Lagrangian method) causes so much artificial diffusion to the velocity field that in practice, no diffusion is even needed. Actually, there exist even methods that try to fight back artificial diffusion of turbulence by using a specialized force (a technique called vorticity confinement).

So in brief, even if you had the most accurate diffusion parameters in the world, the diffusion will still be unrealistically high.

Of course, finding such parameters might be an interesting exercise.

- Mikko

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

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

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!