16#ifndef OPENSWMM_ENGINE_2D_REPORT2D_VARS_HPP
17#define OPENSWMM_ENGINE_2D_REPORT2D_VARS_HPP
37inline const std::vector<std::string>&
tokens() {
38 static const std::vector<std::string> kTokens = {
39 "DEPTH",
"VELOCITY",
"EDGE_FLUX",
"NODE_HEAD",
"SPECIES",
"RAINFALL",
40 "INFILTRATION",
"COUPLING",
"GRADIENTS",
"CONTINUITY",
"ENVELOPES",
42 "GROUNDWATER",
"GW_DETAILED",
55inline bool iequalsTok(
const std::string& a,
const char* b) {
57 for (; i < a.size() && b[i]; ++i)
58 if (std::toupper(
static_cast<unsigned char>(a[i])) !=
59 std::toupper(
static_cast<unsigned char>(b[i])))
61 return i == a.size() && b[i] ==
'\0';
72inline std::vector<std::string>
splitList(
const std::string& text) {
73 std::vector<std::string> toks;
76 if (c ==
',' || c ==
' ' || c ==
'\t' || c ==
'\r' || c ==
'\n') {
102inline std::string
parseMask(
const std::string& text,
unsigned& mask) {
106 return "REPORT_2D_VARIABLES needs DEFAULT|MINIMAL|ALL or a token list";
107 const auto& names =
tokens();
108 for (
const auto& t : toks) {
125 for (std::size_t i = 0; i < names.size(); ++i) {
134 for (
const auto& n : names) {
139 return "Unknown REPORT_2D_VARIABLES token '" + t +
140 "' (expected DEFAULT|MINIMAL|ALL|NONE or " + all +
")";
162 const auto& names =
tokens();
164 for (std::size_t i = 0; i < names.size(); ++i) {
165 if (mask & (1u << i)) {
171 return out.empty() ? std::string(
"DEPTH") : out;
185 for (
const auto& n : species) {
222 if (std::floor(seconds) != seconds ||
223 seconds >=
static_cast<double>(std::numeric_limits<long>::max())) {
224 std::snprintf(buf,
sizeof(buf),
"%.17g", seconds);
227 const long total = seconds > 0.0 ?
static_cast<long>(seconds) : 0L;
228 std::snprintf(buf,
sizeof(buf),
"%02ld:%02ld:%02ld", total / 3600, (total % 3600) / 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:28
const std::vector< std::string > & tokens()
Group tokens in bit order (index i ↔ bit 1u << i).
Definition Report2DVars.hpp:37
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:102
std::string formatMask(unsigned mask)
Preset name when the mask equals one, else the space-separated token list.
Definition Report2DVars.hpp:154
std::vector< std::string > splitList(const std::string &text)
Split on whitespace / commas.
Definition Report2DVars.hpp:72
std::string formatStep(double seconds)
Preserve whole and fractional 2D cadence values.
Definition Report2DVars.hpp:216
std::vector< std::string > parseSpecies(const std::string &text)
Species list from text; "ALL" (alone) → empty list.
Definition Report2DVars.hpp:201
@ ALL_MASK
Definition SolverOptions2D.hpp:235
@ DEPTH
Mesh2_face_depth, Mesh2_face_head.
Definition SolverOptions2D.hpp:216
@ MINIMAL_MASK
MINIMAL: depth map + render reconstruction + envelopes only.
Definition SolverOptions2D.hpp:240
@ DEFAULT_MASK
DEFAULT: everything a user renders or plots; solver diagnostics off.
Definition SolverOptions2D.hpp:237
std::string formatSpecies(const std::vector< std::string > &species)
"ALL" for an empty (unfiltered) list, else the space-separated names.
Definition Report2DVars.hpp:181
bool iequalsTok(const std::string &a, const char *b)
Compare one report token against a required literal ignoring byte case.
Definition Report2DVars.hpp:55