A 3D Smoothed Particle Hydrodynamics (SPH) fluid solver written in C++.
Features
- Particle integration and neighbor search (LBVH/grid helpers).
- Optional Vulkan/GL renderer (samples/shaders provided).
- Unit tests and small Python utilities for quick experiments.
Requirements
- A C++17-capable compiler (MSVC on Windows, GCC/Clang on Linux/macOS).
- Python 3 (for Meson and small scripts).
- Meson build system and Ninja (or another Meson backend).
- Vulkan SDK and graphics drivers for the renderer.
On Windows, install the Visual Studio Build Tools (or full Visual Studio) and the Vulkan SDK if you plan to run without the --no_visualisation cmdline argument.
Building (Meson)
The project uses Meson. From the repository root run:
python -m pip install --user meson ninja
meson setup builddir --buildtype=release
meson compile -C builddirOn Linux/macOS the commands are the same (use your system Python):
pip install --user meson ninja
meson setup builddir --buildtype=release
meson compile -C builddirRun tests with:
meson test -C builddirBinaries will be in builddir (or the directory you chose). Example executables you may find after a successful build:
-
SPHSolver/SPHSolver.exe— SPH solverUsage example:
./builddir/SPHSolver --method wcsph --search lbvh --steps 1000 --dt 0.001 --h 1.0
Options:
Option Description --method <method>Simulation method ( iisphorwcsph)--search <method>Neighborhood search method ( shi,sh,ug,ugm,sg,sgi,lbvh,naive)--load <file>Path to .xyzfile to load scenario from--steps <n>Maximum number of time steps --save_interval <n>Save .xyzfile everynsteps--dt <dt>Time step size --h <h>Smoothing length --stiffness <k>Stiffness parameter (WCSPH) --rho0 <rho>Rest density --viscosity <nu>Viscosity parameter --gamma <gamma>Gamma parameter (WCSPH) --omega <omega>Omega parameter (IISPH) --lbvh_update_freq <n>LBVH rebuild frequency (default: 1)--fluid_size <x> <y> <z>Size of fluid block (three values) --boundary_size <x> <y> <z>Size of boundary/container (three values) --save_latestOverwrite a single particles.xyzfile on each save (keep only latest snapshot)--no_visualizationRun without graphical visualization (headless)