Mondaic

salvus.flow.ng.runner

salvus.flow.ng.runner salvus flow ng runner

In-process forward and adjoint runs.

Functions

run_adjoint()

def run_adjoint(
    w: simple_config.simulation.Waveform,
    mesh: Mesh | UnstructuredMesh,
    event_block: EventBlock,
    source_time_functions: list[BaseSourceTimeFunction],
    adjoint_source_callback: Callable[[EventData], EventMisfit],
    solver: Solver,
    event_name: str | None = None,
    timer: Timer | None = None,
) -> tuple[float, Mesh]: ...

Run a forward + adjoint simulation in-process with the solver.

This runs a coupled forward/adjoint simulation using the Revolve checkpointing algorithm to compute gradients with minimal memory overhead. mesh may be single- or mixed-physics: setup_from_wave_equation resolves either shape into the same NGSetup, and this function drives every block through the SAME generic multi-block session driver (solve_adjoint_through_sessions’s tuple dispatch) — a single-physics mesh is simply the n_blocks == 1 case, not a structurally different code path.

Parameters
  • w simple_config.simulation.Waveform — The waveform configuration.
  • mesh Mesh | UnstructuredMesh — The mesh to run the simulation on.
  • event_block EventBlock — The event block defining sources and receivers — exactly one source block and one receiver block, each resolving to exactly one block of mesh (a source in one block and receivers in another is the ordinary mixed- physics case and is fully supported).
  • source_time_functions list[BaseSourceTimeFunction] — The source time functions to use.
  • adjoint_source_callback Callable[[EventData], EventMisfit] — Callback to compute misfit and adjoint sources from the forward run’s EventData, called exactly once for whichever block the (single) receiver block resolved to.
  • solver Solver — The runtime solver configuration.
  • event_name str | None — An optional name for the event.
  • timer Timer | None — Execution timer.
Returns tuple[float, Mesh] — A tuple of (misfit, gradient) where misfit is a float and the gradient is a Mesh carrying, PER BLOCK, its own native stiffness- and mass-sensitivity component(s) under the generic "GRADIENT"/"GRADIENT_M0"/"GRADIENT_{k}" names (each block contributing over its own, element-disjoint region of the whole mesh), plus the SAME derived VP/RHO(/VS) fields, computed independently per block.

run_forward()

def run_forward(
    w: simple_config.simulation.Waveform,
    mesh: Mesh | UnstructuredMesh,
    event_block: EventBlock,
    source_time_functions: list[BaseSourceTimeFunction],
    solver: Solver,
    event_name: str | None = None,
    timer: Timer | None = None,
) -> EventData: ...

Run a forward simulation in-process with the solver.

Parameters
  • w simple_config.simulation.Waveform — The waveform configuration.
  • mesh Mesh | UnstructuredMesh — The mesh to run the simulation on.
  • event_block EventBlock — The event block defining sources and receivers.
  • source_time_functions list[BaseSourceTimeFunction] — The source time functions to use.
  • solver Solver — The runtime solver configuration.
  • event_name str | None — An optional name for the event.
  • timer Timer | None — Execution timer.
Returns EventData — An EventData object with the recorded seismograms.