OpenSWMM Engine  6.0.0-alpha.4
Data-oriented, plugin-extensible SWMM Engine (6.0.0-alpha.4)
Loading...
Searching...
No Matches
Treatment.cpp File Reference

Treatment expression parser (Shunting-yard) and evaluator (stack machine). More...

#include "Treatment.hpp"
#include <cmath>
#include <stack>
#include <algorithm>
#include <cctype>
#include <unordered_map>
#include <functional>
#include <vector>
Include dependency graph for Treatment.cpp:

Namespaces

namespace  openswmm
 
namespace  openswmm::treatment
 

Functions

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.
 
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.
 
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.
 
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.
 
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.
 
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.
 
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.
 

Detailed Description

Treatment expression parser (Shunting-yard) and evaluator (stack machine).

The parser converts infix treatment expressions into postfix (RPN) token lists. The evaluator is a simple stack machine that processes the postfix token list with concrete variable values.

Numerically identical to the legacy treatmnt.c + mathexpr.c chain.

Author
Caleb Buahin caleb.nosp@m..bua.nosp@m.hin@g.nosp@m.mail.nosp@m..com
License
Apache-2.0