The HydraClims site, in development (plan/09). This page is drawn from FluxCell's own documentation in the project: docs/FLUXCELL.md, docs/API.md and docs/METHOD.md.

Theme
HydraClimsHydrology, Hydrodynamics and Climate Resilience SolutionsBuild a new model

Home / Manual / FluxCell Reference

FluxCell Reference

The GPU solver inside HydraClims, as its authors document it. HydraClims builds the inputs below from Setup; you only meet them directly when you use FluxCell on its own.

1What it is

A conservative, well-balanced, second-order finite-volume solver for the two-dimensional shallow-water equations, written as WebGPU compute shaders. It runs entirely on the GPU, in the browser, with double-precision CPU references for testing. It has no dependencies and no build step.

FluxCell is developed at the HydroInformatics Lab, Tulane University, and released under the MIT licence.

2Equations and scheme

∂U/∂t + ∂F(U)/∂x + ∂G(U)/∂y = S(U, z, n, r),   U = (h, hu, hv)
  • Reconstruction: MUSCL-Hancock, second order in space and time.
  • Fluxes: HLLC, with hydrostatic reconstruction at each face so the bed slope balances the pressure exactly.
  • Wetting and drying on any bed, with Manning friction, rain and point sources, and solid cells for buildings and piers.
  • Physics options: wind stress, Coriolis, a transported scalar with diffusion and settling (including flocculation), a depth-averaged turbulence closure, and a low-Froude correction.

3The method in brief

PartHow FluxCell does it
ReconstructionMUSCL with the monotonized-central limiter (van Leer, 1979), and a Hancock half-step predictor, for second order in space and time
FluxesHLLC Riemann solver; the star-region mass flux is formed so that still water carries exactly zero
Bed slopeHydrostatic reconstruction at each face, so the bed slope balances the pressure exactly and lakes stay at rest
FrictionManning, applied after the update as the exact solution of the local friction equation: unconditionally stable, and it never reverses the flow
Rain and sourcesAdded to the depth without momentum, split from the flux update at first order
Wet and dryFirst-order reconstruction where a stencil is nearly dry or a bed step exceeds the depth, a regularized thin-layer momentum, and a compensated depth update, so depth is never discarded below a threshold
Time stepThe largest allowed by a Courant number of at most 0.4, by the sources, the boundary series and diffusion; chosen on the GPU each step
PrecisionSingle precision on the GPU, with the bed stored relative to a datum chosen in double precision, so a high bed loses no digits
On the GPUOne fused kernel per step: each 16 × 16 workgroup loads a 20 × 20 tile with a two-cell halo. The page reads back once per batch of up to 256 steps; a failed step is rolled back and retried at half the step

4Inputs and options

ConfigurationWhat it is
width, height, dx, dyThe grid: cells across and down, and their size in metres. Row 0 is the south edge
gravity, cflGravity (m/s²) and the Courant number, at most 0.4
boundaryX, boundaryYwall, periodic, open or outflow
hydrographsSegments of an edge with a stage, discharge or incident wave series; a segment overrides its edge
datum'auto', or an elevation taken off the bed in double precision
rainUniform rain, m/s
tracer, diffusivityCarry a passive scalar, with diffusion (m²/s)
settlingThe tracer settles at w = w0 cm: constant (m = 0) or flocculating (m up to 3)
wind, windDragWind at 10 m (m/s, up to 100), with Wu's (1982) drag or a constant coefficient
coriolisThe Coriolis parameter f (1/s), positive in the northern hemisphere
eddyViscosity, smagorinsky, bedTurbulence, schmidtThe turbulence closure, off unless a coefficient is set: constant viscosity, Smagorinsky (Cs up to 0.3), bed-generated turbulence, and the tracer's turbulent Schmidt number
lowFroudeLess numerical damping in slow flow, so eddies and weak currents last (Thornber et al., 2008)
Per cellWhat it is
state, bedThe starting depth and flow [h, hu, hv, 0] and the bed elevation. Dry cells must be still, and solid cells dry
manning, source, solidRoughness, sources in m/s (a discharge spread over its cells), and solid cells (0 or 1)
concentration, sourceConcentrationThe starting tracer, and the tracer carried by source water

5Boundaries

Each edge is a wall, periodic, open or outflow, and segments of an edge can carry a hydrograph: a water level over time, a discharge over time, or an incident wave. A wave edge sends the wave in and lets reflected waves leave.

Grand Isle uses most of them: an incident-wave edge on the Gulf side, an edge held at the still level on the bay side that lets waves leave, and walls at the two ends. New Orleans lets in a set flow, 600 m³/s, at the breach.

6Using it

import { compileKernels, createSolver } from 'fluxcell';

const device = await (await navigator.gpu.requestAdapter()).requestDevice();
const kernels = await compileKernels(device, 'muscl-fused');

const width = 200, height = 100, n = width * height;
const bed = new Float32Array(n);                 // bed elevation (m)
const state = new Float32Array(4 * n);           // [h, hu, hv, 0] per cell
for (let i = 0; i < n; i++) state[4 * i] = i % width < 50 ? 2 : 0.5;

const solver = await createSolver(device,
    { width, height, dx: 1, dy: 1, boundaryX: 'outflow', boundaryY: 'wall' },
    { state, bed, manning: new Float32Array(n).fill(0.03) }, kernels);
await solver.advance(30);                        // 30 s, time step chosen on the GPU
const result = await solver.readState();         // [h, hu, hv, c] per cell
solver.destroy();
KernelUse
muscl-fusedThe production path: one tiled dispatch per step
muscl-hancockThe same discretisation in separate passes
rusanovFirst order, the control

Changing a run

Between steps, setForcing replaces Manning n, sources and source concentrations; setParameters changes wind, Coriolis and settling; setHydrographs replaces boundary series; setBed edits the bed of given cells. Invalid changes throw and leave the state untouched.

7Citing it

If you use FluxCell in your work, please cite:

Erazo Ramirez, C., and Demir, I. (2026). FluxCell: A Single-Dispatch MUSCL-Hancock Solver for Shallow Flow and Scalar Transport in WebGPU (in preparation).

Data in the demos: USGS 3DEP elevation data are in the public domain. The Grand Isle bed is derived from NOAA NCEI CUDEM (public domain, doi:10.25921/ds9v-ky35); its buildings and breakwaters from OpenStreetMap, © OpenStreetMap contributors, ODbL 1.0. The Monai Valley data are from the NTHMP benchmark repository (Liu et al., 2008).