Integrating a Fluid-Simulation

anlumo
Posts: 6
Joined: Thu Nov 29, 2007 3:27 pm

Integrating a Fluid-Simulation

Post by anlumo »

Hi,

I've implemented a grid-based 3D fluid simulation and I'm trying to integrate it with bullet so I can have rigid bodies in the fluid.
For this I have to interface the forces in two ways: from fluid to solid and from solid to fluid.
The solid object method I'm using expects the object velocity for every raster position where the solid intersects, which I'm getting from getVelocityInLocalPoint().
However, how should I apply the momentum of the fluid to the rigid objects? I'm currently using applyImpulse() (once per fluid node interfacing with the rigid body) once per frame, but is that the right way to do it? I'm running into a lot of troubles, where the rigid body bounces around without any external forces applied. Maybe applyForce is the one suitable for this?

Generally, what are the units used for all these methods (provided that one spatial unit is 1m and one temporal unit is 1s)? The force I can calculate from the fluid grid is in Newtons per frame (which is easy to translate into Newtons per second). I guess getVelocityInLocalPoint returns ms^-1, right?

Any help would be greatly appreciated. I've been working on this problem for a whole month now :(
maninalift
Posts: 1
Joined: Wed Mar 19, 2008 4:37 pm

Re: Integrating a Fluid-Simulation

Post by maninalift »

Yes, force would probably be more appropriate than impulse. Force is in Netons (K m s^-2 ), not Newtons per second. Momentum is velocity (m s^-1) times mass (kg). Force is rate of change (s^-1) of momentum.

How you go about transferring force between the rigid body and the water depends on the model you are using for the water.

You say you are modeling water using a grid. Do you mean that you are modeling height of the water surface? This is the approach taken by graphics libraries modeling water. Or do you mean that you have a 3D grid of the water and you are doing a full fluid-dynamics simulation?

If you are doing the former, it will be difficult to get the rigid body to interact with the water in a convincing way if it is doing anything other than bobbing about gently. Bobbing about gently can be achieved with a static approximation: net upforce from water pressure = mass of water displaced by object (volume of object below water line times density of water). Disturbing the water by moving the object though it would require some very unscientific procedures.
User avatar
Erwin Coumans
Site Admin
Posts: 4221
Joined: Sun Jun 26, 2005 6:43 pm
Location: California, USA

Re: Integrating a Fluid-Simulation

Post by Erwin Coumans »

It is possible to use interaction using impulses, and interleaving the solvers inside the same iteration loop (Bullet uses 10 iterations by default). That is what is done in the brand new soft-body <-> rigid body demos, by Nathanael:

http://www.bulletphysics.com/Bullet/php ... f=6&t=1984

It will be included in Bullet, so you can see how the interaction works. Please ask in that thread for details.
Erwin