Skip to content

Fire wind and spotting: single-precision literals, periodic and face edges, fine-region ghosts, script CTests - #40

Merged
hgopalan merged 4 commits into
developmentfrom
flare-wind-port
Nov 24, 2026
Merged

hgopalan merged 4 commits into
developmentfrom
flare-wind-port

Conversation

@hgopalan

@hgopalan hgopalan commented Nov 24, 2026 •

Copy link
Copy Markdown
Collaborator

Related to the fire-wind audit after #35 (tracker row AW-PORT). Stacked on #38 (AW-TRAJ); the first two commits here are #38's and drop out when it merges.

Summary

The audit found six portability and edge items in the fire wind and spotting code. This PR resolves them.

  1. Single precision. Some fire kernels mixed double literals with Real, so a single-precision build computed parts of them in double. The literals are now Real(...). Double precision is bit-identical: the stripped expressions are the same text.
  2. Spotting gather size. The spotting gather indexes nx * ny cells with an int. A grid with more than INT_MAX cells now stops with a message instead of overflowing.
  3. Spotting at the domain edge. A brand used to leave the domain once it passed the outermost cell centre, half a cell before the face. Every face was an exit, periodic or not. Now:
    • a brand flies up to the face;
    • across a periodic face it flies on from the other side;
    • the spot disc reaches across a periodic seam;
    • a brand that meets the ground past a non-periodic face is lost. It used to land in the edge cell.
  4. Open fraction at the edge of a fine fire region. On a fine level that covers part of the domain, the ghost columns just outside the region kept the value 1 (fully open, no roof). They now take the nearest column inside the region, as at a non-periodic face of the domain. erf.fire.structures.wind_open_columns and erf.fire.heat_open_fraction read these columns.
  5. Reductions in the z0 check. The per-step check in the ERF wind sampler does up to three reductions. It needs an ERF change, so it is listed under "Not in this PR". The FLARE side already uses one reduction.
  6. Vacuous CTests. FireFbp_c2 and FireWindSampling_sample20 only checked that a plotfile was written. They are replaced by FireFbp and FireWindSampling, which run the folders' check scripts. Each check is proven to fail on a one-line mutant.

Answers that change:

  • Spotting decks where brands reach a face, or cross a periodic seam: FireFrozenWind (periodic in x and y), FireStructureIgnition (periodic in y), FireExposure and FireRestart. With P_catch < 1, one more surviving brand shifts the random draws of every later brand.
  • Coupled runs with a fine fire level that covers part of the domain and either open-fraction option on.

Interior flights are bit-identical. No gold file changes: these tests check only that their plotfiles are written. As for other fixes, there is no option to keep the old behaviour.

The pre-PR review lenses (user-facing, implementation, numerics and physics) found the seam-disc and face-landing items. Both are fixed here.

Theory

Periodic wrap. A brand keeps its unwrapped position $(p_x, p_y)$, so its landing distance is that of the flight. The fields are read at the wrapped position

$$ q = x_{lo} + \left[(p - x_{lo}) \bmod L\right], \qquad L = n \Delta x $$

  • $x_{lo}$: the low face of the fire grid in that direction.
  • $n$, $\Delta x$: the cell count and cell size.

Why a round-off guard: in single precision, $q$ can come out equal to $x_{lo} + L$. It is pulled back into $[x_{lo}, x_{lo} + L)$, so the landing cell exists.

Stencil. The bilinear stencil uses cell indices $i_0 = \lfloor (q - x_{lo})/\Delta x - \tfrac12 \rfloor$ and $i_0 + 1$. In a periodic direction they wrap modulo $n$. Otherwise they are clamped to $[0, n-1]$, so in the outer half of an edge cell the field is that of the edge cell.

Spot disc. A cell at $c$ is inside the disc of a landing at $\ell$ when $\lvert d \rvert \le r$. In a periodic direction $d$ is the nearest image:

$$ d = (c - \ell) - L \left\lfloor \frac{c - \ell}{L} + \tfrac12 \right\rfloor $$

  • $r$: erf.fire.spotting.spot_radius.

What the ghost fill does: each direction in turn, a ghost still unset takes the cell clamped to its own box's range in that direction. The result is the one a single box over the whole region would get, whatever the box layout.

Changes

  1. FireEngine/ERF_AlbiniSpotting.H
    • albini_stencil_index and albini_wrap (with the round-off guard). The interpolators take the periodicity.
    • The flight reads the fields at the wrapped position and pushes the wrapped landing.
    • A landing past a non-periodic face is dropped. The spot disc uses the nearest image across a periodic seam.
    • An assertion that nx * ny fits an int.
    • Real(...) literals.
  2. FireEngine/ERF_FireRegionGhostFill.H (new): fire_fill_region_ghosts. FireEngine/ERF_FireLayer.cpp calls it for the open fraction and roof height, instead of fire_fill_boundary.
  3. FireEngine/ERF_FbpModel.H, ERF_FireWindAdjust.H, ERF_FireWindAdjust.cpp: Real(...) literals only.
  4. Tests/CTestList.cmake
    • add_test_fire_script takes ARGS and sets SKIP_RUN=0.
    • FireFbp and FireWindSampling replace FireFbp_c2 and FireWindSampling_sample20. Each runs on 2 ranks with max_step=40, in MPI builds that are not Windows.
  5. Exec/RegTests/FireFbp/run_fbp.sh, Exec/RegTests/FireWindSampling/run_wind.sh
    • POSIX sh, since CTest runs them with dash on Ubuntu.
    • A missing or empty log line now fails the check.
  6. Exec/RegTests/FireFrozenWind/check_spot3d.py: mirrors the wrap, the clamp, the round-off guard and the face drop.
  7. Docs
    • theory/fire_spotting_crown.rst: edges, the periodic wrap, the disc and the frozen-wind seam.
    • theory/fire_coupling.rst: the region edge.
    • The ## CTest sections of both READMEs.

No input is added or changed:

Input Default Effect
(none) Spotting near faces and seams, and open fraction at fine-region edges, change as above

Results

The branch is rebased on development after #39, which fixed the CascadeStripes_DamageStates and shuffle_repeat failures on development.

Script CTests at max_step=40 (2 ranks, Debug):

Test Check Value
FireFbp C-2, O-1b, M-1 head rate at step 1 vs independent FBP rel. diff 0
FireFbp directional C-2 burns less than isotropic 502 vs 608 cells
FireWindSampling sampled wind / wind at 20 m, every step worst rel. diff 3.1e-11 (factor 0.775883)
FireWindSampling key written out = historical deck 40 of 40 steps

Mutants, each run against the test named:

Mutant Test Result
old half-cell exit EmberDrift.ABrandInTheOuterHalfCellLands fails
no stencil clamp EmberDrift.ABrandInTheOuterHalfCellLands fails
clamp instead of wrap at a periodic seam EmberDrift.ABrandInTheOuterHalfCellLands fails
no periodic wrap EmberDrift.APeriodicSeamWrapsTheBrand fails
no face drop EmberDrift.ABrandThatLandsPastAFaceIsLost fails
no disc wrap EmberDrift.TheSpotDiscReachesAcrossASeam fails
fire_fill_boundary only both FireRegionGhostFill tests fail
one-shot 2-D clamp (layout dependent) FireRegionGhostFill.TheEdgeOfAPartialRegionTakesItsEdgeColumn fails
FBP ISI wind constant 0.05039 → 0.05 FireFbp 3 head-rate checks fail (1.3 %)
wind sampler scale = 1 FireWindSampling ratio check fails (22 %)

The single-precision build with -Wdouble-promotion has no warnings in the changed source files.

Test(s)

  • New gtests:
    • EmberDrift.ABrandInTheOuterHalfCellLands, APeriodicSeamWrapsTheBrand, ABrandThatLandsPastAFaceIsLost, TheSpotDiscReachesAcrossASeam.
    • FireRegionGhostFill.TheEdgeOfAPartialRegionTakesItsEdgeColumn, AnUncoveredPeriodicImageTakesTheEdgeColumn (also in the FPE suite).
  • EmberDrift.LoftingHeightIsAlbinisEquationTwo now uses the precision-dependent tolerance. It failed before in single precision.
  • Passing locally:
    • Double precision: 31 of 31 gtests in EmberDrift.*, FrozenDrift.*, FireRegionGhostFill.*.
    • Single precision: the same 31.
    • FireFbp and FireWindSampling.
    • 31 of 31 regression tests: FireFrozenWind (all 14, including _spot3d), the five FireSpot*_abort, FireStructureIgnition_on, FireExposure_*, FireRestart_coupled, FireRestart_levelset_straight, FireHeatPlacement_*, FireNearWall_* and FireAnchorLevel.
    • FireFrozenWind_spot3d: the C++ landings match the Python replay to 2.6e-13 m (frozen drift) and 4.7e-13 m (profile drift), with no replay leaving the domain.
  • FireFbp_c2 and FireWindSampling_sample20 are removed. Non-MPI and Windows builds no longer run these two decks.
  • Item 2 (the int gather assertion) has no test: it would need more than 2^31 fire cells.
  • No gold files are affected.

Not in this PR

  • The frozen-wind stencil (frozen_point_wind, ERF_FrozenWind.H) uses the edge column at a periodic seam rather than wrapping. This is documented.
  • The ERF wind sampler's per-step z0 check (fire_column_z0_range_error) does up to three reductions. Folding them into one needs an ERF PR.
  • -Wdouble-promotion warnings outside the files changed here.
  • AW-TOP waits for the open ERF PRs.

🤖 Generated with Claude Code

hgopalan and others added 4 commits November 24, 2026 13:03
The Albini trajectory step was the fall to the lowest ground in the
domain over n_traj_steps. A brand from high ground took a few large
steps and landed too far (+74 % for a 30 m loft 500 m above the lowest
ground). The brand also landed at the end of the step that went below
the ground.

The step is now H_z / n_traj_steps. Over lower ground the brand steps
on, up to its fall to the lowest ground (n_fall steps; 10 n_fall with
frozen_uvw). It lands where its height above the ground, taken as
linear over the last step, reaches zero. A brand that would need more
than 1e6 steps, or a step below the round-off of its height, stops the
run with a message naming n_traj_steps and I_B_min.

Flat-ground answers agree to round-off. Spotting over terrain changes;
no gold file changes (FireFrozenWind_spot3d is a replay check).

Tests: EmberDrift plateau and slope tests, FrozenDrift slope closed
form and plateau aloft cap, the frozen vertical-wind closed form, and
FireFrozenWind_spot_steps_abort. Each fails on a one-line mutant. The
spot3d replay and the canonical Python reference follow the new scheme.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
GCC 11 inlined make_columns with wh = nullptr in the new slope test and
flagged the w write (component 4) against a 4-component buffer with
-Warray-bounds, which fails the GNU@9.3 C++17 warning report. The write
was not reached. The buffer now always holds 5 components; the view
still exposes nc (4 without wh), so the vertical-drift assertion on
nComp() is unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ghosts, script CTests

AW-PORT of the fire-wind audit after #35.

- Spotting: brands fly up to the faces (the stencil is clamped in the
  outer half cell), wrap across periodic faces (distance unwrapped,
  landing cell wrapped, with a round-off guard), and a landing past a
  non-periodic face is dropped. The spot disc uses the nearest image
  across a periodic seam. The gather asserts that nx*ny fits an int.
- Open fraction and roof height: ghost columns at the edge of a partial
  fine fire region take the nearest column of the region
  (fire_fill_region_ghosts, one direction at a time, so the result does
  not depend on the box layout). Ghost cells are marked with -1, a value
  neither field takes, before the exchange; no NaN guard is needed.
- Real(...) literals in the spotting, FBP and WAF kernels; double
  precision bit-identical.
- FireFbp and FireWindSampling run the folders' check scripts (POSIX sh,
  max_step=40, 2 ranks, MPI non-WIN32 builds) in place of the plotfile-only
  FireFbp_c2 and FireWindSampling_sample20; a missing log line fails.
- check_spot3d.py mirrors the wrap, clamp, guard and face drop.
- New gtests, each proven against a mutant.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
GCC -Wunused-variable flagged it in CI (build-warnings check).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@hgopalan
hgopalan merged commit ab9b1a1 into development Nov 24, 2026
11 checks passed
@hgopalan
hgopalan deleted the flare-wind-port branch November 24, 2026 22:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant