Simulating fluid/gas movement

Posts that don't fit into other categories.
Posts: 26
Joined: Mon Apr 17, 2017 10:46 am

Simulating fluid/gas movement

Postby assofohdz » Mon Jun 12, 2017 3:04 am


Just wondering if anyone has done any fluid/gas simulation or approximation thereof using Dyn4j. I'm wondering if I can fake it, by creating small enough elements, fly through them with my ship, then place a force behind the ship at all times, to simulate the vacuum behind a moving element. Pushing elements aside is already working, so it would be a fairly simple thing to try. But I'm not sure the scale of the elements would be supported by the Dyn4j engine. I'm thinking that the linear damping coefficient could be used an indicator for the force (because its, in a way, a mean to discern the fluid/gas viscosity)

I'm looking for a way to simulate a ship moving through water, or a plane moving through cloud (the visual effect of it), in a top-down setting.

Site Admin
Posts: 378
Joined: Sat Feb 06, 2010 10:23 pm

Re: Simulating fluid/gas movement

Postby William » Tue Jun 13, 2017 6:21 pm

I've experimented with Smoothed Particle Hydrodynamics (SPH) in dyn4j before but it wasn't stable enough for me to want to support it.

In regards to the scale of elements - just try the size that you want. If it works, great! If not, consider that the real problem with sizing is usually the default settings, size ratios (for stacking), and tunneling (for collisions). You need to make sure settings like Settings.DEFAULT_MAXIMUM_TRANSLATION are scaled appropriately. You don't want skyscraper sized objects sitting on top of ant sized objects. You don't want super fast and super thin objects colliding because they will likely tunnel through each other.

The linear damping is as you describe, mainly to slow bodies down over time - giving the effect of fluid viscosity or wind resistance.

I would say start simple and see how far you can get with that. If its slow, unstable or doesn't look right, try taking a look at SPH and just run a separate simulation, outside of dyn4j, to simulate the fluids. Or, if you are feeling really ambitious, contribute some fluid simulation code to dyn4j proper.


Return to “General Discussion”

Who is online

Users browsing this forum: No registered users and 2 guests