Panzer  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Panzer_Sum.hpp
Go to the documentation of this file.
1 // @HEADER
2 // *****************************************************************************
3 // Panzer: A partial differential equation assembly
4 // engine for strongly coupled complex multiphysics systems
5 //
6 // Copyright 2011 NTESS and the Panzer contributors.
7 // SPDX-License-Identifier: BSD-3-Clause
8 // *****************************************************************************
9 // @HEADER
10 
11 #ifndef PANZER_EVALUATOR_SUM_HPP
12 #define PANZER_EVALUATOR_SUM_HPP
13 
14 #include "Phalanx_Evaluator_Macros.hpp"
15 #include "Phalanx_MDField.hpp"
16 
18 
20 
21 namespace panzer {
22 
34 template<typename EvalT, typename Traits>
35 class Sum
36  :
37  public panzer::EvaluatorWithBaseImpl<Traits>,
38  public PHX::EvaluatorDerived<EvalT, Traits>
39 {
40  public:
41 
42  Sum(
43  const Teuchos::ParameterList& p);
44 
45  void
47  typename Traits::SetupData d,
49 
50  void
52  typename Traits::EvalData d);
53 
54  private:
55 
56  using ScalarT = typename EvalT::ScalarT;
57  static const int MAX_VALUES=20;
58 
60  // std::vector< PHX::MDField<const ScalarT> > values;
61  // std::vector<double> scalars;
63  PHX::View<const double *> scalars;
64 
65  std::size_t cell_data_size;
66 
67 public:
68  template<unsigned int RANK>
69  struct PanzerSumTag{};
70 
71  template<unsigned int RANK>
72  KOKKOS_INLINE_FUNCTION
73  void operator() (PanzerSumTag<RANK>, const int &i) const;
74 
75 }; // end of class Sum
76 
77 
81 template<typename EvalT, typename TRAITS,typename Tag0,typename Tag1=void,typename Tag2=void>
83  public PHX::EvaluatorDerived<EvalT, TRAITS> {
84 public:
86  void evaluateFields(typename TRAITS::EvalData d);
87 private:
88  typedef typename EvalT::ScalarT ScalarT;
89 };
90 
91 template<typename EvalT, typename TRAITS,typename Tag0>
92 class SumStatic<EvalT,TRAITS,Tag0,void,void> : public panzer::EvaluatorWithBaseImpl<TRAITS>,
93  public PHX::EvaluatorDerived<EvalT, TRAITS> {
94 public:
96  void evaluateFields(typename TRAITS::EvalData d);
97 private:
98  typedef typename EvalT::ScalarT ScalarT;
99 
101  std::vector< PHX::MDField<const ScalarT,Tag0> > values;
102 };
103 
104 template<typename EvalT, typename TRAITS,typename Tag0,typename Tag1>
105 class SumStatic<EvalT,TRAITS,Tag0,Tag1,void> : public panzer::EvaluatorWithBaseImpl<TRAITS>,
106  public PHX::EvaluatorDerived<EvalT, TRAITS> {
107 public:
109 
120  SumStatic(const std::vector<PHX::Tag<typename EvalT::ScalarT>> & inputs,
121  const std::vector<double> & scalar_values,
122  const PHX::Tag<typename EvalT::ScalarT> & output);
123  void postRegistrationSetup(typename TRAITS::SetupData d,
125  void evaluateFields(typename TRAITS::EvalData d);
126 
127  struct ScalarsTag {};
128  KOKKOS_INLINE_FUNCTION
129  void operator()(const ScalarsTag,const unsigned c) const;
130 
131  struct NoScalarsTag {};
132  KOKKOS_INLINE_FUNCTION
133  void operator()(const NoScalarsTag,const unsigned c) const;
134 
135 private:
136  typedef typename EvalT::ScalarT ScalarT;
137 
139  std::vector< PHX::MDField<const ScalarT,Tag0,Tag1> > values;
141 
142  // Functor members
144  enum {MAX_VALUES=20};
146  PHX::View<const ScalarT**> value_views[MAX_VALUES];
147  PHX::View<const double*> scalars;
149 
150  // this is used in the parallel kernel
151 };
152 
153 /*
154 template<typename EvalT, typename TRAITS,typename Tag0,typename Tag1,typename Tag2>
155 class SumStatic<EvalT,TRAITS,Tag0,Tag1,Tag2> : public panzer::EvaluatorWithBaseImpl<TRAITS>,
156  public PHX::EvaluatorDerived<EvalT, TRAITS> {
157 public:
158  SumStatic(const Teuchos::ParameterList& p);
159  void evaluateFields(typename TRAITS::EvalData d);
160 private:
161  typedef typename EvalT::ScalarT ScalarT;
162 
163  PHX::MDField<ScalarT,Tag0,Tag1,Tag2> sum;
164  std::vector< PHX::MDField<ScalarT,Tag0,Tag1,Tag2> > values;
165 };
166 */
167 
171 template<typename EvalT, typename TRAITS,typename Tag0,typename Tag1,typename Tag2>
173 buildStaticSumEvaluator(const std::string & sum_name,
174  const std::vector<std::string> & value_names,
175  const Teuchos::RCP<PHX::DataLayout> & data_layout);
176 
177 }
178 
179 #endif
Teuchos::RCP< PHX::Evaluator< TRAITS > > buildStaticSumEvaluator(const std::string &sum_name, const std::vector< std::string > &value_names, const Teuchos::RCP< PHX::DataLayout > &data_layout)
Sum(const Teuchos::ParameterList &p)
EvalT::ScalarT ScalarT
Definition: Panzer_Sum.hpp:88
static const int MAX_VALUES
Definition: Panzer_Sum.hpp:57
void postRegistrationSetup(typename Traits::SetupData d, PHX::FieldManager< Traits > &fm)
KOKKOS_INLINE_FUNCTION void operator()(PanzerSumTag< RANK >, const int &i) const
PHX::MDField< const ScalarT, Tag0, Tag1 > current_value
Definition: Panzer_Sum.hpp:145
SumStatic(const Teuchos::ParameterList &p)
std::vector< PHX::MDField< const ScalarT, Tag0 > > values
Definition: Panzer_Sum.hpp:101
Wrapper to PHX::EvaluatorWithBaseImpl that implements Panzer-specific helpers.
PHX::View< const double * > scalars
Definition: Panzer_Sum.hpp:63
PHX::MDField< ScalarT > sum
Definition: Panzer_Sum.hpp:59
virtual void postRegistrationSetup(typename Traits::SetupData d, PHX::FieldManager< Traits > &vm)=0
PHX::MDField< ScalarT, Tag0, Tag1 > sum
Definition: Panzer_Sum.hpp:138
void evaluateFields(typename Traits::EvalData d)
typename EvalT::ScalarT ScalarT
Definition: Panzer_Sum.hpp:56
std::size_t cell_data_size
Definition: Panzer_Sum.hpp:65
void evaluateFields(typename TRAITS::EvalData d)
std::vector< PHX::MDField< const ScalarT, Tag0, Tag1 > > values
Definition: Panzer_Sum.hpp:139
PHX::MDField< const ScalarT > values[MAX_VALUES]
Definition: Panzer_Sum.hpp:62