4#include "SwmmInterface.h"
6#include <swmm5_iface.h>
8#include <boost/algorithm/string/predicate.hpp>
34 "infiltration losses",
36 "groundwater outflow",
39 "concentration of pollutant"};
42const std::array<std::string, 7>
node_vars = {
"water depth",
44 "volume of stored water",
47 "flow lost to flooding",
48 "concentration of pollutant"};
51const std::array<std::string, 6>
link_vars = {
"flow rate",
55 "fraction conduit/non-conduit",
56 "concentration of pollutant"};
63 "evaporation + infiltration loss",
69 "total lateral inflow",
70 "flow lost to flooding",
71 "flow leaving through outfalls",
72 "volume of stored water",
73 "actual evaporation rate",
74 "potential evaporation rate"};
81 std::string
const& file_name)
87 if (file_name.length() < 5)
93 std::string
const base_name(file_name.substr(0, file_name.length() - 4));
96 return std::unique_ptr<SwmmInterface>(swmm);
98 ERR(
"Error creating mesh from SWMM file.");
121 ERR(
"SWMMInterface: {:s} is not a SWMM input file.", inp_file_name);
125 std::ifstream in(inp_file_name.c_str());
128 ERR(
"SWMMInterface: Could not open input file {:s}.", inp_file_name);
133 bool header_found(
false);
134 std::size_t pos_end(0);
135 while (!header_found)
137 if (!std::getline(in, line))
140 std::size_t
const pos_beg = line.find_first_not_of(
' ', pos_end);
141 pos_end = line.find_first_of(
" \n", pos_beg);
144 if (line.empty() || pos_beg == pos_end ||
isCommentLine(line))
147 if (line ==
"[TITLE]")
151 INFO(
"SWMMInterface: input file type {:s} not recognised.",
163 std::string
const outfile(
_base_name +
".out");
164 if (OpenSwmmOutFile(
const_cast<char*
>(outfile.c_str())) != 0)
171 std::vector<std::string>& names)
173 std::size_t id(points.size());
176 while (std::getline(in, line))
185 if (split_str.size() != 3)
187 ERR(
"Format not recognised.");
190 names.push_back(split_str[0]);
194 T* pnt =
new T(x, y, 0,
id);
195 points.push_back(pnt);
202 std::vector<GeoLib::Polyline*>& lines,
203 std::vector<std::string>& ply_names,
204 std::vector<GeoLib::Point*>& points,
205 std::vector<std::string>& pnt_names)
207 bool finished(
false);
208 std::size_t id(points.size());
210 std::string polygon_name(
"");
212 while (std::getline(in, line))
221 if (split_str.size() != 3)
223 ERR(
"Polygon format not recognised.");
229 if (split_str[0] != polygon_name)
237 polygon_name = split_str[0];
239 ply_names.push_back(polygon_name);
246 pnt_names.push_back(
"");
261 std::ifstream& in, std::vector<GeoLib::Point*>& points,
262 std::map<std::string, std::size_t>
const& name_id_map)
265 while (std::getline(in, line))
275 if (split_str.size() < 4)
277 ERR(
"Format not recognised.");
280 std::string
const current_name(split_str[0]);
281 auto const it = name_id_map.find(current_name);
282 if (it == name_id_map.end())
284 ERR(
"SwmmInterface::addPointElevation(): Name {:s} not found in "
289 std::size_t
const id = it->second;
296 std::ifstream& in, std::vector<GeoLib::Polyline*>& lines,
297 std::vector<std::string>& line_names,
298 std::vector<GeoLib::Point*>
const& points,
299 std::map<std::string, std::size_t>
const& point_names)
302 while (std::getline(in, line))
312 if (split_str.size() < 7)
314 ERR(
"Conduit format not recognised.");
318 std::string
const inlet(split_str[1]);
319 auto const i_it = point_names.find(inlet);
320 if (i_it == point_names.end())
322 ERR(
"SwmmInterface::readLineElements(): Inlet node {:s} not found "
323 "in coordinates map.",
328 std::string
const outlet(split_str[2]);
329 auto const o_it = point_names.find(outlet);
330 if (o_it == point_names.end())
332 ERR(
"SwmmInterface::readLineElements(): Outlet node {:s} not found "
333 "in coordinates map.",
338 std::size_t a(i_it->second);
341 lines.push_back(ply);
342 line_names.push_back(split_str[0]);
349 bool add_subcatchments)
354 std::ifstream in(inp_file_name.c_str());
357 ERR(
"SWMMInterface: Could not open input file {:s}.", inp_file_name);
361 std::vector<GeoLib::Point*> points;
362 std::vector<GeoLib::Polyline*> lines;
363 std::vector<std::string> pnt_names;
364 std::vector<std::string> line_names;
366 std::string geo_name =
369 while (std::getline(in, line))
371 if (line ==
"[COORDINATES]" || line ==
"[VERTICES]" ||
374 INFO(
"Reading {:s}...", line);
381 if (line ==
"[Polygons]" && add_subcatchments)
383 INFO(
"Reading {:s}...", line);
384 if (!
readPolygons(in, lines, line_names, points, pnt_names))
394 ERR(
"No points found in file");
397 if (points.size() != pnt_names.size())
399 ERR(
"Length of point vector and point name vector do not match.");
406 std::size_t
const n_names(pnt_names.size());
407 for (std::size_t i = 0; i < n_names; ++i)
409 if (!pnt_names[i].empty())
410 name_id_map.insert(std::make_pair(pnt_names[i], i));
418 while (std::getline(in, line))
420 if (line ==
"[JUNCTIONS]" || line ==
"[OUTFALLS]" ||
423 INFO(
"Reading {:s} elevation...", line);
430 if (line ==
"[CONDUITS]")
432 INFO(
"Reading conduits...");
440 else if (line ==
"[PUMPS]")
442 INFO(
"Reading pumps...");
450 else if (line ==
"[WEIRS]")
452 INFO(
"Reading weirs...");
462 geo_objects.
addPointVec(std::move(points), geo_name,
463 std::move(name_id_map));
466 if (lines.size() != line_names.size())
468 ERR(
"Length of line vector and line name vector do not match.");
470 for (
auto ply : lines)
476 std::size_t
const n_names(line_names.size());
477 for (std::size_t i = 0; i < n_names; ++i)
479 line_id_map.insert(std::make_pair(line_names[i], i));
482 std::vector<std::size_t>
const& pnt_id_map(
486 for (std::size_t i = 0; i < polyline->getNumberOfPoints(); ++i)
488 polyline->setPointID(i, pnt_id_map[polyline->getPointID(i)]);
490 polyline->getPointID(i - 1) == polyline->getPointID(i))
492 polyline->removePoint(i);
496 if (polyline->getPointID(0) ==
497 polyline->getPointID(polyline->getNumberOfPoints() - 1))
499 polyline->removePoint(polyline->getNumberOfPoints() - 1);
500 polyline->addPoint(polyline->getPointID(0));
504 std::move(line_id_map));
510 std::ifstream& in, std::vector<MeshLib::Node*>& nodes,
511 std::map<std::string, std::size_t>
const& name_id_map,
512 std::vector<double>& max_depth,
bool read_max_depth)
515 while (std::getline(in, line))
525 if (split_str.size() < 3)
527 ERR(
"Format not recognised.");
530 std::string
const current_name(split_str[0]);
531 auto const it = name_id_map.find(current_name);
532 if (it == name_id_map.end())
534 ERR(
"SwmmInterface::readNodeData(): Name {:s} not found in "
539 std::size_t
const id = it->second;
551 std::ifstream& in, std::vector<MeshLib::Element*>& elements,
552 std::vector<MeshLib::Node*>
const& nodes,
553 std::map<std::string, std::size_t>
const& name_id_map)
556 while (std::getline(in, line))
566 if (split_str.size() < 7)
568 ERR(
"Conduit format not recognised.");
572 std::string
const inlet(split_str[1]);
573 auto const i_it = name_id_map.find(inlet);
574 if (i_it == name_id_map.end())
576 ERR(
"SwmmInterface::readLineElements(): Inlet node {:s} not found "
577 "in coordinates map.",
582 std::string
const outlet(split_str[2]);
583 auto const o_it = name_id_map.find(outlet);
584 if (o_it == name_id_map.end())
586 ERR(
"SwmmInterface::readLineElements(): Outlet node {:s} not found "
587 "in coordinates map.",
592 std::array<MeshLib::Node*, 2>
const line_nodes = {nodes[i_it->second],
593 nodes[o_it->second]};
601 std::ifstream& in, std::map<std::string, std::size_t>
const& name_id_map)
604 while (std::getline(in, line))
613 if (split_str.size() < 8)
615 ERR(
"Subcatchment format not recognised.");
620 sc.
name = split_str[0];
621 sc.
rain_gauge = std::numeric_limits<std::size_t>::max();
623 for (std::size_t i = 0; i < n_gauges; ++i)
631 if (sc.
rain_gauge == std::numeric_limits<std::size_t>::max())
633 ERR(
"Rain gauge for subcatchment '{:s}' not found.", split_str[0]);
637 auto const it = name_id_map.find(split_str[2]);
638 if (it == name_id_map.end())
640 ERR(
"Outlet node for subcatchment '{:s}' not found.", split_str[0]);
653 if (
_mesh !=
nullptr)
655 ERR(
"Mesh already exists.");
659 std::string
const inp_file_name(
_base_name +
".inp");
663 std::ifstream in(inp_file_name.c_str());
666 ERR(
"SWMMInterface: Could not open input file {:s}.", inp_file_name);
671 std::vector<MeshLib::Node*> nodes;
673 while (std::getline(in, line))
675 if (line ==
"[COORDINATES]")
677 INFO(
"Reading coordinates...");
689 else if (line ==
"[SYMBOLS]")
691 INFO(
"Reading symbols...");
692 std::vector<GeoLib::Point*> points;
693 std::vector<std::string> names;
696 for (std::size_t i = 0; i < points.size(); ++i)
700 std::pair<GeoLib::Station, std::string>(stn,
""));
710 std::map<std::string, std::size_t> name_id_map;
711 std::size_t
const n_nodes(nodes.size());
712 for (std::size_t i = 0; i < n_nodes; ++i)
717 std::vector<MeshLib::Element*> elements;
718 std::vector<double> max_depth(n_nodes);
719 std::size_t
const n_types = 3;
720 std::array<std::size_t, n_types> n_elem_types{{0, 0, 0}};
721 while (std::getline(in, line))
723 if (line ==
"[RAINGAGES]")
728 else if (line ==
"[SUBCATCHMENTS]")
730 INFO(
"Reading subcatchment information...");
734 else if (line ==
"[SUBAREAS]")
738 else if (line ==
"[INFILTRATION]")
742 else if (line ==
"[JUNCTIONS]")
744 INFO(
"Reading junctions...");
745 if (!
readNodeData(in, nodes, name_id_map, max_depth,
true))
748 else if (line ==
"[OUTFALLS]")
750 INFO(
"Reading outfalls...");
751 if (!
readNodeData(in, nodes, name_id_map, max_depth,
false))
754 else if (line ==
"[STORAGE]")
756 INFO(
"Reading storages...");
757 if (!
readNodeData(in, nodes, name_id_map, max_depth,
true))
760 else if (line ==
"[CONDUITS]")
762 INFO(
"Reading conduits...");
765 n_elem_types[0] = elements.size();
767 else if (line ==
"[PUMPS]")
769 INFO(
"Reading pumps...");
772 n_elem_types[1] = elements.size();
774 else if (line ==
"[WEIRS]")
776 INFO(
"Reading weirs...");
779 n_elem_types[2] = elements.size();
781 else if (line ==
"[POLLUTANTS]")
786 else if (line ==
"[Polygons]")
788 INFO(
"Reading subcatchments...");
789 std::vector<GeoLib::Polyline*> lines;
790 std::vector<std::string> line_names;
791 std::vector<std::string>
803 if (elements.empty())
813 mat_ids->
resize(elements.size(), 0);
814 for (std::size_t i = 1; i < n_types; ++i)
816 if (n_elem_types[i] > 0)
817 std::fill(mat_ids->begin() + n_elem_types[i - 1],
818 mat_ids->begin() + n_elem_types[i], i);
821 if (nodes.size() == max_depth.size())
826 assert(depth->size() == max_depth.size());
829 ERR(
"Size of max depth array does not fit number of elements. Skipping "
839 std::vector<GeoLib::Polyline*>
const& lines,
840 std::vector<std::string>
const& names)
842 std::size_t
const n_lines(lines.size());
845 if (n_lines != n_subcatchments)
847 ERR(
"Number of subcatchments does not match number of outlines.");
850 for (std::size_t i = 0; i < n_lines; ++i)
853 for (std::size_t j = 0; j < n_subcatchments; ++j)
864 ERR(
"No match in subcatcments for outline '{:s}'.", names[i]);
873 std::vector<std::string> names;
876 std::back_inserter(names),
877 [](
auto const& sc) { return sc.name; });
892 std::vector<std::string> system_name{
"System"};
895 ERR(
"Object type has no name map");
896 std::vector<std::string> empty_vec;
915 return std::string(
"System");
917 ERR(
"Index out of bounds.");
918 return std::string(
"");
923 std::string
const outfile(
_base_name +
".out");
924 if (OpenSwmmOutFile(
const_cast<char*
>(outfile.c_str())) != 0)
930 return SWMM_Nsubcatch;
938 ERR(
"Object type not recognised.");
946 std::string
const outfile(
_base_name +
".out");
947 std::size_t n_time_steps(std::numeric_limits<std::size_t>::max());
948 if (OpenSwmmOutFile(
const_cast<char*
>(outfile.c_str())) != 0)
951 std::size_t n_params(0);
967 ERR(
"Object type not recognised.");
975 std::string
const outfile(
_base_name +
".out");
976 if (OpenSwmmOutFile(
const_cast<char*
>(outfile.c_str())) != 0)
977 return std::numeric_limits<std::size_t>::max();
978 std::size_t
const n_time_steps(
static_cast<std::size_t
>(SWMM_Nperiods));
985 std::string
const& vec_name,
986 std::vector<double>
const& data)
990 ERR(
"Information of this object type cannot be added to mesh.");
996 ERR(
"Data array is empty and cannot be added to mesh.");
1002 ERR(
"Number of mesh nodes ({:d}) does not match length of array "
1011 ERR(
"Number of mesh elements ({:d}) does not match length of array "
1024 ERR(
"Error fetching array '{:s}'.", vec_name);
1027 std::copy(data.cbegin(), data.cend(), prop->
begin());
1032 std::size_t time_step,
1033 std::size_t var_idx)
const
1035 std::vector<double> data;
1036 std::string
const outfile(
_base_name +
".out");
1037 if (OpenSwmmOutFile(
const_cast<char*
>(outfile.c_str())) != 0)
1040 if (time_step >= SWMM_Nperiods)
1042 ERR(
"Time step {:d} not available, file contains only {:d} periods.",
1043 time_step, SWMM_Nperiods);
1047 bool is_var_idx_okay =
true;
1049 std::size_t n_objects;
1054 n_objects = SWMM_Nsubcatch;
1055 if (var_idx > (
n_obj_params[obj_type_id] - 1 + SWMM_Npolluts))
1056 is_var_idx_okay =
false;
1060 n_objects = SWMM_Nnodes;
1061 if (var_idx > (
n_obj_params[obj_type_id] + SWMM_Npolluts))
1062 is_var_idx_okay =
false;
1066 n_objects = SWMM_Nlinks;
1067 if (var_idx > (
n_obj_params[obj_type_id] + SWMM_Npolluts))
1068 is_var_idx_okay =
false;
1074 is_var_idx_okay =
false;
1077 ERR(
"Object type not recognised.");
1082 if (!is_var_idx_okay)
1084 ERR(
"Requested variable does not exist.");
1089 INFO(
"Fetching '{:s}'-data for time step {:d}...",
1090 getArrayName(obj_type, var_idx, SWMM_Npolluts), time_step);
1092 for (std::size_t i = 0; i < n_objects; ++i)
1095 GetSwmmResult(obj_type_id, i, var_idx, time_step, &val);
1096 data.push_back(
static_cast<double>(val));
1104 std::size_t obj_idx,
1105 std::size_t var_idx)
const
1107 std::vector<double> data;
1108 std::string
const outfile(
_base_name +
".out");
1109 if (OpenSwmmOutFile(
const_cast<char*
>(outfile.c_str())) != 0)
1112 bool is_var_idx_okay =
true;
1113 bool is_obj_idx_okay =
true;
1119 if (obj_idx >= SWMM_Nsubcatch)
1120 is_obj_idx_okay =
false;
1121 if (var_idx > (
n_obj_params[obj_type_id] + SWMM_Npolluts))
1122 is_var_idx_okay =
false;
1126 if (obj_idx >= SWMM_Nnodes)
1127 is_obj_idx_okay =
false;
1128 if (var_idx > (
n_obj_params[obj_type_id] + SWMM_Npolluts))
1129 is_var_idx_okay =
false;
1133 if (obj_idx >= SWMM_Nlinks)
1134 is_obj_idx_okay =
false;
1135 if (var_idx > (
n_obj_params[obj_type_id] + SWMM_Npolluts))
1136 is_var_idx_okay =
false;
1141 is_obj_idx_okay =
false;
1143 is_var_idx_okay =
false;
1146 ERR(
"Object type not recognised.");
1151 if (!is_obj_idx_okay)
1153 ERR(
"Requested object index does not exist.");
1158 if (!is_var_idx_okay)
1160 ERR(
"Requested variable does not exist.");
1165 std::size_t
const n_time_steps(
static_cast<std::size_t
>(SWMM_Nperiods));
1166 for (std::size_t i = 0; i < n_time_steps; ++i)
1169 GetSwmmResult(obj_type_id, obj_idx, var_idx, i, &val);
1170 data.push_back(
static_cast<double>(val));
1178 std::size_t var_idx)
const
1180 std::string
const outfile(
_base_name +
".out");
1181 if (OpenSwmmOutFile(
const_cast<char*
>(outfile.c_str())) != 0)
1182 return std::string(
"");
1184 std::string
const name =
getArrayName(obj_type, var_idx, SWMM_Npolluts);
1190 std::size_t var_idx,
1191 std::size_t n_pollutants)
const
1205 return std::string(
"Node_" +
1213 return std::string(
"Link_" +
1220 ERR(
"SwmmInterface::getArrayName() - Index error, no name found.");
1221 return std::string(
"");
1227 while (std::getline(in, line))
1236 if (split_str.size() < 6)
1238 ERR(
"Rain gauge parameter format not recognised.");
1244 if (stn.first.getName() == split_str[0] && split_str[4] ==
"FILE")
1245 stn.second = split_str[5].substr(1, split_str[5].size() - 2);
1250 if (stn.second.empty())
1251 WARN(
"No associated time series found for rain gauge '{:s}'.",
1252 stn.first.getName());
1259 while (std::getline(in, line))
1268 if (split_str.size() < 6)
1270 ERR(
"Parameter format for pollutants not recognised.");
1283 std::size_t
const pos_beg = str.find_first_not_of(
' ', 0);
1284 if (pos_beg == str.find_first_of(
" \n", pos_beg))
1292 return (str.compare(str.find_first_not_of(
' ', 0), 1,
";") == 0);
1296 std::vector<double>& y,
1297 std::vector<double>& z)
const
1299 std::vector<MeshLib::Node*>
const& nodes(
_mesh->getNodes());
1302 x.push_back((*node)[0]);
1303 y.push_back((*node)[1]);
1304 z.push_back((*node)[2]);
1310 std::vector<std::size_t>& outlets)
const
1312 std::vector<MeshLib::Element*>
const& elements(
_mesh->getElements());
1317 ERR(
"Non line-element found in mesh.");
1320 inlets.push_back(getNodeIndex(*elem, 0));
1321 outlets.push_back(getNodeIndex(*elem, 1));
1333 return "subcatchment";
1341 std::size_t time_step)
const
1347 for (std::size_t i = 0; i < n_params; ++i)
1355 ERR(
"No data to write");
1364 std::size_t obj_idx)
const
1371 for (std::size_t i = 0; i < n_params; ++i)
1379 ERR(
"No data to write");
void INFO(fmt::format_string< Args... > fmt, Args &&... args)
void ERR(fmt::format_string< Args... > fmt, Args &&... args)
void WARN(fmt::format_string< Args... > fmt, Args &&... args)
std::string writeToString()
Writes the object to a string.
bool addVectorForWriting(std::string const &vec_name, std::vector< T > const &vec)
void addIndexVectorForWriting(std::size_t s)
Adds an index vector of size s to the CSV file.
std::size_t getNArrays() const
Returns the number of vectors currently staged for writing.
~SwmmInterface()
Destructor.
std::unique_ptr< MeshLib::Mesh > _mesh
Mesh generated from SWMM input (+ optional output data)
std::vector< std::string > _id_nodename_map
Vector storing the names of all nodes/junctions.
std::size_t getNumberOfObjects(SwmmObject obj_type) const
Returns the number of objects of the given type.
bool writeCsvForObject(std::string const &file_name, SwmmObject obj_type, std::size_t obj_idx) const
Write a CSV file for one object of the given type for all time steps.
bool readPollutants(std::ifstream &in)
Reads pollutant names and parameters.
bool readSubcatchments(std::ifstream &in, std::map< std::string, std::size_t > const &name_id_map)
Reads subcatchment information.
std::vector< std::string > getSubcatchmentNameMap() const
Creates a temporary string vector containing all subcatchment names in correct order.
std::string getName(SwmmObject obj_type, std::size_t idx) const
Returns the Name for the indexed object of the given type (or an empty string if an error occurred).
static bool isCommentLine(std::string const &str)
Checks if the given line string is a comment line.
std::string const _base_name
All files for a given SWMM simulation have the same base name.
bool getNodeCoordinateVectors(std::vector< double > &x, std::vector< double > &y, std::vector< double > &z) const
Writes the node coordinates into double vectors for writing of CSV files.
bool getLinkPointIds(std::vector< std::size_t > &inlets, std::vector< std::size_t > &outlets) const
Writes the inlet- and outlet IDs for links into vectors for writing of CSV files.
bool matchSubcatchmentsWithPolygons(std::vector< GeoLib::Polyline * > const &lines, std::vector< std::string > const &names)
Matches existing subcatchment names with subsequently read polylines marking the outlines of said sub...
SwmmInterface(std::string const &swmm_base_name)
Constructor.
static bool readPolygons(std::ifstream &in, std::vector< GeoLib::Polyline * > &lines, std::vector< std::string > &line_names, std::vector< GeoLib::Point * > &points, std::vector< std::string > &pnt_names)
bool addRainGaugeTimeSeriesLocations(std::ifstream &in)
Reads the location of external rain gauge time series files.
std::vector< GeoLib::Point * > _subcatchment_points
Separate node vector containing points for defining subcatchment outlines.
static bool isSwmmInputFile(std::string const &inp_file_name)
Checks if file is a SWMM input file.
bool readLineElements(std::ifstream &in, std::vector< MeshLib::Element * > &elements, std::vector< MeshLib::Node * > const &nodes, std::map< std::string, std::size_t > const &name_id_map)
Reads links/conduits and returns them as a vector of OGS line elements.
bool writeCsvForTimestep(std::string const &file_name, SwmmObject obj_type, std::size_t time_step) const
Write a CSV file for all object of the given type at one time step.
std::vector< std::pair< GeoLib::Station, std::string > > _rain_gauges
Vector containing rain gauge information as well the position of external time series files.
static bool readLinksAsPolylines(std::ifstream &in, std::vector< GeoLib::Polyline * > &lines, std::vector< std::string > &line_names, std::vector< GeoLib::Point * > const &points, std::map< std::string, std::size_t > const &point_names)
During geometry conversion, this reads links (conduits/pumps/weirs) and converts them into polylines.
std::vector< std::string > _id_linkname_map
Vector storing the names of all links/conduits.
static std::unique_ptr< SwmmInterface > create(std::string const &file_name)
std::vector< double > getArrayAtTimeStep(SwmmObject obj_type, std::size_t time_step, std::size_t var_idx) const
Returns an array for a given variable at all nodes/links from a SWMM output file for a given time ste...
std::size_t getNumberOfTimeSteps() const
Returns the number of time steps for the simulation results.
static bool readCoordinates(std::ifstream &in, std::vector< T * > &points, std::vector< std::string > &names)
static bool addResultsToMesh(MeshLib::Mesh &mesh, SwmmObject const type, std::string const &vec_name, std::vector< double > const &data)
bool existsSwmmOutputFile() const
Checks if a SWMM output file exists for the current input.
static bool convertSwmmInputToGeometry(std::string const &inp_file_name, GeoLib::GEOObjects &geo_objects, bool add_subcatchments)
Reading a SWMM input file and conversion into OGS geometry.
static std::string swmmObjectTypeToString(SwmmObject const obj_type)
Returns a string with the name of the object type.
bool readSwmmInputToLineMesh()
Reading a SWMM input file and creating an OGS line mesh. This is automatically called when the object...
std::size_t getNumberOfParameters(SwmmObject obj_type) const
Returns the number of parameters (incl. pollutants) of the given type.
static bool addPointElevation(std::ifstream &in, std::vector< GeoLib::Point * > &points, std::map< std::string, std::size_t > const &name_id_map)
During geometry conversion, this adds elevation values to the existing point vector.
bool readNodeData(std::ifstream &in, std::vector< MeshLib::Node * > &nodes, std::map< std::string, std::size_t > const &name_id_map, std::vector< double > &max_depth, bool read_max_depth)
Reads input information associated with nodes (elevation, depth, etc.)
std::string getArrayName(SwmmObject obj_type, std::size_t var_idx) const
Returns the name of the data array for the given object type and parameter index.
std::vector< Subcatchment > _subcatchments
Vector storing information about all subcatchments.
static bool isSectionFinished(std::string const &str)
Checks if the given line string is empty. Empty strings mark the end of sections in a SWMM input file...
std::vector< double > getArrayForObject(SwmmObject obj_type, std::size_t obj_idx, std::size_t var_idx) const
Returns an array for a given variable for one specific object from a SWMM output file for all time st...
std::vector< std::string > getNames(SwmmObject obj_type) const
Get all the object names for a given object type.
std::vector< std::string > _pollutant_names
Vector storing the names of all pollutants.
Container class for geometric objects.
void addPolylineVec(std::vector< Polyline * > &&lines, std::string const &name, PolylineVec::NameIdMap &&ply_names)
void addPointVec(std::vector< Point * > &&points, std::string &name, PointVec::NameIdMap &&pnt_id_name_map, double const eps=std::sqrt(std::numeric_limits< double >::epsilon()))
const PointVec * getPointVecObj(const std::string &name) const
bool removePointVec(const std::string &name)
const std::vector< std::size_t > & getIDMap() const
Class Polyline consists mainly of a reference to a point vector and a vector that stores the indices ...
std::size_t getPointID(std::size_t const i) const
virtual bool addPoint(std::size_t pnt_id)
A Station (observation site) is basically a Point with some additional information.
std::map< std::string, std::size_t > NameIdMap
std::size_t getNumberOfNodes() const
Get the number of nodes.
std::size_t getNumberOfElements() const
Get the number of elements.
Property manager on mesh items. Class Properties manages scalar, vector or matrix properties....
PropertyVector< T > * createNewPropertyVector(std::string_view name, MeshItemType mesh_item_type, std::size_t n_components=1)
constexpr PROP_VAL_TYPE * begin()
constexpr void assign(R &&r)
constexpr void resize(std::size_t const size)
int writeStringToFile(std::string_view content, std::filesystem::path const &file_path)
std::string getFileExtension(const std::string &path)
void cleanupVectorElements(std::vector< T * > &items)
std::string extractBaseNameWithoutExtension(std::string const &pathname)
std::vector< std::string > splitString(std::string const &str)
T str2number(const std::string &str)
SwmmObject
SWMM object types.
const std::array< std::string, 15 > system_vars
All variables that exist for the system.
const std::array< std::string, 6 > link_vars
Variables that always exist for links. There might be more.
const std::array< std::string, 9 > subcatchment_vars
Variables that always exist for subcatchments. There might be more.
const std::array< std::string, 7 > node_vars
Variables that always exist for nodes. There might be more.
std::array< std::size_t, 4 > const n_obj_params
PropertyVector< T > * getOrCreateMeshProperty(Mesh &mesh, std::string const &property_name, MeshItemType const item_type, int const number_of_components)
TemplateElement< MeshLib::LineRule2 > Line