{"id":21033562,"url":"https://github.com/gabyx/rsfluid","last_synced_at":"2025-08-21T17:27:16.619Z","repository":{"id":65067293,"uuid":"579706002","full_name":"gabyx/RsFluid","owner":"gabyx","description":"An Eulerian fluid simulation written in Rust to learn the language","archived":false,"fork":false,"pushed_at":"2024-03-16T15:35:45.000Z","size":391,"stargazers_count":11,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-04-03T09:41:37.174Z","etag":null,"topics":["fluid-simulation","rust","rust-learning"],"latest_commit_sha":null,"homepage":"","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mpl-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/gabyx.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":"2022-12-18T16:05:43.000Z","updated_at":"2024-11-23T18:39:34.000Z","dependencies_parsed_at":"2024-03-16T17:17:28.394Z","dependency_job_id":"c1f02d33-9020-4109-94c2-b986d7356f15","html_url":"https://github.com/gabyx/RsFluid","commit_stats":null,"previous_names":["gabyx/rsfluid"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gabyx%2FRsFluid","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gabyx%2FRsFluid/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gabyx%2FRsFluid/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gabyx%2FRsFluid/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/gabyx","download_url":"https://codeload.github.com/gabyx/RsFluid/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254349470,"owners_count":22056354,"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":["fluid-simulation","rust","rust-learning"],"created_at":"2024-11-19T12:57:54.553Z","updated_at":"2025-05-15T13:32:10.821Z","avatar_url":"https://github.com/gabyx.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003ca href=\"https://www.rust-lang.org\"\u003e\n\u003cimg src=\"docs/logo-mod.png\" style=\"margin-left: 20pt; width: 250px; margin-top:30pt\" align=\"right\"\u003e\n\u003c/a\u003e\n\u003ch1\u003eRsFluid\u003c/h1\u003e\n\n**Disclosure: The material in this repository has not been reviewed, endorsed,\nor approved of by the Rust Foundation. For more information see the Rust\nFoundation Trademark Policy 2023.**\n\nA small demo project to learn Rust by implementing an Eulerian fluid simulation.\nThis project has been inspired by\n[TenMinutesPhysics](https://matthias-research.github.io/pages/tenMinutePhysics/index.html).\nThe basics are easy to understand, but as always \"the dog is buried in the\ndetails\" as we phrase it in German. Its probably a fact in the field of\nscientific simulation that most boilerplate code is there to deal with the\nbeautiful (😨) boundaries of your simulation domain, data structures etc.\n\nThe simulation is implemented with the same procedure as as in\n[fluid.sim](https://github.com/matthias-research/pages/blob/master/tenMinutePhysics/17-fluidSim.html)\nwith some additional data structures and better encapsulation to support the\ncomputation.\n\n# Introduction\n\nThe CLI simulator is in [src/main.rs](src/main.rs) which sets up the scene with\na [grid](src/solver/grid.rs) and hands it over to the\n[timestepper](src/solver/timestepper.rs) which is responsible to integrate the\ngrid. Disclaimer: This design is not yet perfect but it was more to play around\nwith the different concepts in Rust.\n\nYou can start the simulation with\n\n```shell\ncargo run --release --bin rsfluid -- -e 10.0 -t \"$timestep\" --incompress-iters 100 --dim \"400,200\"\n```\n\nor\n\n```shell\njust run --release --bin rsfluid -- -e 10.0 -t \"$timestep\" --incompress-iters 100 --dim \"400,200\"\n```\n\nTo install `cargo` use\n[this help here](https://doc.rust-lang.org/cargo/getting-started/installation.html).\n\nTo create the video with `30` frames use:\n\n```shell\n./tools/create-video.sh 30\n```\n\nor\n\n```shell\njust video 30\n```\n\n# Parallel Implementation\n\nTo implement the parallel version of\n[`solve_incompressibility`](src/scene/grid.rs#L330) I needed to split\n`grid.cells` successively into parts with an iterator chain until ending up with\nan iterator which produces stencils in the form\n[`PosStencilMut\u003cCell\u003e`](src/scene/grid_stencil.rs#L44). This iterator can be\nconverted to a parallel iterator by replacing the iterator chain with the\nparallel functions from `rayon`.\n\nThe following picture illustrates the topology:\n\n \u003cimg src=\"docs/simulation-grid.svg\" alt=\"Simulation Grid\" width=\"600px\"\u003e\n\nThe parallel version with `./create-video.sh 30 --parallel` is currently much\nslower than the serial one. The parallelization is probably to fine grained to\nbe efficient and the `Cell` driven layout is probably not that good for cache\nfriendliness.\n\n# Videos\n\n## Video Velocity\n\n[![Liquid in Fluid: Velocity](docs/frame-1.png)](https://youtu.be/qZvKNIiBiw4)\n\n## Video Liquid\n\n[![Liquid in Fluid](docs/frame-3.png)](https://youtu.be/BxRfxUcNPv0)\n\n## Video Pressure\n\n[![Liquid in Fluid: Pressure](docs/frame-2.png)](https://youtu.be/44bBZcQKzLQ)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgabyx%2Frsfluid","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgabyx%2Frsfluid","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgabyx%2Frsfluid/lists"}