Loading video...
Video Failed to Load
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

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)

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.

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

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.

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.

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)

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.

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.

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.

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).

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 >>
