A grid-based fluid and smoke simulation written in Objective-C++ and Metal. An older version of the project written for the CPU, using the Raylib framework, is also included.
make
./bin/smoke_gpucd CPU_version
make
./smoke_cpu- Left Click: Drag to apply velocity to the fluid.
- Right Click: Click/Drag to emit smoke into the grid.
- Scroll Wheel: Adjust brush radius.
- Space: Pause/Resume the simulation.
- R: Reset the simulation.
- 1: Toggle Smoke visualization (Default).
- 2: Toggle Speed visualization.
- 3: Toggle Divergence (Pressure Error) visualization.
- B: Toggle Solid Mode (Not in CPU version).
- W: Toggle left side Wind and Smoke Emitter (Not in CPU version) (Default off)
I followed the course notes from the University of British Columbia on Fluid Simulation to learn the algorithms for this simulation.
This project solves Navier-Stokes equations for incompressible fluids (
The pressure Poisson equation is solved using Gauss-Seidel iteration. To accelerate convergence, Successive Over-Relaxation (SOR) is applied to each iteration. The GPU version specifically utilizes Red-Black Gauss-Seidel to enable parallel execution across the grid. Advection for both velocity and smoke is handled via a semi-Lagrangian scheme with bilinear interpolation.