GPU-accelerated wind tunnel that simulates fluid flow around 3D objects using Lattice Boltzmann Methods and OpenGL compute shaders. Written in C with a Next.js web frontend for remote rendering.
The simulation runs a D3Q19 LBM grid on the GPU, pushes hundreds of thousands of particles through the velocity field, and computes drag coefficients in real time. You can run it locally with a desktop window or trigger headless renders on a cloud GPU through the website.
simulation/ C simulation engine (LBM + OpenGL compute shaders)
website/ Next.js frontend that talks to a Modal GPU worker
The core fluid solver. Particles are advected through a 3D velocity field computed by the LBM kernel, with collision detection against arbitrary OBJ meshes. Everything runs on the GPU via OpenGL 4.3 compute shaders.
src/-- simulation loop, LBM solver, particle system, renderingshaders/-- compute shaders for LBM collision/streaming and particle updateslib/-- headers for fluid grid, particles, OpenGL helpersassets/-- OBJ models (car, Ahmed bodies) and fontsobj-file-loader/-- lightweight Wavefront OBJ parser
A Next.js app that lets you configure simulation parameters and kick off GPU renders via Modal. Styled with the Catppuccin Mocha palette.
Features:
- Configure wind speed, visualization mode, collision mode, and model selection
- Upload custom OBJ files for testing your own geometry
- Drag coefficient (Cd) readout with comparison table across runs
- Shareable URLs via hash-encoded parameters
- Demo mode when no GPU backend is configured
You need CMake, a C11 compiler, and OpenGL 4.3+ capable GPU drivers.
Debian/Ubuntu:
sudo apt-get install build-essential cmake pkg-config \
libsdl2-dev libsdl2-ttf-dev libglew-dev mesa-common-dev libgl1-mesa-devArch:
sudo pacman -S base-devel cmake sdl2 sdl2_ttf glew mesacmake -B build -S simulation -DCMAKE_BUILD_TYPE=Release
cmake --build build -j$(nproc)
./build/3d_fluid_simulation_carRun from the repo root so the binary can find simulation/assets/.
cd website
npm install
npm run devThe site works in demo mode without any backend. To enable GPU rendering, set MODAL_RENDER_ENDPOINT in website/.env.local:
MODAL_RENDER_ENDPOINT=https://your-modal-endpoint.modal.run
cd simulation
pip install modal
modal deploy modal_worker.pyThis gives you a URL to set as MODAL_RENDER_ENDPOINT. You'll also need an aws-secret in Modal with AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY for S3 video uploads.
| Key | Action |
|---|---|
| Mouse drag | Orbit camera |
| Scroll wheel | Zoom |
| W/S | Tilt up/down |
| A/D | Rotate around target |
| Q/E | Zoom in/out (step) |
| R | Reset camera |
| Up/Down | Wind speed |
| V | Cycle viz mode |
| 3-9 | Select viz mode |
| Left/Right | Color sensitivity |
| 0/1/2 | Collision off/AABB/per-triangle |
| Esc | Quit |
- Depth -- distance from camera
- Velocity magnitude -- blue (slow) to red (fast)
- Velocity direction -- RGB mapped to XYZ velocity components
- Particle lifetime -- age of each particle
- Turbulence -- laminar vs turbulent regions
- Flow progress -- rainbow gradient by X position
- Vorticity -- lateral motion indicator
MIT
