Skip to content

Feature/poststep hook#129

Merged
fluidnumericsJoe merged 2 commits into
mainfrom
feature/poststep-hook
Jun 10, 2026
Merged

Feature/poststep hook#129
fluidnumericsJoe merged 2 commits into
mainfrom
feature/poststep-hook

Conversation

@fluidnumericsJoe

@fluidnumericsJoe fluidnumericsJoe commented Jun 9, 2026

Copy link
Copy Markdown
Member

Summary

Adds three overridable, type-bound model hooks to the abstract Model type so derived models can run per-step / per-stage work inside the native time-stepping loop without modifying the integrators. All hooks default to no-ops, so existing models are unaffected.

Hook Cadence Default
PreStepHook once per time step, before the RK stages no-op
PreTendencyHook once per tendency evaluation (each RK stage) no-op
PostStepHook once per time step, after this%t advances by this%dt no-op

PreStepHook and PostStepHook fire in all four integrators (euler, low-storage rk2, rk3, rk4). PreTendencyHook is the former PreTendency hook, renamed for a consistent Hook suffix across all three (unchanged in behavior otherwise).

Motivation

Per-step work — e.g. recording off-grid receiver samples from a device-resident solution — should run inside the native stepping loop. The alternative, driving the integrator one step at a time from the host via ForwardStep, forces the entropy/diagnostic and WriteModel device-to-host copies every step, which is unnecessary and slow for a GPU-resident model. Overriding PostStepHook lets a derived model do that work without touching the integrators or paying the ForwardStep diagnostic overhead.

Changes

  • src/SELF_Model.f90: add PreStepHook / PostStepHook, rename PreTendencyPreTendencyHook, wire all three into the integrators.
  • Propagate the PreTendencyPreTendencyHook rename through the DG / ECDG / ESAtmo model types (1D/2D/3D, CPU and GPU) and the Null models.
  • docs/Models/model-hooks.md: new page documenting the hooks, their cadence, and the type-extension override pattern; added to the Models nav.
  • mkdocs.yml: drop the polyfill.io script (sold domain that served malware in the 2024 supply-chain incident; MathJax 3 needs no es6 polyfill on supported browsers).

Compatibility

The rename of PreTendencyPreTendencyHook changes a public type-bound procedure name. Models that override PreTendency must update to the new name; all in-tree models are updated in this PR.

fluidnumericsJoe and others added 2 commits June 7, 2026 21:13
PostStepHook is a new type-bound procedure on the abstract Model type
(default no-op) invoked by every time integrator (Euler, low-storage
RK2/RK3/RK4) once immediately after each completed step, i.e. after
this%t advances by this%dt.

Motivation: per-step work such as recording off-grid receiver samples
from a device-resident solution should run inside the native stepping
loop. The alternative -- driving the integrator one step at a time from
the host via ForwardStep -- forces the entropy/diagnostic and WriteModel
device-to-host copies every step, which is unnecessary and slow for a
GPU-resident model. Overriding PostStepHook lets a derived model perform
that work without touching the integrators or paying the ForwardStep
diagnostic overhead.

The default implementation is a no-op, so existing models are unaffected.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…hooks

Introduce a PreStepHook (default no-op) invoked once per time step before the
Runge-Kutta stages, symmetric with the existing PostStepHook. Rename the
PreTendency hook to PreTendencyHook so all three overridable model hooks share
a consistent "Hook" suffix for discoverability in model extensions.

- PreStepHook / PostStepHook fire once per step (start / end) in all four
  integrators (euler, rk2, rk3, rk4).
- PreTendencyHook fires once per tendency evaluation (RK stage), unchanged in
  behavior aside from the rename.
- Add docs/Models/model-hooks.md describing the hooks, their cadence, and the
  type-extension override pattern; add it to the Models nav.
- Drop the polyfill.io script from mkdocs (sold domain that served malware in
  a 2024 supply-chain incident; MathJax 3 needs no es6 polyfill on supported
  browsers).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@codecov

codecov Bot commented Jun 9, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@fluidnumericsJoe fluidnumericsJoe merged commit 08c90b2 into main Jun 10, 2026
11 checks passed
@fluidnumericsJoe fluidnumericsJoe deleted the feature/poststep-hook branch June 10, 2026 13:03
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