Loading video...

Video Failed to Load

Go Home

Been recently looking into fluid simulations again. This time I've testing if I can make a good SPH simulation but only having "average" cell particles. It seems to work surprisingly well, and it doesn't need sorting either. Explanation thread👇🧵

15,816 views • 1 year ago •via X (Twitter)

11 Comments

Mykhailo Moroz's profile picture
Mykhailo Moroz1 year ago

This is a follow-up of my method from here where particles were stored on the grid itself. This posed a problem since when there are more than 2 particles per cell they average out and information is lost (for ex. velocity difference between particles)

Mykhailo Moroz's profile picture
Mykhailo Moroz1 year ago

This produces a artificial numerical viscosity which becomes detrimental when wanting to have more than 1 particle per cell. On top of that this doesn't allow keeping any persistent information on the particles themselves.

Mykhailo Moroz's profile picture
Mykhailo Moroz1 year ago

So my second idea was "what if we only average the particles for the force/density computations only". Its not something you can do in Shadertoy, as you need some kind of rasterization to splat the particles on the gird. Here I show cell averages with mass > 1 with red spheres

Mykhailo Moroz's profile picture
Mykhailo Moroz1 year ago

I used atomicAdd's for splatting the particle properties, which means using compute shaders. But you can also use the hardware rasterizer, which I plan on trying later, which should allow me to port this to VRChat.

Mykhailo Moroz's profile picture
Mykhailo Moroz1 year ago

The rendering here uses my compute ellipsoid rasterizer which I worked on a while ago. It analytically projects the ellipsoids onto the screen and fills in the pixels inside the ellipse.

Mykhailo Moroz's profile picture
Mykhailo Moroz1 year ago

Algorithms that "average" or "merge" particles to reduce the amount of computation aren't new, for example to do gravity simulations efficiently there is the Barnes-Hut algorithm, where you build an entire hierarchy of particle averages on a tree (usually quad/octree)

Mykhailo Moroz's profile picture
Mykhailo Moroz1 year ago

Then depending on the distance, you select the appropriate "LOD" of the particles when computing the force. This results in O(NlogN) compute time for gravity instead of O(N^2). For "local" fluid simulations the win is more negligible, just a constant factor.

Mykhailo Moroz's profile picture
Mykhailo Moroz1 year ago

While such an approach does reduce the computational overhead, the system will no longer strictly conserve energy, as the interaction is no longer exactly "pairwise", the force is not symmetric i.e. Newton's third law is broken.

Mykhailo Moroz's profile picture
Mykhailo Moroz1 year ago

Without a viscosity term the approximate SPH simulation does start to boil with time, which is expected. But thankfully even a low viscosity fixes this.

Mykhailo Moroz's profile picture
Mykhailo Moroz1 year ago

Not sure if I have seen this applied for Lagrangian fluid simulations before, you may correct me if someone already did something like that (probably yes).

Lucid Scientific, Inc.'s profile picture
Lucid Scientific, Inc.1 year ago

Expand the possibilities of your metabolic research. Resipher tracks real-time cellular oxygen consumption in standard 96-well plates, delivering continuous real-time data directly from your incubator. Request a free virtual demo or quote today >>

Related Videos