WarpFlow v1.0: A Single-Source CPU/GPU Shallow-Water Solver for Operational City-Scale Urban Flood Modeling
Abstract. Operational urban flood management increasingly needs two-dimensional hydrodynamic models that re-run on demand, are driven by data pipelines without hand editing, and run on hardware a municipality already owns. We present WarpFlow, an open-source solver for the two-dimensional shallow-water equations built against these three constraints. WarpFlow solves the full shallow-water equations on a staggered Arakawa C-grid, retaining advective momentum. The scheme combines an Audusse well-balanced hydrostatic reconstruction, a first-order upwind mass flux, and a semi-implicit momentum update with implicit bed friction and advective damping. The velocity update is evaluated in Jacobi form, so it is independent of traversal order. Together with a single-source, three-backend implementation, this yields CPU and GPU results that agree to single-precision round-off. A positivity floor guarantees non-negative depth, and an optional flux-corrected-transport limiter is available where required at wetting fronts. Rainfall, infiltration, drainage sinks, stage and discharge boundaries, and weir/orifice culverts with lumped transport delay are treated as first-class source terms. WarpFlow is a Python package whose kernels compile to multi-core CPU code and to NVIDIA CUDA through Numba and CuPy. The CPU, dense CUDA and memory-sparse tiled CUDA backends share one kernel formulation. Static fields are compressed by lookup-table encoding, and the tiled backend allocates memory only for terrain-bearing tiles, so city-scale domains fit in consumer-GPU memory. Two automatic runtime controls reduce work: active-tile scheduling skips dry terrain tiles, and an adaptive CFL-stride controller amortizes global time-step reductions when the characteristic speed is stable. A hook-based plugin layer and scripting API expose every stage of a run, allowing WarpFlow to operate inside automated modeling pipelines. We verify WarpFlow against analytical dam-break and lake-at-rest solutions, and demonstrate water-budget closure, grid convergence and CPU/GPU reproducibility. We validate it against the Environment Agency 2D benchmark subset and the Malpasset dam break. As an operational showcase, we simulate a 100-year, one-hour Euler-II design storm over the administrative area of Dresden, Germany, across a two-hour window. At 5 m resolution (≈ 365 km² terrain area), the run completes in 51.68 s. At 2 m resolution (≈ 1.66 × 10⁸ total cells, ≈ 9.1 × 10⁷ terrain cells), it completes in ≈ 14.4 min on one consumer GPU, compared with ≈ 15.4 h for the same solver's 24-thread CPU backend (≈ 64.3× speedup). WarpFlow is the engine behind the operational Urban Digital Flood Twin Dresden; here we document the solver. The code is released under the AGPLv3 license.