machmallow 🔥🧁

Soft on the outside, supersonic on the inside.

A 2D compressible CFD solver (Euler & Navier–Stokes) with block-structured hybrid CPU/GPU AMR and cut-cell embedded boundaries, written from scratch in C++/Metal for Apple Silicon.

C++20 Metal / metal-cpp macOS 15+ · Apple Silicon float32 MIT license no dependencies
Mach 2 bow shock and vortical wake over an immersed cylinder, vorticity in the icefire colormap
Mach 2 flow over a cylinder · vorticity (icefire) + schlieren, adaptive mesh, on an Apple M4.

What's inside

Every numerical method implemented from scratch, readable end to end, a mini-AMReX that runs on your Mac's GPU.

◆Block-structured AMR

AMReX-style patch hierarchy of arbitrary depth. Recursive Berger–Colella subcycling, pairwise refluxing, guaranteed nesting on regrid.

◆Hybrid CPU/GPU

The GPU computes fluxes on every level through one shared slot pool; the CPU handles regridding. Metal, shaders compiled at runtime, zero-copy unified memory.

◆Cut cells

The solid surface cuts through the cells (exact volume fractions and face apertures) instead of a blocky staircase, giving clean walls at modest resolution. Slip or viscous no-slip, at any AMR depth.

◆Numerical schemes

Finite volume: 2nd-order MUSCL-Hancock with an HLLC Riemann solver, or 5th-order WENO5 + SSP-RK3. Positivity-preserving, with a verified order of accuracy (including MMS for the viscous terms).

◆Multi-physics

Compressible Navier–Stokes (Pr = 0.72, adiabatic no-slip walls), two-gas mixtures, and single-step Arrhenius reactions for detonation / deflagration.

◆Declarative & validated

A single .ini case file drives everything, pre-flight catches errors, macOS CI. Nothing lands without a quantitative validation gate.

Get running

macOS 15+, Command Line Tools, CMake ≥ 3.24. metal-cpp is vendored, nothing else to install.

# 1. clone
git clone https://github.com/fhermet/machmallow.git
cd machmallow
# 2. build (Release)
cmake -B build -DCMAKE_BUILD_TYPE=Release
cmake --build build
# 3. run a case
./build/run cases/dmr.ini               # double Mach reflection (hybrid AMR)
./build/run cases/cylinder_bowshock.ini # Mach 2 bow shock over a cylinder
./build/run cases/shear.ini             # viscous shear layer (Navier–Stokes)
# 4. render a video
python3 tools/schlieren_video.py --prefix out/dmr --style schlieren

Read the User Guide · Architecture · Numerics · Validation · Case format.