OpenSWMM Engine  6.0.0-alpha.1
Data-oriented, plugin-extensible SWMM Engine (6.0.0-alpha.1)
Loading...
Searching...
No Matches

The central, reentrant simulation context for the new engine. More...

#include "../data/GageData.hpp"
#include "../data/LinkData.hpp"
#include "../data/NameIndex.hpp"
#include "../data/NodeData.hpp"
#include "../data/PollutantData.hpp"
#include "../data/SubcatchData.hpp"
#include "../data/TableData.hpp"
#include "SimulationOptions.hpp"
#include "SpatialFrame.hpp"
#include "UserFlags.hpp"
#include "../data/QualityData.hpp"
#include "../data/InflowData.hpp"
#include "../data/InfraData.hpp"
#include "../data/HydrologyData.hpp"
#include "../data/ForcingData.hpp"
#include <algorithm>
#include <cstdint>
#include <string>
#include <vector>
Include dependency graph for SimulationContext.hpp:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  openswmm::PluginSpec
 One plugin entry from the [PLUGINS] section. More...
 
struct  openswmm::SimulationContext
 Central, reentrant simulation context. More...
 
struct  openswmm::SimulationContext::MassBalance
 Cumulative mass balance totals for runoff and routing. More...
 
struct  openswmm::SimulationContext::RoutingStepStats
 

Namespaces

namespace  openswmm
 

Enumerations

enum class  openswmm::EngineState : int32_t {
  openswmm::EngineState::CREATED = 0 ,
  openswmm::EngineState::OPENED = 1 ,
  openswmm::EngineState::INITIALIZED = 2 ,
  openswmm::EngineState::RUNNING = 3 ,
  openswmm::EngineState::PAUSED = 4 ,
  openswmm::EngineState::ENDED = 5 ,
  openswmm::EngineState::REPORTED = 6 ,
  openswmm::EngineState::CLOSED = 7 ,
  openswmm::EngineState::ERROR_STATE = 8 ,
  openswmm::EngineState::BUILDING = 9
}
 High-level engine lifecycle state. More...
 

Detailed Description

The central, reentrant simulation context for the new engine.

SimulationContext is the single owner of all simulation state. It replaces the ~70 global variables in src/solver/globals.h with a value type that is thread-safe (one context per thread) and trivially clonable for parallel runs.

Architecture summary

Legacy (globals.h) New location
FlowUnits, RouteModel, … ctx.options (SimulationOptions)
StartDate, EndDate, ElapsedTime, … ctx.current_time, ctx.options.*
Node[], Nnodes[] ctx.nodes (NodeData) + ctx.node_names (NameIndex)
Link[], Nlinks[] ctx.links (LinkData) + ctx.link_names (NameIndex)
Subcatch[], Nsubcatch ctx.subcatches (SubcatchData) + ctx.subcatch_names
Gage[], Ngages ctx.gages (GageData) + ctx.gage_names
Pollut[], Npolluts + quality state ctx.pollutants (PollutantData)
Tseries[] / Curve[] ctx.tables (TableData) + ctx.table_names
Coord[] ctx.spatial (SpatialFrame)
— (new) ctx.user_flags (UserFlags)

Lifecycle

ctx.reset() — full cold reset (call before re-running)
ctx.save_state() — snapshot current state into old-step arrays
ctx.advance(dt) — advance simulation clock by dt seconds
ctx.output_due() — true when dt_output_remaining <= EPSILON
ctx.is_complete() — true when current_time >= end_time

Thread safety

A SimulationContext must not be shared between threads without external synchronization. The IO thread receives a deep copy (SimulationSnapshot) posted through the ring queue — not a pointer to the live context.

See also
Legacy reference: src/solver/globals.h
src/engine/data/NodeData.hpp
src/engine/data/LinkData.hpp
src/engine/data/SubcatchData.hpp
src/engine/data/GageData.hpp
src/engine/data/PollutantData.hpp
src/engine/data/TableData.hpp
src/engine/data/NameIndex.hpp
src/engine/core/SimulationOptions.hpp
src/engine/core/SpatialFrame.hpp
src/engine/core/UserFlags.hpp
include/openswmm/plugin_sdk/SimulationSnapshot.hpp
Author
Caleb Buahin caleb.nosp@m..bua.nosp@m.hin@g.nosp@m.mail.nosp@m..com
License\n MIT License