39 #define BOOST_SPIRIT_THREADSAFE 40 #include <boost/spirit/include/classic_assign_actor.hpp> 41 #include <boost/spirit/include/classic_ast.hpp> 42 #include <boost/spirit/include/classic_core.hpp> 43 #include <boost/spirit/include/classic_push_back_actor.hpp> 44 #include <boost/spirit/include/classic_symbols.hpp> 46 #include <boost/random/mersenne_twister.hpp> 47 #include <boost/random/normal_distribution.hpp> 48 #include <boost/random/variate_generator.hpp> 50 #include <boost/algorithm/string/trim.hpp> 51 #include <boost/math/special_functions/bessel.hpp> 53 namespace bsp = boost::spirit::classic;
58 #if defined(__INTEL_COMPILER) 66 namespace LibUtilities
72 return (arg > 0.0) - (arg < 0.0);
81 boost::variate_generator<boost::mt19937 &, boost::normal_distribution<>>
82 _normal(rng, boost::normal_distribution<>(0, sigma));
88 return (x != 0.0 || y != 0.0) ? sqrt(x * x + y * y) : 0.0;
93 return (x != 0.0 || y != 0.0) ? atan2(y, x) : 0.0;
176 typedef bsp::tree_parse_info<std::string::const_iterator,
177 bsp::node_val_data_factory<NekDouble>>
179 typedef bsp::tree_match<std::string::const_iterator,
180 bsp::node_val_data_factory<NekDouble>>::
196 AddConstant(
"MEANINGLESS", 0.0);
197 AddConstant(
"E", M_E);
198 AddConstant(
"LOG2E", M_LOG2E);
199 AddConstant(
"LOG10E", M_LOG10E);
200 AddConstant(
"LN2", M_LN2);
201 AddConstant(
"LN10", M_LN10);
202 AddConstant(
"PI", M_PI);
203 AddConstant(
"PI_2", M_PI_2);
204 AddConstant(
"PI_4", M_PI_4);
205 AddConstant(
"1_PI", M_1_PI);
206 AddConstant(
"2_PI", M_2_PI);
207 AddConstant(
"2_SQRTPI", M_2_SQRTPI);
208 AddConstant(
"SQRT2", M_SQRT2);
209 AddConstant(
"SQRT1_2", M_SQRT1_2);
210 AddConstant(
"GAMMA", 0.57721566490153286060);
211 AddConstant(
"DEG", 57.2957795130823208768);
212 AddConstant(
"PHI", 1.61803398874989484820);
215 m_functionMapNameToInstanceType[
"abs"] = E_ABS;
216 m_functionMapNameToInstanceType[
"asin"] = E_ASIN;
217 m_functionMapNameToInstanceType[
"acos"] = E_ACOS;
218 m_functionMapNameToInstanceType[
"atan"] = E_ATAN;
219 m_functionMapNameToInstanceType[
"atan2"] = E_ATAN2;
220 m_functionMapNameToInstanceType[
"ang"] = E_ANG;
221 m_functionMapNameToInstanceType[
"bessel"] = E_BESSEL;
222 m_functionMapNameToInstanceType[
"ceil"] = E_CEIL;
223 m_functionMapNameToInstanceType[
"cos"] = E_COS;
224 m_functionMapNameToInstanceType[
"cosh"] = E_COSH;
225 m_functionMapNameToInstanceType[
"exp"] = E_EXP;
226 m_functionMapNameToInstanceType[
"fabs"] = E_FABS;
227 m_functionMapNameToInstanceType[
"floor"] = E_FLOOR;
228 m_functionMapNameToInstanceType[
"log"] = E_LOG;
229 m_functionMapNameToInstanceType[
"log10"] = E_LOG10;
230 m_functionMapNameToInstanceType[
"rad"] = E_RAD;
231 m_functionMapNameToInstanceType[
"sin"] = E_SIN;
232 m_functionMapNameToInstanceType[
"sinh"] = E_SINH;
233 m_functionMapNameToInstanceType[
"sqrt"] = E_SQRT;
234 m_functionMapNameToInstanceType[
"tan"] = E_TAN;
235 m_functionMapNameToInstanceType[
"tanh"] = E_TANH;
236 m_functionMapNameToInstanceType[
"sign"] = E_SIGN;
237 m_functionMapNameToInstanceType[
"awgn"] = E_AWGN;
239 m_function[E_ABS] = std::abs;
240 m_function[E_ASIN] = asin;
241 m_function[E_ACOS] = acos;
242 m_function[E_ATAN] = atan;
243 m_function[E_CEIL] = ceil;
244 m_function[E_COS] = cos;
245 m_function[E_COSH] = cosh;
246 m_function[E_EXP] = exp;
247 m_function[E_FABS] = fabs;
248 m_function[E_FLOOR] = floor;
249 m_function[E_LOG] = log;
250 m_function[E_LOG10] = log10;
251 m_function[E_SIN] = sin;
252 m_function[E_SINH] = sinh;
253 m_function[E_SQRT] = sqrt;
254 m_function[E_TAN] = tan;
255 m_function[E_TANH] = tanh;
256 m_function[E_SIGN] =
sign;
257 m_function2[E_ATAN2] = atan2;
258 m_function2[E_ANG] =
ang;
259 m_function2[E_RAD] =
rad;
260 m_function2[E_BESSEL] = boost::math::cyl_bessel_j;
272 for (
auto &it_es : m_executionStack)
274 for (
auto &it : it_es)
280 m_executionStack.clear();
288 m_generator.seed(seed);
296 for (
auto const &it : constants)
298 AddConstant(it.first, it.second);
307 ConstantMap::const_iterator it = m_constantMapNameToId.find(name);
308 if (it == m_constantMapNameToId.end())
312 m_constantsParser.add(name.c_str(), value);
313 int index = m_constant.size();
314 m_constantMapNameToId[
name] = index;
315 m_constant.push_back(value);
320 if (m_constant[it->second] != value)
322 std::string errormsg =
323 "Attempt to add numerically different constants under the " 326 std::cout << errormsg << std::endl;
337 NekDouble *value =
find(m_constantsParser, name.c_str());
338 ASSERTL1(value != NULL,
"Constant variable not found: " + name);
347 for (
auto const &it : params)
349 SetParameter(it.first, it.second);
358 ParameterMap::const_iterator it = m_parameterMapNameToId.find(name);
359 if (it == m_parameterMapNameToId.end())
361 m_parameterMapNameToId[
name] = m_parameter.size();
362 m_parameter.push_back(value);
367 m_parameter[it->second] = value;
376 ParameterMap::const_iterator it = m_parameterMapNameToId.find(name);
377 ASSERTL1(it != m_parameterMapNameToId.end(),
378 "Parameter not found: " +
name);
379 return m_parameter[it->second];
387 return m_total_eval_time;
396 auto it = m_parsedMapExprToExecStackId.find(expr);
397 if (it != m_parsedMapExprToExecStackId.end())
412 std::vector<std::string> variableNames;
413 bsp::parse((
char *)vlist.c_str(),
415 *(+(+bsp::graph_p)[bsp::push_back_a(variableNames)] >>
424 bsp::ast_parse<bsp::node_val_data_factory<NekDouble>,
426 bsp::space_parser>(expr.begin(), expr.end(),
427 myGrammar, bsp::space_p);
430 "Unable to fully parse function. Stopped just before: " +
431 std::string(parseInfo.stop, parseInfo.stop + 15));
435 throw std::runtime_error(
436 "Unable to fully parse function at: " +
437 std::string(parseInfo.stop, parseInfo.stop + 15));
444 ExecutionStack stack;
445 VariableMap variableMap;
447 int stackId = m_executionStack.size();
451 for (
int i = 0; i < variableNames.size(); i++)
453 variableMap[variableNames[i]] = i;
458 PrecomputedValue v = PrepareExecutionAsYouParse(parseInfo.trees.begin(),
459 stack, variableMap, 0);
465 "Constant expression yeilds non-empty execution stack. " 466 "Bug in PrepareExecutionAsYouParse()");
468 int const_index = AddConstant(
469 std::string(
"EXPRESSION_") + std::to_string(stackId), v.second);
470 stack.push_back(makeStep<StoreConst>(0, const_index));
473 m_parsedMapExprToExecStackId[expr] = stackId;
478 m_executionStack.push_back(stack);
479 m_stackVariableMap.push_back(variableMap);
480 m_state_sizes.push_back(m_state_size);
492 ASSERTL1(m_executionStack.size() > id,
493 "unknown analytic expression, it must first be defined " 494 "with DefineFunction(...)");
496 ExecutionStack &stack = m_executionStack[id];
498 m_state.resize(m_state_sizes[
id]);
499 for (
int i = 0; i < stack.size(); i++)
501 (*stack[i]).run_once();
505 m_total_eval_time += m_timer.TimePerTest(1);
513 NekDouble
Evaluate(
const int id,
const NekDouble x,
const NekDouble y,
514 const NekDouble z,
const NekDouble t)
518 ASSERTL1(m_executionStack.size() > id,
519 "unknown analytic expression, it must first be defined with " 520 "DefineFunction(...)");
522 ExecutionStack &stack = m_executionStack[id];
525 m_state.resize(m_state_sizes[
id]);
527 if (m_variable.size() < 4)
529 m_variable.resize(4);
541 for (
int i = 0; i < stack.size(); i++)
543 (*stack[i]).run_once();
547 m_total_eval_time += m_timer.TimePerTest(1);
559 ASSERTL1(m_executionStack.size() > id,
560 "unknown analytic expression, it must first be defined with " 561 "DefineFunction(...)");
563 ExecutionStack &stack = m_executionStack[id];
564 VariableMap &variableMap = m_stackVariableMap[id];
566 ASSERTL1(point.size() == variableMap.size(),
567 "The number of variables used to define this expression should" 568 " match the point dimensionality.");
571 m_state.resize(m_state_sizes[
id]);
572 m_variable.resize(point.size());
573 VariableMap::const_iterator it;
575 for (it = variableMap.begin(); it != variableMap.end(); ++it)
577 m_variable[it->second] = point[it->second];
581 for (
int i = 0; i < stack.size(); i++)
583 (*stack[i]).run_once();
587 m_total_eval_time += m_timer.TimePerTest(1);
602 std::vector<Array<OneD, const NekDouble>> points = {x, y, z, t};
603 Evaluate(
id, points, result);
605 m_total_eval_time += m_timer.TimePerTest(1);
617 const int num_points = points[0].num_elements();
618 ASSERTL1(m_executionStack.size() > id,
619 "unknown analytic expression, it must first be defined " 620 "with DefineFunction(...)");
621 ASSERTL1(result.num_elements() >= num_points,
622 "destination array must have enough capacity to store " 623 "expression values at each given point");
625 ExecutionStack &stack = m_executionStack[id];
630 const int max_chunk_size = 1024;
631 const int nvals = points.size();
632 const int chunk_size = (std::min)(max_chunk_size, num_points);
634 if (m_state.size() < chunk_size * m_state_sizes[id])
636 m_state.resize(m_state_sizes[
id] * chunk_size, 0.0);
638 if (m_variable.size() < nvals * chunk_size)
640 m_variable.resize(nvals * chunk_size, 0.0);
642 if (result.num_elements() < num_points)
648 int work_left = num_points;
649 while (work_left > 0)
651 const int this_chunk_size = (std::min)(work_left, 1024);
652 for (
int i = 0; i < this_chunk_size; i++)
654 for (
int j = 0; j < nvals; ++j)
656 m_variable[i + this_chunk_size * j] = points[j][offset + i];
659 for (
int i = 0; i < stack.size(); i++)
661 (*stack[i]).run_many(this_chunk_size);
663 for (
int i = 0; i < this_chunk_size; i++)
665 result[offset + i] = m_state[i];
667 work_left -= this_chunk_size;
668 offset += this_chunk_size;
671 m_total_eval_time += m_timer.TimePerTest(1);
712 const ParsedTreeIterator &location, ExecutionStack &stack,
713 VariableMap &variableMap,
int stateIndex)
715 std::string valueStr(location->value.begin(), location->value.end());
716 boost::algorithm::trim(valueStr);
718 const bsp::parser_id parserID = location->value.id();
719 #if defined(NEKTAR_DEBUG) || defined(NEKTAR_FULLDEBUG) 720 const int num_children = location->children.size();
723 if (parserID == AnalyticExpression::constantID)
726 "Illegal children under constant node: " + valueStr);
728 auto it = m_constantMapNameToId.find(valueStr);
729 ASSERTL1(it != m_constantMapNameToId.end(),
730 "Cannot find the value for the specified constant: " +
733 return std::make_pair(
true, m_constant[it->second]);
735 else if (parserID == AnalyticExpression::numberID)
738 "Illegal children under number node: " + valueStr);
739 return std::make_pair(
740 true, boost::lexical_cast<NekDouble>(valueStr.c_str()));
742 else if (parserID == AnalyticExpression::variableID)
745 "Illegal children under variable node: " + valueStr);
747 VariableMap::const_iterator it = variableMap.find(valueStr);
749 "Unknown variable parsed: " + valueStr);
752 stack.push_back(makeStep<StoreVar>(stateIndex, it->second));
753 return std::make_pair(
false, 0);
755 else if (parserID == AnalyticExpression::parameterID)
758 "Illegal children under parameter node: " + valueStr);
760 auto it = m_parameterMapNameToId.find(valueStr);
761 ASSERTL1(it != m_parameterMapNameToId.end(),
762 "Unknown parameter parsed: " + valueStr);
765 stack.push_back(makeStep<StorePrm>(stateIndex, it->second));
766 return std::make_pair(
false, 0);
768 else if (parserID == AnalyticExpression::functionID)
770 auto it = m_functionMapNameToInstanceType.find(valueStr);
771 ASSERTL1(it != m_functionMapNameToInstanceType.end(),
772 "Invalid function specified: " + valueStr);
773 ASSERTL1(num_children == 1 || num_children == 2,
774 "Function " + valueStr +
775 " has neither one or two " 776 "arguments: this is not implemented yet.");
778 if (location->children.size() == 1)
780 PrecomputedValue v = PrepareExecutionAsYouParse(
781 location->children.begin(), stack, variableMap, stateIndex);
784 if (it->second == E_AWGN)
787 AddConstant(std::string(
"SUB_EXPR_") +
788 std::to_string(m_constant.size()),
791 makeStep<StoreConst>(stateIndex, const_index));
792 stack.push_back(makeStep<EvalAWGN>(stateIndex, stateIndex));
793 return std::make_pair(
false, 0);
798 return std::make_pair(
true,
799 m_function[it->second](v.second));
804 PrecomputedValue v1 =
805 PrepareExecutionAsYouParse(location->children.begin() + 0,
806 stack, variableMap, stateIndex);
807 PrecomputedValue v2 = PrepareExecutionAsYouParse(
808 location->children.begin() + 1, stack, variableMap,
812 if (
true == v1.first &&
true == v2.first)
814 return std::make_pair(
815 true, m_function2[it->second](v1.second, v2.second));
824 stack.push_back(makeStep<EvalAbs>(stateIndex, stateIndex));
825 return std::make_pair(
false, 0);
827 stack.push_back(makeStep<EvalAsin>(stateIndex, stateIndex));
828 return std::make_pair(
false, 0);
830 stack.push_back(makeStep<EvalAcos>(stateIndex, stateIndex));
831 return std::make_pair(
false, 0);
833 stack.push_back(makeStep<EvalAtan>(stateIndex, stateIndex));
834 return std::make_pair(
false, 0);
836 stack.push_back(makeStep<EvalAtan2>(stateIndex, stateIndex,
838 return std::make_pair(
false, 0);
840 stack.push_back(makeStep<EvalAng>(stateIndex, stateIndex,
842 return std::make_pair(
false, 0);
844 stack.push_back(makeStep<EvalBessel>(stateIndex, stateIndex,
846 return std::make_pair(
false, 0);
848 stack.push_back(makeStep<EvalCeil>(stateIndex, stateIndex));
849 return std::make_pair(
false, 0);
851 stack.push_back(makeStep<EvalCos>(stateIndex, stateIndex));
852 return std::make_pair(
false, 0);
854 stack.push_back(makeStep<EvalCosh>(stateIndex, stateIndex));
855 return std::make_pair(
false, 0);
857 stack.push_back(makeStep<EvalExp>(stateIndex, stateIndex));
858 return std::make_pair(
false, 0);
860 stack.push_back(makeStep<EvalFabs>(stateIndex, stateIndex));
861 return std::make_pair(
false, 0);
864 makeStep<EvalFloor>(stateIndex, stateIndex));
865 return std::make_pair(
false, 0);
867 stack.push_back(makeStep<EvalLog>(stateIndex, stateIndex));
868 return std::make_pair(
false, 0);
871 makeStep<EvalLog10>(stateIndex, stateIndex));
872 return std::make_pair(
false, 0);
874 stack.push_back(makeStep<EvalRad>(stateIndex, stateIndex,
876 return std::make_pair(
false, 0);
878 stack.push_back(makeStep<EvalSin>(stateIndex, stateIndex));
879 return std::make_pair(
false, 0);
881 stack.push_back(makeStep<EvalSinh>(stateIndex, stateIndex));
882 return std::make_pair(
false, 0);
884 stack.push_back(makeStep<EvalSqrt>(stateIndex, stateIndex));
885 return std::make_pair(
false, 0);
887 stack.push_back(makeStep<EvalTan>(stateIndex, stateIndex));
888 return std::make_pair(
false, 0);
890 stack.push_back(makeStep<EvalTanh>(stateIndex, stateIndex));
891 return std::make_pair(
false, 0);
893 stack.push_back(makeStep<EvalSign>(stateIndex, stateIndex));
894 return std::make_pair(
false, 0);
896 ASSERTL0(
false,
"Evaluation of " + valueStr +
897 " is not implemented yet");
899 return std::make_pair(
false, 0);
901 else if (parserID == AnalyticExpression::unaryID)
904 "Illegal factor - it can only be '-' and it was: " +
907 "Illegal number of children under factor node: " +
909 PrecomputedValue v = PrepareExecutionAsYouParse(
910 location->children.begin(), stack, variableMap, stateIndex);
915 return std::make_pair(
true, -v.second);
917 stack.push_back(makeStep<EvalNeg>(stateIndex, stateIndex));
918 return std::make_pair(
false, 0);
920 else if (parserID == AnalyticExpression::operatorID)
924 "Too few or too many arguments for mathematical operator: " +
926 PrecomputedValue left = PrepareExecutionAsYouParse(
927 location->children.begin() + 0, stack, variableMap, stateIndex);
928 PrecomputedValue right =
929 PrepareExecutionAsYouParse(location->children.begin() + 1,
930 stack, variableMap, stateIndex + 1);
934 if ((left.first ==
true) && (right.first ==
true))
936 switch (*valueStr.begin())
939 return std::make_pair(
true, left.second + right.second);
941 return std::make_pair(
true, left.second - right.second);
943 return std::make_pair(
true, left.second * right.second);
945 return std::make_pair(
true, left.second / right.second);
947 return std::make_pair(
948 true, std::pow(left.second, right.second));
950 return std::make_pair(
true,
951 left.second == right.second);
953 if (*(valueStr.end() - 1) ==
'=')
955 return std::make_pair(
true,
956 left.second <= right.second);
960 return std::make_pair(
true,
961 left.second < right.second);
963 return std::make_pair(
false, 0);
965 if (*(valueStr.end() - 1) ==
'=')
967 return std::make_pair(
true,
968 left.second >= right.second);
972 return std::make_pair(
true,
973 left.second > right.second);
975 return std::make_pair(
false, 0);
978 "Invalid operator encountered: " + valueStr);
980 return std::make_pair(
false, 0);
985 if (
true == left.first)
988 AddConstant(std::string(
"SUB_EXPR_") +
989 std::to_string(m_constant.size()),
991 stack.push_back(makeStep<StoreConst>(stateIndex, const_index));
993 if (
true == right.first)
996 AddConstant(std::string(
"SUB_EXPR_") +
997 std::to_string(m_constant.size()),
1000 makeStep<StoreConst>(stateIndex + 1, const_index));
1003 switch (*valueStr.begin())
1006 stack.push_back(makeStep<EvalSum>(stateIndex, stateIndex,
1008 return std::make_pair(
false, 0);
1010 stack.push_back(makeStep<EvalSub>(stateIndex, stateIndex,
1012 return std::make_pair(
false, 0);
1014 stack.push_back(makeStep<EvalMul>(stateIndex, stateIndex,
1016 return std::make_pair(
false, 0);
1018 stack.push_back(makeStep<EvalDiv>(stateIndex, stateIndex,
1020 return std::make_pair(
false, 0);
1022 stack.push_back(makeStep<EvalPow>(stateIndex, stateIndex,
1024 return std::make_pair(
false, 0);
1026 stack.push_back(makeStep<EvalLogicalEqual>(
1027 stateIndex, stateIndex, stateIndex + 1));
1028 return std::make_pair(
false, 0);
1030 if (*(valueStr.end() - 1) ==
'=')
1032 stack.push_back(makeStep<EvalLogicalLeq>(
1033 stateIndex, stateIndex, stateIndex + 1));
1037 stack.push_back(makeStep<EvalLogicalLess>(
1038 stateIndex, stateIndex, stateIndex + 1));
1040 return std::make_pair(
false, 0);
1043 if (*(valueStr.end() - 1) ==
'=')
1045 stack.push_back(makeStep<EvalLogicalGeq>(
1046 stateIndex, stateIndex, stateIndex + 1));
1050 stack.push_back(makeStep<EvalLogicalGreater>(
1051 stateIndex, stateIndex, stateIndex + 1));
1053 return std::make_pair(
false, 0);
1057 "Invalid operator encountered: " + valueStr);
1059 return std::make_pair(
false, 0);
1061 else if (parserID == AnalyticExpression::operatorID)
1065 "Too few or too many arguments for mathematical operator: " +
1068 ASSERTL0(
false,
"Illegal expression encountered: " + valueStr);
1069 return std::make_pair(
false, 0);
1095 for (
auto const &it : vars)
1106 static const int constantID = 1;
1107 static const int numberID = 2;
1108 static const int variableID = 3;
1109 static const int parameterID = 4;
1110 static const int functionID = 5;
1111 static const int unaryID = 6;
1112 static const int operatorID = 7;
1115 const std::vector<std::string> &
variables)
1117 variables_p(variables)
1134 expression = logical_or;
1138 *((bsp::root_node_d[bsp::str_p(
"||")] >> logical_and));
1142 *((bsp::root_node_d[bsp::str_p(
"&&")] >> equality));
1145 lt_gt >> *((bsp::root_node_d[bsp::str_p(
"==")] >> lt_gt));
1148 *((bsp::root_node_d[bsp::str_p(
"<=")] >> add_sub) |
1149 (bsp::root_node_d[bsp::str_p(
">=")] >> add_sub) |
1150 (bsp::root_node_d[bsp::ch_p(
'<')] >> add_sub) |
1151 (bsp::root_node_d[bsp::ch_p(
'>')] >> add_sub));
1154 negate >> *((bsp::root_node_d[bsp::ch_p(
'+')] >>
negate) |
1155 (bsp::root_node_d[bsp::ch_p(
'-')] >>
negate));
1157 negate = !(bsp::root_node_d[bsp::ch_p(
'-')]) >> mult_div;
1159 mult_div = exponential >>
1160 *((bsp::root_node_d[bsp::ch_p(
'*')] >> exponential) |
1161 (bsp::root_node_d[bsp::ch_p(
'/')] >> exponential));
1164 base >> !(bsp::root_node_d[bsp::ch_p(
'^')] >> exponential);
1166 base = number |
function | variable | constant | parameter |
1167 bsp::inner_node_d[bsp::ch_p(
'(') >> expression >>
1170 bsp::leaf_node_d[bsp::lexeme_d[(bsp::alpha_p |
'_' |
'$') >>
1171 *(bsp::alnum_p |
'_' |
1177 bsp::infix_node_d[bsp::inner_node_d[bsp::ch_p(
'(') >>
1179 *(
',' >> expression) >>
1183 bsp::leaf_node_d[bsp::lexeme_d[
self.variables_p]] >> op;
1185 number = bsp::leaf_node_d[bsp::lexeme_d[bsp::real_p]] >> op;
1188 bsp::leaf_node_d[bsp::lexeme_d[*
self.constants_p]] >> op;
1190 op = bsp::eps_p(bsp::end_p |
"||" |
"&&" |
"==" |
"<=" |
">=" |
1191 '<' |
'>' |
'+' |
'-' |
'*' |
'/' |
'^' |
')' |
1201 bsp::rule<ScannerT, bsp::parser_context<>, bsp::parser_tag<N>>;
1303 typedef std::vector<NekDouble> &
vr;
1304 typedef const std::vector<NekDouble> &
cvr;
1309 template <
typename StepType>
1312 return (
new StepType(m_generator, m_state, m_constant, m_parameter,
1313 m_variable, dest, src_left, src_right));
1363 : rng(rn), state(s), consts(c), params(p), vars(v), storeIdx(i),
1364 argIdx1(l), argIdx2(r){};
1372 virtual void run_many(ci n) = 0;
1373 virtual void run_once() = 0;
1383 for (
int i = 0; i < n; i++)
1384 state[storeIdx * n + i] = state[argIdx1];
1388 state[storeIdx] = state[argIdx1];
1399 for (
int i = 0; i < n; i++)
1400 state[storeIdx * n + i] = consts[argIdx1];
1404 state[storeIdx] = consts[argIdx1];
1409 StoreVar(rgt rn, vr s, cvr c, cvr
p, cvr v, ci i, ci l, ci r)
1415 for (
int i = 0; i < n; i++)
1416 state[storeIdx * n + i] = vars[argIdx1 * n + i];
1420 state[storeIdx] = vars[argIdx1];
1425 StorePrm(rgt rn, vr s, cvr c, cvr
p, cvr v, ci i, ci l, ci r)
1431 for (
int i = 0; i < n; i++)
1432 state[storeIdx * n + i] = params[argIdx1];
1436 state[storeIdx] = params[argIdx1];
1441 EvalSum(rgt rn, vr s, cvr c, cvr
p, cvr v, ci i, ci l, ci r)
1447 for (
int i = 0; i < n; i++)
1448 state[storeIdx * n + i] =
1449 state[argIdx1 * n + i] + state[argIdx2 * n + i];
1453 state[storeIdx] = state[argIdx1] + state[argIdx2];
1458 EvalSub(rgt rn, vr s, cvr c, cvr
p, cvr v, ci i, ci l, ci r)
1464 for (
int i = 0; i < n; i++)
1465 state[storeIdx * n + i] =
1466 state[argIdx1 * n + i] - state[argIdx2 * n + i];
1470 state[storeIdx] = state[argIdx1] - state[argIdx2];
1475 EvalMul(rgt rn, vr s, cvr c, cvr
p, cvr v, ci i, ci l, ci r)
1481 for (
int i = 0; i < n; i++)
1482 state[storeIdx * n + i] =
1483 state[argIdx1 * n + i] * state[argIdx2 * n + i];
1487 state[storeIdx] = state[argIdx1] * state[argIdx2];
1492 EvalDiv(rgt rn, vr s, cvr c, cvr
p, cvr v, ci i, ci l, ci r)
1498 for (
int i = 0; i < n; i++)
1499 state[storeIdx * n + i] =
1500 state[argIdx1 * n + i] / state[argIdx2 * n + i];
1504 state[storeIdx] = state[argIdx1] / state[argIdx2];
1509 EvalPow(rgt rn, vr s, cvr c, cvr
p, cvr v, ci i, ci l, ci r)
1515 for (
int i = 0; i < n; i++)
1516 state[storeIdx * n + i] =
1517 std::pow(state[argIdx1 * n + i], state[argIdx2 * n + i]);
1521 state[storeIdx] = std::pow(state[argIdx1], state[argIdx2]);
1526 EvalNeg(rgt rn, vr s, cvr c, cvr
p, cvr v, ci i, ci l, ci r)
1532 for (
int i = 0; i < n; i++)
1533 state[storeIdx * n + i] = -state[argIdx1 * n + i];
1537 state[storeIdx] = -state[argIdx1];
1548 for (
int i = 0; i < n; i++)
1549 state[storeIdx * n + i] =
1550 (state[argIdx1 * n + i] == state[argIdx2 * n + i]);
1554 state[storeIdx] = (state[argIdx1] == state[argIdx2]);
1565 for (
int i = 0; i < n; i++)
1566 state[storeIdx * n + i] =
1567 (state[argIdx1 * n + i] <= state[argIdx2 * n + i]);
1571 state[storeIdx] = (state[argIdx1] <= state[argIdx2]);
1582 for (
int i = 0; i < n; i++)
1583 state[storeIdx * n + i] =
1584 (state[argIdx1 * n + i] < state[argIdx2 * n + i]);
1588 state[storeIdx] = (state[argIdx1] < state[argIdx2]);
1599 for (
int i = 0; i < n; i++)
1600 state[storeIdx * n + i] =
1601 (state[argIdx1 * n + i] >= state[argIdx2 * n + i]);
1605 state[storeIdx] = (state[argIdx1] >= state[argIdx2]);
1616 for (
int i = 0; i < n; i++)
1617 state[storeIdx * n + i] =
1618 (state[argIdx1 * n + i] > state[argIdx2 * n + i]);
1622 state[storeIdx] = (state[argIdx1] > state[argIdx2]);
1627 EvalAbs(rgt rn, vr s, cvr c, cvr
p, cvr v, ci i, ci l, ci r)
1633 for (
int i = 0; i < n; i++)
1634 state[storeIdx * n + i] = std::abs(state[argIdx1 * n + i]);
1638 state[storeIdx] = std::abs(state[argIdx1]);
1643 EvalSign(rgt rn, vr s, cvr c, cvr
p, cvr v, ci i, ci l, ci r)
1649 for (
int i = 0; i < n; i++)
1650 state[storeIdx * n + i] = ((state[argIdx1 * n + i] > 0.0) -
1651 (state[argIdx1 * n + i] < 0.0));
1655 state[storeIdx] = ((state[argIdx1] > 0.0) - (state[argIdx1] < 0.0));
1660 EvalAsin(rgt rn, vr s, cvr c, cvr
p, cvr v, ci i, ci l, ci r)
1666 for (
int i = 0; i < n; i++)
1667 state[storeIdx * n + i] = std::asin(state[argIdx1 * n + i]);
1671 state[storeIdx] = std::asin(state[argIdx1]);
1676 EvalAcos(rgt rn, vr s, cvr c, cvr
p, cvr v, ci i, ci l, ci r)
1682 for (
int i = 0; i < n; i++)
1683 state[storeIdx * n + i] = std::acos(state[argIdx1 * n + i]);
1687 state[storeIdx] = std::acos(state[argIdx1]);
1692 EvalAtan(rgt rn, vr s, cvr c, cvr
p, cvr v, ci i, ci l, ci r)
1698 for (
int i = 0; i < n; i++)
1699 state[storeIdx * n + i] = std::atan(state[argIdx1 * n + i]);
1703 state[storeIdx] = std::atan(state[argIdx1]);
1714 for (
int i = 0; i < n; i++)
1715 state[storeIdx * n + i] =
1716 std::atan2(state[argIdx1 * n + i], state[argIdx2 * n + i]);
1720 state[storeIdx] = std::atan2(state[argIdx1], state[argIdx2]);
1725 EvalAng(rgt rn, vr s, cvr c, cvr
p, cvr v, ci i, ci l, ci r)
1731 for (
int i = 0; i < n; i++)
1732 state[storeIdx * n + i] =
1733 ang(state[argIdx1 * n + i], state[argIdx2 * n + i]);
1737 state[storeIdx] =
ang(state[argIdx1], state[argIdx2]);
1748 for (
int i = 0; i < n; i++)
1749 state[storeIdx * n + i] = boost::math::cyl_bessel_j(
1750 state[argIdx1 * n + i], state[argIdx2 * n + i]);
1755 boost::math::cyl_bessel_j(state[argIdx1], state[argIdx2]);
1760 EvalCeil(rgt rn, vr s, cvr c, cvr
p, cvr v, ci i, ci l, ci r)
1766 for (
int i = 0; i < n; i++)
1767 state[storeIdx * n + i] = std::ceil(state[argIdx1 * n + i]);
1771 state[storeIdx] = std::ceil(state[argIdx1]);
1776 EvalCos(rgt rn, vr s, cvr c, cvr
p, cvr v, ci i, ci l, ci r)
1782 for (
int i = 0; i < n; i++)
1783 state[storeIdx * n + i] = std::cos(state[argIdx1 * n + i]);
1787 state[storeIdx] = std::cos(state[argIdx1]);
1792 EvalCosh(rgt rn, vr s, cvr c, cvr
p, cvr v, ci i, ci l, ci r)
1798 for (
int i = 0; i < n; i++)
1799 state[storeIdx * n + i] = std::cosh(state[argIdx1 * n + i]);
1803 state[storeIdx] = std::cosh(state[argIdx1]);
1808 EvalExp(rgt rn, vr s, cvr c, cvr
p, cvr v, ci i, ci l, ci r)
1814 for (
int i = 0; i < n; i++)
1815 state[storeIdx * n + i] = std::exp(state[argIdx1 * n + i]);
1819 state[storeIdx] = std::exp(state[argIdx1]);
1824 EvalFabs(rgt rn, vr s, cvr c, cvr
p, cvr v, ci i, ci l, ci r)
1830 for (
int i = 0; i < n; i++)
1831 state[storeIdx * n + i] = std::fabs(state[argIdx1 * n + i]);
1835 state[storeIdx] = std::fabs(state[argIdx1]);
1846 for (
int i = 0; i < n; i++)
1847 state[storeIdx * n + i] = std::floor(state[argIdx1 * n + i]);
1851 state[storeIdx] = std::floor(state[argIdx1]);
1856 EvalLog(rgt rn, vr s, cvr c, cvr
p, cvr v, ci i, ci l, ci r)
1862 for (
int i = 0; i < n; i++)
1863 state[storeIdx * n + i] = std::log(state[argIdx1 * n + i]);
1867 state[storeIdx] = std::log(state[argIdx1]);
1878 for (
int i = 0; i < n; i++)
1879 state[storeIdx * n + i] = std::log10(state[argIdx1 * n + i]);
1883 state[storeIdx] = std::log10(state[argIdx1]);
1888 EvalRad(rgt rn, vr s, cvr c, cvr
p, cvr v, ci i, ci l, ci r)
1894 for (
int i = 0; i < n; i++)
1895 state[storeIdx * n + i] =
1896 rad(state[argIdx1 * n + i], state[argIdx2 * n + i]);
1900 state[storeIdx] =
rad(state[argIdx1], state[argIdx2]);
1905 EvalSin(rgt rn, vr s, cvr c, cvr
p, cvr v, ci i, ci l, ci r)
1911 for (
int i = 0; i < n; i++)
1912 state[storeIdx * n + i] = std::sin(state[argIdx1 * n + i]);
1916 state[storeIdx] = std::sin(state[argIdx1]);
1921 EvalSinh(rgt rn, vr s, cvr c, cvr
p, cvr v, ci i, ci l, ci r)
1927 for (
int i = 0; i < n; i++)
1928 state[storeIdx * n + i] = std::sinh(state[argIdx1 * n + i]);
1932 state[storeIdx] = std::sinh(state[argIdx1]);
1937 EvalSqrt(rgt rn, vr s, cvr c, cvr
p, cvr v, ci i, ci l, ci r)
1943 for (
int i = 0; i < n; i++)
1944 state[storeIdx * n + i] = std::sqrt(state[argIdx1 * n + i]);
1948 state[storeIdx] = std::sqrt(state[argIdx1]);
1953 EvalTan(rgt rn, vr s, cvr c, cvr
p, cvr v, ci i, ci l, ci r)
1959 for (
int i = 0; i < n; i++)
1960 state[storeIdx * n + i] = std::tan(state[argIdx1 * n + i]);
1964 state[storeIdx] = std::tan(state[argIdx1]);
1969 EvalTanh(rgt rn, vr s, cvr c, cvr
p, cvr v, ci i, ci l, ci r)
1975 for (
int i = 0; i < n; i++)
1976 state[storeIdx * n + i] = std::tanh(state[argIdx1 * n + i]);
1980 state[storeIdx] = std::tanh(state[argIdx1]);
1985 EvalAWGN(rgt rn, vr s, cvr c, cvr
p, cvr v, ci i, ci l, ci r)
1993 boost::variate_generator<boost::mt19937 &,
1994 boost::normal_distribution<>>
1996 boost::normal_distribution<>(0, state[storeIdx * n]));
1997 for (
int i = 0; i < n; i++)
1999 state[storeIdx * n + i] = _normal();
2004 boost::variate_generator<boost::mt19937 &,
2005 boost::normal_distribution<>>
2006 _normal(rng, boost::normal_distribution<>(0, state[storeIdx]));
2007 state[storeIdx] = _normal();
2027 m_impl = std::move(r.m_impl);
2033 m_impl->SetRandomSeed(seed);
2037 std::map<std::string, NekDouble>
const &
constants)
2039 m_impl->AddConstants(constants);
2044 return m_impl->AddConstant(name, value);
2049 return m_impl->GetConstant(name);
2054 m_impl->SetParameters(params);
2059 m_impl->SetParameter(name, value);
2064 return m_impl->GetParameter(name);
2069 return m_impl->GetTime();
2073 const std::string &
function)
2075 return m_impl->DefineFunction(vlist,
function);
2080 return m_impl->Evaluate(AnalyticExpression_id);
2084 const NekDouble x,
const NekDouble y,
2085 const NekDouble z,
const NekDouble t)
2087 return m_impl->Evaluate(AnalyticExpression_id, x, y, z, t);
2091 std::vector<NekDouble>
point)
2093 return m_impl->EvaluateAtPoint(AnalyticExpression_id, point);
2103 m_impl->Evaluate(expression_id, x, y, z, t, result);
2107 const int expression_id,
2111 m_impl->Evaluate(expression_id, points, result);
static NekDouble ang(NekDouble x, NekDouble y)
NekDouble(* PFD3)(NekDouble, NekDouble, NekDouble)
EvalTan(rgt rn, vr s, cvr c, cvr p, cvr v, ci i, ci l, ci r)
virtual void run_many(ci n)
declaring this guy pure virtual shortens virtual table. It saves some execution time.
virtual void run_many(ci n)
declaring this guy pure virtual shortens virtual table. It saves some execution time.
EvalLogicalGeq(rgt rn, vr s, cvr c, cvr p, cvr v, ci i, ci l, ci r)
EvalAWGN(rgt rn, vr s, cvr c, cvr p, cvr v, ci i, ci l, ci r)
variables(std::vector< std::string > const &vars)
std::map< std::string, int > ConstantMap
bsp_rule< operatorID> logical_or
boost::mt19937 m_generator
EvalAng(rgt rn, vr s, cvr c, cvr p, cvr v, ci i, ci l, ci r)
#define ASSERTL0(condition, msg)
bsp_rule< variableID > variable
~Interpreter()
Default destructor.
CopyState(rgt rn, vr s, cvr c, cvr p, cvr v, ci i, ci l, ci r)
AnalyticExpression(const bsp::symbols< NekDouble > *constants, const std::vector< std::string > &variables)
bsp_rule< operatorID> exponent
NekDouble m_total_eval_time
EvalAcos(rgt rn, vr s, cvr c, cvr p, cvr v, ci i, ci l, ci r)
EvalLog(rgt rn, vr s, cvr c, cvr p, cvr v, ci i, ci l, ci r)
Timer m_timer
Timer and sum of evaluation times.
EvalAtan(rgt rn, vr s, cvr c, cvr p, cvr v, ci i, ci l, ci r)
EvalLogicalLess(rgt rn, vr s, cvr c, cvr p, cvr v, ci i, ci l, ci r)
int DefineFunction(const std::string &vlist, const std::string &expr)
Defines a function for the purposes of evaluation.
void Evaluate(const int id, const Array< OneD, const NekDouble > &x, const Array< OneD, const NekDouble > &y, const Array< OneD, const NekDouble > &z, const Array< OneD, const NekDouble > &t, Array< OneD, NekDouble > &result)
Evaluate a function which depends only on constants and/or parameters.
std::pair< bool, NekDouble > PrecomputedValue
std::vector< NekDouble > & vr
Short names to minimise the infractructural code mess in defining functors below. ...
NekDouble Evaluate(const int id, const NekDouble x, const NekDouble y, const NekDouble z, const NekDouble t)
Evaluate a function which depends only on constants and/or parameters.
int m_state_size
This counter is used by PrepareExecutionAsYouParse for finding the minimal state size necessary for e...
Nektar::LibUtilities::functions functions_p
virtual void run_many(ci n)
declaring this guy pure virtual shortens virtual table. It saves some execution time.
std::map< std::string, int > ParameterMap
std::vector< VariableMap > m_stackVariableMap
Keeping map of variables individually per each analytic expression allows correctly handling expressi...
NekDouble Evaluate(const int id)
Evaluate a function which depends only on constants and/or parameters.
FunctionNameMap m_functionMapNameToInstanceType
EvalSinh(rgt rn, vr s, cvr c, cvr p, cvr v, ci i, ci l, ci r)
bsp::tree_parse_info< std::string::const_iterator, bsp::node_val_data_factory< NekDouble > > ParsedTreeInfo
EvalFloor(rgt rn, vr s, cvr c, cvr p, cvr v, ci i, ci l, ci r)
EvalSum(rgt rn, vr s, cvr c, cvr p, cvr v, ci i, ci l, ci r)
EvalLogicalLeq(rgt rn, vr s, cvr c, cvr p, cvr v, ci i, ci l, ci r)
std::map< std::string, int > FunctionNameMap
std::vector< NekDouble > m_variable
EvalSign(rgt rn, vr s, cvr c, cvr p, cvr v, ci i, ci l, ci r)
const bsp::symbols< NekDouble > * constants_p
EvaluationStep(rgt rn, ci i, ci l, ci r, vr s, cvr c, cvr p, cvr v)
virtual void run_many(ci n)
declaring this guy pure virtual shortens virtual table. It saves some execution time.
virtual void run_many(ci n)
declaring this guy pure virtual shortens virtual table. It saves some execution time.
virtual void run_many(ci n)
declaring this guy pure virtual shortens virtual table. It saves some execution time.
ParameterMap m_parameterMapNameToId
The following data structures hold input data to be used on evaluation stage. There are three types o...
virtual void run_many(ci n)
declaring this guy pure virtual shortens virtual table. It saves some execution time.
NekDouble GetTime() const
Returns the total walltime spent in evaluation procedures in seconds.
ExpressionEvaluator()
Initializes the evaluator.
EvalSqrt(rgt rn, vr s, cvr c, cvr p, cvr v, ci i, ci l, ci r)
Interpreter()
Default constructor.
virtual void run_many(ci n)
declaring this guy pure virtual shortens virtual table. It saves some execution time.
NekDouble GetParameter(std::string const &name)
Get the value of a parameter.
Interpreter & operator=(Interpreter &&)
Default assignment operator.
StoreConst(rgt rn, vr s, cvr c, cvr p, cvr v, ci i, ci l, ci r)
NekDouble sign(NekDouble arg)
PrecomputedValue PrepareExecutionAsYouParse(const ParsedTreeIterator &location, ExecutionStack &stack, VariableMap &variableMap, int stateIndex)
Prepares an execution stack for the evaluation of a function.
void Evaluate(const int id, const std::vector< Array< OneD, const NekDouble >> &points, Array< OneD, NekDouble > &result)
Evaluate a function which depends only on constants and/or parameters.
void SetParameters(std::map< std::string, NekDouble > const ¶ms)
Set parameter values.
bsp_rule< constantID > constant
EvalCosh(rgt rn, vr s, cvr c, cvr p, cvr v, ci i, ci l, ci r)
virtual void run_many(ci n)
declaring this guy pure virtual shortens virtual table. It saves some execution time.
EvalAsin(rgt rn, vr s, cvr c, cvr p, cvr v, ci i, ci l, ci r)
EvalLogicalGreater(rgt rn, vr s, cvr c, cvr p, cvr v, ci i, ci l, ci r)
void SetParameter(std::string const &name, NekDouble value)
Set parameter values.
virtual void run_many(ci n)
declaring this guy pure virtual shortens virtual table. It saves some execution time.
EvalCeil(rgt rn, vr s, cvr c, cvr p, cvr v, ci i, ci l, ci r)
Concrete implementation of the interface defined in Interpreter.
EvalTanh(rgt rn, vr s, cvr c, cvr p, cvr v, ci i, ci l, ci r)
bsp_rule< operatorID> logical_and
std::unique_ptr< ExpressionEvaluator > m_impl
Concrete implementation of the above API calls.
std::vector< const Array< OneD, const NekDouble > * > VariableArray
virtual void run_many(ci n)
declaring this guy pure virtual shortens virtual table. It saves some execution time.
VariableMap m_expressionVariableMap
std::map< int, TwoArgFunc > m_function2
bsp_rule< operatorID> exponential
virtual void run_many(ci n)
declaring this guy pure virtual shortens virtual table. It saves some execution time.
definition(AnalyticExpression const &self)
int AddConstant(std::string const &name, NekDouble value)
Set constants to be evaluated.
EvalSin(rgt rn, vr s, cvr c, cvr p, cvr v, ci i, ci l, ci r)
NekDouble awgn(NekDouble sigma)
bsp_rule< operatorID> lt_gt
void AddConstants(std::map< std::string, NekDouble > const &constants)
Set constants to be evaluated.
void negate(NekPoint< DataType > &rhs)
Function objects (functors)
virtual void run_many(ci n)
declaring this guy pure virtual shortens virtual table. It saves some execution time.
virtual void run_many(ci n)
declaring this guy pure virtual shortens virtual table. It saves some execution time.
EvalFabs(rgt rn, vr s, cvr c, cvr p, cvr v, ci i, ci l, ci r)
virtual void run_many(ci n)
declaring this guy pure virtual shortens virtual table. It saves some execution time.
bsp_rule< operatorID> equality
virtual void run_many(ci n)
declaring this guy pure virtual shortens virtual table. It saves some execution time.
virtual void run_many(ci n)
declaring this guy pure virtual shortens virtual table. It saves some execution time.
std::map< std::string, int > ExpressionMap
#define LIB_UTILITIES_EXPORT
virtual void run_many(ci n)
declaring this guy pure virtual shortens virtual table. It saves some execution time.
virtual ~EvaluationStep()
void AddConstants(std::map< std::string, NekDouble > const &constants)
Set constants to be evaluated.
bsp_rule< operatorID> base
void SetRandomSeed(unsigned int seed)
Sets the random seed for the pseudorandom number generator.
virtual void run_many(ci n)
declaring this guy pure virtual shortens virtual table. It saves some execution time.
const std::vector< NekDouble > & cvr
EvaluationStep * makeStep(ci dest, ci src_left=0, ci src_right=0)
Factory method which makes code little less messy.
EvalExp(rgt rn, vr s, cvr c, cvr p, cvr v, ci i, ci l, ci r)
std::vector< int > m_state_sizes
Vector of state sizes per each.
virtual void run_many(ci n)
declaring this guy pure virtual shortens virtual table. It saves some execution time.
bsp::tree_match< std::string::const_iterator, bsp::node_val_data_factory< NekDouble > >::tree_iterator ParsedTreeIterator
virtual void run_many(ci n)
declaring this guy pure virtual shortens virtual table. It saves some execution time.
NekDouble GetConstant(std::string const &name)
Return the value of a constant.
NekDouble(* PFD4)(NekDouble, NekDouble, NekDouble, NekDouble)
virtual void run_many(ci n)
declaring this guy pure virtual shortens virtual table. It saves some execution time.
virtual void run_many(ci n)
declaring this guy pure virtual shortens virtual table. It saves some execution time.
NekDouble GetTime() const
Returns the total walltime spent in evaluation procedures in seconds.
virtual void run_many(ci n)
declaring this guy pure virtual shortens virtual table. It saves some execution time.
void SetParameter(std::string const &name, NekDouble value)
Set parameter values.
virtual void run_many(ci n)
declaring this guy pure virtual shortens virtual table. It saves some execution time.
bsp::symbols< NekDouble > m_constantsParser
ci storeIdx
indices in the above arrays uniquely defining actual command arguments
StoreVar(rgt rn, vr s, cvr c, cvr p, cvr v, ci i, ci l, ci r)
EvalCos(rgt rn, vr s, cvr c, cvr p, cvr v, ci i, ci l, ci r)
void SetRandomSeed(unsigned int seed=123u)
Sets the random seed for the pseudorandom number generator.
EvalMul(rgt rn, vr s, cvr c, cvr p, cvr v, ci i, ci l, ci r)
std::vector< NekDouble > m_constant
~ExpressionEvaluator(void)
Destructor that removes all entries from the execution stack.
virtual void run_many(ci n)
declaring this guy pure virtual shortens virtual table. It saves some execution time.
EvalLog10(rgt rn, vr s, cvr c, cvr p, cvr v, ci i, ci l, ci r)
Interpreter class for the evaluation of mathematical expressions.
bsp::rule< ScannerT, bsp::parser_context<>, bsp::parser_tag< N > > bsp_rule
bg::model::point< double, 3, bg::cs::cartesian > point
virtual void run_many(ci n)
declaring this guy pure virtual shortens virtual table. It saves some execution time.
std::map< int, OneArgFunc > m_function
ExpressionMap m_parsedMapExprToExecStackId
These vector and map store pre-processed evaluation sequences for the analytic expressions. Each ExecutionStack is an ordered container of steps of sequential execution process which evaluates an analytic expression.
vr state
references to arrays holding the common state
std::vector< NekDouble > m_parameter
virtual void run_many(ci n)
declaring this guy pure virtual shortens virtual table. It saves some execution time.
static NekDouble rad(NekDouble x, NekDouble y)
void SetParameters(std::map< std::string, NekDouble > const ¶ms)
Set parameter values.
bsp_rule< unaryID > negate
std::vector< EvaluationStep * > ExecutionStack
std::vector< ExecutionStack > m_executionStack
int DefineFunction(const std::string &vlist, const std::string &expr)
Defines a function for the purposes of evaluation.
bsp_rule< operatorID> const & start() const
virtual void run_many(ci n)
declaring this guy pure virtual shortens virtual table. It saves some execution time.
NekDouble(* PFD1)(NekDouble)
StorePrm(rgt rn, vr s, cvr c, cvr p, cvr v, ci i, ci l, ci r)
bsp_rule< parameterID > parameter
EvalAbs(rgt rn, vr s, cvr c, cvr p, cvr v, ci i, ci l, ci r)
virtual void run_many(ci n)
declaring this guy pure virtual shortens virtual table. It saves some execution time.
std::map< std::string, int > VariableMap
NekDouble EvaluateAtPoint(const int id, std::vector< NekDouble > point)
Evaluate a function which depends on zero or more variables.
rgt rng
reference to random number generator
bsp_rule< numberID > number
EvalAtan2(rgt rn, vr s, cvr c, cvr p, cvr v, ci i, ci l, ci r)
virtual void run_many(ci n)
declaring this guy pure virtual shortens virtual table. It saves some execution time.
NekDouble GetParameter(std::string const &name)
Get the value of a parameter.
InputIterator find(InputIterator first, InputIterator last, InputIterator startingpoint, const EqualityComparable &value)
NekDouble Evaluate(const int id)
Evaluate a function which depends only on constants and/or parameters.
NekDouble GetConstant(std::string const &name)
Return the value of a constant.
EvalSub(rgt rn, vr s, cvr c, cvr p, cvr v, ci i, ci l, ci r)
virtual void run_many(ci n)
declaring this guy pure virtual shortens virtual table. It saves some execution time.
virtual void run_many(ci n)
declaring this guy pure virtual shortens virtual table. It saves some execution time.
virtual void run_many(ci n)
declaring this guy pure virtual shortens virtual table. It saves some execution time.
EvalLogicalEqual(rgt rn, vr s, cvr c, cvr p, cvr v, ci i, ci l, ci r)
NekDouble EvaluateAtPoint(const int id, const std::vector< NekDouble > point)
Evaluate a function which depends on zero or more variables.
std::vector< NekDouble > m_state
This vector stores the execution state (memory) used by the sequential execution process.
virtual void run_many(ci n)
declaring this guy pure virtual shortens virtual table. It saves some execution time.
bsp_rule< operatorID> mult_div
EvalRad(rgt rn, vr s, cvr c, cvr p, cvr v, ci i, ci l, ci r)
EvalBessel(rgt rn, vr s, cvr c, cvr p, cvr v, ci i, ci l, ci r)
#define ASSERTL1(condition, msg)
Assert Level 1 – Debugging which is used whether in FULLDEBUG or DEBUG compilation mode...
virtual void run_many(ci n)
declaring this guy pure virtual shortens virtual table. It saves some execution time.
ConstantMap m_constantMapNameToId
EvalNeg(rgt rn, vr s, cvr c, cvr p, cvr v, ci i, ci l, ci r)
virtual void run_many(ci n)
declaring this guy pure virtual shortens virtual table. It saves some execution time.
virtual void run_many(ci n)
declaring this guy pure virtual shortens virtual table. It saves some execution time.
EvalDiv(rgt rn, vr s, cvr c, cvr p, cvr v, ci i, ci l, ci r)
NekDouble(* PFD2)(NekDouble, NekDouble)
bsp_rule< operatorID> add_sub
EvalPow(rgt rn, vr s, cvr c, cvr p, cvr v, ci i, ci l, ci r)
int AddConstant(std::string const &name, NekDouble value)
Set constants to be evaluated.
bsp_rule< operatorID> expression