![]() |
OpenSWMM Engine
6.0.0-alpha.4
Data-oriented, plugin-extensible SWMM Engine (6.0.0-alpha.4)
|
Classes | |
| struct | Token |
| struct | TreatExpr |
Enumerations | |
| enum class | TokenType : int { NUMBER = 0 , VARIABLE = 1 , ADD = 2 , SUB = 3 , MUL = 4 , DIV = 5 , POW = 6 , NEG = 7 , FUNC_EXP = 8 , FUNC_LOG = 9 , FUNC_SQRT = 10 , FUNC_MIN = 11 , FUNC_MAX = 12 , FUNC_ABS = 13 , FUNC_SGN = 14 , FUNC_STEP = 15 , LPAREN = 16 , RPAREN = 17 , COMMA = 18 } |
| enum class | TreatVar : int { C = 0 , R = 1 , DT = 2 , HRT = 3 , Q = 4 , V = 5 , D = 6 , C_POLLUT = 7 , R_POLLUT = 8 , AREA = 9 } |
Functions | |
| int | parse (const std::string &expr_str, TreatExpr &result) |
| Parse the strict C/R equation prefix and convert built-in-only RHS to postfix. | |
| int | validate (const std::string &expr_str, std::string &msg, int &col) |
| Validate built-in-only treatment grammar with an editor diagnostic and source offset. | |
| double | evaluate (const TreatExpr &expr, double c, double dt, double hrt, double q, double v, double d, double area) |
| Evaluate built-in treatment postfix with scalar hydraulic inputs only. | |
| double | applyTreatment (const TreatExpr &expr, double c_in, double dt, double hrt, double q, double v, double d, double area) |
| Apply scalar-only treatment and clamp its output to removal-only concentration bounds. | |
| int | parse (const std::string &expr_str, TreatExpr &result, const std::vector< std::string > &pollut_names) |
| Parse named pollutant/co-treatment references against a stable name table. | |
| double | evaluate (const TreatExpr &expr, double c, double dt, double hrt, double q, double v, double d, const double *cin, const double *removal, int n_pollut, double area, const double *cpollut) |
| Evaluate treatment postfix with optional pollutant concentration/removal views. | |
| int | parse (const std::string &expr_str, TreatExpr &result, int(*pollut_lookup)(const std::string &name)) |
| Parse named treatment references using an optional native name-resolution function. | |
|
strong |
|
strong |
| double openswmm::treatment::applyTreatment | ( | const TreatExpr & | expr, |
| double | c_in, | ||
| double | dt, | ||
| double | hrt, | ||
| double | q, | ||
| double | v, | ||
| double | d, | ||
| double | area ) |
Apply scalar-only treatment and clamp its output to removal-only concentration bounds.
Apply treatment at a node for one pollutant.
| [in] | expr | Stable parsed expression; is_removal selects removal versus direct concentration. |
| [in] | c_in | Finite nonnegative current/inflow native concentration to bound output. |
| [in] | dt | Accepted duration s. |
| [in] | hrt | Residence time hours. |
| [in] | q | Display-unit treatment flow. |
| [in] | v | Caller treatment volume convention, passed verbatim. |
| [in] | d | Display-unit node depth. |
| [in] | area | Display length2 node area. |
For a removal equation (R=): the expression result is clamped to [0,1] and the output concentration is c_in * (1 - R). For a concentration equation (C=): the expression result is clamped to [0, c_in] and the output concentration is the expression result. This matches the legacy treatmnt.c behavior.
| double openswmm::treatment::evaluate | ( | const TreatExpr & | expr, |
| double | c, | ||
| double | dt, | ||
| double | hrt, | ||
| double | q, | ||
| double | v, | ||
| double | d, | ||
| const double * | cin, | ||
| const double * | removal, | ||
| int | n_pollut, | ||
| double | area, | ||
| const double * | cpollut ) |
Evaluate treatment postfix with optional pollutant concentration/removal views.
Evaluate with co-treatment support (R_pollutant references).
| [in] | expr | Stable postfix expression; caller supplies valid stack/enum metadata and expected units. |
| [in] | c | Current pollutant concentration in caller's native concentration units. |
| [in] | dt | Accepted interval s. |
| [in] | hrt | Hydraulic residence time hours. |
| [in] | q | Native treatment FLOW/Q input in project display flow units. |
| [in] | v | Caller-supplied volume in its treatment convention; used verbatim (no conversion). |
| [in] | d | Native treatment DEPTH/D in project display length. |
| [in] | area | Node surface area in project display length2, used verbatim. |
| [in] | cin | Optional readable n_pollut inflow concentration array, fallback for named C rows. |
| [in] | removal | Optional readable n_pollut removal fractions; negative/not-computed treated0. |
| [in] | n_pollut | Nonnegative readable extent of all provided pollutant arrays; token index outside [0,n_pollut) produces0 without dereference. |
| [in] | cpollut | Optional readable n_pollut current mixed concentration view, preferred over cin for named C rows; null falls back to cin, both null gives0. Arrays borrowed for call only. |
| double openswmm::treatment::evaluate | ( | const TreatExpr & | expr, |
| double | c, | ||
| double | dt, | ||
| double | hrt, | ||
| double | q, | ||
| double | v, | ||
| double | d, | ||
| double | area ) |
Evaluate built-in treatment postfix with scalar hydraulic inputs only.
Evaluate a treatment expression with given variable values.
| [in] | expr | Stable postfix expression; caller supplies valid stack/enum metadata and expected units. |
| [in] | c | Current pollutant concentration in caller's native concentration units. |
| [in] | dt | Accepted interval s. |
| [in] | hrt | Hydraulic residence time hours. |
| [in] | q | Native treatment FLOW/Q input in project display flow units. |
| [in] | v | Caller-supplied volume in its treatment convention; used verbatim (no conversion). |
| [in] | d | Native treatment DEPTH/D in project display length. |
| [in] | area | Node surface area in project display length2, used verbatim. |
| int openswmm::treatment::parse | ( | const std::string & | expr_str, |
| TreatExpr & | result ) |
Parse the strict C/R equation prefix and convert built-in-only RHS to postfix.
Parse a treatment expression string into postfix tokens.
| [in] | expr_str | Whole C=... or R=... expression; surrounding LHS whitespace permitted, case ignored. |
| [out] | result | Clears tokens and is_removal first, retains pollutant_idx. Success installs postfix; shunting-yard failure clears tokens, other early failures can retain chosen removal flag. |
The expression string should be of the form "C = ..." or "R = ...". The parser determines whether this is a concentration or removal equation from the left-hand side, then parses the right-hand side (after the '=') into a postfix token sequence using the Shunting-yard algorithm.
Supported operators: + - * / ^ (standard precedence) Supported functions: exp, log, sqrt, min, max, abs, sgn, step Supported variables: C, R, DT, HRT, Q, V, D, AREA
| int openswmm::treatment::parse | ( | const std::string & | expr_str, |
| TreatExpr & | result, | ||
| const std::vector< std::string > & | pollut_names ) |
Parse named pollutant/co-treatment references against a stable name table.
Parse a treatment expression, resolving pollutant references against a name table.
| [in] | expr_str | Callback-enabled equation text; first character C/R, no leading whitespace. |
| [out] | result | Reset and filled through parse_impl; partial output may remain on failure. |
| [in] | pollut_names | Stable native names, case-insensitive first match supplies zero-based ID; lookup returns negative for absent. Borrowed only during call, not retained. |
The deck-compile path holds the pollutant NAMES, not a free function, so this is the overload it needs. Without it no deck-authored pollutant reference resolves at all — neither a bare name (legacy's project_findObject(POLLUT, s) branch, treatmnt.c:313) nor the R_xxx co-treatment form.
| int openswmm::treatment::parse | ( | const std::string & | expr_str, |
| TreatExpr & | result, | ||
| int(* | pollut_lookup )(const std::string &name) ) |
Parse named treatment references using an optional native name-resolution function.
Parse with pollutant name resolution for co-treatment.
| [in] | expr_str | Whole expression passed unchanged to legacy-permissive parse_impl. |
| [out] | result | Reset/fill candidate; partial parse output may remain on diagnostic failure. |
| [in] | pollut_lookup | Optional function pointer returning nonnegative native species ID or -1 for absent; called synchronously with original-case name, must stay callable throughout call. |
| int openswmm::treatment::validate | ( | const std::string & | expr_str, |
| std::string & | msg, | ||
| int & | col ) |
Validate built-in-only treatment grammar with an editor diagnostic and source offset.
Validate a treatment expression without touching engine state.
| [in] | expr_str | Whole C=... or R=... expression; byte offsets refer to this complete string. |
| [out] | msg | Cleared first, populated on diagnostic failure. |
| [out] | col | Set -1 first; zero-based byte error offset when attributable, otherwise -1. |
Diagnostic peer of parse() for editors: same grammar, but reports a human-readable message and character position on failure. Stricter than parse() in one deliberate way — unknown characters are an error here, where the tokenizer silently skips them. Ends with a parse() cross-check so the verdict can never drift ahead of what the engine accepts.