Skip to content

grassEqualsBugs/SmokeSimulation

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

69 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Smoke Simulation

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.

Build and Run

make
./bin/smoke_gpu

CPU Version

cd CPU_version
make
./smoke_cpu

Controls

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

Technical Details

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 ($a = -\frac{\nabla p}{\rho}, \nabla \cdot u = 0$) using the projection method on a staggered MAC grid.

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.

About

A grid-based fluid and smoke simulation featuring both GPU (Metal) and CPU (Raylib) implementations.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors