{"id":28566328,"url":"https://github.com/inonitz/compute-shader-fluid-2d","last_synced_at":"2025-06-10T15:09:45.231Z","repository":{"id":264261185,"uuid":"892861745","full_name":"inonitz/compute-shader-fluid-2d","owner":"inonitz","description":"Implementation of GPU Gems 38 using OpenGL Compute Shaders","archived":false,"fork":false,"pushed_at":"2025-04-05T03:39:24.000Z","size":3765,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"gpu-gems38","last_synced_at":"2025-04-05T04:23:48.205Z","etag":null,"topics":["advection-diffusion","avx","c","computational-fluid-dynamics","cpp","fluid-simulation-2d","glbinding","glfw3","glsl","gpgpu","gpgpu-computing","gpu-gems","imgui","opengl","opengl4","semi-lagrangian-advection","sse41"],"latest_commit_sha":null,"homepage":"","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/inonitz.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-11-22T23:27:47.000Z","updated_at":"2025-04-05T03:39:27.000Z","dependencies_parsed_at":null,"dependency_job_id":"ca62f7fd-722e-48ca-b341-5ac4359f5806","html_url":"https://github.com/inonitz/compute-shader-fluid-2d","commit_stats":null,"previous_names":["inonitz/premake-mdk-workspace","inonitz/compute-shader-fluid-2d"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/inonitz%2Fcompute-shader-fluid-2d","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/inonitz%2Fcompute-shader-fluid-2d/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/inonitz%2Fcompute-shader-fluid-2d/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/inonitz%2Fcompute-shader-fluid-2d/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/inonitz","download_url":"https://codeload.github.com/inonitz/compute-shader-fluid-2d/tar.gz/refs/heads/gpu-gems38","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/inonitz%2Fcompute-shader-fluid-2d/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":259098638,"owners_count":22804793,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["advection-diffusion","avx","c","computational-fluid-dynamics","cpp","fluid-simulation-2d","glbinding","glfw3","glsl","gpgpu","gpgpu-computing","gpu-gems","imgui","opengl","opengl4","semi-lagrangian-advection","sse41"],"created_at":"2025-06-10T15:09:44.200Z","updated_at":"2025-06-10T15:09:45.191Z","avatar_url":"https://github.com/inonitz.png","language":"C++","readme":"[![Contributors][contributors-shield]][contributors-url]\n[![Forks][forks-shield]][forks-url]\n[![Stargazers][stars-shield]][stars-url]\n[![MIT][license-shield]][license-url]\n\n\n\n\u003c!-- PROJECT LOGO --\u003e\n\u003cbr /\u003e\n\u003cdiv align=\"center\"\u003e\n\u003ch3 align=\"center\"\u003e2D Incompressible Fluid Simulation\u003c/h3\u003e\n\n  \u003cp align=\"center\"\u003e\n    Implementation of \u003c/br\u003e\n      \u003ca href=\"https://developer.nvidia.com/gpugems/gpugems/part-vi-beyond-triangles/chapter-38-fast-fluid-dynamics-simulation-gpu\"\u003e\n        Chapter 38. Fast Fluid Dynamics Simulation on the GPU\n    \u003c/a\u003e \n  \u003c/p\u003e\n\u003c/div\u003e\n\n\n\u003c!-- ABOUT THE PROJECT --\u003e\n## About The Project\nThe following code simulates a 2D Incompressible Fluid using an:\n* Eulerian-Grid Scheme\n* Semi-lagrangian Advection Method [Unconditionally Stable]\n* System-of-Equations Jacobi Method Solver [Very easy to implement GPGPU]\n* Central Difference for Approximating Calculus Operators [O(x^2) Error]\n\n* **Essentially All methods here are references to the original work of** [Stam1999 - stable fluids](https://pages.cs.wisc.edu/~chaol/data/cs777/stam-stable_fluids.pdf)  \n**[Here](https://en.wikipedia.org/wiki/Projection_method_(fluid_dynamics)) is a wikipedia article describing the method of solution**\n\n\u003cbr\u003e\n\nThe currently most-updated revision ```29cleanup3/``` features the following:\n* Force/Dye/Force-Dye User-Simulation Interaction\n* Vorticity Confinement with variable coefficient\n* Variable Kinematic Viscosity, Delta Time \u0026 Poisson-Solver Iterations\n* Real-Time CFL/Reynolds Number Calculations (they're there to check solver correctness/stability)\n* Visualizations of Calculation Textures, in particular Velocity-Pressure/Dye/Curl/Absolute Curl/Velocity Error/Pressure Error/Velocity-X/Velocity-Y/Pressure/CFL\n* Real-Time Measurements of internal solver components - CPU \u0026 GPU Side:\n  * A GPU Timer (gl-Begin/End-Query) essentially acts as a fence,   \n    waiting for all previous GPU commands to finish  \n    **In Short: Using GPU Timers degrades Performance by a few milliseconds**\n\n  * When GPU Timers are not used, the calculations will be deferred until glfwSwapbuffers(),\n    which by then will be dispatched \u0026 computed, updating glMemoryBarrier\n\n\u003c/br\u003e\n\n### Pretty Pictures\nTomorrow, Im Tired lol :)\n\n\n\u003c/br\u003e\n\n  \n### Project Structure\nThe Underlying Project Structure uses my [premake5-workspace-template](https://github.com/inonitz/premake5-workspace-template) repo,  \nYou can expect the [```program/```](https://github.com/inonitz/compute-shader-fluid-2d/tree/gpu-gems38/projects/program) folder to occupy all revisions of the fluid-solver,   \nculminating eventually with [```29cleanup3/```](https://github.com/inonitz/compute-shader-fluid-2d/tree/gpu-gems38/projects/program/source/29cleanup3) as the currently best revision\n\u003cbr\u003e\n\u003cbr\u003e\n\u003cbr\u003e\n\n\n### Built With\n\u003cbr\u003e [\u003cimg height=\"100px\" src=\"https://raw.githubusercontent.com/cginternals/glbinding/master/glbinding-logo.svg?sanitize=true\"\u003e][glbinding-url] \u003c/br\u003e\n\u003cbr\u003e \n  [![GLFW v3.4][GLFW.js]][GLFW-url]\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\n  [![ImGui][ImGui.js]][ImGui-url]\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\n  [![Premake][Premake.js]][Premake-url]\n\u003c/br\u003e\n\n\u003c!-- GETTING STARTED --\u003e\n## Getting Started\n\n### Prerequisites - Instructions below work too, but you should follow [premake5-workspace-template](https://github.com/inonitz/premake5-workspace-template)\n* [premake](https://premake.github.io/docs/) \n* Working compiler toolchain, preferably clang\n  * Windows: You should use [llvm](https://github.com/llvm/llvm-project/releases)\n  * Linux:\n      1. [installing-specific-llvm-version](https://askubuntu.com/questions/1508260/how-do-i-install-clang-18-on-ubuntu)\n      2. [configuring-symlinks](https://unix.stackexchange.com/questions/596226/how-to-change-clang-10-llvm-10-etc-to-clang-llvm-etc)\n      3. **You Don't have to use LLVM, gcc works too**\n  * Define these environment variables (in your PATH):\n    * LLVMInstallDir\n    * LLVMToolsVersion\n* Powershell / Any Standard unix-shell\n\n\n### Installation\nJust Clone the repo\n\n\u003cbr\u003e\n\n\n\u003c!-- USAGE EXAMPLES --\u003e\n## Usage\n### Build Process\n```sh\npremake5 --os=windows --arch=x86_64 --cc=clang gmake2\npremake5 --os=windows --arch=x86_64 --cc=clang vs2022\npremake5 --os=linux   --arch=x86_64 --cc=gcc   gmake2\npremake5 --os=linux   --arch=x86_64 --cc=clang gmake2\n```\nYou can also use this command to perform the whole build process,  \nif youre using gmake2 and a commandline:  \n```sh\npremake5 --os=windows/linux --arch=x86_64 buildallrel\n```\n**Dont forget to actually build using your favorite IDE/command-line utility**\n\n\u003cbr\u003e\n\n### Execution\n**Static Library Builds: (premake5 gmake2, config=releaselib_amd64)**\n```sh\n./build/bin/ReleaseLib_amd64_program/program\n```  \n**DLL/Shared Library Builds: (premake5 gmake2, config=releasedll_amd64)**\n```sh\n./build/bin/ReleaseDll_amd64/program\n```\n**Visual Studio 2022 - Just Run normally using ```Local Windows Debugger```**\n\n\u003c!-- ROADMAP --\u003e\n## Roadmap\n- Replacing Jacobi Method with the Multigrid Method for better performance \u0026 faster fluid convergence\n- Adding Arbitrary boundaries\n- Extending to 3D\n- MAC Staggered Grid\n- Different Simulation Schemes (FVM, etc...) for better simulation accuracy\n- Extending to compressible/Turbulent Models\n\n\n\u003c!-- CONTRIBUTING --\u003e\n## Contributing\nIf you have a suggestion, please fork the repo and create a pull request. You can also simply open an issue with the tag \"enhancement\".  \n\n\n\u003c!-- LICENSE --\u003e\n## License\nDistributed under the MIT License. See `LICENSE` file for more information.\n\n\n\u003c!-- ACKNOWLEDGEMENTS --\u003e\n## Acknowledgements\n* [Kumodatsu](https://github.com/Kumodatsu/template-cpp-premake5/tree/master) For the initial template repo\n* [Jarod42](https://github.com/Jarod42/premake-export-compile-commands/tree/Improvements) For the Improvements branch of export-compile-commands\n* [Best-README](https://github.com/othneildrew/Best-README-Template)\n\n\n\u003c!-- References --\u003e\n## References\n* [Fluid Mechanics 101](https://www.youtube.com/@fluidmechanics101/videos)\n* [GPU Gems 38](https://developer.nvidia.com/gpugems/gpugems/part-vi-beyond-triangles/chapter-38-fast-fluid-dynamics-simulation-gpu)\n* [Stable Fluids - Stam 1999](https://www.dgp.toronto.edu/public_user/stam/reality/Research/pdf/ns.pdf)\n* [Colour Advice](https://www.kennethmoreland.com/color-advice/)\n* [Computational Methods for Fluid Dynamics - Fourth Edition (Ferziger, Perić, L. Street)](https://www.amazon.com/Computational-Methods-Fluid-Dynamics-Ferziger/dp/3319996916)\n* [Online PDF of the Above Book](https://elmoukrie.com/wp-content/uploads/2022/05/joel-h.-ferziger-milovan-peric-robert-l.-street-computational-methods-for-fluid-dynamics-springer-international-publishing-2020.pdf)\n\n\n\n\n\u003c!-- MARKDOWN LINKS \u0026 IMAGES --\u003e\n\u003c!-- https://www.markdownguide.org/basic-syntax/#reference-style-links --\u003e\n[contributors-shield]: https://img.shields.io/github/contributors/inonitz/premake5-workspace-template?style=for-the-badge\u0026color=blue\n[contributors-url]: https://github.com/inonitz/premake5-workspace-template/graphs/contributors\n[forks-shield]: https://img.shields.io/github/forks/inonitz/premake5-workspace-template?style=for-the-badge\u0026color=blue\n[forks-url]: https://github.com/inonitz/premake5-workspace-template/network/members\n[stars-shield]: https://img.shields.io/github/stars/inonitz/premake5-workspace-template?style=for-the-badge\u0026color=blue\n[stars-url]: https://github.com/inonitz/premake5-workspace-template/stargazers\n[issues-shield]: https://img.shields.io/github/issues/inonitz/premake5-workspace-template.svg?style=for-the-badge\n[issues-url]: https://github.com/inonitz/premake5-workspace-template/issues\n[license-shield]: https://img.shields.io/github/license/inonitz/premake5-workspace-template?style=for-the-badge\n[license-url]: https://github.com/inonitz/premake5-workspace-template/blob/master/LICENSE\n[linkedin-shield]: https://img.shields.io/badge/-LinkedIn-black.svg?style=for-the-badge\u0026logo=linkedin\u0026colorB=555\n[linkedin-url]: https://linkedin.com/in/linkedin_username\n[product-screenshot]: images/screenshot.png\n[Next.js]: https://img.shields.io/badge/next.js-000000?style=for-the-badge\u0026logo=nextdotjs\u0026logoColor=white\n\n[ImGui-url]: https://github.com/ocornut/imgui\n[ImGui.js]: https://avatars.githubusercontent.com/u/8225057?v=4\u0026size=150\n[glbinding-url]: https://github.com/cginternals/glbinding/releases/tag/v3.3.0\n[glbinding.js]: https://raw.githubusercontent.com/cginternals/glbinding/master/glbinding-logo.svg?sanitize=true\n[GLFW-url]: https://github.com/glfw/glfw/releases/tag/3.4\n[GLFW.js]: https://avatars.githubusercontent.com/u/3905364?s=200\u0026v=4\u0026size=150\n[Premake-url]: https://github.com/premake/premake-core\n[Premake.js]: https://avatars.githubusercontent.com/u/11135954?s=150\u0026v=4\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Finonitz%2Fcompute-shader-fluid-2d","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Finonitz%2Fcompute-shader-fluid-2d","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Finonitz%2Fcompute-shader-fluid-2d/lists"}