36 #ifndef _ANALYTIC_EXPRESSION_EVALUATOR_HPP
37 #define _ANALYTIC_EXPRESSION_EVALUATOR_HPP
43 #include <boost/version.hpp>
44 #include <boost/random/mersenne_twister.hpp>
45 #include <boost/random/variate_generator.hpp>
46 #include <boost/random/normal_distribution.hpp>
48 #if( BOOST_VERSION / 100 % 1000 >= 36 )
49 #include <boost/spirit/include/classic_core.hpp>
50 #include <boost/spirit/include/classic_ast.hpp>
51 #include <boost/spirit/include/classic_symbols.hpp>
52 #include <boost/spirit/include/classic_assign_actor.hpp>
53 #include <boost/spirit/include/classic_push_back_actor.hpp>
55 namespace boost_spirit = boost::spirit::classic;
57 #include <boost/spirit/core.hpp>
58 #include <boost/spirit/tree/ast.hpp>
59 #include <boost/spirit/symbols/symbols.hpp>
60 #include <boost/spirit/actor/assign_actor.hpp>
61 #include <boost/spirit/actor/push_back_actor.hpp>
63 namespace boost_spirit = boost::spirit;
69 #if defined(__INTEL_COMPILER)
77 namespace LibUtilities
81 if (x != 0. || y != 0.)
82 return sqrt (x*x + y*y);
90 if ((x != 0.) || (y != 0.))
131 typedef boost_spirit::tree_parse_info<
132 std::string::const_iterator,
133 boost_spirit::node_val_data_factory<NekDouble>
135 typedef boost_spirit::tree_match<
136 std::string::const_iterator,
137 boost_spirit::node_val_data_factory<NekDouble>
227 const int AnalyticExpression_id,
238 const int AnalyticExpression_id,
239 std::vector<NekDouble> point);
243 const int expression_id,
244 const Array<OneD, const NekDouble>&,
245 const Array<OneD, const NekDouble>&,
246 const Array<OneD, const NekDouble>&,
247 const Array<OneD, const NekDouble>&,
248 Array<OneD, NekDouble>& result);
255 const int expression_id,
256 const std::vector<Array<OneD, const NekDouble> > points,
257 Array<OneD, NekDouble>& result);
325 for (std::vector<std::string>::const_iterator it = vars.begin(); it != vars.end(); it++)
351 template <
typename ScannerT>
360 boost_spirit::rule<ScannerT, boost_spirit::parser_context<>, boost_spirit::parser_tag<constantID> >
constant;
361 boost_spirit::rule<ScannerT, boost_spirit::parser_context<>, boost_spirit::parser_tag<numberID> >
number;
362 boost_spirit::rule<ScannerT, boost_spirit::parser_context<>, boost_spirit::parser_tag<variableID> >
variable;
363 boost_spirit::rule<ScannerT, boost_spirit::parser_context<>, boost_spirit::parser_tag<parameterID> >
parameter;
364 boost_spirit::rule<ScannerT, boost_spirit::parser_context<>, boost_spirit::parser_tag<functionID> >
function;
365 boost_spirit::rule<ScannerT, boost_spirit::parser_context<>, boost_spirit::parser_tag<factorID> >
factor;
366 boost_spirit::rule<ScannerT, boost_spirit::parser_context<>, boost_spirit::parser_tag<operatorID> >
exponential;
367 boost_spirit::rule<ScannerT, boost_spirit::parser_context<>, boost_spirit::parser_tag<operatorID> >
mult_div;
368 boost_spirit::rule<ScannerT, boost_spirit::parser_context<>, boost_spirit::parser_tag<operatorID> >
add_sub;
369 boost_spirit::rule<ScannerT, boost_spirit::parser_context<>, boost_spirit::parser_tag<operatorID> >
lt_gt;
370 boost_spirit::rule<ScannerT, boost_spirit::parser_context<>, boost_spirit::parser_tag<operatorID> >
equality;
371 boost_spirit::rule<ScannerT, boost_spirit::parser_context<>, boost_spirit::parser_tag<operatorID> >
logical_and;
372 boost_spirit::rule<ScannerT, boost_spirit::parser_context<>, boost_spirit::parser_tag<operatorID> >
logical_or;
373 boost_spirit::rule<ScannerT, boost_spirit::parser_context<>, boost_spirit::parser_tag<operatorID> >
expression;
374 boost_spirit::rule<ScannerT, boost_spirit::parser_context<>, boost_spirit::parser_tag<operatorID> >
op;
376 boost_spirit::rule<ScannerT, boost_spirit::parser_context<>, boost_spirit::parser_tag<operatorID> >
const&
465 typedef std::vector<NekDouble>&
vr;
466 typedef const std::vector<NekDouble>&
cvr;
467 typedef const int ci;
471 template<
typename StepType>
515 CopyState(
rgt rn,
vr s,
cvr c,
cvr p,
cvr v,
ci i,
ci l,
ci r):
EvaluationStep(rn,i,l,r,s,c,p,v) {}
521 StoreConst(
rgt rn,
vr s,
cvr c,
cvr p,
cvr v,
ci i,
ci l,
ci r):
EvaluationStep(rn,i,l,r,s,c,p,v) {}
527 StoreVar(
rgt rn,
vr s,
cvr c,
cvr p,
cvr v,
ci i,
ci l,
ci r):
EvaluationStep(rn,i,l,r,s,c,p,v) {}
533 StorePrm(
rgt rn,
vr s,
cvr c,
cvr p,
cvr v,
ci i,
ci l,
ci r):
EvaluationStep(rn,i,l,r,s,c,p,v) {}
539 EvalSum(
rgt rn,
vr s,
cvr c,
cvr p,
cvr v,
ci i,
ci l,
ci r):
EvaluationStep(rn,i,l,r,s,c,p,v) {}
545 EvalSub(
rgt rn,
vr s,
cvr c,
cvr p,
cvr v,
ci i,
ci l,
ci r):
EvaluationStep(rn,i,l,r,s,c,p,v) {}
551 EvalMul(
rgt rn,
vr s,
cvr c,
cvr p,
cvr v,
ci i,
ci l,
ci r):
EvaluationStep(rn,i,l,r,s,c,p,v) {}
557 EvalDiv(
rgt rn,
vr s,
cvr c,
cvr p,
cvr v,
ci i,
ci l,
ci r):
EvaluationStep(rn,i,l,r,s,c,p,v) {}
563 EvalPow(
rgt rn,
vr s,
cvr c,
cvr p,
cvr v,
ci i,
ci l,
ci r):
EvaluationStep(rn,i,l,r,s,c,p,v) {}
569 EvalNeg(
rgt rn,
vr s,
cvr c,
cvr p,
cvr v,
ci i,
ci l,
ci r):
EvaluationStep(rn,i,l,r,s,c,p,v) {}
575 EvalLogicalEqual(
rgt rn,
vr s,
cvr c,
cvr p,
cvr v,
ci i,
ci l,
ci r):
EvaluationStep(rn,i,l,r,s,c,p,v) {}
581 EvalLogicalLeq(
rgt rn,
vr s,
cvr c,
cvr p,
cvr v,
ci i,
ci l,
ci r):
EvaluationStep(rn,i,l,r,s,c,p,v) {}
587 EvalLogicalLess(
rgt rn,
vr s,
cvr c,
cvr p,
cvr v,
ci i,
ci l,
ci r):
EvaluationStep(rn,i,l,r,s,c,p,v) {}
593 EvalLogicalGeq(
rgt rn,
vr s,
cvr c,
cvr p,
cvr v,
ci i,
ci l,
ci r):
EvaluationStep(rn,i,l,r,s,c,p,v) {}
599 EvalLogicalGreater(
rgt rn,
vr s,
cvr c,
cvr p,
cvr v,
ci i,
ci l,
ci r):
EvaluationStep(rn,i,l,r,s,c,p,v) {}
605 EvalAbs(
rgt rn,
vr s,
cvr c,
cvr p,
cvr v,
ci i,
ci l,
ci r):
EvaluationStep(rn,i,l,r,s,c,p,v) {}
611 EvalSign(
rgt rn,
vr s,
cvr c,
cvr p,
cvr v,
ci i,
ci l,
ci r):
EvaluationStep(rn,i,l,r,s,c,p,v) {}
612 virtual void run_many(
ci n) {
for(
int i=0;i<n;i++) state[storeIdx*n+i] = ((state[argIdx1*n+i] > 0.0) - (
state[
argIdx1*n+i] < 0.0)); }
617 EvalAsin(
rgt rn,
vr s,
cvr c,
cvr p,
cvr v,
ci i,
ci l,
ci r):
EvaluationStep(rn,i,l,r,s,c,p,v) {}
623 EvalAcos(
rgt rn,
vr s,
cvr c,
cvr p,
cvr v,
ci i,
ci l,
ci r):
EvaluationStep(rn,i,l,r,s,c,p,v) {}
629 EvalAtan(
rgt rn,
vr s,
cvr c,
cvr p,
cvr v,
ci i,
ci l,
ci r):
EvaluationStep(rn,i,l,r,s,c,p,v) {}
635 EvalAtan2(
rgt rn,
vr s,
cvr c,
cvr p,
cvr v,
ci i,
ci l,
ci r):
EvaluationStep(rn,i,l,r,s,c,p,v) {}
641 EvalAng(
rgt rn,
vr s,
cvr c,
cvr p,
cvr v,
ci i,
ci l,
ci r):
EvaluationStep(rn,i,l,r,s,c,p,v) {}
647 EvalCeil(
rgt rn,
vr s,
cvr c,
cvr p,
cvr v,
ci i,
ci l,
ci r):
EvaluationStep(rn,i,l,r,s,c,p,v) {}
653 EvalCos(
rgt rn,
vr s,
cvr c,
cvr p,
cvr v,
ci i,
ci l,
ci r):
EvaluationStep(rn,i,l,r,s,c,p,v) {}
659 EvalCosh(
rgt rn,
vr s,
cvr c,
cvr p,
cvr v,
ci i,
ci l,
ci r):
EvaluationStep(rn,i,l,r,s,c,p,v) {}
665 EvalExp(
rgt rn,
vr s,
cvr c,
cvr p,
cvr v,
ci i,
ci l,
ci r):
EvaluationStep(rn,i,l,r,s,c,p,v) {}
671 EvalFabs(
rgt rn,
vr s,
cvr c,
cvr p,
cvr v,
ci i,
ci l,
ci r):
EvaluationStep(rn,i,l,r,s,c,p,v) {}
677 EvalFloor(
rgt rn,
vr s,
cvr c,
cvr p,
cvr v,
ci i,
ci l,
ci r):
EvaluationStep(rn,i,l,r,s,c,p,v) {}
683 EvalLog(
rgt rn,
vr s,
cvr c,
cvr p,
cvr v,
ci i,
ci l,
ci r):
EvaluationStep(rn,i,l,r,s,c,p,v) {}
689 EvalLog10(
rgt rn,
vr s,
cvr c,
cvr p,
cvr v,
ci i,
ci l,
ci r):
EvaluationStep(rn,i,l,r,s,c,p,v) {}
695 EvalRad(
rgt rn,
vr s,
cvr c,
cvr p,
cvr v,
ci i,
ci l,
ci r):
EvaluationStep(rn,i,l,r,s,c,p,v) {}
701 EvalSin(
rgt rn,
vr s,
cvr c,
cvr p,
cvr v,
ci i,
ci l,
ci r):
EvaluationStep(rn,i,l,r,s,c,p,v) {}
707 EvalSinh(
rgt rn,
vr s,
cvr c,
cvr p,
cvr v,
ci i,
ci l,
ci r):
EvaluationStep(rn,i,l,r,s,c,p,v) {}
713 EvalSqrt(
rgt rn,
vr s,
cvr c,
cvr p,
cvr v,
ci i,
ci l,
ci r):
EvaluationStep(rn,i,l,r,s,c,p,v) {}
719 EvalTan(
rgt rn,
vr s,
cvr c,
cvr p,
cvr v,
ci i,
ci l,
ci r):
EvaluationStep(rn,i,l,r,s,c,p,v) {}
725 EvalTanh(
rgt rn,
vr s,
cvr c,
cvr p,
cvr v,
ci i,
ci l,
ci r):
EvaluationStep(rn,i,l,r,s,c,p,v) {}
731 EvalAWGN(
rgt rn,
vr s,
cvr c,
cvr p,
cvr v,
ci i,
ci l,
ci r):
EvaluationStep(rn,i,l,r,s,c,p,v) {}
735 boost::variate_generator<RandomGeneratorType&, boost::normal_distribution<> >
741 boost::variate_generator<RandomGeneratorType&, boost::normal_distribution<> >
751 #endif // _ANALYTIC_EXPRESSION_EVALUATOR_HPP