85#ifndef OPENSWMM_ENGINE_HOT_START_MANAGER_HPP
86#define OPENSWMM_ENGINE_HOT_START_MANAGER_HPP
144 double infil[6] = {0, 0, 0, 0, 0, 0};
186 std::vector<HotStartNodeRecord>
nodes;
187 std::vector<HotStartLinkRecord>
links;
219 std::vector<std::vector<double>>
403 const std::string& path,
404 const std::string& engine_checkpoint);
452 std::function<
void(
const std::string&)> warn_cb = {});
471 std::function<
void(
const std::string&)> warn_cb = {});
505 std::function<
void(
const std::string&)> warn_cb = {},
506 std::vector<double>*
runoff =
nullptr,
507 LegacySpeciesTrailer* species =
nullptr);
527 const std::function<
void(
const std::string&)>& warn);
571 const std::vector<double>* runoff =
nullptr);
587 static bool flush(HotStartFile& hs);
615 static
bool write_file(const HotStartFile& hs, const std::
string& path);
630 static
bool read_file(HotStartFile& hs, const std::
string& path);
643 static uint32_t crc32(const uint8_t* data, std::
size_t len) noexcept;
HotStartManager()=delete
Prevent instantiation of the static hot-start utility class.
static bool apply_species_surface(const LegacySpeciesTrailer &tr, SimulationContext &ctx, const std::function< void(const std::string &)> &warn)
Apply a legacy trailer surface block by reaction-species name.
Definition HotStartManager.cpp:2707
static std::size_t legacy_runoff_size(const SimulationContext &ctx, int n_land)
Number of doubles in legacy's runoff section (hotstart.c saveRunoff) for the current model with n_lan...
Definition HotStartManager.cpp:2362
static const std::string & last_io_error() noexcept
Description of the most recent I/O error (empty = none).
Definition HotStartManager.cpp:120
static int save_legacy_routing(const std::string &path, const SimulationContext &ctx, const std::vector< double > *runoff=nullptr)
Write the current routing state as a legacy EPA SWMM5 .hsf (SAVE HOTSTART), byte-format-compatible wi...
Definition HotStartManager.cpp:2755
static int apply(HotStartFile &hs, SimulationContext &ctx, std::function< void(const std::string &)> warn_cb={})
Apply hot start records to a simulation context.
Definition HotStartManager.cpp:1974
static HotStartFile * save(const SimulationContext &ctx, const std::string &path)
Capture current engine state and write a feature-dependent native hot start.
Definition HotStartManager.cpp:1577
static int apply_legacy_routing(const std::string &path, SimulationContext &ctx, std::function< void(const std::string &)> warn_cb={}, std::vector< double > *runoff=nullptr, LegacySpeciesTrailer *species=nullptr)
Read a legacy EPA SWMM5 .hsf (USE HOTSTART) file and apply its routing state to the context,...
Definition HotStartManager.cpp:2379
static HotStartFile * open(const std::string &path)
Read and validate a hot start file.
Definition HotStartManager.cpp:1951
static bool is_native_file(const std::string &path) noexcept
Probe the native hot-start magic without parsing records.
Definition HotStartManager.cpp:1962
static HotStartFile * save_with_engine_checkpoint(const SimulationContext &ctx, const runoff::RunoffSolver *runoff, const groundwater::GWSolver *gw, const std::string &path, const std::string &engine_checkpoint)
Capture a native hot start with an optional complete engine-session checkpoint.
Definition HotStartManager.cpp:1763
static bool flush(HotStartFile &hs)
Rewrite a dirty native hot-start object to its stored path.
Definition HotStartManager.cpp:2881
Mutable two-zone groundwater state with independent scalar per-subcatchment RKF45....
Definition Groundwater.hpp:181
Owned three-pool non-LID reservoir, native soil state and completed routing history....
Definition Runoff.hpp:195
Definition HotStartManager.hpp:99
@ runoff
Definition ProcessPerf.hpp:24
Definition ExplicitInertialSolver.hpp:68
Definition ExchangeLaw.hpp:60
In-memory hot start file data.
Definition HotStartManager.hpp:177
bool set_link_depth(const std::string &id, double v)
Edit the first exact-ID stored link depth and mark the file dirty.
Definition HotStartManager.cpp:898
std::vector< double > gw_ledger
the cumulative terms (m3): 9, +link since G-X3
Definition HotStartManager.hpp:221
std::vector< double > gw_unsat_mass
column-store mass
Definition HotStartManager.hpp:238
bool set_node_depth(const std::string &id, double v)
Edit the first exact-ID stored node depth and mark the file dirty.
Definition HotStartManager.cpp:865
std::string fv_dry_state
V18: named disconnected FV scalar inventories.
Definition HotStartManager.hpp:181
std::string snow_state
V14: native degree-day and UEB accepted/held states.
Definition HotStartManager.hpp:178
HotStartHeader header
Definition HotStartManager.hpp:185
std::vector< double > link_species
Definition HotStartManager.hpp:199
bool set_subcatch_runoff(const std::string &id, double v)
Edit the first exact-ID stored subcatchment runoff and mark the file dirty.
Definition HotStartManager.cpp:909
std::vector< double > gw_species_ledger
Definition HotStartManager.hpp:239
bool dirty
True if set_*() was called.
Definition HotStartManager.hpp:246
std::vector< std::string > warnings
Populated by HotStartManager::apply()
Definition HotStartManager.hpp:248
std::vector< double > node_species
Definition HotStartManager.hpp:198
bool set_node_head(const std::string &id, double v)
Edit the first exact-ID stored node hydraulic head and mark the file dirty.
Definition HotStartManager.cpp:876
std::string surface_state
V16: subcatchment ponded water, groundwater flow and surface quality (StateAccessors::get_surface_sta...
Definition HotStartManager.hpp:184
std::vector< HotStartNodeRecord > nodes
Definition HotStartManager.hpp:186
std::string gw_transport_state
V17: canonical SIGMA chemistry, edge receipts and clocks.
Definition HotStartManager.hpp:182
std::vector< double > gw_theta_sigma
closure-B layers, layer-major
Definition HotStartManager.hpp:218
std::vector< std::string > species
Definition HotStartManager.hpp:197
std::string path
File path (for flush-on-close)
Definition HotStartManager.hpp:245
uint32_t gw_n_cells
Definition HotStartManager.hpp:214
static constexpr int kGwSpeciesLedgerTerms
Definition HotStartManager.hpp:243
std::vector< HotStartLinkRecord > links
Definition HotStartManager.hpp:187
std::vector< double > gw_hu
unsaturated storage (m of water)
Definition HotStartManager.hpp:217
std::vector< HotStartSubcatchRecord > subcatches
Definition HotStartManager.hpp:188
std::string engine_checkpoint
V15: complete accepted engine/2D state for qualified native restarts (may be empty from V16)
Definition HotStartManager.hpp:180
std::vector< std::string > gw_species
row names, in file order
Definition HotStartManager.hpp:236
std::vector< std::vector< double > > gw_interface
V12: receiving interface; V13 appends pending/cumulative ET and held surface evaporation.
Definition HotStartManager.hpp:220
std::vector< double > gw_hg
saturated thickness (m)
Definition HotStartManager.hpp:216
uint32_t gw_m_layers
Definition HotStartManager.hpp:215
bool set_link_flow(const std::string &id, double v)
Edit the first exact-ID stored link flow and mark the file dirty.
Definition HotStartManager.cpp:887
std::vector< double > gw_sat_mass
saturated-zone mass
Definition HotStartManager.hpp:237
Node hydraulic state at hot-start save time.
Definition HotStartManager.hpp:108
double bottom
Definition HotStartManager.hpp:110
int layer
Definition HotStartManager.hpp:109
double top
Definition HotStartManager.hpp:110
double volume
Definition HotStartManager.hpp:110
double porosity
Definition HotStartManager.hpp:110
double theta
Definition HotStartManager.hpp:110
Link hydraulic state at hot-start save time.
Definition HotStartManager.hpp:127
double depth
Definition HotStartManager.hpp:130
double age
A2a (V3): water age (seconds); -1 = not tracked / pre-V3 file.
Definition HotStartManager.hpp:133
double volume
Definition HotStartManager.hpp:131
std::string id
Definition HotStartManager.hpp:128
double flow
Definition HotStartManager.hpp:129
Definition HotStartManager.hpp:112
std::vector< HotStartLidCellRecord > lid_cells
V8 retained moisture and geometry identity.
Definition HotStartManager.hpp:117
std::vector< double > lid_quality_mass
V9 retained cell pollutant mass.
Definition HotStartManager.hpp:116
std::vector< double > lid_richards
V11: per-row storage and material identity.
Definition HotStartManager.hpp:114
double age
A2a (V3): water age (seconds); -1 = not tracked / pre-V3 file.
Definition HotStartManager.hpp:123
double volume
Definition HotStartManager.hpp:121
std::string id
Definition HotStartManager.hpp:113
double lid_treated_volume
V8 clogging history (ft3)
Definition HotStartManager.hpp:118
std::vector< double > lid_infiltration
V10 S,Ks,IMDmax,IMD,F,Fu,Fumax,Lu,T,head,saturated.
Definition HotStartManager.hpp:115
double depth
Definition HotStartManager.hpp:119
double head
Definition HotStartManager.hpp:120
Subcatchment state at hot-start save time.
Definition HotStartManager.hpp:137
double gw_lower_depth
lower zone depth (ft)
Definition HotStartManager.hpp:148
double infil[6]
flat 6-elem state (model-dependent)
Definition HotStartManager.hpp:144
double runoff
Definition HotStartManager.hpp:139
int infil_model
Definition HotStartManager.hpp:143
double gw_theta
upper zone moisture content
Definition HotStartManager.hpp:147
double gwater
Definition HotStartManager.hpp:140
std::string id
Definition HotStartManager.hpp:138
Static utility class for hot start file operations.
Definition HotStartManager.hpp:333
std::vector< double > washoff
[sc * ns + s] washoff concentration
Definition HotStartManager.hpp:337
int n_landuses
-1: the file has no surface block
Definition HotStartManager.hpp:336
int n_subcatch
Definition HotStartManager.hpp:335
std::vector< std::string > species
Definition HotStartManager.hpp:334
std::vector< double > ponded
[sc * ns + s] ponded mass
Definition HotStartManager.hpp:338
std::vector< double > buildup
[(sc * nlu + lu) * ns + s], per normalizer unit
Definition HotStartManager.hpp:339
Central, reentrant simulation context.
Definition SimulationContext.hpp:390