26 : exprtk::ifunction<double>(1),
curve_(curve)
28 exprtk::disable_has_side_effects(*
this);
47 bool spatial_position_is_required);
50 void reinitialize(exprtk::symbol_table<double>& symbol_table);
75 exprtk::symbol_table<T>& symbol_table,
76 std::vector<std::string>
const& string_expressions)
78 using settings_t =
typename exprtk::parser<T>::settings_store;
79 exprtk::parser<T> parser(settings_t::default_compile_all_opts +
80 settings_t::e_collect_assings);
82 std::vector<exprtk::expression<T>> expressions(string_expressions.size());
83 for (
unsigned i = 0; i < string_expressions.size(); ++i)
85 expressions[i].register_symbol_table(symbol_table);
86 if (!parser.compile(string_expressions[i], expressions[i]))
88 OGS_FATAL(
"Error: {:s}\tExpression: {:s}\n", parser.error(),
89 string_expressions[i]);
93 typename exprtk::parser<T>::dependent_entity_collector::symbol_t>
95 parser.dec().assignment_symbols(assignments);
96 if (!assignments.empty())
99 for (
auto const& [name, type] : assignments)
108 "Expression '{:s}' assigns to the already-defined symbol(s) "
109 "'{:s}'. Assignment to the built-in variables (t, x, y, z), to "
110 "MPL variables, curves or constants is not allowed because it "
111 "would corrupt the shared evaluation state. Assignment to "
112 "user-defined local 'var's is permitted.",
113 string_expressions[i], names);
130 bool spatial_position_is_required);
140 exprtk::symbol_table<double>& symbol_table,
141 std::vector<std::string>
const& curve_names,
142 std::map<std::string,
143 std::unique_ptr<MathLib::PiecewiseLinearInterpolation>>
const&
145 std::map<std::string, CurveWrapper>& curve_wrappers);
147extern template std::vector<exprtk::expression<double>>
149 std::vector<std::string>
const&);
154 std::vector<std::string>
const& expression_strings);
158 std::vector<std::string>
const& expression_symbol_names,
159 std::map<std::string,
160 std::unique_ptr<MathLib::PiecewiseLinearInterpolation>>
const&
std::vector< exprtk::expression< T > > compileExpressions(exprtk::symbol_table< T > &symbol_table, std::vector< std::string > const &string_expressions)
bool isBuiltinSymbol(std::string_view const name)
exprtk::symbol_table< double > createBaseSymbolTable(bool spatial_position_is_required)
void registerCurveWrappers(exprtk::symbol_table< double > &symbol_table, std::vector< std::string > const &curve_names, std::map< std::string, std::unique_ptr< MathLib::PiecewiseLinearInterpolation > > const &curves, std::map< std::string, CurveWrapper > &curve_wrappers)
std::vector< std::string > collectVariables(std::vector< std::string > const &expression_strings)
template std::vector< exprtk::expression< double > > compileExpressions< double >(exprtk::symbol_table< double > &, std::vector< std::string > const &)
std::vector< std::string > collectUsedCurveNames(std::vector< std::string > const &expression_symbol_names, std::map< std::string, std::unique_ptr< MathLib::PiecewiseLinearInterpolation > > const &curves)
Returns the subset of expression_symbol_names that are keys in curves.
bool hasSpatialVariables(std::vector< std::string > const &variables)
MathLib::PiecewiseLinearInterpolation const & curve_
double operator()(double const &t) override
CurveWrapper(MathLib::PiecewiseLinearInterpolation const &curve)
SymbolTableCache()=default
void setTimeAndPosition(double t, SpatialPosition const &pos) const
void reinitialize(exprtk::symbol_table< double > &symbol_table)
Re-caches pointers from a (possibly moved) symbol_table.
bool spatial_position_is_required_