“Trece años dedicò a esas heterogéneas fatigas, pero la mano de un forastero lo asesinò y su novela era insensata y nadie encontrò el laberinto.”
J.L. Borges, El jardìn de senderos que se bifurcan.

A Better Fluid Simulation — Multigrid Method

Continuing my little foray into fluid simulation, here is a better fluid simulation using the multi-grid algorithm with a Jacobi kernel. It also uses a vertex grid, meaning the pressure and velocities are diagonally offset by half a grid cell, instead of a colocated grid.

This is faster and produces more curls than my previous attempt with a plain Jacobi method on a colocated grid. I also hacked in open boundary conditions, where the fluid flows outside of the simulation area without bouncing back.

You can click and drag the mouse inside the canvas below to create splats of color. Double-clicking resets the simulation. Your browser needs to support WebAssembly and WebGL 2.0.