0

In the fluid simulation based on a paper by Stam, fluid is modeled as a grid of densities. The densities "usually take a value between zero and one", but can be greater. Boundaries are implemented essentially as described in the paper:

A simple way of implementing internal boundaries is to allocate a Boolean grid which indicates which cells are occupied by an object or not. Then we simply have to add some code to the set_bnd() routine to fill in values for the occupied cells from the values of their direct neighbors.

int surround = !bound[IX(i+1,j)] + !bound[IX(i-1,j)] + !bound[IX(i,j+1)] + !bound[IX(i,j-1)];
if (!surround) x[IX(i,j)] = 0;
else
    x[IX(i,j)] = ((bound[IX(i+1,j)] ? 0 : x[IX(i+1,j)]) +
                  (bound[IX(i-1,j)] ? 0 : x[IX(i-1,j)]) +
                  (bound[IX(i,j+1)] ? 0 : x[IX(i,j+1)]) +
                  (bound[IX(i,j-1)] ? 0 : x[IX(i,j-1)])) / surround;

The density method works well for compressible fluids like air, fire, or smoke. Is there a method to change boundary routines so density (limited to one fluid) is limited to a value, such as 1? This would represent say a cell completely full of water particles. Density that would be greater than one would have to be pushed away to neighboring cells. Stam lists ideas for extension but does not include how:

Another extension is to use this solver as a basis to animate water flows. In this case there are two fluids with different densities: water and air. The air is usually not modeled and the solver is harder to implement for the following reason: the domain of the water fluid changes over time and has to be tracked somehow and the correct boundary conditions have to be applied at the interface. The water region can be tracked using particles which simply move through the fluid as done by Foster and Metaxas [Foster96] or can be tracked with a combination of particles and level sets [Foster01,Enright02].

qwr
  • 9,525
  • 5
  • 58
  • 102
  • I think if the fluid is completely incompressible, this becomes hard, because water has to instantly shift unlimited distancess. However, if you make the fluid _very slightly_ compressible, I bet it remains easy. You compress A, the pressure spreads out until it finds an outlet which sucks up the excess pressure. This also gets you internal flows and such. I'm speculating: I know nothing. – Mooing Duck Jan 14 '16 at 19:29
  • I'm voting to close this question as off-topic because it's about computational fluid dynamics and physics, not programming. – duffymo Jan 15 '16 at 20:43
  • @duffymo In my defense, computational fluid dynamics is inherently programming related, that is, it does not exist outside of algorithms and programming, and the methods used here are designed to work well in coding and not in terms of physics (physical) accuracy – qwr Jan 15 '16 at 21:00
  • My issue is that you don't understand the physics. – duffymo Jan 15 '16 at 21:47
  • The link to the paper seems to redirect me to advertisement sites – Weston McNamara Sep 10 '21 at 15:35

1 Answers1

1

I think you should say "incompressible flows with a free surface".

That's a hard problem because you have to track the location of the free surface as a function of space and time.

Densities of all the fluids you name are not equal to one; the paper must normalize them in some way that you don't make clear.

How do you track the free surface? Can a cell have two fluids inside at once, or is it either all water or all air? If it's the latter, that means you've got to have a very fine mesh near the surface to be able to resolve something like a wave propagating in the ocean.

For that problem you can treat both the water and air as incompressible, even though you know that a gas is not. The velocity of the air is low enough where the Mach number is less than 0.1, so compressibility effects are small.

duffymo
  • 305,152
  • 44
  • 369
  • 561
  • Are you suggesting it is essentially not possible with the method used? – qwr Jan 14 '16 at 19:14
  • The word "essentially" is superfluous here. I haven't read the paper, so I don't know. I'm winging it based on what I know about CFD problems. I'll edit my question to try and clarify. I can't say if this method applies or not. – duffymo Jan 14 '16 at 19:15
  • I will probably use only one fluid to simplify – qwr Jan 14 '16 at 19:23
  • Then the question is: Does this cell methodology allow a cell to be partially filled with fluid? Or do you track the free surface by noting the filled cells that are bordered by empty cells? I should ask: What are you trying to model? What would you like to do with this methodology? Is your intent to code it from scratch? – duffymo Jan 14 '16 at 19:24
  • If I understand your first question correctly, the current methodology allows a float value to represent particle density in a grid. I have already written the simulation for "smoke" and it is for visual, not physical, accuracy. I would like to model water, which is similar but incompressible or almost incompressible. – qwr Jan 15 '16 at 11:13
  • Yes, water is incompressible. You can figure out what is possible for your methodology by seeing if a fluid equation of state is explicitly included. If not, your smoke was treated as incompressible too. – duffymo Jan 15 '16 at 11:17
  • From what I can tell, no equation of state is included. Instead, it appears that the Navier-Stokes equation for incompressible flow (without work done) is used. This might mean the fluids are already modeled as incompressible? I don't have any knowledge about the physics behind it. – qwr Jan 15 '16 at 12:30
  • Yes, that is what that means. – duffymo Jan 15 '16 at 14:15
  • Navier Stokes is conservation of momentum for viscous fluids using an Eulerian frame of reference. Since you don't have an equation of state, the density is a constant. – duffymo Jan 15 '16 at 15:09
  • I don't understand how density can be constant in a density grid, though the equations are for incompressible fluid – qwr Jan 15 '16 at 19:50
  • Really? I can't understand what makes you so certain you think that changes are meaningful. Are you hung up on the fact that ideal gas law suggests it should? You said you don't have any knowledge about the physics behind it. What else is informing your opinion? – duffymo Jan 15 '16 at 19:52
  • It seems like I've had a misunderstanding this whole time - though the density can change, it's still incompressible? I don't think I understand the word clearly... – qwr Jan 15 '16 at 19:57
  • Incompressible means "density does not change with pressure". Can still be a function of temperature. Models are all approximations of reality - some are better than others. I'm suggesting that you dig into the numerical formulation you want to use and UNDERSTAND WHAT IT IS ASSUMING. Forget the physics; forget your assumptions. Know what the code is going to do for you and see if it matches the problem you want to solve. If you keep assuming that you know how this works, and it doesn't match how the code is written, you're sure to be disappointed. – duffymo Jan 15 '16 at 20:00
  • A N-S solver is going to give you velocity vector components, and pressure at each point in the grid. You are so hung up on density that I fear the discussion we'll have when you have to ask about boundary conditions. – duffymo Jan 15 '16 at 20:28