GustGrid
A CUDA-powered C++/OpenGL tool for real-time PC airflow and thermal simulation
Install / Use
/learn @josephHelfenbein/GustGridREADME
<a id="readme-top"></a>
<!-- *** Thanks for checking out the Best-README-Template. If you have a suggestion *** that would make this better, please fork the repo and create a pull request *** or simply open an issue with the tag "enhancement". *** Don't forget to give the project a star! *** Thanks again! Now go create something AMAZING! :D --> <!-- PROJECT SHIELDS --> <!-- *** I'm using markdown "reference style" links for readability. *** Reference links are enclosed in brackets [ ] instead of parentheses ( ). *** See the bottom of this document for the declaration of the reference variables *** for contributors-url, forks-url, etc. This is an optional, concise syntax you may use. *** https://www.markdownguide.org/basic-syntax/#reference-style-links -->
[![Issues][issues-shield]][issues-url]
[![MIT License][license-shield]][license-url]
[![LinkedIn][linkedin-shield]][linkedin-url]
About The Project
GustGrid is a high-performance simulation engine built in C++ and OpenGL, leveraging NVIDIA CUDA to deliver real-time visualization of PC airflow and thermal dynamics. By harnessing GPU-accelerated fluid dynamics, it accurately models heat dissipation, fan performance, and airflow patterns within complex computer chassis geometries. Its intuitive graphical interface allows users to interactively adjust component layouts and cooling configurations, enabling rapid design iterations and optimized thermal management for any PC build.
<b>Features:</b>
<ul> <li><b>Voxel-based Fluid & Thermal Simulation:</b> Simulates a 64×256×128 voxel grid (volume pixels), with one CUDA thread per voxel for maximum parallelism.</li> <li><b>All-in-one Physics:</b> Handles semi-Lagrangian advection, fan thrust, buoyancy, wall interactions, pressure projection, dissipation, convection, and conduction all on the GPU.</li> <li><b>GPU-powered Pressure Solve:</b> Computes divergence, performs Jacobi iterations in shared memory, subtracts pressure gradients, and enforces boundary conditions to ensure incompressibility.</li> <li><b>Advanced Heat Transfer:</b> Models convective (wind-chill style) and conductive (solid/fluid-specific diffusivity) heat exchange, alongside explicit heat sources and neighbor dissipation.</li> <li><b>Interactive OpenGL Renderer:</b> Real-time ray marching volume heatmaps, PBR shading for chassis components, and custom controls for dynamic scene adjustments.</li> </ul>https://github.com/user-attachments/assets/2e30b726-3e83-4628-b07e-84914f9ded4c
<img src="src/textures/screenshot3.png" />Built With
- [![C++][C++]][c++-url]
- [![OpenGL][OpenGL]][OpenGL-url]
- [![CUDA][CUDA]][CUDA-url]
See the open issues for a full list of proposed features (and known issues).
Physics Pipeline (per frame and voxel)
<ol> <li><b>Update Fan Visibility:</b></li> <ul><li>Ray march from each fan’s world position to the voxel center. If any solid voxel blocks the ray, fan influence is disabled for that fan.</li></ul> <li><b>Velocity Update (advectKernel):</b> <ul> <li><b>Advection:</b> Backward-trace voxel positions along velocity, trilinearly sample previous velocity field.</li> <li><b>Wall Proximity:</b> Scale advection strength by local solid proximity to simulate drag near chassis.</li> <li><b>Fan Thrust:</b> Add axial and radial forces for voxels within a fan’s beam, attenuated by distance and alignment.</li> <li><b>Buoyancy:</b> Apply upward acceleration for hot voxels using α·ΔT·g, capped for stability.</li> <li><b>Thermal Swirl & Back-pressure:</b> Inject swirl in high ΔT regions and push fluid away from solid neighbors for hot pockets.</li> </ul> <li><b>Pressure Projection</b></li> <ul> <li><b>Divergence:</b> Compute ∇·u using central differences, treating solids as zero-velocity.</li> <li><b>Jacobi Solver:</b> Iterate: load local tile in shared memory, average neighbor pressures, subtract divergence·scale, blend with previous pressure (β-relaxation).</li> <li><b>Velocity Correction:</b> Subtract ∇p from velocity, incorporate thermal-pressure tweaks at boundaries, and reflect velocities into solids.</li> </ul> <li><b>Temperature Advection & Dissipation</b></li> <ul> <li><b>Forward-trace Advection:</b> Advect temperature using updated velocity, accumulate into tempSum/weightSum for weighted average.</li> <li><b>Dissipation:</b> Compute per-voxel dissipation based on ΔT and velocity magnitude, then scatter dissipated energy into neighbors via tempSumDiss.</li> <li><b>Normalize & Combine:</b> Compute advected temperature = tempSum/weightSum (or fallback), apply keepFraction, then add neighbor-dissipated heat.</li> </ul> <li><b>Convective & Conductive Heat Exchange</b></li> <ul> <li><b>Convective Heat:</b> For |ΔT|>threshold, loop over neighbors, compute heat transfer coefficients based on relative velocity and flow alignment, clamp and apply ∂T.</li> <li><b>Conductive Diffusion:</b> Apply finite-difference diffusion with solid vs fluid diffusivity multipliers, add explicit heat sources, and clamp T to [ambient−10, ambient+200].</li> </ol>Prerequisites
Linux
To compile the project on Linux, you'll need:
- G++ - Install the
g++compiler, version supporting at least C++ 17. - A CUDA-compatible NVIDIA GPU
- Libraries - Use your package manager to install:
libfreetype6-dev(for font rendering)libglfw3-dev(for creating windows, OpenGL contexts)cmake(for building)cuda-tools(for CUDA)
- Run the
Linux Release (CMake)configuration in VSCode, orLinux Debug (CMake)for debugging without optimization flags.
Windows
To compile the project on Windows, you'll need:
- Visual Studio 2022 - Install Visual Studio 2022 at https://visualstudio.microsoft.com/downloads/ installing the
Linux, Mac, and embedded development with C++toolset, and also the individual componentsWindows 10 SDKandMSVC v143. - vcpkg - Install vcpkg at https://learn.microsoft.com/en-us/vcpkg/get_started/get-started?pivots=shell-powershell and add environment variables
VCPKG_ROOT=(PATH TO VCPKG)PATH=(PATH TO VCPKG) - Install needed packages with vcpkg
vcpkg install freetype glfw3
- CMake - Install CMake at https://cmake.org/download/.
- CUDA - Install CUDA at https://developer.nvidia.com/cuda-downloads and add environment variables
CUDA_PATH=C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\(YOUR CUDA VERSION)PATH=C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\(YOUR CUDA VERSION)\binPATH=C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\(YOUR CUDA VERSION)\libnvvp - Go to the project directory in
x64 Native Tools Command Prompt for VS 2022and runcode ., then run theWindows Release (CMake)configuration in VSCode, orWindows Debug (CMake)for debugging without optimization flags.
License
Distributed under the MIT License. See LICENSE.txt for more information.
Acknowledgments
- Best README Template
- Learn OpenGL
- CUDA C++ Programming Guide
- Fast Fluid Dynamics Simulation on the GPU
- "(FREE) Gaming Pc" (https://skfb.ly/oGSTB) by Moonway 3D is licensed under Creative Commons Attribution (http://creativecommons.org/licenses/by/4.0/).
- "AM4 Cpu [ Free ]" (https://skfb.ly/pqx6R) by Igor.Jop is licensed under Creative Commons Attribution (http://creativecommons.org/licenses/by/4.0/).
- "Cooler Master CPU Cooler" (https://skfb.ly/oQV6T) by BlenderFace is licensed under Creative Commons Attribution (http://creativecommons.org/licenses/by/4.0/).
- "GeForce RTX 2060 Super Founders Edition" (https://skfb.ly/6Y7ww) by exéla is licensed under Creative Commons Attribution-NonCommercial (http://creativecommons.org/licenses/by-nc/4.0/).
