OpenSWMM Engine  6.0.0-alpha.3
Data-oriented, plugin-extensible SWMM Engine (6.0.0-alpha.3)
Loading...
Searching...
No Matches
SimulationContext.hpp
Go to the documentation of this file.
1
59
60#ifndef OPENSWMM_ENGINE_SIMULATION_CONTEXT_HPP
61#define OPENSWMM_ENGINE_SIMULATION_CONTEXT_HPP
62
63#include <cmath>
64#include <functional>
65#include "FilePathPair.hpp"
66#include "../data/GageData.hpp"
67#include "../data/LinkData.hpp"
68#include "../data/NameIndex.hpp"
69#include "../data/NodeData.hpp"
74#include "../data/TableData.hpp"
75#include "SimulationOptions.hpp"
76#include "SpatialFrame.hpp"
77#include "UserFlags.hpp"
80#include "../data/InfraData.hpp"
85
86#include <algorithm>
87#include <cstdint>
88#include <string>
89#include <vector>
90
91namespace openswmm {
92
93// ============================================================================
94// Plugin specification (from [PLUGINS] section)
95// ============================================================================
96
107 std::string path;
108 std::vector<std::string> init_args;
109};
110
111// ============================================================================
112// [FILES] section spec — secondary file references
113// ============================================================================
114
124enum class FileMode {
128};
129
156
193
194// ============================================================================
195// Engine state enumeration
196// ============================================================================
197
206enum class EngineState : int32_t {
208 OPENED = 1,
211 PAUSED = 4,
212 ENDED = 5,
214 CLOSED = 7,
217};
218
219// ============================================================================
220// StateAccessors
221// ============================================================================
222
242 std::function<bool(int subcatch_index, int& out_model, double* out_infil)> get_infil_state;
243
246 std::function<bool(int subcatch_index, int model, const double* infil)> set_infil_state;
247
249 std::function<bool(int subcatch_index, double& out_theta, double& out_lower_depth)> get_gw_state;
250
252 std::function<bool(int subcatch_index, double theta, double lower_depth)> set_gw_state;
253
255 bool can_read() const noexcept {
256 return static_cast<bool>(get_infil_state) || static_cast<bool>(get_gw_state);
257 }
258
260 bool can_write() const noexcept {
261 return static_cast<bool>(set_infil_state) || static_cast<bool>(set_gw_state);
262 }
263};
264
265// ============================================================================
266// 2D model-IO bridge (forward declarations)
267// ============================================================================
268
269// Plain 2D data structs (all header-only and define-free; see
270// src/engine/2d/data/). Forward-declared so SimulationContext can carry
271// non-owning pointers without pulling the 2D module into every TU.
272namespace twoD {
273struct MeshData;
274struct SolverOptions2D;
275struct BoundaryData;
276struct PendingBoundaryRow;
277struct PendingEdgeConveyanceRow;
278} // namespace twoD
279
280// ============================================================================
281// SimulationContext
282// ============================================================================
283
293
294 // =========================================================================
295 // Engine state
296 // =========================================================================
297
300
301 // =========================================================================
302 // Project title / notes
303 // =========================================================================
304
314 std::vector<std::string> title_notes;
315
316 // =========================================================================
317 // Options & configuration
318 // =========================================================================
319
325
338
339 // =========================================================================
340 // Simulation clock
341 // =========================================================================
342
361 double current_time = 0.0;
362
370 double current_date = 0.0;
371
384 double elapsed_ms = 0.0;
385
392 double old_elapsed_ms = 0.0;
393
404 double next_report_ms = 0.0;
405
413
414 // =========================================================================
415 // Object data stores (Structure-of-Arrays)
416 // =========================================================================
417
423
434
440
448
454
460
466
472
473 // =========================================================================
474 // Name-to-index lookup (O(1))
475 // =========================================================================
476
482
488
494
500
506
512
513 // =========================================================================
514 // Quality data (landuse, buildup, washoff, treatment)
515 // =========================================================================
516
522
523 // =========================================================================
524 // Inflow data (external, DWF, RDII, patterns)
525 // =========================================================================
526
533
534 // =========================================================================
535 // Infrastructure data (transects, streets, inlets, controls)
536 // =========================================================================
537
540 std::vector<transect::TransectData> transect_tables;
545 std::uint64_t xsect_generation = 0;
546
555
560
561 // =========================================================================
562 // Events (from [EVENTS] section)
563 // =========================================================================
564
570 struct Event {
571 double start = 0.0;
572 double end = 0.0;
573 };
574 std::vector<Event> events;
575
576 // =========================================================================
577 // Subcatchment adjustment patterns (from [ADJUSTMENTS] section)
578 // =========================================================================
579
586 double adjust_temp[12] = {0,0,0,0,0,0,0,0,0,0,0,0};
587 double adjust_evap[12] = {1,1,1,1,1,1,1,1,1,1,1,1};
588 double adjust_rain[12] = {1,1,1,1,1,1,1,1,1,1,1,1};
589 double adjust_hydcon[12] = {1,1,1,1,1,1,1,1,1,1,1,1};
590
596 std::vector<int> subcatch_n_perv_pattern;
597 std::vector<int> subcatch_d_store_pattern;
598 std::vector<int> subcatch_infil_pattern;
599
601 std::vector<double> base_n_perv;
602 std::vector<double> base_ds_perv;
604
605 // =========================================================================
606 // Hydrology data (snowpacks, aquifers, LID)
607 // =========================================================================
608
616
617 // =========================================================================
618 // Spatial data
619 // =========================================================================
620
626
627 // =========================================================================
628 // User-defined flags
629 // =========================================================================
630
637
638 // =========================================================================
639 // Object tags (from [TAGS] section)
640 // =========================================================================
641
642 // Tags from the [TAGS] section now live per-index on
643 // NodeData::tags / LinkData::tags / SubcatchData::tags. Storing
644 // them name-keyed here was a latent rename bug — a tagged node
645 // would lose its tag the moment `swmm_node_rename` was called.
646
647 // =========================================================================
648 // Runtime forcing data
649 // =========================================================================
650
660
661 // =========================================================================
662 // Plugin specifications (from [PLUGINS] section)
663 // =========================================================================
664
670 std::vector<PluginSpec> plugin_specs;
671
681
691
712 struct TwoDModelIO {
716 std::vector<twoD::PendingBoundaryRow>* pending_bc = nullptr;
717 std::vector<twoD::PendingEdgeConveyanceRow>* pending_ec = nullptr;
719
720 // =========================================================================
721 // Error / warning tracking
722 // =========================================================================
723
728 int error_code = 0;
729
735
739 std::string error_message;
740
748 std::vector<std::string> warnings;
749
757 std::vector<std::string> errors;
758
770 std::vector<std::uint8_t> coupled_node;
771
772 // =========================================================================
773 // Mass balance accumulators (SoA — vectorisable batch updates)
774 // =========================================================================
775
785 struct MassBalance {
786 // Runoff totals
787 double runoff_rainfall = 0.0;
788 double runoff_evap = 0.0;
789 double runoff_infil = 0.0;
790 double runoff_runoff = 0.0;
791 double runoff_snowremov = 0.0;
792 double runoff_init_store = 0.0;
793 double runoff_final_store= 0.0;
794
795 // Routing totals
798 double routing_gw_inflow = 0.0;
799 double routing_rdii = 0.0;
800 double routing_external = 0.0;
801 double routing_flooding = 0.0;
802 double routing_outflow = 0.0;
803 double routing_evap_loss = 0.0;
804 double routing_seep_loss = 0.0;
807
808 // User-forced volumes (diagnostic — subset of routing_external)
810
811 // User-forced quality mass (diagnostic — cumulative mass injected via user_conc_mass_flux)
812 std::vector<double> routing_forcing_qual_inflow;
813
814 // Groundwater mass balance totals (all in feet — depth per unit area)
815 // Matches legacy TGwaterTotals
816 double gw_infil = 0.0;
817 double gw_upper_evap = 0.0;
818 double gw_lower_evap = 0.0;
819 double gw_lower_perc = 0.0;
820 double gw_lateral_flow = 0.0;
821 double gw_init_storage = 0.0;
822 double gw_final_storage = 0.0;
823
824 // Per-step accumulators (reset each step for reporting)
825 double step_flooding = 0.0;
826 double step_outflow = 0.0;
827 double step_dw_inflow = 0.0;
828 double step_gw_inflow = 0.0;
829 double step_rdii_inflow = 0.0;
830 double step_ext_inflow = 0.0;
831
832 // Quality mass balance (per-pollutant, in mass units)
833 std::vector<double> qual_init_buildup;
834 std::vector<double> qual_final_buildup;
835 std::vector<double> qual_surface_buildup;
836 std::vector<double> qual_wet_deposition;
837 std::vector<double> qual_sweeping;
838 std::vector<double> qual_bmp_removal;
839 std::vector<double> qual_infil_loss;
840 std::vector<double> qual_runoff_load;
841 std::vector<double> qual_routing_wet;
842 std::vector<double> qual_routing_outflow;
843 std::vector<double> qual_routing_flood;
844 std::vector<double> qual_routing_init;
845 std::vector<double> qual_routing_final;
846 std::vector<double> qual_routing_reacted;
847 std::vector<double> qual_routing_ii_in;
848 std::vector<double> qual_routing_dw_in;
849 std::vector<double> qual_routing_gw_in;
850 std::vector<double> qual_routing_ex_in;
851 std::vector<double> qual_routing_seep;
852 std::vector<double> qual_routing_evap;
853
855 auto np = static_cast<std::size_t>(n_pollutants);
856 qual_init_buildup.assign(np, 0.0);
857 qual_final_buildup.assign(np, 0.0);
858 qual_surface_buildup.assign(np, 0.0);
859 qual_wet_deposition.assign(np, 0.0);
860 qual_sweeping.assign(np, 0.0);
861 qual_bmp_removal.assign(np, 0.0);
862 qual_infil_loss.assign(np, 0.0);
863 qual_runoff_load.assign(np, 0.0);
864 qual_routing_wet.assign(np, 0.0);
865 qual_routing_outflow.assign(np, 0.0);
866 qual_routing_flood.assign(np, 0.0);
867 qual_routing_init.assign(np, 0.0);
868 qual_routing_final.assign(np, 0.0);
869 qual_routing_reacted.assign(np, 0.0);
870 qual_routing_ii_in.assign(np, 0.0);
871 qual_routing_dw_in.assign(np, 0.0);
872 qual_routing_gw_in.assign(np, 0.0);
873 qual_routing_ex_in.assign(np, 0.0);
874 qual_routing_seep.assign(np, 0.0);
875 qual_routing_evap.assign(np, 0.0);
876 routing_forcing_qual_inflow.assign(np, 0.0);
877 }
878
879 void reset() {
880 // Save quality vectors, reset scalars, restore vectors
881 auto qi = std::move(qual_init_buildup);
882 auto qf = std::move(qual_final_buildup);
883 auto qsb = std::move(qual_surface_buildup);
884 auto qwd = std::move(qual_wet_deposition);
885 auto qsw = std::move(qual_sweeping);
886 auto qbmp = std::move(qual_bmp_removal);
887 auto qil = std::move(qual_infil_loss);
888 auto qrl = std::move(qual_runoff_load);
889 auto qrw = std::move(qual_routing_wet);
890 auto qro = std::move(qual_routing_outflow);
891 auto qrf = std::move(qual_routing_flood);
892 auto qri = std::move(qual_routing_init);
893 auto qrfi = std::move(qual_routing_final);
894 auto qrr = std::move(qual_routing_reacted);
895 auto qrii = std::move(qual_routing_ii_in);
896 auto qrdw = std::move(qual_routing_dw_in);
897 auto qrgw = std::move(qual_routing_gw_in);
898 auto qrex = std::move(qual_routing_ex_in);
899 auto qrseep = std::move(qual_routing_seep);
900 auto qrevap = std::move(qual_routing_evap);
901 auto qrfqi = std::move(routing_forcing_qual_inflow);
902 *this = MassBalance{};
903 qual_init_buildup = std::move(qi);
904 qual_final_buildup = std::move(qf);
905 qual_surface_buildup = std::move(qsb);
906 qual_wet_deposition = std::move(qwd);
907 qual_sweeping = std::move(qsw);
908 qual_bmp_removal = std::move(qbmp);
909 qual_infil_loss = std::move(qil);
910 qual_runoff_load = std::move(qrl);
911 qual_routing_wet = std::move(qrw);
912 qual_routing_outflow = std::move(qro);
913 qual_routing_flood = std::move(qrf);
914 qual_routing_init = std::move(qri);
915 qual_routing_final = std::move(qrfi);
916 qual_routing_reacted = std::move(qrr);
917 qual_routing_ii_in = std::move(qrii);
918 qual_routing_dw_in = std::move(qrdw);
919 qual_routing_gw_in = std::move(qrgw);
920 qual_routing_ex_in = std::move(qrex);
921 qual_routing_seep = std::move(qrseep);
922 qual_routing_evap = std::move(qrevap);
923 routing_forcing_qual_inflow = std::move(qrfqi);
924 // Zero out the quality vectors (except init_buildup which is
925 // computed once during initQuality and must survive reset)
926 for (auto* v : {&qual_final_buildup,
940 std::fill(v->begin(), v->end(), 0.0);
941 }
942 }
943
945 double runoff_error() const {
946 double total_in = runoff_rainfall + runoff_init_store;
948 return (total_in > 0.0) ? (total_in - total_out) / total_in : 0.0;
949 }
950
952 double routing_error() const {
953 double total_in = routing_dry_weather + routing_wet_weather +
956 double total_out = routing_flooding + routing_outflow +
959 return (total_in > 0.0) ? (total_in - total_out) / total_in : 0.0;
960 }
961
963 double gw_error() const {
964 double total_in = gw_infil + gw_init_storage;
965 double total_out = gw_upper_evap + gw_lower_evap + gw_lower_perc +
967 return (total_in > 0.0) ? (total_in - total_out) / total_in : 0.0;
968 }
970
982 double init_storage = 0.0;
983 double final_storage = 0.0;
984 double rainfall_in = 0.0;
985 double coupling_1d_to_2d_in = 0.0;
987 double outfall_in = 0.0;
988 double outfall_out = 0.0;
989 double boundary_in = 0.0;
990 double boundary_out = 0.0;
991 double evap_out = 0.0;
992 bool active = false;
993
995 double error() const {
996 double total_in = rainfall_in + coupling_1d_to_2d_in + outfall_in
998 double total_out = coupling_2d_to_1d_out + outfall_out + boundary_out
1000 return (total_in > 0.0) ? (total_in - total_out) / total_in : 0.0;
1001 }
1003
1004 // =========================================================================
1005 // Routing time-step statistics
1006 // =========================================================================
1007
1009 struct MaxStats {
1010 int obj_type = -1;
1011 int index = -1;
1012 double value = 0.0;
1013 };
1014
1015 static constexpr int MAX_STATS = 5;
1016
1025
1027 double min_step = 1.0e30;
1028 double max_step = 0.0;
1029 double sum_step = 0.0;
1030 long n_steps = 0;
1031 double steady_pct = 0.0;
1032
1034 static constexpr int N_TIME_BINS = 5;
1035 long step_counts[N_TIME_BINS + 1] = {};
1036 double step_intervals[N_TIME_BINS + 1] = {};
1037
1040 double sum_iterations = 0.0;
1041 double max_courant = 0.0;
1042
1043 void update(double dt) {
1044 min_step = std::min(min_step, dt);
1045 max_step = std::max(max_step, dt);
1046 sum_step += dt;
1047 ++n_steps;
1048 }
1049
1051 void update_iterations(int iters, bool converged) {
1052 sum_iterations += iters;
1053 if (!converged) ++n_non_converged;
1054 }
1055
1059 void init_histogram(double route_step, double min_route_step) {
1060 if (route_step <= 0.0) return;
1061 if (min_route_step <= 0.0) min_route_step = route_step;
1062 double log_hi = std::log10(route_step);
1063 double log_lo = std::log10(min_route_step);
1064 double delta = (log_hi - log_lo) / static_cast<double>(N_TIME_BINS);
1065 step_intervals[0] = route_step;
1066 for (int i = 1; i <= N_TIME_BINS; ++i)
1067 step_intervals[i] = std::pow(10.0, log_hi - i * delta);
1068 step_intervals[N_TIME_BINS] = min_route_step;
1069 }
1070
1074 if (n_steps == 0 || max_step <= 0.0) return;
1075 double hi = max_step;
1076 double lo = (min_step < 1.0e30) ? min_step : 0.0;
1077 if (lo <= 0.0) lo = hi;
1078 init_histogram(hi, lo);
1079 }
1080
1082 void record_step_bin(double dt) {
1083 for (int i = 0; i < N_TIME_BINS; ++i) {
1084 if (dt >= step_intervals[i+1]) {
1085 step_counts[i]++;
1086 return;
1087 }
1088 }
1089 step_counts[N_TIME_BINS - 1]++;
1090 }
1091
1092 double avg_step() const {
1093 return (n_steps > 0) ? sum_step / static_cast<double>(n_steps) : 0.0;
1094 }
1095
1096 double pct_non_converged() const {
1097 return (n_steps > 0) ? 100.0 * static_cast<double>(n_non_converged) / static_cast<double>(n_steps) : 0.0;
1098 }
1099
1101 return (n_steps > 0) ? sum_iterations / static_cast<double>(n_steps) : 0.0;
1102 }
1104
1105 // =========================================================================
1106 // Control action log — Gap #67
1107 // Populated by ControlEngine::applyPendingActions() when rpt_controls is on.
1108 // =========================================================================
1109
1113 std::string rule_name;
1115 double date;
1116 };
1117
1119 std::vector<ControlLogEntry> control_log;
1120
1121 // =========================================================================
1122 // Input file path (for model write / hot start)
1123 // =========================================================================
1124
1129 std::string inp_file_path;
1130
1131 // =========================================================================
1132 // Context-level operations
1133 // =========================================================================
1134
1139 static void updateMaxStats(MaxStats arr[], int obj_type, int idx, double value) {
1140 MaxStats candidate;
1141 candidate.obj_type = obj_type;
1142 candidate.index = idx;
1143 candidate.value = value;
1144 for (int k = 0; k < MAX_STATS; ++k) {
1145 if (std::fabs(candidate.value) > std::fabs(arr[k].value)) {
1146 MaxStats tmp = arr[k];
1147 arr[k] = candidate;
1148 candidate = tmp;
1149 }
1150 }
1151 }
1152
1159 long step_count = routing_stats.n_steps;
1160 if (step_count <= 0) return;
1161 double inv_steps = 1.0 / static_cast<double>(step_count);
1162
1163 // CFL-critical elements: percentage of steps each element was critical
1164 for (int j = 0; j < n_nodes(); ++j) {
1165 double x = nodes.stat_time_courant_critical[static_cast<std::size_t>(j)] * inv_steps;
1166 updateMaxStats(max_courant_crit, 0, j, 100.0 * x);
1167 }
1168 for (int j = 0; j < n_links(); ++j) {
1169 double x = links.stat_time_courant_critical[static_cast<std::size_t>(j)] * inv_steps;
1170 updateMaxStats(max_courant_crit, 1, j, 100.0 * x);
1171 }
1172
1173 // Flow instability index (matching legacy normalization)
1174 long rpt_steps = routing_stats.n_steps;
1175 if (rpt_steps > 2) {
1176 double z = 100.0 / (2.0 / 3.0 * static_cast<double>(rpt_steps - 2));
1177 for (int j = 0; j < n_links(); ++j) {
1178 double x = static_cast<double>(links.stat_flow_turns[static_cast<std::size_t>(j)]) * z;
1180 }
1181 }
1182
1183 // Non-convergence: fraction of total steps each node failed to converge
1184 for (int j = 0; j < n_nodes(); ++j) {
1185 double x = static_cast<double>(nodes.stat_non_converged_count[static_cast<std::size_t>(j)]) * inv_steps;
1187 }
1188 }
1189
1197 void reset() {
1199 control_log.clear();
1200 current_time = 0.0;
1201 current_date = 0.0;
1203 elapsed_ms = 0.0;
1204 old_elapsed_ms = 0.0;
1205 next_report_ms = 0.0;
1206 error_code = 0;
1207 warning_code = 0;
1208 error_message.clear();
1209 warnings.clear();
1210 errors.clear();
1211 title_notes.clear();
1212
1213 // Clear SoA stores
1214 nodes = NodeData{};
1215 links = LinkData{};
1217 gages = GageData{};
1219 tables = TableData{};
1220
1221 // Clear name indices
1222 node_names.clear();
1223 link_names.clear();
1224 subcatch_names.clear();
1225 gage_names.clear();
1226 pollutant_names.clear();
1227 table_names.clear();
1228
1229 // Clear inflow-related stores that aren't reset by their owning solvers
1231
1232 // Clear daily climate state (re-initialized by SWMMEngine on next run)
1234
1235 // Clear spatial, flags, events, and forcing. Per-object tags
1236 // are owned by NodeData/LinkData/SubcatchData and cleared when
1237 // those SoAs are resized/cleared by the wider reset path.
1239 user_flags.clear();
1240 events.clear();
1241 std::fill(std::begin(adjust_temp), std::end(adjust_temp), 0.0);
1242 std::fill(std::begin(adjust_evap), std::end(adjust_evap), 1.0);
1243 std::fill(std::begin(adjust_rain), std::end(adjust_rain), 1.0);
1244 std::fill(std::begin(adjust_hydcon), std::end(adjust_hydcon), 1.0);
1247 subcatch_infil_pattern.clear();
1248 base_n_perv.clear();
1249 base_ds_perv.clear();
1251 forcing = ForcingData{};
1252 }
1253
1260 void save_state() noexcept {
1261 nodes.save_state();
1262 links.save_state();
1263 // NOTE: subcatches.save_state() is intentionally NOT called here.
1264 // Subcatchment old-state (old_runoff/old_runon/conc_old) is the
1265 // runoff-step snapshot used to linearly interpolate lateral inflow
1266 // between runoff evaluations (legacy subcatch_setOldState, called
1267 // ONLY inside runoff_execute — i.e. per WET/DRY step, not per routing
1268 // step). Saving it here, every routing step, clobbered old_runoff with
1269 // the current value so old==new and the lateral inflow jumped to the
1270 // full new runoff instantly instead of ramping. It is now saved in the
1271 // runoff-advance loop in SWMMEngine::stepRunoff().
1272 }
1273
1280 void reset_state() noexcept {
1281 nodes.reset_state();
1282 links.reset_state();
1283 subcatches.reset_state();
1284 gages.reset_state();
1285 tables.reset_cursors();
1286 current_time = 0.0;
1287 current_date = options.start_date;
1289 elapsed_ms = 0.0;
1290 old_elapsed_ms = 0.0;
1291 // Legacy swmm5.c:721 — ReportTime = 1000 * ReportStep (ms from SIM start)
1292 next_report_ms = 1000.0 * options.report_step;
1293 }
1294
1306 nodes.resize(node_names.size());
1307 links.resize(link_names.size());
1308 subcatches.resize(subcatch_names.size());
1309 gages.resize(gage_names.size());
1310 pollutants.resize_pollutants(pollutant_names.size());
1311 int np = static_cast<int>(pollutant_names.size());
1312 nodes.resize_quality(np);
1313 links.resize_quality(np);
1314 subcatches.resize_quality(np);
1315
1316 // Resize spatial coordinate arrays
1317 spatial.node_x.assign(static_cast<std::size_t>(node_names.size()), 0.0);
1318 spatial.node_y.assign(static_cast<std::size_t>(node_names.size()), 0.0);
1319 spatial.link_x.assign(static_cast<std::size_t>(link_names.size()), 0.0);
1320 spatial.link_y.assign(static_cast<std::size_t>(link_names.size()), 0.0);
1321 spatial.subcatch_x.assign(static_cast<std::size_t>(subcatch_names.size()), 0.0);
1322 spatial.subcatch_y.assign(static_cast<std::size_t>(subcatch_names.size()), 0.0);
1323
1324 // Resize link vertex and subcatchment polygon arrays
1325 spatial.link_vertices_x.resize(static_cast<std::size_t>(link_names.size()));
1326 spatial.link_vertices_y.resize(static_cast<std::size_t>(link_names.size()));
1327 spatial.subcatch_polygon_x.resize(static_cast<std::size_t>(subcatch_names.size()));
1328 spatial.subcatch_polygon_y.resize(static_cast<std::size_t>(subcatch_names.size()));
1329
1330 // Resize gage coordinates
1331 spatial.gage_x.assign(static_cast<std::size_t>(gage_names.size()), 0.0);
1332 spatial.gage_y.assign(static_cast<std::size_t>(gage_names.size()), 0.0);
1333 }
1334
1344 nodes.shrink_to_fit();
1345 links.shrink_to_fit();
1346 subcatches.shrink_to_fit();
1347 gages.shrink_to_fit();
1348 pollutants.shrink_to_fit();
1349 landuses.shrink_to_fit();
1350 buildup.shrink_to_fit();
1351 washoff.shrink_to_fit();
1352 treatment.shrink_to_fit();
1353 spatial.shrink_to_fit();
1354 }
1355
1356 // =========================================================================
1357 // Convenience accessors
1358 // =========================================================================
1359
1361 int n_nodes() const noexcept { return node_names.size(); }
1362
1364 int n_links() const noexcept { return link_names.size(); }
1365
1367 int n_subcatches() const noexcept { return subcatch_names.size(); }
1368
1370 int n_gages() const noexcept { return gage_names.size(); }
1371
1373 int n_pollutants() const noexcept { return pollutant_names.size(); }
1374 int n_landuses() const noexcept { return landuse_names.size(); }
1375
1377 int n_tables() const noexcept { return table_names.size(); }
1378};
1379
1380} /* namespace openswmm */
1381
1382#endif /* OPENSWMM_ENGINE_SIMULATION_CONTEXT_HPP */
Climate processing — evaporation, temperature, wind.
Carrier for an external file reference in a SWMM model.
Per-element runtime forcing state — SoA layout.
Structure-of-Arrays (SoA) storage for rain gages.
SoA stores for snowpacks, aquifers, LID controls, and LID usage.
SoA stores for external inflows, DWF, RDII, and time patterns.
SoA stores for transects, streets, inlets, and control rules.
O(1) name-to-index lookup for SWMM objects.
Structure-of-Arrays (SoA) storage for all node types.
Relational (normalized) Structure-of-Arrays side-tables for node subtypes.
Structure-of-Arrays (SoA) storage for pollutants and water quality.
SoA stores for land uses, buildup, washoff, and treatment.
Simulation options parsed from the [OPTIONS] section.
Spatial frame — CRS specification and coordinate data for nodes/links.
Structure-of-Arrays (SoA) storage for subcatchments.
Time series and rating curve data with bidirectional cursor.
Irregular transect cross-section geometry (HEC-2 style).
User-defined model flags (InfoWorks ICM-style, two-section design).
Bidirectional name↔index registry for SWMM objects.
Definition NameIndex.hpp:45
Stores the full user-flags data: schema definitions + per-object values.
Definition UserFlags.hpp:127
FileMode
Mode keyword for one [FILES] row — SAVE or USE.
Definition SimulationContext.hpp:124
EngineState
High-level engine lifecycle state.
Definition SimulationContext.hpp:206
@ USE
Definition SimulationContext.hpp:127
@ NONE
Definition SimulationContext.hpp:125
@ SAVE
Definition SimulationContext.hpp:126
@ CLOSED
Resources released.
Definition SimulationContext.hpp:214
@ ENDED
Simulation loop completed.
Definition SimulationContext.hpp:212
@ ERROR_STATE
Fatal error; call swmm_engine_last_error()
Definition SimulationContext.hpp:215
@ RUNNING
Simulation loop in progress.
Definition SimulationContext.hpp:210
@ REPORTED
Summary report written.
Definition SimulationContext.hpp:213
@ BUILDING
Programmatic model construction in progress (no .inp)
Definition SimulationContext.hpp:216
@ CREATED
Context allocated, no input loaded.
Definition SimulationContext.hpp:207
@ PAUSED
Simulation paused (future hot-swap support)
Definition SimulationContext.hpp:211
@ INITIALIZED
Initial conditions applied.
Definition SimulationContext.hpp:209
@ OPENED
Input file parsed, objects allocated.
Definition SimulationContext.hpp:208
Definition Infiltration.cpp:18
Definition NodeCoupling.cpp:15
SoA storage for aquifer parameter sets.
Definition HydrologyData.hpp:66
Definition QualityData.hpp:63
Definition InfraData.hpp:123
Definition InflowData.hpp:71
Definition InflowData.hpp:27
Two-string carrier for any external file path that appears in a SWMM .inp file.
Definition FilePathPair.hpp:47
Definition SimulationContext.hpp:157
FileMode runoff_mode
Definition SimulationContext.hpp:161
FilePathPair hotstart_use_path
Legacy semantics: USE — single hot-start input file.
Definition SimulationContext.hpp:174
FilePathPair rainfall_path
Definition SimulationContext.hpp:159
FileMode rainfall_mode
Definition SimulationContext.hpp:158
FilePathPair outflows_path
Legacy semantics: SAVE only.
Definition SimulationContext.hpp:171
FilePathPair runoff_path
Definition SimulationContext.hpp:162
std::vector< HotstartSaveEntry > hotstart_saves
Definition SimulationContext.hpp:179
bool has_any() const noexcept
Definition SimulationContext.hpp:183
FilePathPair rdii_path
Definition SimulationContext.hpp:165
FilePathPair inflows_path
Legacy semantics: USE only.
Definition SimulationContext.hpp:168
FileMode rdii_mode
Definition SimulationContext.hpp:164
Definition ForcingData.hpp:52
Structure-of-Arrays storage for all rain gages.
Definition GageData.hpp:77
Configuration parsed from the [FILES] section.
Definition SimulationContext.hpp:150
double datetime
Definition SimulationContext.hpp:154
FilePathPair path
Definition SimulationContext.hpp:151
Definition InfraData.hpp:74
Definition InfraData.hpp:90
Definition QualityData.hpp:29
SoA storage for LID control type definitions.
Definition HydrologyData.hpp:99
SoA storage for LID usage assignments to subcatchments.
Definition HydrologyData.hpp:140
Structure-of-Arrays storage for all nodes.
Definition NodeData.hpp:114
Owns the three node subtype side-tables plus the reverse index map.
Definition NodeSubtypes.hpp:357
Definition InflowData.hpp:208
One plugin entry from the [PLUGINS] section.
Definition SimulationContext.hpp:106
std::string path
Shared library path.
Definition SimulationContext.hpp:107
std::vector< std::string > init_args
Extra tokens from the [PLUGINS] row.
Definition SimulationContext.hpp:108
Static properties for each pollutant species.
Definition PollutantData.hpp:55
Definition InflowData.hpp:112
Definition InflowData.hpp:196
double new_setting
The new target setting value (0-1)
Definition SimulationContext.hpp:1114
std::string rule_name
Name of the rule that triggered the change.
Definition SimulationContext.hpp:1113
double date
OADate when the change occurred.
Definition SimulationContext.hpp:1115
int link_idx
Index of the link whose setting changed.
Definition SimulationContext.hpp:1112
double end
Event end (DateTime decimal days)
Definition SimulationContext.hpp:572
double start
Event start (DateTime decimal days)
Definition SimulationContext.hpp:571
double boundary_in
Cumulative boundary inflow (m³)
Definition SimulationContext.hpp:989
double evap_out
Cumulative evaporation loss (m³)
Definition SimulationContext.hpp:991
double outfall_in
Cumulative 1D outfall discharge into 2D (m³)
Definition SimulationContext.hpp:987
double boundary_out
Cumulative boundary outflow (m³)
Definition SimulationContext.hpp:990
double coupling_2d_to_1d_out
Cumulative 2D→1D drainage out (m³)
Definition SimulationContext.hpp:986
double final_storage
Latest surface storage (m³)
Definition SimulationContext.hpp:983
double init_storage
Initial surface storage (m³)
Definition SimulationContext.hpp:982
double error() const
2D surface continuity error (fraction).
Definition SimulationContext.hpp:995
double outfall_out
Cumulative 2D→pipe withdrawal at submerged outfalls (m³)
Definition SimulationContext.hpp:988
bool active
True if the 2D module ran.
Definition SimulationContext.hpp:992
double rainfall_in
Cumulative rainfall volume (m³)
Definition SimulationContext.hpp:984
double coupling_1d_to_2d_in
Cumulative 1D→2D spill into 2D (m³)
Definition SimulationContext.hpp:985
Cumulative mass balance totals for runoff and routing.
Definition SimulationContext.hpp:785
double routing_rdii
Definition SimulationContext.hpp:799
std::vector< double > qual_routing_ex_in
External (interface file) quality mass inflow.
Definition SimulationContext.hpp:850
double gw_infil
Cumulative infiltration to GW (ft)
Definition SimulationContext.hpp:816
double routing_gw_inflow
Definition SimulationContext.hpp:798
double routing_init_storage
Definition SimulationContext.hpp:805
double routing_evap_loss
Definition SimulationContext.hpp:803
std::vector< double > qual_surface_buildup
Accumulated buildup during sim.
Definition SimulationContext.hpp:835
double routing_dry_weather
Definition SimulationContext.hpp:796
std::vector< double > qual_routing_final
Final stored quality mass.
Definition SimulationContext.hpp:845
double runoff_runoff
Total surface runoff volume (ft3)
Definition SimulationContext.hpp:790
std::vector< double > qual_init_buildup
Initial buildup mass.
Definition SimulationContext.hpp:833
std::vector< double > qual_routing_init
Initial stored quality mass.
Definition SimulationContext.hpp:844
std::vector< double > qual_runoff_load
Mass load in surface runoff.
Definition SimulationContext.hpp:840
std::vector< double > qual_final_buildup
Final buildup mass.
Definition SimulationContext.hpp:834
double routing_final_storage
Definition SimulationContext.hpp:806
double runoff_init_store
Initial surface storage (ft3)
Definition SimulationContext.hpp:792
double gw_lower_perc
Cumulative deep percolation (ft)
Definition SimulationContext.hpp:819
double routing_seep_loss
Definition SimulationContext.hpp:804
std::vector< double > qual_routing_flood
Quality mass lost to flooding.
Definition SimulationContext.hpp:843
double runoff_snowremov
Total snow removal volume (ft3)
Definition SimulationContext.hpp:791
std::vector< double > qual_routing_dw_in
Dry weather quality mass inflow.
Definition SimulationContext.hpp:848
double gw_upper_evap
Cumulative upper zone evaporation (ft)
Definition SimulationContext.hpp:817
double routing_external
Definition SimulationContext.hpp:800
std::vector< double > qual_infil_loss
Mass lost to infiltration.
Definition SimulationContext.hpp:839
double runoff_final_store
Final surface storage (ft3)
Definition SimulationContext.hpp:793
std::vector< double > qual_routing_reacted
Quality mass lost to decay.
Definition SimulationContext.hpp:846
double routing_wet_weather
Definition SimulationContext.hpp:797
std::vector< double > qual_wet_deposition
Wet deposition mass.
Definition SimulationContext.hpp:836
double gw_final_storage
Final GW storage (ft)
Definition SimulationContext.hpp:822
std::vector< double > qual_routing_seep
Quality mass lost to seepage.
Definition SimulationContext.hpp:851
double step_gw_inflow
Definition SimulationContext.hpp:828
double runoff_rainfall
Total rainfall volume (ft3)
Definition SimulationContext.hpp:787
void reset()
Definition SimulationContext.hpp:879
double gw_lateral_flow
Cumulative lateral GW flow (ft)
Definition SimulationContext.hpp:820
std::vector< double > qual_routing_ii_in
RDII quality mass inflow.
Definition SimulationContext.hpp:847
double routing_flooding
Definition SimulationContext.hpp:801
void resize_quality(int n_pollutants)
Definition SimulationContext.hpp:854
double gw_error() const
Groundwater continuity error (fraction). Gap #72.
Definition SimulationContext.hpp:963
double runoff_evap
Total evaporation volume (ft3)
Definition SimulationContext.hpp:788
double gw_init_storage
Initial GW storage (ft)
Definition SimulationContext.hpp:821
std::vector< double > qual_routing_gw_in
Groundwater quality mass inflow.
Definition SimulationContext.hpp:849
double step_flooding
Definition SimulationContext.hpp:825
std::vector< double > qual_sweeping
Mass removed by sweeping.
Definition SimulationContext.hpp:837
std::vector< double > routing_forcing_qual_inflow
Per-pollutant cumulative user-forced quality mass.
Definition SimulationContext.hpp:812
double routing_error() const
Routing continuity error (fraction).
Definition SimulationContext.hpp:952
double gw_lower_evap
Cumulative lower zone evaporation (ft)
Definition SimulationContext.hpp:818
std::vector< double > qual_routing_outflow
Quality mass leaving at outfalls.
Definition SimulationContext.hpp:842
double routing_forcing_inflow
Cumulative user-forced lateral inflow (ft3)
Definition SimulationContext.hpp:809
double step_rdii_inflow
Definition SimulationContext.hpp:829
double runoff_infil
Total infiltration volume (ft3)
Definition SimulationContext.hpp:789
double step_outflow
Definition SimulationContext.hpp:826
std::vector< double > qual_bmp_removal
BMP treatment removal.
Definition SimulationContext.hpp:838
double routing_outflow
Definition SimulationContext.hpp:802
double runoff_error() const
Runoff continuity error (fraction).
Definition SimulationContext.hpp:945
std::vector< double > qual_routing_wet
Wet weather quality inflow to routing.
Definition SimulationContext.hpp:841
std::vector< double > qual_routing_evap
Quality mass lost to evaporation.
Definition SimulationContext.hpp:852
double step_dw_inflow
Definition SimulationContext.hpp:827
double step_ext_inflow
Definition SimulationContext.hpp:830
Top-N element statistic entry (matching legacy TMaxStats).
Definition SimulationContext.hpp:1009
int index
element index (-1 = unused slot)
Definition SimulationContext.hpp:1011
int obj_type
0 = NODE, 1 = LINK
Definition SimulationContext.hpp:1010
double value
statistic value (percentage or index)
Definition SimulationContext.hpp:1012
void update_iterations(int iters, bool converged)
Record iteration count for a routing step.
Definition SimulationContext.hpp:1051
double sum_step
Sum of all routing time steps (sec)
Definition SimulationContext.hpp:1029
double sum_iterations
Sum of iterations for averaging.
Definition SimulationContext.hpp:1040
static constexpr int N_TIME_BINS
Number of time step histogram bins (matching legacy TIMELEVELS=5).
Definition SimulationContext.hpp:1034
long n_steps
Total number of routing steps.
Definition SimulationContext.hpp:1030
double avg_step() const
Definition SimulationContext.hpp:1092
void init_histogram(double route_step, double min_route_step)
Definition SimulationContext.hpp:1059
double max_step
Maximum routing time step used (sec)
Definition SimulationContext.hpp:1028
double min_step
Minimum routing time step used (sec)
Definition SimulationContext.hpp:1027
void update(double dt)
Definition SimulationContext.hpp:1043
double steady_pct
Percent of time in steady state.
Definition SimulationContext.hpp:1031
double step_intervals[N_TIME_BINS+1]
Histogram bin edges.
Definition SimulationContext.hpp:1036
void record_step_bin(double dt)
Add a step to the histogram (call during simulation or post-process)
Definition SimulationContext.hpp:1082
long step_counts[N_TIME_BINS+1]
Histogram bin counts.
Definition SimulationContext.hpp:1035
double max_courant
Maximum Courant number observed.
Definition SimulationContext.hpp:1041
double pct_non_converged() const
Definition SimulationContext.hpp:1096
void build_histogram()
Definition SimulationContext.hpp:1073
long n_non_converged
Non-convergence and iteration tracking.
Definition SimulationContext.hpp:1039
double computed_avg_iterations() const
Definition SimulationContext.hpp:1100
std::vector< twoD::PendingBoundaryRow > * pending_bc
Definition SimulationContext.hpp:716
twoD::MeshData * mesh
Definition SimulationContext.hpp:713
std::vector< twoD::PendingEdgeConveyanceRow > * pending_ec
Definition SimulationContext.hpp:717
twoD::BoundaryData * boundary
Definition SimulationContext.hpp:715
twoD::SolverOptions2D * options
Definition SimulationContext.hpp:714
struct openswmm::SimulationContext::MassBalance mass_balance
NameIndex aquifer_names
Definition SimulationContext.hpp:612
TransectStore transects
Definition SimulationContext.hpp:538
UserFlags user_flags
User-defined flags from [USER_FLAGS] section.
Definition SimulationContext.hpp:636
LinkSubtypes link_subtypes
Relational per-subtype link side-tables (Phase 6) — the link analogue of node_subtypes....
Definition SimulationContext.hpp:447
void save_state() noexcept
Snapshot current state into old-step arrays before solving.
Definition SimulationContext.hpp:1260
double old_elapsed_ms
Elapsed routing time (ms) at the START of the current step.
Definition SimulationContext.hpp:392
NameIndex subcatch_names
Subcatchment name → subcatchment index.
Definition SimulationContext.hpp:493
NameIndex node_names
Node name → node index.
Definition SimulationContext.hpp:481
InletUsageStore inlet_usages
Definition SimulationContext.hpp:558
MaxStats max_courant_crit[MAX_STATS]
Top-5 CFL time-step critical elements.
Definition SimulationContext.hpp:1018
int n_nodes() const noexcept
Number of nodes.
Definition SimulationContext.hpp:1361
ExtInflowData ext_inflows
Definition SimulationContext.hpp:527
static void updateMaxStats(MaxStats arr[], int obj_type, int idx, double value)
Insertion sort into a descending-by-absolute-value top-N array.
Definition SimulationContext.hpp:1139
NodeData nodes
All node state and properties.
Definition SimulationContext.hpp:422
std::uint64_t xsect_generation
Definition SimulationContext.hpp:545
double adjust_rain[12]
Definition SimulationContext.hpp:588
MaxStats max_non_converged[MAX_STATS]
Top-5 nodes with highest non-convergence frequency.
Definition SimulationContext.hpp:1022
TableData tables
All time series and rating curves.
Definition SimulationContext.hpp:471
double adjust_temp[12]
Monthly climate adjustment factors from [ADJUSTMENTS] section.
Definition SimulationContext.hpp:586
MaxStats max_mass_bal_errs[MAX_STATS]
Top-5 nodes with highest continuity errors.
Definition SimulationContext.hpp:1024
int error_code
Most recent error code (0 = no error).
Definition SimulationContext.hpp:728
RDIIAssignData rdii_assigns
Definition SimulationContext.hpp:529
AquiferStore aquifers
Definition SimulationContext.hpp:611
NameIndex snowpack_names
Definition SimulationContext.hpp:610
std::vector< int > subcatch_d_store_pattern
Definition SimulationContext.hpp:597
InletStore inlets
Definition SimulationContext.hpp:557
GageData gages
All rain gage state and properties.
Definition SimulationContext.hpp:459
FilesSpec files
Secondary file references parsed from [FILES].
Definition SimulationContext.hpp:680
std::vector< ControlLogEntry > control_log
Chronological log of all control actions taken during the simulation.
Definition SimulationContext.hpp:1119
DwfData dwf_inflows
Definition SimulationContext.hpp:528
NameIndex gage_names
Rain gage name → gage index.
Definition SimulationContext.hpp:499
BuildupData buildup
Definition SimulationContext.hpp:519
int n_gages() const noexcept
Number of rain gages.
Definition SimulationContext.hpp:1370
std::string inp_file_path
Path to the input .inp file (empty if not opened from a file).
Definition SimulationContext.hpp:1129
std::vector< std::uint8_t > coupled_node
Per-node flag: 1 if the node is a 2D-coupled junction (a non-outfall coupling point),...
Definition SimulationContext.hpp:770
NodeSubtypes node_subtypes
Relational side-tables for node subtypes (storage/outfall/divider).
Definition SimulationContext.hpp:433
NameIndex table_names
Time series / curve name → table index.
Definition SimulationContext.hpp:511
bool gpkg_units_internal
Definition SimulationContext.hpp:554
std::vector< std::string > errors
Accumulated error messages written to report file.
Definition SimulationContext.hpp:757
RDIIDecayData rdii_decay
Parsed [RDII_DECAY] data (exponential IA model)
Definition SimulationContext.hpp:531
EngineState state
Current lifecycle state of the engine.
Definition SimulationContext.hpp:299
WashoffData washoff
Definition SimulationContext.hpp:520
int warning_code
Most recent warning code (0 = no warning).
Definition SimulationContext.hpp:734
NameIndex landuse_names
Definition SimulationContext.hpp:517
int n_tables() const noexcept
Number of tables (time series + curves).
Definition SimulationContext.hpp:1377
struct openswmm::SimulationContext::RoutingStepStats routing_stats
LidControlStore lid_controls
Definition SimulationContext.hpp:613
std::vector< int > subcatch_infil_pattern
Definition SimulationContext.hpp:598
double adjust_hydcon[12]
Definition SimulationContext.hpp:589
std::vector< std::string > title_notes
Project title and notes (from [TITLE] section).
Definition SimulationContext.hpp:314
std::vector< std::string > warnings
Accumulated warning messages written to report file.
Definition SimulationContext.hpp:748
ControlRuleStore control_rules
Definition SimulationContext.hpp:559
struct openswmm::SimulationContext::MassBalance2D mass_balance_2d
TreatmentData treatment
Definition SimulationContext.hpp:521
bool has_subcatch_adj_patterns
True if any pattern index >= 0.
Definition SimulationContext.hpp:603
void finalize_max_stats()
Compute top-5 arrays for CFL-critical, flow turns, and non-convergence.
Definition SimulationContext.hpp:1158
LinkData links
All link state and properties.
Definition SimulationContext.hpp:439
UnitHydData unit_hyds
Parsed [HYDROGRAPHS] data.
Definition SimulationContext.hpp:530
double dt_controls_remaining
Time remaining until the next control rule event (seconds).
Definition SimulationContext.hpp:412
void reset()
Fully reset the context to a CREATED state.
Definition SimulationContext.hpp:1197
int n_pollutants() const noexcept
Number of pollutants.
Definition SimulationContext.hpp:1373
LidUsageStore lid_usage
Definition SimulationContext.hpp:615
double next_report_ms
Next report instant in MILLISECONDS from start_date.
Definition SimulationContext.hpp:404
climate::ClimateState climate_state
Daily climate state — temperature, evaporation, wind, humidity.
Definition SimulationContext.hpp:337
MaxStats max_flow_turns[MAX_STATS]
Top-5 links with highest flow instability index.
Definition SimulationContext.hpp:1020
void allocate_objects()
Allocate all object arrays after input parsing is complete.
Definition SimulationContext.hpp:1305
StateAccessors state_accessors
Solver-neutral accessors for reading and writing solver-internal state at hot-start save/load time.
Definition SimulationContext.hpp:690
int n_subcatches() const noexcept
Number of subcatchments.
Definition SimulationContext.hpp:1367
int n_links() const noexcept
Number of links.
Definition SimulationContext.hpp:1364
std::vector< double > base_ds_perv
Definition SimulationContext.hpp:602
NameIndex link_names
Link name → link index.
Definition SimulationContext.hpp:487
std::vector< PluginSpec > plugin_specs
Plugin library specs parsed from [PLUGINS].
Definition SimulationContext.hpp:670
StreetStore streets
Definition SimulationContext.hpp:556
double current_time
Current simulation time in SECONDS from start_date.
Definition SimulationContext.hpp:361
struct openswmm::SimulationContext::TwoDModelIO twod_io
double elapsed_ms
Elapsed routing time in MILLISECONDS from start_date.
Definition SimulationContext.hpp:384
ForcingData forcing
Per-element runtime forcing state (lateral inflows, head boundaries, rainfall, evap,...
Definition SimulationContext.hpp:659
int n_landuses() const noexcept
Definition SimulationContext.hpp:1374
std::vector< double > base_n_perv
Base values for pattern-adjusted parameters (populated at init).
Definition SimulationContext.hpp:601
double adjust_evap[12]
Definition SimulationContext.hpp:587
std::string error_message
Human-readable message for the last error/warning.
Definition SimulationContext.hpp:739
SpatialFrame spatial
Coordinate reference system and georeferenced coordinates.
Definition SimulationContext.hpp:625
std::vector< transect::TransectData > transect_tables
Built transect geometry tables (indexed same as transects).
Definition SimulationContext.hpp:540
SnowpackStore snowpacks
Definition SimulationContext.hpp:609
std::vector< int > subcatch_n_perv_pattern
Per-subcatchment pattern indices for N-PERV, DSTORE, INFIL adjustments.
Definition SimulationContext.hpp:596
PatternData patterns
Definition SimulationContext.hpp:532
static constexpr int MAX_STATS
Definition SimulationContext.hpp:1015
NameIndex lid_names
Definition SimulationContext.hpp:614
NameIndex pollutant_names
Pollutant name → pollutant index.
Definition SimulationContext.hpp:505
void shrink_all_to_fit()
Release excess vector capacity on all owned SoA data stores.
Definition SimulationContext.hpp:1343
void reset_state() noexcept
Reset all state variables to initial conditions (cold start).
Definition SimulationContext.hpp:1280
std::vector< Event > events
Definition SimulationContext.hpp:574
SubcatchData subcatches
All subcatchment state and properties.
Definition SimulationContext.hpp:453
LanduseData landuses
Definition SimulationContext.hpp:518
SimulationOptions options
Parsed simulation options (from [OPTIONS] section).
Definition SimulationContext.hpp:324
PollutantData pollutants
Pollutant definitions and per-object quality state.
Definition SimulationContext.hpp:465
double current_date
Absolute current date/time (decimal days, OADate (days since 12/30/1899)).
Definition SimulationContext.hpp:370
All SWMM simulation options parsed from [OPTIONS] section.
Definition SimulationOptions.hpp:124
SoA storage for snowpack parameter sets.
Definition HydrologyData.hpp:36
Spatial frame containing CRS and georeferenced coordinates.
Definition SpatialFrame.hpp:82
Solver-neutral hooks for reading and writing solver-internal state (infiltration, groundwater) at hot...
Definition SimulationContext.hpp:239
std::function< bool(int subcatch_index, int model, const double *infil)> set_infil_state
Definition SimulationContext.hpp:246
std::function< bool(int subcatch_index, int &out_model, double *out_infil)> get_infil_state
Definition SimulationContext.hpp:242
bool can_write() const noexcept
True iff the write-side accessors are wired.
Definition SimulationContext.hpp:260
std::function< bool(int subcatch_index, double theta, double lower_depth)> set_gw_state
Apply groundwater zone state to a subcatchment.
Definition SimulationContext.hpp:252
std::function< bool(int subcatch_index, double &out_theta, double &out_lower_depth)> get_gw_state
Read groundwater zone state (upper-zone moisture and lower-zone depth).
Definition SimulationContext.hpp:249
bool can_read() const noexcept
True iff the read-side accessors are wired.
Definition SimulationContext.hpp:255
Definition InfraData.hpp:54
Structure-of-Arrays storage for all subcatchments.
Definition SubcatchData.hpp:41
SoA collection of all time series and curves in the model.
Definition TableData.hpp:658
Definition InfraData.hpp:26
Definition QualityData.hpp:133
Definition InflowData.hpp:154
Definition QualityData.hpp:98
Definition Climate.hpp:71
One entry per control rule action that changed a link setting.
Definition SimulationContext.hpp:1111
Event time periods for event-based analysis/reporting.
Definition SimulationContext.hpp:570
System mass-balance totals for the optional 2D surface domain.
Definition SimulationContext.hpp:981
Cumulative mass balance totals for runoff and routing.
Definition SimulationContext.hpp:785
Top-N element statistic entry (matching legacy TMaxStats).
Definition SimulationContext.hpp:1009
Definition SimulationContext.hpp:1026
Non-owning pointers to the engine's 2D surface-routing model storage (mesh, solver options,...
Definition SimulationContext.hpp:712
Central, reentrant simulation context.
Definition SimulationContext.hpp:292
SoA storage for per-edge boundary conditions.
Definition BoundaryData.hpp:55
SoA storage for 2D triangular mesh geometry and topology.
Definition MeshData.hpp:34
Configuration for the 2D surface routing CVODE solver.
Definition SolverOptions2D.hpp:132