Panzer  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Panzer_Sum_decl.hpp
Go to the documentation of this file.
1 // @HEADER
2 // ***********************************************************************
3 //
4 // Panzer: A partial differential equation assembly
5 // engine for strongly coupled complex multiphysics systems
6 // Copyright (2011) Sandia Corporation
7 //
8 // Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation,
9 // the U.S. Government retains certain rights in this software.
10 //
11 // Redistribution and use in source and binary forms, with or without
12 // modification, are permitted provided that the following conditions are
13 // met:
14 //
15 // 1. Redistributions of source code must retain the above copyright
16 // notice, this list of conditions and the following disclaimer.
17 //
18 // 2. Redistributions in binary form must reproduce the above copyright
19 // notice, this list of conditions and the following disclaimer in the
20 // documentation and/or other materials provided with the distribution.
21 //
22 // 3. Neither the name of the Corporation nor the names of the
23 // contributors may be used to endorse or promote products derived from
24 // this software without specific prior written permission.
25 //
26 // THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY
27 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
28 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
29 // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE
30 // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
31 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
32 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
33 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
34 // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
35 // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
36 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
37 //
38 // Questions? Contact Roger P. Pawlowski (rppawlo@sandia.gov) and
39 // Eric C. Cyr (eccyr@sandia.gov)
40 // ***********************************************************************
41 // @HEADER
42 
43 #ifndef PANZER_EVALUATOR_SUM_HPP
44 #define PANZER_EVALUATOR_SUM_HPP
45 
46 #include "Phalanx_Evaluator_Macros.hpp"
47 #include "Phalanx_MDField.hpp"
48 
50 
52 
53 namespace panzer {
54 
67  static const int MAX_VALUES=20;
68 
69  PHX::MDField<ScalarT> sum;
70  // std::vector< PHX::MDField<const ScalarT> > values;
71  // std::vector<double> scalars;
72  PHX::MDField<const ScalarT> values[MAX_VALUES];
73  Kokkos::View<const double *,PHX::Device> scalars;
74 
75  std::size_t cell_data_size;
76 
77 public:
78  template<unsigned int RANK>
79  struct PanzerSumTag{};
80 
81  template<unsigned int RANK>
82  void operator() (PanzerSumTag<RANK>, const int &i) const;
83 
85 
89 template<typename EvalT, typename TRAITS,typename Tag0,typename Tag1=void,typename Tag2=void>
91  public PHX::EvaluatorDerived<EvalT, TRAITS> {
92 public:
94  void postRegistrationSetup(typename TRAITS::SetupData d,
96  void evaluateFields(typename TRAITS::EvalData d);
97 private:
98  typedef typename EvalT::ScalarT ScalarT;
99 };
100 
101 template<typename EvalT, typename TRAITS,typename Tag0>
102 class SumStatic<EvalT,TRAITS,Tag0,void,void> : public panzer::EvaluatorWithBaseImpl<TRAITS>,
103  public PHX::EvaluatorDerived<EvalT, TRAITS> {
104 public:
106  void postRegistrationSetup(typename TRAITS::SetupData d,
108  void evaluateFields(typename TRAITS::EvalData d);
109 private:
110  typedef typename EvalT::ScalarT ScalarT;
111 
112  PHX::MDField<ScalarT,Tag0> sum;
113  std::vector< PHX::MDField<const ScalarT,Tag0> > values;
114 };
115 
116 template<typename EvalT, typename TRAITS,typename Tag0,typename Tag1>
117 class SumStatic<EvalT,TRAITS,Tag0,Tag1,void> : public panzer::EvaluatorWithBaseImpl<TRAITS>,
118  public PHX::EvaluatorDerived<EvalT, TRAITS> {
119 public:
121  void postRegistrationSetup(typename TRAITS::SetupData d,
123  void evaluateFields(typename TRAITS::EvalData d);
124 
125  struct ScalarsTag {};
126  KOKKOS_INLINE_FUNCTION
127  void operator()(const ScalarsTag,const unsigned c) const;
128 
129  struct NoScalarsTag {};
130  KOKKOS_INLINE_FUNCTION
131  void operator()(const NoScalarsTag,const unsigned c) const;
132 
133 private:
134  typedef typename EvalT::ScalarT ScalarT;
135 
136  PHX::MDField<ScalarT,Tag0,Tag1> sum;
137  std::vector< PHX::MDField<const ScalarT,Tag0,Tag1> > values;
139 
140  // Functor members
142  enum {MAX_VALUES=20};
143  PHX::MDField<const ScalarT,Tag0,Tag1> current_value;
144  Kokkos::View<const ScalarT**,PHX::Device> value_views[MAX_VALUES];
145  Kokkos::View<const double*,PHX::Device> scalars;
147 
148  // this is used in the parallel kernel
149 };
150 
151 /*
152 template<typename EvalT, typename TRAITS,typename Tag0,typename Tag1,typename Tag2>
153 class SumStatic<EvalT,TRAITS,Tag0,Tag1,Tag2> : public panzer::EvaluatorWithBaseImpl<TRAITS>,
154  public PHX::EvaluatorDerived<EvalT, TRAITS> {
155 public:
156  SumStatic(const Teuchos::ParameterList& p);
157  void postRegistrationSetup(typename TRAITS::SetupData d,
158  PHX::FieldManager<TRAITS>& fm);
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
PHX::MDField< ScalarT > sum
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)
EvalT::ScalarT ScalarT
Kokkos::View< const double *, PHX::Device > scalars
#define PANZER_EVALUATOR_CLASS(NAME)
Macro definition of an evaluator class.
PHX::MDField< const ScalarT, Tag0, Tag1 > current_value
SumStatic(const Teuchos::ParameterList &p)
Kokkos::View< const double *, PHX::Device > scalars
std::vector< PHX::MDField< const ScalarT, Tag0 > > values
void operator()(const size_t &cell) const
Wrapper to PHX::EvaluatorWithBaseImpl that implements Panzer-specific helpers.
std::vector< ScalarT > values
#define PANZER_EVALUATOR_CLASS_END
Macro definition to end an evaluator class declaration.
static const int MAX_VALUES
void evaluateFields(typename TRAITS::EvalData d)
void postRegistrationSetup(typename TRAITS::SetupData d, PHX::FieldManager< TRAITS > &fm)
std::vector< PHX::MDField< const ScalarT, Tag0, Tag1 > > values