Fluid Simulation

December 4, 2019 ยท View on GitHub

LBM fluid simulation based on wgpu-rs.

src/lbm implementation is standard LBM. src/optimized_mem_lbm implementation is based on the following paper: A New Approach to Reduce Memory Consumption in Lattice Boltzmann Method on GPU

poiseuille pigments diffuse

poiseuille

Performance per frame

render size: full screen on iPhone, 1600px x 1200px on macOS.

Standard LBM Poiseuille flow with 100 * 75 lattice

DeviceOS VersionFPSCPU costGPU frame time
MBP 2018 (i7, AMD Radeon Pro 560X)macOS 10.15.160fps17%3.8ms
MBP 2018 (i7, Intel(R) UHD Graphics 630)macOS 10.15.160fps21%2.0ms
iPhone 6 plusiOS 12.4.360fps80%13.5ms
iPhone Xs MaxiOS 13.2.360fps54%6.3ms
iPad Pro (11-inch)iOS 13.1.312fps83%5.4ms

Memory consumption optimized Poiseuille flow with 200 * 150 lattice and particles separately

DeviceOS VersionFPSMemoryCPU costGPU frame time
iPhone 6 plusiOS 12.4.360fps88.8 MB88%16.2ms
iPhone Xs MaxiOS 13.2.360fps148.7 MB53%8.2ms
iPad Pro (11-inch)iOS 13.1.3120fps165.5 MB87%6.2ms

Run

# on macOS
# run poiseuille flow
cargo run --example fluid poiseuille
# run lid-driven cavity 
cargo run --example fluid lid-driven-cavity
# run pigments diffuse  
cargo run --example fluid pigments-diffuse

# build for iOS
cargo build --target aarch64-apple-ios

# run on iOS device
cd iOS
pod install
# then use Xcode to open fluid_demo.xcworkspace