A portable C++17, 3D lattice Boltzmann (D3Q19 BGK) wind-tunnel solver with a built-in, stylized sports-car obstacle. The flow is incompressible in the low-Mach approximation. It uses OpenMP for CPU cell loops, streamwise MPI slab decomposition for multiple processes, and an optional CUDA backend for NVIDIA GPUs. CUDA plus MPI exchanges halo faces through host memory, so CUDA-aware MPI is not required.
The car is a voxelized coupe body with a low nose, cabin, tapered tail, underbody, and two wheel pairs. The side, floor, and ceiling cells are no-slip tunnel walls. The inlet prescribes lattice velocity and unit density; the outlet copies the upstream plane (zero-gradient approximation). Solid surfaces use halfway bounce-back. The reported car_force_x and car_force_z are instantaneous streamwise and vertical momentum exchange in lattice units after subtracting unit-density ambient pressure (positive z is lift, negative z is downforce). They can change sign during startup transients.
cmake -S . -B build -DCMAKE_BUILD_TYPE=Release
cmake --build build -jCMake uses MPI, OpenMP, and CUDA when they are installed. Each is optional:
cmake -S . -B build-cpu -DAEROSOLVER_ENABLE_CUDA=OFF
cmake -S . -B build-serial -DAEROSOLVER_ENABLE_MPI=OFF \
-DAEROSOLVER_ENABLE_OPENMP=OFF -DAEROSOLVER_ENABLE_CUDA=OFFIf --backend cuda reports that the binary was built without CUDA, reconfigure that same build directory and rebuild:
cmake -S . -B build -DAEROSOLVER_ENABLE_CUDA=ON
cmake --build build -jFor a specific GPU generation, pass -DCMAKE_CUDA_ARCHITECTURES=86 (or the appropriate compute capability) when configuring. The default is supplied by CMake or the CUDA compiler; set this option explicitly for deployment on a different GPU generation. --backend auto selects CUDA only when every MPI rank has a GPU; otherwise all ranks run on CPUs. MPI ranks on one node are assigned to GPUs round-robin using their node-local rank. Set OMP_NUM_THREADS to control CPU threads per rank.
OMP_NUM_THREADS=8 ./build/aerosolver --nx 96 --ny 48 --nz 32 --steps 500 \
--velocity 0.06 --reynolds 180 --backend auto --vtk output/car
OMP_NUM_THREADS=4 mpiexec -n 4 ./build/aerosolver --nx 128 --ny 64 --nz 48 \
--steps 1000 --backend cpu --vtk output/car_mpi--backend accepts auto, cpu, or cuda. --vtk PREFIX writes PREFIX_rank0.vtk, PREFIX_rank1.vtk, etc.; open each file in a VTK viewer. Fields are solid (0 fluid, 1 tunnel, 2 car), density, and velocity components ux, uy, uz. Coordinates and values are in lattice units. Use --help for all options.
Each run prints resources fields with the number of MPI nodes and ranks, total CPU threads used by the solver, the per-rank CPU thread range, physical GPU devices in use, and ranks assigned to GPUs. On CUDA runs, each GPU rank uses one host thread for the time-stepping kernels; gpu_ranks may exceed gpu_devices_in_use when ranks share a device. The GPU count uses device PCI IDs within each node, so a GPU shared by multiple ranks is counted once. field_memory_mib_est sums solver field arrays and halo buffers across ranks; it excludes MPI/CUDA runtime overhead and VTK output buffering. The final elapsed_s is the slowest rank's solver wall time, and mlups is global lattice updates per second in millions, including backend setup and final transfer.
For example, two MPI ranks sharing one GPU report:
resources nodes=1
mpi_ranks=2
cpu_threads_total=2
cpu_threads_per_rank=1-1
gpu_devices_in_use=1
gpu_ranks=2
field_memory_mib_est=10.8
The Reynolds number is based on the car's 0.42 × nx lattice-cell length. The solver computes kinematic viscosity as U × L / Re and relaxation time as 0.5 + 3 × viscosity. It rejects relaxation times below 0.505. Each MPI rank needs at least two x planes, so nx >= 2 × ranks.
This is a parallel flow solver and visualization starting point, not a validated full-scale vehicle aerodynamic model. BGK at the supported Reynolds numbers, a coarse built-in voxel car, simple inlet/outlet conditions, and the absence of turbulence modeling limit physical accuracy. Use a validated mesh and turbulence model before drawing engineering conclusions about drag or downforce. Monitor mean_density during long runs; a value far from 1 indicates that the simple boundaries have accumulated mass and the reported forces are unreliable.
Run ctest --test-dir build --output-on-failure for serial, MPI, and automatic backend smoke checks supported by the build. For a full CPU/CUDA parity check on a machine with CUDA and MPI, run:
python3 tests/compare_backends.py --solver ./build/aerosolverThe parity check runs six grid and time-step configurations, including two- and three-rank MPI cases, and compares every VTK cell's solid mask, density, and velocity components. It also compares the reported diagnostics and checks one versus four OpenMP threads. Temporary VTK files are removed when the check finishes.
For CPU/CUDA timing results, crossover points, and reproducible benchmark commands, see the performance report. On the measured one-GPU node, CUDA becomes useful sooner as the grid or step count grows; several MPI ranks sharing that GPU add overhead.
The C++ and CUDA sources use Google-style names and formatting, configured in .clang-format. Format changes with:
clang-format -i src/*.cpp src/*.hpp src/*.cuThe repository also includes a reproducible, CPU-only Slurm lab: one Ubuntu controller and two compute VMs on libvirt, configured with Ansible, Munge, NFS, environment modules, SlurmDBD/MariaDB, QoS, cgroups and node exporters. The third compute VM is optional.
scripts/provision.py --nodes 2
scripts/validate_cluster.py
scripts/scenario.py drained-node --applyRead the architecture and IP inventory, administrator runbook, user quick-start, fault drills, handover, incident communications, postmortems, and measured lab results and sanitized evidence snapshot. GitHub Actions checks shell/Ansible syntax, topology, fault coverage and the serial solver; live VM and Slurm checks run locally because hosted CI runners do not provide this libvirt cluster.