11 #ifndef PANZER_EXPR_EVAL_HPP
12 #define PANZER_EXPR_EVAL_HPP
20 #include <type_traits>
24 #include <Kokkos_Core.hpp>
72 using Function = std::function<void(std::string const& name, Teuchos::any&, std::vector<Teuchos::any>& rhs)>;
76 void set(std::string
const& name,
Function const& value);
81 T
const&
get(std::string
const& name)
const {
84 "EvalBase::get: \"" << name <<
"\" not found");
85 return Teuchos::any_ref_cast<T>(it->second);
133 template <
typename DataType,
typename NewScalarType>
139 template <
typename NestedDataType,
typename NewScalarType>
144 template <
typename NestedDataType,
typename NewScalarType>
149 template <
typename NestedDataType,
typename NewScalarType,
size_t N>
155 template <
typename ViewType,
typename NewScalarType>
158 template <
typename DT,
typename NewScalarType,
typename ... VP>
196 template <
typename DT,
typename ... VP>
209 using scalar_type =
typename original_view_type::non_const_value_type;
244 void set(std::string
const& name,
bool value);
285 template <
typename DT,
typename ... VP>
290 #endif // PANZER_EXPR_EVAL_HPP
void many_many_binary_op(BinaryOpCode code, Teuchos::any &result, Teuchos::any &left, Teuchos::any &right) override
Base class for panzer::Expr::Eval, does everything that is independent of the Kokkos::View template p...
void make_constant(Teuchos::any &result, double const &value) override
virtual void many_many_binary_op(BinaryOpCode code, Teuchos::any &result, Teuchos::any &left, Teuchos::any &right)=0
void set(std::string const &name, bool value)
Assign a boolean value to a variable symbol.
Rebinds a Kokkos::View data type to use a new scalar type.
virtual void make_constant(Teuchos::any &result, double const &value)=0
BinaryOpCode
Denotes the native binary operators in the Teuchos::MathExpr language.
void single_many_ternary_op(Teuchos::any &result, Teuchos::any &cond, Teuchos::any &left, Teuchos::any &right) override
virtual void many_many_ternary_op(Teuchos::any &result, Teuchos::any &cond, Teuchos::any &left, Teuchos::any &right)=0
#define TEUCHOS_TEST_FOR_EXCEPTION(throw_exception_test, Exception, msg)
virtual void single_single_ternary_op(Teuchos::any &result, Teuchos::any &cond, Teuchos::any &left, Teuchos::any &right)=0
std::function< void(std::string const &name, Teuchos::any &, std::vector< Teuchos::any > &rhs)> Function
The type of user-defined functions which are callable in the math language.
virtual void many_neg_op(Teuchos::any &result, Teuchos::any &right)=0
typename RebindDataType< NestedDataType, NewScalarType >::type * type
typename RebindDataType< NestedDataType, NewScalarType >::type[] type
virtual void inspect_arg(Teuchos::any const &arg, bool &is_many, bool &is_bool)=0
void ternary_op(Teuchos::any &result, Teuchos::any &cond, Teuchos::any &left, Teuchos::any &right)
Executes the ternary operator, e.g. (a > b) ? a : b.
void single_neg_op(Teuchos::any &result, Teuchos::any &right) override
void at_reduce(Teuchos::any &result, int prod, std::vector< Teuchos::any > &rhs) override
Called at every reduced production in the math language.
void binary_op(BinaryOpCode code, Teuchos::any &result, Teuchos::any &left, Teuchos::any &right)
Executes a binary operator.
void set(std::string const &name, Function const &value)
Registers an EvalBase::Function, binding it to a name and making it callable.
PHX::MDField< ScalarT, panzer::Cell, panzer::IP > result
A field that will be used to build up the result of the integral we're performing.
virtual void single_single_binary_op(BinaryOpCode code, Teuchos::any &result, Teuchos::any &left, Teuchos::any &right)=0
void single_many_binary_op(BinaryOpCode code, Teuchos::any &result, Teuchos::any &left, Teuchos::any &right) override
void inspect_arg(Teuchos::any const &arg, bool &is_many, bool &is_bool) override
typename original_view_type::non_const_value_type scalar_type
The scalar type.
void many_many_ternary_op(Teuchos::any &result, Teuchos::any &cond, Teuchos::any &left, Teuchos::any &right) override
typename RebindDataType< NestedDataType, NewScalarType >::type[N] type
virtual void many_single_ternary_op(Teuchos::any &result, Teuchos::any &cond, Teuchos::any &left, Teuchos::any &right)=0
std::map< std::string, Teuchos::any > symbol_map
Stores all current symbols including variables and functions.
virtual void single_neg_op(Teuchos::any &result, Teuchos::any &right)=0
Builds on RebindDataType, but acts directly on a Kokkos::View type.
Interprets mathematical expressions in a string and evaluates them using Kokkos::View objects as valu...
virtual void single_many_binary_op(BinaryOpCode code, Teuchos::any &result, Teuchos::any &left, Teuchos::any &right)=0
void many_neg_op(Teuchos::any &result, Teuchos::any &right) override
void neg_op(Teuchos::any &result, Teuchos::any &right)
Executes the only native unary operator in the math language, numeric negation via a minus sign...
void many_single_ternary_op(Teuchos::any &result, Teuchos::any &cond, Teuchos::any &left, Teuchos::any &right) override
void at_shift(Teuchos::any &result, int token, std::string &text) override
Called at every parsed token in the math language.
NewScalarType type
The new data type, suitable as the first template argument to Kokkos::View.
virtual void many_single_binary_op(BinaryOpCode code, Teuchos::any &result, Teuchos::any &left, Teuchos::any &right)=0
DT view_data_type
The data type, including dimension information.
void single_single_ternary_op(Teuchos::any &result, Teuchos::any &cond, Teuchos::any &left, Teuchos::any &right) override
void single_single_binary_op(BinaryOpCode code, Teuchos::any &result, Teuchos::any &left, Teuchos::any &right) override
virtual void single_many_ternary_op(Teuchos::any &result, Teuchos::any &cond, Teuchos::any &left, Teuchos::any &right)=0
void set_cmath_functions(Eval< DT, VP...> &eval)
Add support for functions such as sqrt(), sin(), and cos()
void many_single_binary_op(BinaryOpCode code, Teuchos::any &result, Teuchos::any &left, Teuchos::any &right) override