43 #ifndef PANZER_EXPR_EVAL_IMPL_HPP 
   44 #define PANZER_EXPR_EVAL_IMPL_HPP 
   58   static KOKKOS_FORCEINLINE_FUNCTION
 
   59   T 
apply(
bool cond, T 
const& left, T 
const& right) {
 
   60     return cond ? left : right;
 
   65   static KOKKOS_FORCEINLINE_FUNCTION
 
   66   bool apply(
bool left, 
bool right) {
 
   72   static KOKKOS_FORCEINLINE_FUNCTION
 
   73   bool apply(
bool left, 
bool right) {
 
   80   static KOKKOS_FORCEINLINE_FUNCTION
 
   81   bool apply(T 
const& left, T 
const& right) {
 
   88   static KOKKOS_FORCEINLINE_FUNCTION
 
   89   bool apply(T 
const& left, T 
const& right) {
 
   96   static KOKKOS_FORCEINLINE_FUNCTION
 
   97   bool apply(T 
const& left, T 
const& right) {
 
  103   template <
typename T>
 
  104   static KOKKOS_FORCEINLINE_FUNCTION
 
  105   bool apply(T 
const& left, T 
const& right) {
 
  106     return left <= right;
 
  111   template <
typename T>
 
  112   static KOKKOS_FORCEINLINE_FUNCTION
 
  113   bool apply(T 
const& left, T 
const& right) {
 
  114     return left == right;
 
  119   template <
typename T>
 
  120   static KOKKOS_FORCEINLINE_FUNCTION
 
  121   T 
apply(T 
const& left, T 
const& right) {
 
  127   template <
typename T>
 
  128   static KOKKOS_FORCEINLINE_FUNCTION
 
  129   T 
apply(T 
const& left, T 
const& right) {
 
  135   template <
typename T>
 
  136   static KOKKOS_FORCEINLINE_FUNCTION
 
  137   T 
apply(T 
const& left, T 
const& right) {
 
  143   template <
typename T>
 
  144   static KOKKOS_FORCEINLINE_FUNCTION
 
  145   T 
apply(T 
const& left, T 
const& right) {
 
  151   template <
typename T>
 
  152   static KOKKOS_FORCEINLINE_FUNCTION
 
  153   T 
apply(T 
const& left, T 
const& right) {
 
  155     return pow(left, right);
 
  160   template <
typename T>
 
  161   static KOKKOS_FORCEINLINE_FUNCTION
 
  168 template <
typename Indexed, 
size_t IterationRank, 
size_t IndexedRank = Indexed::rank>
 
  171 template <
typename ViewType>
 
  173   template <
typename Integral>
 
  174   static KOKKOS_FORCEINLINE_FUNCTION
 
  175   typename ViewType::reference_type 
index(ViewType 
const& x, Integral) { 
return x(); }
 
  178 template <
typename ViewType>
 
  180   template <
typename Integral>
 
  181   static KOKKOS_FORCEINLINE_FUNCTION
 
  182   typename ViewType::reference_type 
index(ViewType 
const& x, Integral i) { 
return x(i); }
 
  185 template <
typename ViewType>
 
  187   template <
typename Integral>
 
  188   static KOKKOS_FORCEINLINE_FUNCTION
 
  189   typename ViewType::reference_type 
index(ViewType 
const& x, Integral, Integral) { 
return x(); }
 
  192 template <
typename ViewType>
 
  194   template <
typename Integral>
 
  195   static KOKKOS_FORCEINLINE_FUNCTION
 
  196   typename ViewType::reference_type 
index(ViewType 
const& x, Integral i, Integral) { 
return x(i); }
 
  199 template <
typename ViewType>
 
  201   template <
typename Integral>
 
  202   static KOKKOS_FORCEINLINE_FUNCTION
 
  203   typename ViewType::reference_type 
index(ViewType 
const& x, Integral i, Integral j) { 
return x(i, j); }
 
  207 template <
typename T, 
typename ... TS>
 
  210 template <
typename T>
 
  212   static constexpr 
size_t value = T::rank;
 
  215 template <
typename T, 
typename ... TS>
 
  222 template <
typename A, 
typename B>
 
  224   static constexpr 
size_t a_rank = A::rank;
 
  225   static constexpr 
size_t b_rank = B::rank;
 
  231 template <
typename C, 
typename A, 
typename B>
 
  233   static constexpr 
size_t a_rank = A::rank;
 
  234   static constexpr 
size_t b_rank = B::rank;
 
  235   static constexpr 
size_t c_rank = C::rank;
 
  242 template <
typename Op, 
typename Result, 
typename Left, 
typename Right, 
size_t Rank = Result::rank>
 
  245 template <
typename Op, 
typename Result, 
typename Left, 
typename Right>
 
  252   KOKKOS_INLINE_FUNCTION
 
  254     result_() = Op::apply(left_(), right_());
 
  257     left_ = Teuchos::any_cast<Left>(left);
 
  258     right_ = Teuchos::any_cast<Right>(right);
 
  259     result_ = 
NonConstResult(Kokkos::ViewAllocateWithoutInitializing(name));
 
  260     Kokkos::parallel_for(name, Kokkos::RangePolicy<execution_space>(0, 1), *
this);
 
  261     result = Result(result_);
 
  265 template <
typename Op, 
typename Result, 
typename Left, 
typename Right>
 
  272   KOKKOS_INLINE_FUNCTION
 
  273   void operator()(
typename execution_space::size_type i)
 const {
 
  280     left_ = Teuchos::any_cast<Left>(left);
 
  281     right_ = Teuchos::any_cast<Right>(right);
 
  282     auto extent_0 = std::max(left_.extent(0), right_.extent(0));
 
  283     result_ = 
NonConstResult(Kokkos::ViewAllocateWithoutInitializing(name), extent_0);
 
  284     Kokkos::parallel_for(name, Kokkos::RangePolicy<execution_space>(0, extent_0), *
this);
 
  285     result = Result{result_};
 
  289 template <
typename Op, 
typename Result, 
typename Left, 
typename Right>
 
  296   KOKKOS_INLINE_FUNCTION
 
  297   void operator()(
typename execution_space::size_type i, 
typename execution_space::size_type j)
 const {
 
  304     left_ = Teuchos::any_cast<Left>(left);
 
  305     right_ = Teuchos::any_cast<Right>(right);
 
  306     auto extent_0 = std::max(left_.extent(0), right_.extent(0));
 
  307     auto extent_1 = std::max(left_.extent(1), right_.extent(1));
 
  308     result_ = 
NonConstResult(Kokkos::ViewAllocateWithoutInitializing(name), extent_0, extent_1);
 
  309     using policy_type = Kokkos::MDRangePolicy<execution_space, Kokkos::Rank<2>>;
 
  310     Kokkos::parallel_for(name, policy_type({0, 0}, {extent_0, extent_1}), *
this);
 
  311     result = Result{result_};
 
  315 template <typename Cond, typename Left, typename Right, size_t Rank = MaxRank<Cond, Left, Right>::value>
 
  318 template <
typename Cond, 
typename Left, 
typename Right>
 
  327   KOKKOS_INLINE_FUNCTION
 
  328   void operator()(
typename execution_space::size_type i)
 const {
 
  335     cond_ = Teuchos::any_cast<Cond>(cond);
 
  336     left_ = Teuchos::any_cast<Left>(left);
 
  337     right_ = Teuchos::any_cast<Right>(right);
 
  339       std::max(cond_.extent(0),
 
  340         std::max(left_.extent(0), right_.extent(0)));
 
  341     result_ = 
NonConstResult(Kokkos::ViewAllocateWithoutInitializing(name), extent_0);
 
  342     Kokkos::parallel_for(name, Kokkos::RangePolicy<execution_space>(0, extent_0), *
this);
 
  347 template <
typename Cond, 
typename Left, 
typename Right>
 
  356   KOKKOS_INLINE_FUNCTION
 
  357   void operator()(
typename execution_space::size_type i, 
typename execution_space::size_type j)
 const {
 
  364     cond_ = Teuchos::any_cast<Cond>(cond);
 
  365     left_ = Teuchos::any_cast<Left>(left);
 
  366     right_ = Teuchos::any_cast<Right>(right);
 
  368       std::max(cond_.extent(0),
 
  369         std::max(left_.extent(0), right_.extent(0)));
 
  371       std::max(cond_.extent(1),
 
  372         std::max(left_.extent(1), right_.extent(1)));
 
  373     result_ = 
NonConstResult(Kokkos::ViewAllocateWithoutInitializing(name), extent_0, extent_1);
 
  374     using policy_type = Kokkos::MDRangePolicy<execution_space, Kokkos::Rank<2>>;
 
  375     Kokkos::parallel_for(name, policy_type({0, 0}, {extent_0, extent_1}), *
this);
 
  380 template <
typename DT, 
typename ... VP>
 
  386 template <
typename DT, 
typename ... VP>
 
  389   auto host_view = Kokkos::create_mirror_view(view);
 
  391   Kokkos::deep_copy(view, host_view);
 
  395 template <
typename DT, 
typename ... VP>
 
  398   auto host_view = Kokkos::create_mirror_view(view);
 
  400   Kokkos::deep_copy(view, host_view);
 
  403   this->inspect_arg(symbol_map[name], a, b);
 
  406 template <
typename DT, 
typename ... VP>
 
  408   symbol_map[name] = value;
 
  411 template <
typename DT, 
typename ... VP>
 
  414   auto host_view = Kokkos::create_mirror_view(view);
 
  416   Kokkos::deep_copy(view, host_view);
 
  419   this->inspect_arg(result, a, b);
 
  422 template <
typename DT, 
typename ... VP>
 
  438         "value is of illegal type " << arg.
typeName() << 
", view type is " 
  443 template <
typename DT, 
typename ... VP>
 
  450 template <
typename DT, 
typename ... VP>
 
  458 template <
typename DT, 
typename ... VP>
 
  466 template <
typename DT, 
typename ... VP>
 
  473 template <
typename DT, 
typename ... VP>
 
  493 template <
typename DT, 
typename ... VP>
 
  515 template <
typename DT, 
typename ... VP>
 
  537 template <
typename DT, 
typename ... VP>
 
  557 template <
typename Op, 
typename Result, 
size_t Rank = Result::rank>
 
  560 template <
typename Op, 
typename Result>
 
  566   KOKKOS_INLINE_FUNCTION
 
  567   void operator()(
typename execution_space::size_type i)
 const {
 
  568     result_() = Op::apply(right_());
 
  571     right_ = Teuchos::any_cast<Result>(right);
 
  572     result_ = 
NonConstResult(Kokkos::ViewAllocateWithoutInitializing(name));
 
  573     Kokkos::parallel_for(name, Kokkos::RangePolicy<execution_space>(0, 1), *
this);
 
  574     result = Result(result_);
 
  578 template <
typename Op, 
typename Result>
 
  584   KOKKOS_INLINE_FUNCTION
 
  585   void operator()(
typename execution_space::size_type i)
 const {
 
  586     result_(i) = Op::apply(right_(i));
 
  589     right_ = Teuchos::any_cast<Result>(right);
 
  590     auto extent_0 = right_.extent(0);
 
  591     result_ = 
NonConstResult(Kokkos::ViewAllocateWithoutInitializing(name), extent_0);
 
  592     Kokkos::parallel_for(name, Kokkos::RangePolicy<execution_space>(0, extent_0), *
this);
 
  593     result = Result(result_);
 
  597 template <
typename Op, 
typename Result>
 
  603   KOKKOS_INLINE_FUNCTION
 
  604   void operator()(
typename execution_space::size_type i, 
typename execution_space::size_type j)
 const {
 
  605     result_(i, j) = Op::apply(right_(i, j));
 
  608     right_ = Teuchos::any_cast<Result>(right);
 
  609     auto extent_0 = right_.extent(0);
 
  610     auto extent_1 = right_.extent(1);
 
  611     result_ = 
NonConstResult(Kokkos::ViewAllocateWithoutInitializing(name), extent_0, extent_1);
 
  612     using policy_type = Kokkos::MDRangePolicy<execution_space, Kokkos::Rank<2>>;
 
  613     Kokkos::parallel_for(name, policy_type({0, 0}, {extent_0, extent_1}), *
this);
 
  614     result = Result(result_);
 
  618 template <
typename DT, 
typename ... VP>
 
  623 template <
typename DT, 
typename ... VP>
 
  629   template <
typename T>
 
  630   static KOKKOS_FORCEINLINE_FUNCTION
 
  638   template <
typename T>
 
  639   static KOKKOS_FORCEINLINE_FUNCTION
 
  647   template <
typename T>
 
  648   static KOKKOS_FORCEINLINE_FUNCTION
 
  656   template <
typename T>
 
  657   static KOKKOS_FORCEINLINE_FUNCTION
 
  665   template <
typename T>
 
  666   static KOKKOS_FORCEINLINE_FUNCTION
 
  674   template <
typename T>
 
  675   static KOKKOS_FORCEINLINE_FUNCTION
 
  683   template <
typename T>
 
  684   static KOKKOS_FORCEINLINE_FUNCTION
 
  691 template <
typename Op, 
typename EvalType>
 
  694     auto& right = rhs.at(0);
 
  695     using single_type = 
typename EvalType::const_single_view_type;
 
  696     using many_type = 
typename EvalType::const_view_type;
 
  697     if (right.type() == 
typeid(single_type)) {
 
  699     } 
else if (right.type() == 
typeid(many_type)) {
 
  703           "Unexpected type " << right.typeName() << 
" passed to UnaryFunction \"" << name << 
"\"\n");
 
  708 template <
typename DT, 
typename ... VP>
 
  710   using eval_type = 
Eval<DT, VP ...>;
 
  723 #endif // PANZER_EXPR_EVAL_IMPL_HPP 
typename RebindViewType< Result, typename Result::non_const_value_type >::type NonConstResult
 
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
 
Kokkos::View< scalar_type const, VP...> const_single_view_type
One scalar (same for all evaluation points), read-only. 
 
Kokkos::View< typename RebindDataType< view_data_type, scalar_type const  >::type, VP...> const_view_type
One scalar for each evaluation point, read-only. 
 
void set(std::string const &name, bool value)
Assign a boolean value to a variable symbol. 
 
static KOKKOS_FORCEINLINE_FUNCTION bool apply(T const &left, T const &right)
 
typename RebindViewType< biggest_type, typename biggest_type::const_value_type >::type const_type
 
typename RebindViewType< Result, typename Result::non_const_value_type >::type NonConstResult
 
static KOKKOS_FORCEINLINE_FUNCTION T apply(T const &right)
 
BinaryOpCode
Denotes the native binary operators in the Teuchos::MathExpr language. 
 
UnaryFunctor(std::string const &name, Teuchos::any &result, Teuchos::any &right)
 
typename Result::execution_space execution_space
 
void single_many_ternary_op(Teuchos::any &result, Teuchos::any &cond, Teuchos::any &left, Teuchos::any &right) override
 
static KOKKOS_FORCEINLINE_FUNCTION T apply(T const &left, T const &right)
 
#define TEUCHOS_TEST_FOR_EXCEPTION(throw_exception_test, Exception, msg)
 
typename RebindViewType< Result, typename Result::non_const_value_type >::type NonConstResult
 
BinaryFunctor(std::string const &name, Teuchos::any &result, Teuchos::any &left, Teuchos::any &right)
 
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. 
 
static KOKKOS_FORCEINLINE_FUNCTION T apply(T const &right)
 
static KOKKOS_FORCEINLINE_FUNCTION T apply(T const &left, T const &right)
 
static KOKKOS_FORCEINLINE_FUNCTION T apply(T const &right)
 
typename RebindViewType< Result, typename Result::non_const_value_type >::type NonConstResult
 
static KOKKOS_FORCEINLINE_FUNCTION ViewType::reference_type index(ViewType const &x, Integral, Integral)
 
KOKKOS_INLINE_FUNCTION void operator()(typename execution_space::size_type i, typename execution_space::size_type j) const 
 
typename std::conditional<(b_rank > a_rank), Right, Left >::type biggest_ab_type
 
static constexpr size_t c_rank
 
typename TernaryResultType< Cond, Left, Right >::non_const_type NonConstResult
 
void single_neg_op(Teuchos::any &result, Teuchos::any &right) override
 
UnaryFunctor(std::string const &name, Teuchos::any &result, Teuchos::any &right)
 
typename Result::execution_space execution_space
 
KOKKOS_INLINE_FUNCTION void operator()(typename execution_space::size_type i) const 
 
TernaryFunctor(std::string const &name, Teuchos::any &result, Teuchos::any &cond, Teuchos::any &left, Teuchos::any &right)
 
Kokkos::View< bool const, VP...> const_single_bool_view_type
One boolean (same for all evaluation points), read-only. 
 
static KOKKOS_FORCEINLINE_FUNCTION bool apply(T const &left, T const &right)
 
static constexpr size_t b_rank
 
void set(std::string const &name, Function const &value)
Registers an EvalBase::Function, binding it to a name and making it callable. 
 
Kokkos::View< typename RebindDataType< view_data_type, bool const  >::type, VP...> const_bool_view_type
One boolean for each evaluation point, read-only. 
 
Declares the panzer::Expr::Eval templated class. 
 
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. 
 
static KOKKOS_FORCEINLINE_FUNCTION bool apply(T const &left, T const &right)
 
static KOKKOS_FORCEINLINE_FUNCTION ViewType::reference_type index(ViewType const &x, Integral i, Integral)
 
static KOKKOS_FORCEINLINE_FUNCTION bool apply(T const &left, T const &right)
 
static KOKKOS_FORCEINLINE_FUNCTION T apply(bool cond, T const &left, T const &right)
 
typename Result::execution_space execution_space
 
static constexpr size_t left_value
 
typename Result::execution_space execution_space
 
static KOKKOS_FORCEINLINE_FUNCTION T apply(T const &right)
 
typename std::conditional<(c_rank > biggest_ab_type::rank), Cond, biggest_ab_type >::type biggest_type
 
static KOKKOS_FORCEINLINE_FUNCTION T apply(T const &right)
 
static KOKKOS_FORCEINLINE_FUNCTION ViewType::reference_type index(ViewType const &x, Integral i, Integral j)
 
typename Result::execution_space execution_space
 
typename RebindViewType< Result, typename Result::non_const_value_type >::type NonConstResult
 
void single_many_binary_op(BinaryOpCode code, Teuchos::any &result, Teuchos::any &left, Teuchos::any &right) override
 
void operator()(std::string const &name, Teuchos::any &result, std::vector< Teuchos::any > &rhs) const 
 
KOKKOS_INLINE_FUNCTION void operator()(typename execution_space::size_type i) const 
 
void inspect_arg(Teuchos::any const &arg, bool &is_many, bool &is_bool) override
 
static KOKKOS_FORCEINLINE_FUNCTION T apply(T const &right)
 
typename RebindViewType< Result, typename Result::non_const_value_type >::type NonConstResult
 
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
 
static constexpr size_t a_rank
 
KOKKOS_INLINE_FUNCTION void operator()(typename execution_space::size_type i) const 
 
typename TernaryResultType< Cond, Left, Right >::type Result
 
static KOKKOS_FORCEINLINE_FUNCTION T apply(T const &right)
 
static KOKKOS_FORCEINLINE_FUNCTION T apply(T const &right)
 
typename Result::execution_space execution_space
 
typename Result::execution_space execution_space
 
BinaryFunctor(std::string const &name, Teuchos::any &result, Teuchos::any &left, Teuchos::any &right)
 
static KOKKOS_FORCEINLINE_FUNCTION ViewType::reference_type index(ViewType const &x, Integral)
 
Builds on RebindDataType, but acts directly on a Kokkos::View type. 
 
typename RebindViewType< biggest_type, typename biggest_type::non_const_value_type >::type type
 
KOKKOS_INLINE_FUNCTION void operator()(typename execution_space::size_type) const 
 
UnaryFunctor(std::string const &name, Teuchos::any &result, Teuchos::any &right)
 
Interprets mathematical expressions in a string and evaluates them using Kokkos::View objects as valu...
 
void many_neg_op(Teuchos::any &result, Teuchos::any &right) override
 
static KOKKOS_FORCEINLINE_FUNCTION bool apply(bool left, bool right)
 
typename RebindViewType< biggest_type, typename Left::non_const_value_type >::type non_const_type
 
KOKKOS_INLINE_FUNCTION void operator()(typename execution_space::size_type i, typename execution_space::size_type j) const 
 
KOKKOS_INLINE_FUNCTION void operator()(typename execution_space::size_type i) const 
 
static constexpr size_t right_value
 
void many_single_ternary_op(Teuchos::any &result, Teuchos::any &cond, Teuchos::any &left, Teuchos::any &right) override
 
static KOKKOS_FORCEINLINE_FUNCTION ViewType::reference_type index(ViewType const &x, Integral i)
 
TernaryFunctor(std::string const &name, Teuchos::any &result, Teuchos::any &cond, Teuchos::any &left, Teuchos::any &right)
 
static constexpr size_t value
 
Kokkos::View< bool, VP...> single_bool_view_type
One boolean (same for all evaluation points) 
 
static KOKKOS_FORCEINLINE_FUNCTION bool apply(T const &left, T const &right)
 
Kokkos::View< scalar_type, VP...> single_view_type
One scalar (same for all evaluation points) 
 
std::string typeName() const 
 
static KOKKOS_FORCEINLINE_FUNCTION T apply(T const &left, T const &right)
 
static constexpr size_t a_rank
 
void single_single_ternary_op(Teuchos::any &result, Teuchos::any &cond, Teuchos::any &left, Teuchos::any &right) override
 
typename RebindViewType< biggest_type, typename Left::const_value_type >::type type
 
const std::type_info & type() const 
 
static KOKKOS_FORCEINLINE_FUNCTION T apply(T const &left, T const &right)
 
typename std::conditional<(b_rank > a_rank), B, A >::type biggest_type
 
typename Result::execution_space execution_space
 
void single_single_binary_op(BinaryOpCode code, Teuchos::any &result, Teuchos::any &left, Teuchos::any &right) override
 
void set_cmath_functions(Eval< DT, VP...> &eval)
Add support for functions such as sqrt(), sin(), and cos() 
 
typename TernaryResultType< Cond, Left, Right >::non_const_type NonConstResult
 
BinaryFunctor(std::string const &name, Teuchos::any &result, Teuchos::any &left, Teuchos::any &right)
 
static constexpr size_t b_rank
 
KOKKOS_INLINE_FUNCTION void operator()(typename execution_space::size_type i, typename execution_space::size_type j) const 
 
void many_single_binary_op(BinaryOpCode code, Teuchos::any &result, Teuchos::any &left, Teuchos::any &right) override
 
typename TernaryResultType< Cond, Left, Right >::type Result
 
static KOKKOS_FORCEINLINE_FUNCTION bool apply(bool left, bool right)
 
static KOKKOS_FORCEINLINE_FUNCTION T apply(T const &left, T const &right)