Runs a single SWMM simulation on a worker thread and emits live progress, warnings, and completion signals back to the GUI thread.
More...
#include <simulationrunner.h>
|
| void | started (int jobId) |
| |
| void | simulationDatesKnown (int jobId, QDateTime start, QDateTime end) |
| | Emitted once the engine is initialised and its OPTIONS section has been parsed. Carries the engine-side simulation window as calendar QDateTime values. The GUI status model uses these to render readable start / end / current columns.
|
| |
| void | progressChanged (int jobId, double fraction, QDateTime currentSimDate, double runoffErrFrac, double routingErrFrac, double avgTimestepSec, double twoDErrFrac) |
| | Per-tick progress signal emitted from the step loop.
|
| |
| void | warningReceived (int jobId, int code, QString message) |
| |
| void | finished (int jobId, bool success, int errorCode, QString errorMessage, double runoffErrFrac, double routingErrFrac, double twoDErrFrac) |
| |
| void | twoDSolverStats (int jobId, QString backend, int momentum, int ltsTiers, qint64 steps, QVector< qint64 > tierCells) |
| | 2D solver telemetry (swmm_2d_get_run_stats), emitted once after start and with every progress tick of a 2D run.
|
| |
| void | twoDInitialized (int jobId, QString h5Path, QVector< double > vx, QVector< double > vy, QVector< double > vz, QVector< int > cellFlat) |
| |
| void | twoDDepthsAvailable (int jobId, QVector< float > depths, QDateTime simTime, double elapsedSec) |
| |
| void | twoDEdgeGeometryAvailable (int jobId, QVector< float > length, QVector< float > nx, QVector< float > ny) |
| |
| void | twoDFluxAvailable (int jobId, QVector< float > flux, QDateTime simTime, double elapsedSec) |
| |
| void | twoDRainfallAvailable (int jobId, QVector< float > rainfall, QVector< float > rainCum, QDateTime simTime, double elapsedSec) |
| |
| void | twoDVertexDepthsAvailable (int jobId, QVector< double > vdepths, QDateTime simTime, double elapsedSec) |
| |
| void | twoDHeadsAvailable (int jobId, QVector< float > heads, QDateTime simTime, double elapsedSec) |
| |
| void | twoDEnvelopesAvailable (int jobId, QVector< float > maxDepth, QVector< float > maxVel) |
| |
|
| | SimulationRunner (int jobId, const QString &instanceName, const QString &inpPath, const QString &rptPath, const QString &outPath, const QString &engineVersion="6.0.0", QObject *parent=nullptr) |
| |
| void | start () |
| |
| void | cancel () |
| | Request early termination. Step-loop exits at the next iteration; swmm_engine_end + swmm_engine_report + swmm_engine_close STILL run so the partial .out and .rpt files are flushed to disk — Cancel saves whatever the engine has produced up to the moment of cancellation.
|
| |
| void | setPaused (bool paused) |
| |
| bool | isPaused () const |
| |
| int | jobId () const |
| |
| QString | outPath () const |
| |
| QString | inpPath () const |
| |
|
| static QString | parseTwoDOutputFile (const QString &inpPath) |
| | Scan a .inp for [2D_OPTIONS] OUTPUT_FILE and return the resolved absolute path of the 2D HDF5 output file (or an empty string when the key is absent).
|
| |
| static QString | parseTwoDOption (const QString &inpPath, const QString &key) |
| | Scan a .inp for a [2D_OPTIONS] key and return its value as a QString verbatim (empty when absent).
|
| |
Runs a single SWMM simulation on a worker thread and emits live progress, warnings, and completion signals back to the GUI thread.
The runner uses the full lifecycle (create → open → initialize → start → step-loop → end → report → close → destroy) so that both SWMM_ProgressCallback and SWMM_WarningCallback can be registered. Static C callbacks post back via QMetaObject::invokeMethod with Qt::QueuedConnection.
Ownership: created and destroyed on the GUI thread by SWMMVis. The runner self-deletes after emitting finished.
◆ SimulationRunner()
| SimulationRunner::SimulationRunner |
( |
int |
jobId, |
|
|
const QString & |
instanceName, |
|
|
const QString & |
inpPath, |
|
|
const QString & |
rptPath, |
|
|
const QString & |
outPath, |
|
|
const QString & |
engineVersion = "6.0.0", |
|
|
QObject * |
parent = nullptr |
|
) |
| |
|
explicit |
◆ cancel()
| void SimulationRunner::cancel |
( |
| ) |
|
Request early termination. Step-loop exits at the next iteration; swmm_engine_end + swmm_engine_report + swmm_engine_close STILL run so the partial .out and .rpt files are flushed to disk — Cancel saves whatever the engine has produced up to the moment of cancellation.
◆ finished
| void SimulationRunner::finished |
( |
int |
jobId, |
|
|
bool |
success, |
|
|
int |
errorCode, |
|
|
QString |
errorMessage, |
|
|
double |
runoffErrFrac, |
|
|
double |
routingErrFrac, |
|
|
double |
twoDErrFrac |
|
) |
| |
|
signal |
- Parameters
-
| runoffErrFrac | runoff continuity error fraction (0.001 = 0.1 %) |
| routingErrFrac | routing continuity error fraction |
| twoDErrFrac | 2D surface continuity error fraction; NaN when the run has no active 2D model |
◆ inpPath()
| QString SimulationRunner::inpPath |
( |
| ) |
const |
|
inline |
◆ isPaused()
| bool SimulationRunner::isPaused |
( |
| ) |
const |
|
inline |
◆ jobId()
| int SimulationRunner::jobId |
( |
| ) |
const |
|
inline |
◆ outPath()
| QString SimulationRunner::outPath |
( |
| ) |
const |
|
inline |
◆ parseTwoDOption()
| QString SimulationRunner::parseTwoDOption |
( |
const QString & |
inpPath, |
|
|
const QString & |
key |
|
) |
| |
|
static |
Scan a .inp for a [2D_OPTIONS] key and return its value as a QString verbatim (empty when absent).
Used by the GUI to honour engine-side settings — e.g. matching the render dry-cell threshold to the engine's DRY_DEPTH so shallow inundation runs aren't clipped.
◆ parseTwoDOutputFile()
| QString SimulationRunner::parseTwoDOutputFile |
( |
const QString & |
inpPath | ) |
|
|
static |
Scan a .inp for [2D_OPTIONS] OUTPUT_FILE and return the resolved absolute path of the 2D HDF5 output file (or an empty string when the key is absent).
The engine's parser fills SolverOptions2D::output_file from the same key, but openswmm_2d.h has no accessor, so this helper exists as a parallel scan callers can use to predict where the engine will write — useful both at open time (to look for an existing file from a previous run) and at finished time (to swap in an HDF5Mesh2DSource for scrubbing).
◆ progressChanged
| void SimulationRunner::progressChanged |
( |
int |
jobId, |
|
|
double |
fraction, |
|
|
QDateTime |
currentSimDate, |
|
|
double |
runoffErrFrac, |
|
|
double |
routingErrFrac, |
|
|
double |
avgTimestepSec, |
|
|
double |
twoDErrFrac |
|
) |
| |
|
signal |
Per-tick progress signal emitted from the step loop.
- Parameters
-
| fraction | 0.0–1.0 sim-time progress |
| currentSimDate | engine "current time" converted from the SWMM OADate to a calendar QDateTime — lets the status model assign it verbatim without re-deriving from start + offset (which can drift across DST boundaries). |
| runoffErrFrac | cumulative runoff continuity error so far |
| routingErrFrac | cumulative routing continuity error so far |
| twoDErrFrac | cumulative 2D surface continuity error so far; NaN when the run has no active 2D model |
◆ setPaused()
| void SimulationRunner::setPaused |
( |
bool |
paused | ) |
|
Request pause — the step-loop parks in a short sleep until setPaused(false) is called. Safe to call from the GUI thread.
◆ simulationDatesKnown
| void SimulationRunner::simulationDatesKnown |
( |
int |
jobId, |
|
|
QDateTime |
start, |
|
|
QDateTime |
end |
|
) |
| |
|
signal |
Emitted once the engine is initialised and its OPTIONS section has been parsed. Carries the engine-side simulation window as calendar QDateTime values. The GUI status model uses these to render readable start / end / current columns.
◆ start()
| void SimulationRunner::start |
( |
| ) |
|
Launch the simulation on a worker thread via QtConcurrent::run.
◆ started
| void SimulationRunner::started |
( |
int |
jobId | ) |
|
|
signal |
◆ twoDDepthsAvailable
| void SimulationRunner::twoDDepthsAvailable |
( |
int |
jobId, |
|
|
QVector< float > |
depths, |
|
|
QDateTime |
simTime, |
|
|
double |
elapsedSec |
|
) |
| |
|
signal |
◆ twoDEdgeGeometryAvailable
| void SimulationRunner::twoDEdgeGeometryAvailable |
( |
int |
jobId, |
|
|
QVector< float > |
length, |
|
|
QVector< float > |
nx, |
|
|
QVector< float > |
ny |
|
) |
| |
|
signal |
◆ twoDEnvelopesAvailable
| void SimulationRunner::twoDEnvelopesAvailable |
( |
int |
jobId, |
|
|
QVector< float > |
maxDepth, |
|
|
QVector< float > |
maxVel |
|
) |
| |
|
signal |
◆ twoDFluxAvailable
| void SimulationRunner::twoDFluxAvailable |
( |
int |
jobId, |
|
|
QVector< float > |
flux, |
|
|
QDateTime |
simTime, |
|
|
double |
elapsedSec |
|
) |
| |
|
signal |
◆ twoDHeadsAvailable
| void SimulationRunner::twoDHeadsAvailable |
( |
int |
jobId, |
|
|
QVector< float > |
heads, |
|
|
QDateTime |
simTime, |
|
|
double |
elapsedSec |
|
) |
| |
|
signal |
◆ twoDInitialized
| void SimulationRunner::twoDInitialized |
( |
int |
jobId, |
|
|
QString |
h5Path, |
|
|
QVector< double > |
vx, |
|
|
QVector< double > |
vy, |
|
|
QVector< double > |
vz, |
|
|
QVector< int > |
cellFlat |
|
) |
| |
|
signal |
◆ twoDRainfallAvailable
| void SimulationRunner::twoDRainfallAvailable |
( |
int |
jobId, |
|
|
QVector< float > |
rainfall, |
|
|
QVector< float > |
rainCum, |
|
|
QDateTime |
simTime, |
|
|
double |
elapsedSec |
|
) |
| |
|
signal |
◆ twoDSolverStats
| void SimulationRunner::twoDSolverStats |
( |
int |
jobId, |
|
|
QString |
backend, |
|
|
int |
momentum, |
|
|
int |
ltsTiers, |
|
|
qint64 |
steps, |
|
|
QVector< qint64 > |
tierCells |
|
) |
| |
|
signal |
2D solver telemetry (swmm_2d_get_run_stats), emitted once after start and with every progress tick of a 2D run.
- Parameters
-
| backend | solver label chosen at initialize, e.g. "cpu (explicit marcher)" or "omp (Kokkos OpenMP …)" |
| momentum | 0 LOCAL_INERTIAL, 1 FULL_SWE, 2 DIFFUSIVE_WAVE |
| ltsTiers | configured [2D_OPTIONS] LTS_TIERS |
| steps | cumulative marcher substeps so far |
| tierCells | rebuild-sampled cells per LTS tier (empty until the first rebuild) |
◆ twoDVertexDepthsAvailable
| void SimulationRunner::twoDVertexDepthsAvailable |
( |
int |
jobId, |
|
|
QVector< double > |
vdepths, |
|
|
QDateTime |
simTime, |
|
|
double |
elapsedSec |
|
) |
| |
|
signal |
◆ warningReceived
| void SimulationRunner::warningReceived |
( |
int |
jobId, |
|
|
int |
code, |
|
|
QString |
message |
|
) |
| |
|
signal |
The documentation for this class was generated from the following files: