OpenSWMM Engine  6.0.0-alpha.4
Data-oriented, plugin-extensible SWMM Engine (6.0.0-alpha.4)
Loading...
Searching...
No Matches
SubcatchData.hpp
Go to the documentation of this file.
1// SPDX-License-Identifier: Apache-2.0
2//
3// Copyright 2026 Caleb Buahin
4//
5// Licensed under the Apache License, Version 2.0 (the "License");
6// you may not use this file except in compliance with the License.
7// You may obtain a copy of the License at
8//
9// http://www.apache.org/licenses/LICENSE-2.0
10//
11// Unless required by applicable law or agreed to in writing, software
12// distributed under the License is distributed on an "AS IS" BASIS,
13// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14// See the License for the specific language governing permissions and
15// limitations under the License.
16
33
34#ifndef OPENSWMM_ENGINE_SUBCATCH_DATA_HPP
35#define OPENSWMM_ENGINE_SUBCATCH_DATA_HPP
36
37#include <vector>
38#include <string>
39#include <cstdint>
40#include <algorithm>
41#include <limits>
42
43namespace openswmm {
44
45// ============================================================================
46// SubcatchData — SoA layout
47// ============================================================================
48
58
59 // -----------------------------------------------------------------------
60 // Static properties — set at parse time
61 // -----------------------------------------------------------------------
62
69 std::vector<int> outlet_node;
70
75 std::vector<int> outlet_subcatch;
76
82 std::vector<std::string> outlet_name;
83
91 std::vector<std::string> snowpack_name;
92
100 std::vector<std::string> gage_name;
101
106 std::vector<int> gage;
107
112 std::vector<double> area;
113
118 std::vector<double> width;
119
124 std::vector<double> slope;
125
130 std::vector<double> curb_length;
131
142 std::vector<double> rain_scale_factor;
143
156 std::vector<double> snow_scale_factor;
157
162 std::vector<double> frac_imperv;
163
168 std::vector<double> frac_imperv_no_store;
169
174 std::vector<double> n_imperv;
175
180 std::vector<double> n_perv;
181
186 std::vector<double> ds_imperv;
187
192 std::vector<double> ds_perv;
193
194 // -----------------------------------------------------------------------
195 // Inter-subarea routing (from [SUBAREAS] section)
196 // -----------------------------------------------------------------------
197
205 std::vector<int> subarea_routing;
206
213 std::vector<double> pct_routed;
214
215 // -----------------------------------------------------------------------
216 // Infiltration parameters (per subcatchment)
217 // -----------------------------------------------------------------------
218
220 std::vector<int> infil_model;
221
223 std::vector<double> infil_p1;
225 std::vector<double> infil_p2;
227 std::vector<double> infil_p3;
229 std::vector<double> infil_p4;
231 std::vector<double> infil_p5;
232
233 // -----------------------------------------------------------------------
234 // State variables — updated each timestep
235 // -----------------------------------------------------------------------
236
241 std::vector<double> runoff;
242
247 std::vector<double> rainfall;
248
253 std::vector<double> evap_loss;
254
259 std::vector<double> infil_loss;
260
265 std::vector<double> ponded_depth;
266
271 std::vector<double> gw_flow;
272
277 std::vector<double> snow_depth;
278
283 std::vector<double> lid_drain_flow;
284
285 // -----------------------------------------------------------------------
286 // Previous-step state
287 // -----------------------------------------------------------------------
288
290 std::vector<double> old_runoff;
291
293 std::vector<double> old_gw_flow;
294
296 std::vector<double> old_snow_depth;
297
299 std::vector<double> old_lid_drain_flow;
300
301 // -----------------------------------------------------------------------
302 // Runon coupling — subcatch-to-subcatch routing
303 // -----------------------------------------------------------------------
304
307 std::vector<double> runon_inflow;
308
310 std::vector<double> old_runon_inflow;
311
315 std::vector<double> outfall_runon_vol;
316
317 // -----------------------------------------------------------------------
318 // Groundwater surface water head coupling
319 // -----------------------------------------------------------------------
320
323 std::vector<double> gw_sw_head;
324
326 std::vector<double> gw_node_avail_flow;
327
334 std::vector<double> gw_max_infil_vol;
335
336 // -----------------------------------------------------------------------
337 // Quality washoff output
338 // -----------------------------------------------------------------------
339
342 std::vector<double> washoff_load;
343
344 // -----------------------------------------------------------------------
345 // Per-subcatch quality state — flat 2D: [subcatch * n_pollutants + pollutant]
346 // -----------------------------------------------------------------------
347
353 std::vector<double> conc;
354
356 std::vector<double> conc_old;
357
364 std::vector<double> ponded_qual;
365
368
369 // -----------------------------------------------------------------------
370 // Per-object INP comment
371 // -----------------------------------------------------------------------
372
378 std::vector<std::string> comments;
379
386 std::vector<std::string> tags;
387
388 // -----------------------------------------------------------------------
389 // Report flag — per-object output filter
390 // -----------------------------------------------------------------------
391
394 std::vector<char> rpt_flag;
395
396 // -----------------------------------------------------------------------
397 // Cumulative statistics
398 // -----------------------------------------------------------------------
399
404 std::vector<double> stat_precip_vol;
405 std::vector<double> stat_evap_vol;
406 std::vector<double> stat_infil_vol;
407 std::vector<double> stat_imperv_vol;
408 std::vector<double> stat_perv_vol;
409
414 std::vector<double> stat_runoff_vol;
415
420 std::vector<double> stat_max_runoff;
421
422 // Gap #63: Per-subcatch groundwater statistics (accumulated each GW step)
423 std::vector<double> stat_gw_infil_vol;
424 std::vector<double> stat_gw_upper_evap_vol;
425 std::vector<double> stat_gw_lower_evap_vol;
426 std::vector<double> stat_gw_deep_perc_vol;
427 std::vector<double> stat_gw_flow_vol;
428 std::vector<double> stat_gw_max_flow;
429 std::vector<double> stat_gw_sum_theta;
430 std::vector<double> stat_gw_sum_depth;
431 std::vector<double> stat_gw_final_theta;
432 std::vector<double> stat_gw_final_depth;
433 std::vector<long> stat_gw_steps;
434
435 // -----------------------------------------------------------------------
436 // Groundwater parameters (from [GROUNDWATER] section)
437 // -----------------------------------------------------------------------
438
440 std::vector<int> gw_aquifer;
441
443 std::vector<int> gw_node;
444
446 std::vector<double> gw_surf_elev;
447
449 std::vector<double> gw_a1;
450
452 std::vector<double> gw_b1;
453
455 std::vector<double> gw_a2;
456
458 std::vector<double> gw_b2;
459
461 std::vector<double> gw_a3;
462
464 std::vector<double> gw_tw;
465
467 std::vector<double> gw_hstar;
468
469 // -----------------------------------------------------------------------
470 // Snowpack assignment (index into SnowpackStore, -1 = none)
471 // -----------------------------------------------------------------------
472
474 std::vector<int> snowpack;
475
483 std::vector<double> snow_net_imperv;
484
492 std::vector<double> snow_net_perv;
493
513 std::vector<double> snow_melt_imperv;
514
516 std::vector<double> snow_melt_perv;
517
531 std::vector<double> snow_melt_age_imperv;
532
534 std::vector<double> snow_melt_age_perv;
535
543 std::vector<double> total_lid_area_ft2;
544
552 std::vector<double> lid_return_to_perv_cfs;
553
562 std::vector<double> lid_drain_runon_cfs;
563
564 // -----------------------------------------------------------------------
565 // Cumulative pollutant washoff loads — flat 2D: [subcatch * n_pollutants + pollutant]
566 // -----------------------------------------------------------------------
567
572 std::vector<double> total_load;
573
576
577 void resize_total_load(int n_sc, int n_poll) {
579 total_load.assign(
580 static_cast<std::size_t>(n_sc) * static_cast<std::size_t>(n_poll), 0.0);
581 }
582
583 // -----------------------------------------------------------------------
584 // Land-use coverage — flat 2D: [subcatch * n_landuses + landuse]
585 // -----------------------------------------------------------------------
586
591 std::vector<double> coverage;
592
595
601 std::vector<double> sweep_last_swept;
602
608 void resize_coverage(int n_sc, int n_lu) {
609 coverage_n_landuses = n_lu;
610 auto sz = static_cast<std::size_t>(n_sc) * static_cast<std::size_t>(n_lu);
611 coverage.assign(sz, 0.0);
612 sweep_last_swept.assign(sz, 0.0);
613 }
614
615 // -----------------------------------------------------------------------
616 // Capacity management
617 // -----------------------------------------------------------------------
618
619 int count() const noexcept { return static_cast<int>(area.size()); }
620
621 void resize(int n) {
622 const auto un = static_cast<std::size_t>(n);
623
624 outlet_node.assign(un, -1);
625 outlet_subcatch.assign(un, -1);
626 outlet_name.resize(un);
627 snowpack_name.resize(un);
628 gage_name.resize(un);
629 gage.assign(un, -1);
630 area.assign(un, 0.0);
631 width.assign(un, 0.0);
632 slope.assign(un, 0.0);
633 curb_length.assign(un, 0.0);
634 rain_scale_factor.assign(un, 1.0);
635 snow_scale_factor.assign(un, 1.0);
636 frac_imperv.assign(un, 0.0);
637 frac_imperv_no_store.assign(un, 0.0);
638 n_imperv.assign(un, 0.013);
639 n_perv.assign(un, 0.1);
640 ds_imperv.assign(un, 0.0);
641 ds_perv.assign(un, 0.0);
642 subarea_routing.assign(un, 0); // TO_OUTLET
643 pct_routed.assign(un, 0.0);
644
645 infil_model.assign(un, 0);
646 infil_p1.assign(un, 0.0);
647 infil_p2.assign(un, 0.0);
648 infil_p3.assign(un, 0.0);
649 infil_p4.assign(un, 0.0);
650 infil_p5.assign(un, 0.0);
651
652 runoff.assign(un, 0.0);
653 rainfall.assign(un, 0.0);
654 evap_loss.assign(un, 0.0);
655 infil_loss.assign(un, 0.0);
656 ponded_depth.assign(un, 0.0);
657 gw_flow.assign(un, 0.0);
658 snow_depth.assign(un, 0.0);
659 lid_drain_flow.assign(un, 0.0);
660 old_runoff.assign(un, 0.0);
661 old_gw_flow.assign(un, 0.0);
662 old_snow_depth.assign(un, 0.0);
663 old_lid_drain_flow.assign(un, 0.0);
664 runon_inflow.assign(un, 0.0);
665 old_runon_inflow.assign(un, 0.0);
666 outfall_runon_vol.assign(un, 0.0);
667 gw_sw_head.assign(un, 0.0);
668 gw_node_avail_flow.assign(un, 0.0);
669 gw_max_infil_vol.assign(un, std::numeric_limits<double>::max());
670
671 comments.assign(un, std::string{});
672 tags.assign(un, std::string{});
673
674 rpt_flag.assign(un, 0);
675
676 stat_precip_vol.assign(un, 0.0);
677 stat_evap_vol.assign(un, 0.0);
678 stat_infil_vol.assign(un, 0.0);
679 stat_imperv_vol.assign(un, 0.0);
680 stat_perv_vol.assign(un, 0.0);
681 stat_runoff_vol.assign(un, 0.0);
682 stat_max_runoff.assign(un, 0.0);
683 stat_gw_infil_vol.assign(un, 0.0);
684 stat_gw_upper_evap_vol.assign(un, 0.0);
685 stat_gw_lower_evap_vol.assign(un, 0.0);
686 stat_gw_deep_perc_vol.assign(un, 0.0);
687 stat_gw_flow_vol.assign(un, 0.0);
688 stat_gw_max_flow.assign(un, 0.0);
689 stat_gw_sum_theta.assign(un, 0.0);
690 stat_gw_sum_depth.assign(un, 0.0);
691 stat_gw_final_theta.assign(un, 0.0);
692 stat_gw_final_depth.assign(un, 0.0);
693 stat_gw_steps.assign(un, 0L);
694
695 gw_aquifer.assign(un, -1);
696 gw_node.assign(un, -1);
697 gw_surf_elev.assign(un, 0.0);
698 gw_a1.assign(un, 0.0);
699 gw_b1.assign(un, 0.0);
700 gw_a2.assign(un, 0.0);
701 gw_b2.assign(un, 0.0);
702 gw_a3.assign(un, 0.0);
703 gw_tw.assign(un, 0.0);
704 gw_hstar.assign(un, 0.0);
705 snowpack.assign(un, -1);
706 snow_net_imperv.assign(un, -1.0);
707 snow_net_perv.assign(un, -1.0);
708 snow_melt_imperv.assign(un, -1.0);
709 snow_melt_perv.assign(un, -1.0);
710 snow_melt_age_imperv.assign(un, -1.0);
711 snow_melt_age_perv.assign(un, -1.0);
712 total_lid_area_ft2.assign(un, 0.0);
713 lid_return_to_perv_cfs.assign(un, 0.0);
714 lid_drain_runon_cfs.assign(un, 0.0);
715 }
716
720 void grow_to(int n) {
721 if (n <= count()) return;
722 const auto un = static_cast<std::size_t>(n);
723 auto g = [&](auto& vec, auto def) { vec.resize(un, def); };
724 g(outlet_node, -1); g(outlet_subcatch, -1);
725 outlet_name.resize(un); snowpack_name.resize(un);
726 gage_name.resize(un); g(gage, -1);
727 g(area, 0.0); g(width, 0.0); g(slope, 0.0); g(curb_length, 0.0);
728 g(rain_scale_factor, 1.0); g(snow_scale_factor, 1.0);
729 g(frac_imperv, 0.0); g(frac_imperv_no_store, 0.0);
730 g(n_imperv, 0.013); g(n_perv, 0.1);
731 g(ds_imperv, 0.0); g(ds_perv, 0.0);
732 g(subarea_routing, 0); g(pct_routed, 0.0);
733 g(infil_model, 0);
734 g(infil_p1, 0.0); g(infil_p2, 0.0); g(infil_p3, 0.0);
735 g(infil_p4, 0.0); g(infil_p5, 0.0);
736 g(runoff, 0.0); g(rainfall, 0.0);
737 g(evap_loss, 0.0); g(infil_loss, 0.0);
738 g(ponded_depth, 0.0); g(gw_flow, 0.0);
739 g(snow_depth, 0.0); g(lid_drain_flow, 0.0);
740 g(old_runoff, 0.0); g(old_gw_flow, 0.0);
741 g(old_snow_depth, 0.0); g(old_lid_drain_flow, 0.0);
742 g(runon_inflow, 0.0); g(old_runon_inflow, 0.0);
743 g(gw_sw_head, 0.0); g(gw_node_avail_flow, 0.0);
744 g(gw_max_infil_vol, std::numeric_limits<double>::max());
745 g(outfall_runon_vol, 0.0);
746 comments.resize(un, std::string{});
747 tags.resize(un, std::string{});
748
749 g(rpt_flag, static_cast<char>(0));
750 g(stat_precip_vol, 0.0); g(stat_evap_vol, 0.0);
751 g(stat_infil_vol, 0.0); g(stat_imperv_vol, 0.0);
752 g(stat_perv_vol, 0.0); g(stat_runoff_vol, 0.0);
753 g(stat_max_runoff, 0.0);
756 g(stat_gw_flow_vol, 0.0); g(stat_gw_max_flow, 0.0);
757 g(stat_gw_sum_theta, 0.0); g(stat_gw_sum_depth, 0.0);
759 stat_gw_steps.resize(un, 0L);
760 g(gw_aquifer, -1); g(gw_node, -1); g(gw_surf_elev, 0.0);
761 g(gw_a1, 0.0); g(gw_b1, 0.0); g(gw_a2, 0.0); g(gw_b2, 0.0);
762 g(gw_a3, 0.0); g(gw_tw, 0.0); g(gw_hstar, 0.0);
763 g(snowpack, -1);
764 g(snow_net_imperv, -1.0);
765 g(snow_net_perv, -1.0);
766 g(snow_melt_imperv, -1.0);
767 g(snow_melt_perv, -1.0);
768 g(snow_melt_age_imperv, -1.0);
769 g(snow_melt_age_perv, -1.0);
770 g(total_lid_area_ft2, 0.0);
772 g(lid_drain_runon_cfs, 0.0);
773 // Note: conc, conc_old, ponded_qual, washoff_load handled by resize_quality()
774 // Note: coverage, total_load handled separately
775 }
776
795 void reserve_to(int n) {
796 if (n <= 0) return;
797 const auto un = static_cast<std::size_t>(n);
798 if (outlet_node.capacity() >= un) return;
799 auto r = [&](auto& vec) { vec.reserve(un); };
800 r(outlet_node); r(outlet_subcatch); r(gage); r(area);
805 r(infil_p3); r(infil_p4); r(infil_p5); r(runoff);
815 r(gw_node); r(gw_surf_elev); r(gw_a1); r(gw_b1);
816 r(gw_a2); r(gw_b2); r(gw_a3); r(gw_tw);
821 r(gage_name); r(comments); r(tags); r(stat_gw_steps);
822 }
823
832 void erase_at(int idx) {
833 const auto ui = static_cast<std::size_t>(idx);
834 auto e = [&](auto& v) { if (ui < v.size()) v.erase(v.begin() + static_cast<std::ptrdiff_t>(idx)); };
835
837 e(area); e(width); e(slope); e(curb_length);
841
842 e(infil_model); e(infil_p1); e(infil_p2); e(infil_p3); e(infil_p4); e(infil_p5);
843
849 e(comments); e(tags); e(rpt_flag);
850
857
859 e(gw_a1); e(gw_b1); e(gw_a2); e(gw_b2); e(gw_a3); e(gw_tw); e(gw_hstar);
864
865 // Flat 2D quality arrays: [sc * np + p]
866 if (conc_n_pollutants > 0) {
867 const auto np = static_cast<std::size_t>(conc_n_pollutants);
868 const auto base = ui * np;
869 auto erase2d = [&](auto& v) {
870 if (base + np <= v.size())
871 v.erase(v.begin() + static_cast<std::ptrdiff_t>(base),
872 v.begin() + static_cast<std::ptrdiff_t>(base + np));
873 };
874 erase2d(conc); erase2d(conc_old); erase2d(ponded_qual); erase2d(washoff_load);
875 }
876
877 // Flat 2D total load: [sc * np + p]
878 if (total_load_n_pollutants > 0) {
879 const auto np = static_cast<std::size_t>(total_load_n_pollutants);
880 const auto base = ui * np;
881 if (base + np <= total_load.size())
882 total_load.erase(
883 total_load.begin() + static_cast<std::ptrdiff_t>(base),
884 total_load.begin() + static_cast<std::ptrdiff_t>(base + np));
885 }
886
887 // Flat 2D coverage/sweep matrices: [sc * n_lu + lu]
888 if (coverage_n_landuses > 0) {
889 const auto nlu = static_cast<std::size_t>(coverage_n_landuses);
890 const auto base = ui * nlu;
891 auto erase2d = [&](auto& v) {
892 if (base + nlu <= v.size())
893 v.erase(v.begin() + static_cast<std::ptrdiff_t>(base),
894 v.begin() + static_cast<std::ptrdiff_t>(base + nlu));
895 };
896 erase2d(coverage); erase2d(sweep_last_swept);
897 }
898 }
899
903 void resize_quality(int n_pollutants) {
904 conc_n_pollutants = n_pollutants;
905 if (n_pollutants > 0) {
906 auto total = static_cast<std::size_t>(count()) *
907 static_cast<std::size_t>(n_pollutants);
908 conc.assign(total, 0.0);
909 conc_old.assign(total, 0.0);
910 ponded_qual.assign(total, 0.0);
911 washoff_load.assign(total, 0.0);
912 }
913 }
914
915 void resize_washoff_load(int n_pollutants) {
916 if (n_pollutants > 0) {
917 washoff_load.assign(
918 static_cast<std::size_t>(count()) *
919 static_cast<std::size_t>(n_pollutants), 0.0);
920 }
921 }
922
927 outlet_node.shrink_to_fit();
928 outlet_subcatch.shrink_to_fit();
929 outlet_name.shrink_to_fit();
930 gage.shrink_to_fit();
931 area.shrink_to_fit();
932 width.shrink_to_fit();
933 slope.shrink_to_fit();
934 curb_length.shrink_to_fit();
935 rain_scale_factor.shrink_to_fit();
936 snow_scale_factor.shrink_to_fit();
937 frac_imperv.shrink_to_fit();
938 frac_imperv_no_store.shrink_to_fit();
939 n_imperv.shrink_to_fit();
940 n_perv.shrink_to_fit();
941 ds_imperv.shrink_to_fit();
942 ds_perv.shrink_to_fit();
943 subarea_routing.shrink_to_fit();
944 pct_routed.shrink_to_fit();
945
946 infil_model.shrink_to_fit();
947 infil_p1.shrink_to_fit();
948 infil_p2.shrink_to_fit();
949 infil_p3.shrink_to_fit();
950 infil_p4.shrink_to_fit();
951 infil_p5.shrink_to_fit();
952
953 runoff.shrink_to_fit();
954 rainfall.shrink_to_fit();
955 evap_loss.shrink_to_fit();
956 infil_loss.shrink_to_fit();
957 ponded_depth.shrink_to_fit();
958 gw_flow.shrink_to_fit();
959 snow_depth.shrink_to_fit();
960 lid_drain_flow.shrink_to_fit();
961 old_runoff.shrink_to_fit();
962 old_gw_flow.shrink_to_fit();
963 old_snow_depth.shrink_to_fit();
964 old_lid_drain_flow.shrink_to_fit();
965 runon_inflow.shrink_to_fit();
966 old_runon_inflow.shrink_to_fit();
967 outfall_runon_vol.shrink_to_fit();
968 gw_sw_head.shrink_to_fit();
969 gw_node_avail_flow.shrink_to_fit();
970 gw_max_infil_vol.shrink_to_fit();
971
972 comments.shrink_to_fit();
973 tags.shrink_to_fit();
974
975 rpt_flag.shrink_to_fit();
976
977 stat_precip_vol.shrink_to_fit();
978 stat_evap_vol.shrink_to_fit();
979 stat_infil_vol.shrink_to_fit();
980 stat_imperv_vol.shrink_to_fit();
981 stat_perv_vol.shrink_to_fit();
982 stat_runoff_vol.shrink_to_fit();
983 stat_max_runoff.shrink_to_fit();
984
985 gw_aquifer.shrink_to_fit();
986 gw_node.shrink_to_fit();
987 gw_surf_elev.shrink_to_fit();
988 gw_a1.shrink_to_fit();
989 gw_b1.shrink_to_fit();
990 gw_a2.shrink_to_fit();
991 gw_b2.shrink_to_fit();
992 gw_a3.shrink_to_fit();
993 gw_tw.shrink_to_fit();
994 gw_hstar.shrink_to_fit();
995 snowpack.shrink_to_fit();
996 snow_net_imperv.shrink_to_fit();
997 snow_net_perv.shrink_to_fit();
998 snow_melt_imperv.shrink_to_fit();
999 snow_melt_perv.shrink_to_fit();
1000 snow_melt_age_imperv.shrink_to_fit();
1001 snow_melt_age_perv.shrink_to_fit();
1002
1003 conc.shrink_to_fit();
1004 conc_old.shrink_to_fit();
1005 ponded_qual.shrink_to_fit();
1006 washoff_load.shrink_to_fit();
1007 total_load.shrink_to_fit();
1008 coverage.shrink_to_fit();
1009 sweep_last_swept.shrink_to_fit();
1010 }
1011
1012 void save_state() noexcept {
1013 std::copy(runoff.begin(), runoff.end(), old_runoff.begin());
1014 std::copy(runon_inflow.begin(), runon_inflow.end(), old_runon_inflow.begin());
1015 std::copy(conc.begin(), conc.end(), conc_old.begin());
1016 }
1017
1018 void reset_state() noexcept {
1019 std::fill(runoff.begin(), runoff.end(), 0.0);
1020 std::fill(rainfall.begin(), rainfall.end(), 0.0);
1021 std::fill(snow_net_imperv.begin(), snow_net_imperv.end(), -1.0);
1022 std::fill(snow_net_perv.begin(), snow_net_perv.end(), -1.0);
1023 std::fill(snow_melt_imperv.begin(), snow_melt_imperv.end(), -1.0);
1024 std::fill(snow_melt_perv.begin(), snow_melt_perv.end(), -1.0);
1025 std::fill(snow_melt_age_imperv.begin(), snow_melt_age_imperv.end(), -1.0);
1026 std::fill(snow_melt_age_perv.begin(), snow_melt_age_perv.end(), -1.0);
1027 std::fill(evap_loss.begin(), evap_loss.end(), 0.0);
1028 std::fill(infil_loss.begin(), infil_loss.end(), 0.0);
1029 std::fill(ponded_depth.begin(), ponded_depth.end(), 0.0);
1030 std::fill(old_runoff.begin(), old_runoff.end(), 0.0);
1031 std::fill(old_gw_flow.begin(), old_gw_flow.end(), 0.0);
1032 std::fill(snow_depth.begin(), snow_depth.end(), 0.0);
1033 std::fill(old_snow_depth.begin(), old_snow_depth.end(), 0.0);
1034 std::fill(lid_drain_flow.begin(), lid_drain_flow.end(), 0.0);
1035 std::fill(old_lid_drain_flow.begin(), old_lid_drain_flow.end(), 0.0);
1036 std::fill(runon_inflow.begin(), runon_inflow.end(), 0.0);
1037 std::fill(old_runon_inflow.begin(), old_runon_inflow.end(), 0.0);
1038 std::fill(gw_sw_head.begin(), gw_sw_head.end(), 0.0);
1039 std::fill(gw_node_avail_flow.begin(), gw_node_avail_flow.end(), 0.0);
1040 std::fill(washoff_load.begin(), washoff_load.end(), 0.0);
1041 std::fill(conc.begin(), conc.end(), 0.0);
1042 std::fill(conc_old.begin(), conc_old.end(), 0.0);
1043 }
1044};
1045
1046} /* namespace openswmm */
1047
1048#endif /* OPENSWMM_ENGINE_SUBCATCH_DATA_HPP */
Definition NodeCoupling.cpp:16
Structure-of-Arrays storage for all subcatchments.
Definition SubcatchData.hpp:57
std::vector< int > gage
Rain gage index for this subcatchment.
Definition SubcatchData.hpp:106
std::vector< double > total_lid_area_ft2
Total LID area for this subcatchment (ft²).
Definition SubcatchData.hpp:543
void reset_state() noexcept
Definition SubcatchData.hpp:1018
std::vector< int > infil_model
Infiltration model: 0=HORTON, 1=MOD_HORTON, 2=GREEN_AMPT, 3=MOD_GREEN_AMPT, 4=CURVE_NUMBER.
Definition SubcatchData.hpp:220
std::vector< double > old_snow_depth
Snow depth at the previous runoff evaluation (for interpolation).
Definition SubcatchData.hpp:296
std::vector< double > gw_b2
Groundwater flow exponent B2.
Definition SubcatchData.hpp:458
std::vector< double > snow_net_perv
Snow-modified net precipitation for pervious subarea (ft/sec).
Definition SubcatchData.hpp:492
std::vector< double > stat_gw_infil_vol
Cumulative infiltration to GW (ft³)
Definition SubcatchData.hpp:423
std::vector< std::string > snowpack_name
Snow pack name string for deferred resolution.
Definition SubcatchData.hpp:91
int total_load_n_pollutants
Number of pollutants in total_load matrix.
Definition SubcatchData.hpp:575
std::vector< double > outfall_runon_vol
Gap #28: accumulated outfall-routed volume (ft³) between runoff steps.
Definition SubcatchData.hpp:315
std::vector< double > stat_precip_vol
Total precipitation volume (project volume units).
Definition SubcatchData.hpp:404
std::vector< double > gw_surf_elev
Surface elevation for groundwater calculations.
Definition SubcatchData.hpp:446
std::vector< double > gw_sw_head
Surface water head at GW receiving node (project length units).
Definition SubcatchData.hpp:323
void resize_quality(int n_pollutants)
Resize per-subcatch quality arrays after pollutant count is known.
Definition SubcatchData.hpp:903
std::vector< double > slope
Average slope of catchment (fraction).
Definition SubcatchData.hpp:124
std::vector< double > infil_p1
Infiltration param 1: f0 (Horton), suction (GA), CN (CN).
Definition SubcatchData.hpp:223
std::vector< double > old_gw_flow
GW flow at the previous runoff evaluation (for interpolation).
Definition SubcatchData.hpp:293
std::vector< int > snowpack
Snowpack index for this subcatchment (-1 = none).
Definition SubcatchData.hpp:474
std::vector< std::string > gage_name
Rain gage name string for deferred resolution.
Definition SubcatchData.hpp:100
std::vector< double > gw_tw
Threshold groundwater table elevation.
Definition SubcatchData.hpp:464
std::vector< double > evap_loss
Current evaporation loss rate (project length/time units).
Definition SubcatchData.hpp:253
std::vector< double > old_runoff
Runoff at the previous timestep.
Definition SubcatchData.hpp:290
std::vector< double > gw_node_avail_flow
Available node flow for GW negative flow limit (cfs/ft2).
Definition SubcatchData.hpp:326
std::vector< double > stat_infil_vol
Cumulative infiltration volume (ft3)
Definition SubcatchData.hpp:406
std::vector< double > gw_flow
Groundwater outflow rate (project flow units).
Definition SubcatchData.hpp:271
std::vector< double > stat_evap_vol
Cumulative evaporation volume (ft3)
Definition SubcatchData.hpp:405
std::vector< double > lid_drain_flow
Total LID drain outflow (cfs) over the current runoff step.
Definition SubcatchData.hpp:283
std::vector< double > stat_gw_sum_theta
Sum of upper-zone theta (for time-avg)
Definition SubcatchData.hpp:429
std::vector< double > snow_melt_imperv
The MELT-ONLY part of snow_net_imperv (ft/sec).
Definition SubcatchData.hpp:513
std::vector< double > stat_perv_vol
Cumulative pervious runoff volume (ft3)
Definition SubcatchData.hpp:408
std::vector< double > snow_scale_factor
Subcatchment-level snowfall scale factor (default 1.0 = no scaling).
Definition SubcatchData.hpp:156
void reserve_to(int n)
Reserve capacity for n subcatchments without changing count().
Definition SubcatchData.hpp:795
std::vector< double > area
Subcatchment area (project area units).
Definition SubcatchData.hpp:112
std::vector< double > gw_a3
Groundwater flow coefficient A3.
Definition SubcatchData.hpp:461
std::vector< double > old_lid_drain_flow
LID drain outflow at the previous runoff evaluation (for interpolation).
Definition SubcatchData.hpp:299
std::vector< int > outlet_subcatch
Index of the subcatch that receives overflow (-1 if none).
Definition SubcatchData.hpp:75
std::vector< double > gw_hstar
Water table elevation at which lateral GW flow ceases.
Definition SubcatchData.hpp:467
int coverage_n_landuses
Number of landuses stored in the coverage and sweep matrices.
Definition SubcatchData.hpp:594
std::vector< std::string > comments
Object comment from the INP file (';'-prefixed lines immediately above this subcatchment's data row),...
Definition SubcatchData.hpp:378
std::vector< double > stat_gw_upper_evap_vol
Cumulative upper zone evap (ft³)
Definition SubcatchData.hpp:424
std::vector< double > old_runon_inflow
Previous-step runon inflow (for interpolation).
Definition SubcatchData.hpp:310
std::vector< double > stat_runoff_vol
Total runoff volume (project volume units).
Definition SubcatchData.hpp:414
std::vector< double > n_imperv
Manning's n for impervious area.
Definition SubcatchData.hpp:174
std::vector< double > lid_drain_runon_cfs
LID drain flow routed to a target subcatchment (CFS).
Definition SubcatchData.hpp:562
std::vector< double > n_perv
Manning's n for pervious area.
Definition SubcatchData.hpp:180
std::vector< double > infil_p4
Infiltration param 4: dry time (Horton), 0 (GA/CN).
Definition SubcatchData.hpp:229
void resize_coverage(int n_sc, int n_lu)
Resize the coverage and sweep matrices.
Definition SubcatchData.hpp:608
std::vector< double > lid_return_to_perv_cfs
LID surface return flow to pervious area (CFS).
Definition SubcatchData.hpp:552
std::vector< std::string > tags
Per-object tag from the INP [TAGS] section.
Definition SubcatchData.hpp:386
std::vector< double > runon_inflow
Runoff inflow from upstream subcatchments (project flow units).
Definition SubcatchData.hpp:307
std::vector< double > rain_scale_factor
Subcatchment-level rainfall scale factor (default 1.0 = no scaling).
Definition SubcatchData.hpp:142
std::vector< double > stat_gw_final_theta
Upper-zone theta at last GW step.
Definition SubcatchData.hpp:431
std::vector< double > gw_a2
Groundwater flow coefficient A2.
Definition SubcatchData.hpp:455
std::vector< double > stat_gw_lower_evap_vol
Cumulative lower zone evap (ft³)
Definition SubcatchData.hpp:425
int conc_n_pollutants
Number of pollutants in the quality arrays.
Definition SubcatchData.hpp:367
std::vector< std::string > outlet_name
Outlet name string for deferred resolution.
Definition SubcatchData.hpp:82
std::vector< double > stat_gw_deep_perc_vol
Cumulative deep percolation (ft³)
Definition SubcatchData.hpp:426
std::vector< double > snow_melt_age_imperv
S2b — WATER AGE of the meltwater in snow_melt_imperv (sec).
Definition SubcatchData.hpp:531
std::vector< double > stat_imperv_vol
Cumulative impervious runoff volume (ft3)
Definition SubcatchData.hpp:407
std::vector< double > ponded_qual
Ponded surface water quality mass per (subcatch, pollutant).
Definition SubcatchData.hpp:364
std::vector< double > pct_routed
Fraction of runoff routed between subareas (0–1).
Definition SubcatchData.hpp:213
std::vector< double > infil_p2
Infiltration param 2: fmin (Horton), conductivity (GA), unused (CN).
Definition SubcatchData.hpp:225
std::vector< double > snow_melt_age_perv
S2b — water age of the meltwater in snow_melt_perv (sec). See above.
Definition SubcatchData.hpp:534
std::vector< double > stat_gw_max_flow
Peak lateral GW outflow (CFS)
Definition SubcatchData.hpp:428
std::vector< double > gw_a1
Groundwater flow coefficient A1.
Definition SubcatchData.hpp:449
void resize(int n)
Definition SubcatchData.hpp:621
std::vector< double > stat_gw_final_depth
Water table height at last GW step (ft)
Definition SubcatchData.hpp:432
std::vector< double > snow_net_imperv
Snow-modified net precipitation for impervious subareas (ft/sec).
Definition SubcatchData.hpp:483
std::vector< double > ds_perv
Depression storage depth for pervious area (project length units).
Definition SubcatchData.hpp:192
std::vector< double > width
Width of overland flow path (project length units).
Definition SubcatchData.hpp:118
std::vector< double > infil_loss
Current infiltration loss rate (project length/time units).
Definition SubcatchData.hpp:259
std::vector< double > frac_imperv_no_store
Fraction of impervious area with no depression storage (0–1).
Definition SubcatchData.hpp:168
std::vector< double > conc_old
Previous-step quality in subcatchment runoff.
Definition SubcatchData.hpp:356
int count() const noexcept
Definition SubcatchData.hpp:619
void erase_at(int idx)
Erase the subcatchment at index idx from every parallel array.
Definition SubcatchData.hpp:832
std::vector< double > gw_max_infil_vol
Gap #40: max infiltration volume (ft) upper GW zone can accept next step.
Definition SubcatchData.hpp:334
void resize_total_load(int n_sc, int n_poll)
Definition SubcatchData.hpp:577
std::vector< char > rpt_flag
Whether this subcatchment is included in report/output (0=no, 1=yes).
Definition SubcatchData.hpp:394
std::vector< int > gw_aquifer
Aquifer index for this subcatchment (-1 = none).
Definition SubcatchData.hpp:440
std::vector< int > outlet_node
Index of the drain-to node or subcatchment.
Definition SubcatchData.hpp:69
void grow_to(int n)
Grow all arrays to hold at least n subcatchments, preserving existing data.
Definition SubcatchData.hpp:720
std::vector< double > runoff
Current total runoff flow rate (project flow units).
Definition SubcatchData.hpp:241
void shrink_to_fit()
Release excess vector capacity accumulated during parsing.
Definition SubcatchData.hpp:926
std::vector< double > coverage
Coverage fraction per (subcatchment x landuse).
Definition SubcatchData.hpp:591
std::vector< double > snow_depth
Area-weighted snow pack SWE depth (ft), end of runoff step.
Definition SubcatchData.hpp:277
std::vector< double > stat_max_runoff
Maximum reported runoff rate (project flow units).
Definition SubcatchData.hpp:420
std::vector< double > infil_p5
Infiltration param 5: max infil (Horton), 0 (GA/CN).
Definition SubcatchData.hpp:231
std::vector< long > stat_gw_steps
Step count for GW averages.
Definition SubcatchData.hpp:433
std::vector< double > rainfall
Current total rainfall depth rate (project length/time units).
Definition SubcatchData.hpp:247
std::vector< double > washoff_load
Washoff mass rate per (subcatch, pollutant) (mass/sec).
Definition SubcatchData.hpp:342
std::vector< double > ponded_depth
Current total ponded depth over subcatchment (project length units).
Definition SubcatchData.hpp:265
void save_state() noexcept
Definition SubcatchData.hpp:1012
std::vector< double > snow_melt_perv
The melt-only part of snow_net_perv (ft/sec). See above.
Definition SubcatchData.hpp:516
std::vector< double > frac_imperv
Fraction of area that is impervious (0–1).
Definition SubcatchData.hpp:162
std::vector< int > gw_node
Receiving node index for groundwater flow (-1 = none).
Definition SubcatchData.hpp:443
std::vector< double > gw_b1
Groundwater flow exponent B1.
Definition SubcatchData.hpp:452
std::vector< double > infil_p3
Infiltration param 3: decay (Horton), initial deficit (GA), drying time (CN).
Definition SubcatchData.hpp:227
std::vector< double > sweep_last_swept
Gap #34: days since last swept per (subcatch x landuse).
Definition SubcatchData.hpp:601
std::vector< double > total_load
Total washoff load per (subcatchment x pollutant) (mass units).
Definition SubcatchData.hpp:572
std::vector< double > ds_imperv
Depression storage depth for impervious area (project length units).
Definition SubcatchData.hpp:186
std::vector< int > subarea_routing
Inter-subarea routing mode.
Definition SubcatchData.hpp:205
void resize_washoff_load(int n_pollutants)
Definition SubcatchData.hpp:915
std::vector< double > stat_gw_sum_depth
Sum of water table height (ft, for time-avg)
Definition SubcatchData.hpp:430
std::vector< double > stat_gw_flow_vol
Cumulative lateral GW outflow (ft³)
Definition SubcatchData.hpp:427
std::vector< double > conc
Current quality concentration in subcatchment runoff.
Definition SubcatchData.hpp:353
std::vector< double > curb_length
Total curb length (project length units).
Definition SubcatchData.hpp:130