pcisph-wasm
is a 2D Predictive-Corrective Smoothed Particle Hydrodynamics (SPH) simulation in Rust with WASM + WebGL. It implements a parallelized solver using rayon and wasm-bindgen-rayon.
For a quick demo, please see https://pcisph-wasm.netlify.app. The WASM version of this project is deployed to Netlify (since Github Pages does not support setting HTTP headers) after building with Github Actions. Further information can be found on on my website, including an introduction to SPH math and a simple SPH solver.
# debian/ubuntu
apt install build-essential pkg-config cmake libfreetype6-dev libfontconfig1-dev
RUST_LOG=info cargo run --package native --release
Press r
to reset simulation or space
to add a block of particles
# install dependencies
npm install
# compile to WASM, run webpack, and spawn a local server
npm run serve
Then visit http://localhost:8080
This project is distributed under the MIT license.
This solver is not exactly PCISPH, but can be viewed as 1-iteration of SPH relaxation plus sub-stepping. The “prediction-relaxation” scheme of my implementation actually comes mainly from the (much easier to follow) paper "Particle-based Viscoelastic Fluid Simulation”, as opposed to "Predictive-Corrective Incompressible SPH”.