Fluid simulation project cover

Fluid Simulation

December 2020

I have been thinking for some time about creating compelling visuals based on fluid movements. More precisely, I wanted to focus on blobs of fluid movements, something that would look like a lava lamp. After spending some time looking at different fluid simulations, I came across a rather interesting implementation designed for fast simulation at interactive framerates. Clavet et al.‘s SPH Fluid model, named Particle-based Viscoelastic Fluid Simulation, appears to bear many of the features I was looking forward to implementing. The resulting liquid looked very “blobby” and highly viscous. From a technical point of view, their implementation looked quite robust, stable and efficient to simulate splash, filament, and drops of fluid. The core of their algorithm consists of a unique procedure that enforces incompressibility and particle anti-clustering. This procedure, called Double Density Relaxation, takes two different particle densities measurements to predict the particles’ next positions.

Going through their publication, the authors presented the method intuitively, and I thought it was the perfect level of challenge to implement. As such, I set myself to implement their method as my term project. To realize this project, I made use of openFrameworks: a C++ toolkit for creative coding. It includes several libraries commonly used in computer graphics, such as OpenGL, GLEW and GLUT. It also comes with FreeImage for image saving. The final program consists of a robust particle-rendering system, a mouse-controlled camera, a small GUI to play with the different parameters of the fluid simulation, and an offline rendering function to export the simulation as a sequence of images.