To run the code locally, clone the project and run:
cargo run --release
This will execute the visualization demo locally.
To verify the correctness of the code we use the following unit tests:
- Compare the velocity field of the lid-driven cavity benchmark at the center of the domain with reference data from "U. Ghia, K. N. Ghia, C. T. Shin, High-Re solutions for incompressible flow using Navier-Stokes equations and multigrid method".
- Run a channel flow simulaiton at low Reynolds (Poiseuille flow) and check the velocity profile at the outlet.
- [WIP] Computation of drag and lift in the Turek cylinder benchmark CFD case is described in "Schafer, M., Turek, S. Benchmark Computations of Laminar Flow Around a Cylinder".
cargo test --release
To translate the code to WASM follow the Macroquad instructions
rustup target add wasm32-unknown-unknown
cargo build --target wasm32-unknown-unknown --release
This will produce .wasm
file in target/debug/wasm32-unknown-unknown/main.wasm
or in target/release/wasm32-unknown-unknown/main.wasm
if built with --release
. Copy it into the pages
folder.
cp target/release/wasm32-unknown-unknown/main.wasm pages
One of the ways to then server static .wasm
and .html
(blocked by CORS otherwise):
cargo install basic-http-server
cd pages
basic-http-server .
In this small project I had the opportuninty to learn about:
- Rust: a modern high-performace language
- WASM: a binary instruction format that, albeit some penalty, makes it possible to run performance critical code in a web browser.
- LBM: an application of Boltzmann particle (microscopic) principles in a lattice grid to simulate computation fluid dynamics (CFD) without directly solving the Navier-Stokes equations.
- Computational geometry algorithms to raster a polygon
Add (experimental) WASM features:
- Use SIMD instructions
- Parition the lattice and use threads to parallelize (spawing a thread is very expensive in WASM, must be done carefully)