Skip to content

lucas-schuermann/pcisph-wasm

Repository files navigation

Build Netlify Status

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.

Running

Package Dependencies

# debian/ubuntu
apt install build-essential pkg-config cmake libfreetype6-dev libfontconfig1-dev

Native (cargo)

RUST_LOG=info cargo run --package native --release

Press r to reset simulation or space to add a block of particles

Web (npm)

# install dependencies
npm install

# compile to WASM, run webpack, and spawn a local server
npm run serve

Then visit http://localhost:8080

License

This project is distributed under the MIT license.

Note

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”.

About

2D Predictive-Corrective Smoothed Particle Hydrodynamics (SPH) simulation in Rust with WASM + WebGL

Resources

License

Stars

Watchers

Forks