15#ifndef OPENSWMM_ENGINE_2D_REPORT2D_VARS_HPP
16#define OPENSWMM_ENGINE_2D_REPORT2D_VARS_HPP
28inline const std::vector<std::string>&
tokens() {
29 static const std::vector<std::string> kTokens = {
30 "DEPTH",
"VELOCITY",
"EDGE_FLUX",
"NODE_HEAD",
"SPECIES",
"RAINFALL",
31 "INFILTRATION",
"COUPLING",
"GRADIENTS",
"CONTINUITY",
"ENVELOPES",
36inline bool iequalsTok(
const std::string& a,
const char* b) {
38 for (; i < a.size() && b[i]; ++i)
39 if (std::toupper(
static_cast<unsigned char>(a[i])) !=
40 std::toupper(
static_cast<unsigned char>(b[i])))
return false;
41 return i == a.size() && b[i] ==
'\0';
45inline std::vector<std::string>
splitList(
const std::string& text) {
46 std::vector<std::string> toks;
49 if (c ==
',' || c ==
' ' || c ==
'\t' || c ==
'\r' || c ==
'\n') {
50 if (!cur.empty()) { toks.push_back(cur); cur.clear(); }
55 if (!cur.empty()) toks.push_back(cur);
64inline std::string
parseMask(
const std::string& text,
unsigned& mask) {
68 return "REPORT_2D_VARIABLES needs DEFAULT|MINIMAL|ALL or a token list";
69 const auto& names =
tokens();
70 for (
const auto& t : toks) {
76 for (std::size_t i = 0; i < names.size(); ++i) {
77 if (
iequalsTok(t, names[i].c_str())) { mask |= (1u << i); found =
true;
break; }
81 for (
const auto& n : names) {
if (!all.empty()) all +=
"|"; all += n; }
82 return "Unknown REPORT_2D_VARIABLES token '" + t +
83 "' (expected DEFAULT|MINIMAL|ALL|NONE or " + all +
")";
96 const auto& names =
tokens();
98 for (std::size_t i = 0; i < names.size(); ++i) {
99 if (mask & (1u << i)) {
100 if (!out.empty()) out +=
' ';
104 return out.empty() ? std::string(
"DEPTH") : out;
109 if (species.empty())
return "ALL";
111 for (
const auto& n : species) {
112 if (!out.empty()) out +=
' ';
121 if (v.size() == 1 &&
iequalsTok(v[0],
"ALL")) v.clear();
127 const long total = seconds > 0.0 ?
static_cast<long>(seconds + 0.5) : 0L;
129 std::snprintf(buf,
sizeof(buf),
"%02ld:%02ld:%02ld",
130 total / 3600, (total % 3600) / 60, total % 60);
Configuration options for the 2D surface routing solver.
Dataset groups the 2D results writer can emit ([2D_OPTIONS] REPORT_2D_VARIABLES). One bit per group; ...
Definition Report2DVars.hpp:25
const std::vector< std::string > & tokens()
Group tokens in bit order (index i ↔ bit 1u << i).
Definition Report2DVars.hpp:28
std::string parseMask(const std::string &text, unsigned &mask)
Parse a token list or a preset (DEFAULT | MINIMAL | ALL | NONE) into a bitmask. DEPTH is always inclu...
Definition Report2DVars.hpp:64
std::string formatMask(unsigned mask)
Preset name when the mask equals one, else the space-separated token list.
Definition Report2DVars.hpp:91
std::vector< std::string > splitList(const std::string &text)
Split on whitespace / commas.
Definition Report2DVars.hpp:45
std::string formatStep(double seconds)
HH:MM:SS (REPORT_STEP spelling).
Definition Report2DVars.hpp:126
std::vector< std::string > parseSpecies(const std::string &text)
Species list from text; "ALL" (alone) → empty list.
Definition Report2DVars.hpp:119
@ ALL_MASK
Definition SolverOptions2D.hpp:193
@ DEPTH
Mesh2_face_depth, Mesh2_face_head.
Definition SolverOptions2D.hpp:182
@ MINIMAL_MASK
MINIMAL: depth map + render reconstruction + envelopes only.
Definition SolverOptions2D.hpp:198
@ DEFAULT_MASK
DEFAULT: everything a user renders or plots; solver diagnostics off.
Definition SolverOptions2D.hpp:195
std::string formatSpecies(const std::vector< std::string > &species)
"ALL" for an empty (unfiltered) list, else the space-separated names.
Definition Report2DVars.hpp:108
bool iequalsTok(const std::string &a, const char *b)
Definition Report2DVars.hpp:36