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
- 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
| Part | How FluxCell does it |
|---|---|
| Reconstruction | MUSCL with the monotonized-central limiter (van Leer, 1979), and a Hancock half-step predictor, for second order in space and time |
| Fluxes | HLLC Riemann solver; the star-region mass flux is formed so that still water carries exactly zero |
| Bed slope | Hydrostatic reconstruction at each face, so the bed slope balances the pressure exactly and lakes stay at rest |
| Friction | Manning, applied after the update as the exact solution of the local friction equation: unconditionally stable, and it never reverses the flow |
| Rain and sources | Added to the depth without momentum, split from the flux update at first order |
| Wet and dry | First-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 step | The 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 |
| Precision | Single 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 GPU | One 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
| Configuration | What it is |
|---|---|
| width, height, dx, dy | The grid: cells across and down, and their size in metres. Row 0 is the south edge |
| gravity, cfl | Gravity (m/s²) and the Courant number, at most 0.4 |
| boundaryX, boundaryY | wall, periodic, open or outflow |
| hydrographs | Segments 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 |
| rain | Uniform rain, m/s |
| tracer, diffusivity | Carry a passive scalar, with diffusion (m²/s) |
| settling | The tracer settles at w = w0 cm: constant (m = 0) or flocculating (m up to 3) |
| wind, windDrag | Wind at 10 m (m/s, up to 100), with Wu's (1982) drag or a constant coefficient |
| coriolis | The Coriolis parameter f (1/s), positive in the northern hemisphere |
| eddyViscosity, smagorinsky, bedTurbulence, schmidt | The 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 |
| lowFroude | Less numerical damping in slow flow, so eddies and weak currents last (Thornber et al., 2008) |
| Per cell | What it is |
|---|---|
| state, bed | The starting depth and flow [h, hu, hv, 0] and the bed elevation. Dry cells must be still, and solid cells dry |
| manning, source, solid | Roughness, sources in m/s (a discharge spread over its cells), and solid cells (0 or 1) |
| concentration, sourceConcentration | The 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();
| Kernel | Use |
|---|---|
| muscl-fused | The production path: one tiled dispatch per step |
| muscl-hancock | The same discretisation in separate passes |
| rusanov | First 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).