OpenSWMM Engine  6.0.0-alpha.4
Data-oriented, plugin-extensible SWMM Engine (6.0.0-alpha.4)
Loading...
Searching...
No Matches
openswmm::twoD::PluginSurfaceSolver Class Referencefinal

#include <PluginSurfaceSolver.hpp>

Inheritance diagram for openswmm::twoD::PluginSurfaceSolver:
Collaboration diagram for openswmm::twoD::PluginSurfaceSolver:

Public Types

using Destroy = void (*)(void*)
 

Public Member Functions

 PluginSurfaceSolver (ISurfaceSolver *solver, Destroy destroy, std::shared_ptr< GpuExecutionOwner > owner)
 Take ownership of a matched plugin solver and its destruction route.
 
 ~PluginSurfaceSolver () override
 Destroy the plugin implementation synchronously on its execution owner.
 
void initialize (MeshData &m, SurfaceStateData &s, SolverOptions2D &o) override
 Initialize the plugin backend synchronously and cache its status.
 
double advance (double from, double to) override
 Advance the plugin backend synchronously to a requested endpoint.
 
void reinitialize (double t) override
 Reseed the plugin backend after external state edits.
 
void resyncFromVolumes (double t) override
 Resynchronize backend time while preserving its volume-owner semantics.
 
void finalize () override
 Release plugin backend resources on the execution-owner thread.
 
double completedSourceTime () const noexcept override
 Read the adapter's last synchronized backend status.
 
long last_num_steps () const noexcept override
 Read the adapter's last synchronized backend status.
 
double last_step_size () const noexcept override
 Read the adapter's last synchronized backend status.
 
const std::vector< double > & last_coupling_exchange () const noexcept override
 Borrow the most recently refreshed coupling-volume snapshot.
 
RunStats run_stats () const noexcept override
 Read the adapter's last synchronized backend status.
 
bool is_initialized () const noexcept override
 Read the adapter's last synchronized backend status.
 
- Public Member Functions inherited from openswmm::twoD::ISurfaceSolver
virtual ~ISurfaceSolver ()=default
 Destroy a backend solver through its polymorphic interface.
 

Member Typedef Documentation

◆ Destroy

Constructor & Destructor Documentation

◆ PluginSurfaceSolver()

openswmm::twoD::PluginSurfaceSolver::PluginSurfaceSolver ( ISurfaceSolver * solver,
Destroy destroy,
std::shared_ptr< GpuExecutionOwner > owner )
inline

Take ownership of a matched plugin solver and its destruction route.

Parameters
[in]solverRequired owned ISurfaceSolver pointer allocated by the matched loaded plugin.
[in]destroyRequired matching plugin deallocator; consumes solver exactly once during teardown.
[in]ownerRequired shared controlling-thread owner used for all backend dispatch/destruction.
Precondition
The plugin module remains loaded and pinned through teardown. Constructor does not validate pointers or initialize the backend. Caller serializes this adapter's public calls and cached reads.

◆ ~PluginSurfaceSolver()

openswmm::twoD::PluginSurfaceSolver::~PluginSurfaceSolver ( )
inlineoverride

Destroy the plugin implementation synchronously on its execution owner.

Precondition
No outstanding calls or cached-reference readers; plugin and owner remain live.
Note
Invokes the allocating plugin's deallocator and catches all failures, reporting a teardown message to stderr. Does not finalize/unload the process Kokkos runtime. An exceptional failed dispatch cannot guarantee plugin resources were released.

Member Function Documentation

◆ advance()

double openswmm::twoD::PluginSurfaceSolver::advance ( double from,
double to )
inlineoverridevirtual

Advance the plugin backend synchronously to a requested endpoint.

Parameters
[in]fromFinite elapsed start time, seconds, matching backend state.
[in]toFinite target time, seconds, at least from.
Returns
Actual elapsed time reached from the backend; synchronously refreshes copied telemetry/receipts before returning.
Note
Runs on the controlling thread. Exceptions propagate; no adapter rollback. Caller serializes model edits, adapter methods and cached getters.

Implements openswmm::twoD::ISurfaceSolver.

◆ completedSourceTime()

double openswmm::twoD::PluginSurfaceSolver::completedSourceTime ( ) const
inlineoverridevirtualnoexcept

Read the adapter's last synchronized backend status.

Returns
Cached completed-source horizon in elapsed seconds; -1 initially/unavailable.
Note
No dispatch or allocation; cache may be stale after a failed backend call. Fields are not atomic, so serialize reads with adapter mutations.

Reimplemented from openswmm::twoD::ISurfaceSolver.

◆ finalize()

void openswmm::twoD::PluginSurfaceSolver::finalize ( )
inlineoverridevirtual

Release plugin backend resources on the execution-owner thread.

Postcondition
Synchronously finalizes plugin resources on the owner thread, then refreshes cached status and receipts. The plugin object itself is still owned until adapter destruction.
Note
Caller serializes teardown with all operations/getters. Backend or cache-copy exceptions propagate; no rollback or library unload occurs.

Implements openswmm::twoD::ISurfaceSolver.

◆ initialize()

void openswmm::twoD::PluginSurfaceSolver::initialize ( MeshData & m,
SurfaceStateData & s,
SolverOptions2D & o )
inlineoverridevirtual

Initialize the plugin backend synchronously and cache its status.

Parameters
[in,out]mBorrowed built SI mesh retained by the plugin; must outlive backend use.
[in,out]sBorrowed surface state mutated/retained by the plugin.
[in,out]oBorrowed validated options retained by the plugin.
Postcondition
Synchronously initializes on the owner thread, then refreshes the adapter status/receipt cache.
Note
Callback exceptions propagate; partial backend mutation may occur and caches refresh only after a successful backend call. No model ownership is transferred; all referenced buffers remain valid through finalization/destruction.

Implements openswmm::twoD::ISurfaceSolver.

◆ is_initialized()

bool openswmm::twoD::PluginSurfaceSolver::is_initialized ( ) const
inlineoverridevirtualnoexcept

Read the adapter's last synchronized backend status.

Returns
Last refreshed backend initialization flag; false initially.
Note
No dispatch or allocation; cache may be stale after a failed backend call. Fields are not atomic, so serialize reads with adapter mutations.

Implements openswmm::twoD::ISurfaceSolver.

◆ last_coupling_exchange()

const std::vector< double > & openswmm::twoD::PluginSurfaceSolver::last_coupling_exchange ( ) const
inlineoverridevirtualnoexcept

Borrow the most recently refreshed coupling-volume snapshot.

Returns
Borrowed adapter-owned copied coupling volumes in m3, positive surface-to-network. Valid until the next refresh or adapter destruction; never free/modify it.
Note
No plugin dispatch; caller serializes cached-reference use with advance/reinitialize/finalize. Empty cache means no live exchange tuple is available.

Reimplemented from openswmm::twoD::ISurfaceSolver.

◆ last_num_steps()

long openswmm::twoD::PluginSurfaceSolver::last_num_steps ( ) const
inlineoverridevirtualnoexcept

Read the adapter's last synchronized backend status.

Returns
Cached last-advance substep count, zero before the first refresh.
Note
No dispatch or allocation; cache may be stale after a failed backend call. Fields are not atomic, so serialize reads with adapter mutations.

Implements openswmm::twoD::ISurfaceSolver.

◆ last_step_size()

double openswmm::twoD::PluginSurfaceSolver::last_step_size ( ) const
inlineoverridevirtualnoexcept

Read the adapter's last synchronized backend status.

Returns
Cached last substep size in seconds, zero initially.
Note
No dispatch or allocation; cache may be stale after a failed backend call. Fields are not atomic, so serialize reads with adapter mutations.

Implements openswmm::twoD::ISurfaceSolver.

◆ reinitialize()

void openswmm::twoD::PluginSurfaceSolver::reinitialize ( double t)
inlineoverridevirtual

Reseed the plugin backend after external state edits.

Parameters
[in]tFinite elapsed simulation time in seconds for the edited state.
Postcondition
Synchronously delegates to the plugin on the owner thread, then refreshes cached telemetry/receipts.
Note
Reseeds using the backend reinitialize contract. Errors propagate and can leave backend/cache state different; caller provides exclusive access and valid retained arrays.

Implements openswmm::twoD::ISurfaceSolver.

◆ resyncFromVolumes()

void openswmm::twoD::PluginSurfaceSolver::resyncFromVolumes ( double t)
inlineoverridevirtual

Resynchronize backend time while preserving its volume-owner semantics.

Parameters
[in]tFinite elapsed simulation time in seconds for the edited state.
Postcondition
Synchronously delegates to the plugin on the owner thread, then refreshes cached telemetry/receipts.
Note
Preserves signed volumes only when the concrete backend implements that override. Errors propagate and can leave backend/cache state different; caller provides exclusive access and valid retained arrays.

Reimplemented from openswmm::twoD::ISurfaceSolver.

◆ run_stats()

RunStats openswmm::twoD::PluginSurfaceSolver::run_stats ( ) const
inlineoverridevirtualnoexcept

Read the adapter's last synchronized backend status.

Returns
Value-owned copy of the last refreshed cumulative backend statistics.
Note
No dispatch or allocation; cache may be stale after a failed backend call. Fields are not atomic, so serialize reads with adapter mutations.

Reimplemented from openswmm::twoD::ISurfaceSolver.


The documentation for this class was generated from the following file: