# moving objects in fluid

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

## Recommended Posts

hi, ive implemented stable fluids paper, i have arbitrary boundaries in my fluid, but i dont know how i would make movable objects. my idea is to add velocity in the path of the object first and then move the object the frame after, but I think there must be better ways. is there reading on this?

##### Share on other sites
One way to do this, which would be an unsophisticated one-way interaction only, is to pretend your moving objects have no mass, and simply have them move with the local fluid velocity, and to align themselves with that velocity. But, you may want interaction.

So, a more realistic one-way interaction is to compute from the fluid flow some force acting on your object, and apply that force to the object. Then, do a rigid body integration (assuming your object is a rigid body) to move the object in time. When it moves, for the next time step you have to recompute the fluid force at the object's new location. The simplest force to calculate would be a viscous drag force based on an assumed drag coefficient. The drag force pushes on the object in the direction of the fluid velocity minus the object's own velocity (this difference being the relative fluid velocity). An extension of this would be to add a lifting force...but this is more difficult because it is a function of shape and rotational velocity of the object. For a bit more info on some of this, see my GDC talk on wind dynamics available here:

GDC 2006 Proceedings (Search for my name)

I also wrote a chapter on the subject in Game Programming Gems 5

The next step is to make this a two-way interaction, e.g., the fluid affects the object and the object affects the fluid. This too is a bit tricky. One way to deal with this is to simply change your arbitrary boundary to include the surface of your moving objects. The problem with this is that it would treat your moving object as being static unless you change the boundary conditions at that surface to reflect the object's motion...and it might be difficult to map the object's motion into the choice of boundary condition you have implemented, or it might make the thing unstable (even though the technique has been labeled as "stable fluids"). Another way would be to treat the object not as a surface boundary but instead as a point source of fluid density or vorticity...in a way similar to the interaction Jos Stam coded in his implementations of the stable fluids method.

Hope this helps!

##### Share on other sites
thankyou graham, there are useful points there for the future, my problem is more regarding object affecting fluid, i am moving objects around with the mouse at the moment, because the object moves much faster then the speed of the fluid, moving causes density and velocity to be overwritten where they are not pushed from the way of the object first.

it sounds as if using a "point source of fluid density or vorticity" would work to solve this, but i dont understand completely how it would work, is there an example of this?

##### Share on other sites
Stam's little demo code manipulates the fluid, as I recall, by adding or removing fluid density. The governing equations (continuity and Navier-Stokes, which he's formulated in a certain way) cause the fluid to move based on this user-prescribed density change. So, if you add density at a point, the fluid velocity moves away from that point. When an object moves through the fluid, you want the fluid to move out of its way...to move nominally away from the center of the object. So, a really simple object->fluid interaction (vs. fluid->object as I described previously), is to have the object add density to the fluid at its center when it moves. If the object is moving fast, or isn't well approximated as a sphere, then you may add density at all fluid grid cells that intersect a line swept out by the object's center point over the course of a time step.

Now...this isn't a truly proper way to have the object interact. It pushes the fluid out of the way, but doesn't take into account the velocity of the object, and if you look at it properly you'll see that the fluid appears emitted by the object. In fact, you are modeling a simple "source"...the object is becoming a source of new fluid. Which isn't right. In reality, the fluid moves around the object. To do things more correctly, you need to add vorticity in addition to density. The vorticity plus density together, properly applied, cause the fluid to move around the object...there will still be fluid inside the object but for simple visual simulation you would just not pay any attention to this (for engineering/very high fidelity simulation, you'd model the fluid domain to exclude the volume inside the object). Er, so, I haven't looked at Stam's work recently, and I don't recall if he explicitly has a step that deals directly with vorticity. I would say to get things going, and maybe its sufficient for your purposes anyway, just add density.

Hope this helps!

1. 1
2. 2
3. 3
Rutin
15
4. 4
khawk
14
5. 5
frob
12

• 9
• 11
• 11
• 23
• 12
• ### Forum Statistics

• Total Topics
633660
• Total Posts
3013221
×