Panzer  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Panzer_GatherSolution_Tpetra_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_GATHER_SOLUTION_TPETRA_DECL_HPP
44 #define PANZER_EVALUATOR_GATHER_SOLUTION_TPETRA_DECL_HPP
45 
46 #include "Phalanx_config.hpp"
47 #include "Phalanx_Evaluator_Macros.hpp"
48 #include "Phalanx_MDField.hpp"
49 
51 
52 #include "PanzerDiscFE_config.hpp"
53 #include "Panzer_Dimension.hpp"
54 #include "Panzer_Traits.hpp"
57 
58 #include"Panzer_NodeType.hpp"
59 
61 
63 
64 namespace panzer {
65 
66 template <typename LocalOrdinalT,typename GlobalOrdinalT>
67 class UniqueGlobalIndexer; //forward declaration
68 
76 template<typename EvalT, typename Traits,typename LO,typename GO,typename NodeT=panzer::TpetraNodeType>
78 
79 // **************************************************************
80 // **************************************************************
81 // * Specializations
82 // **************************************************************
83 // **************************************************************
84 
85 
86 // **************************************************************
87 // Residual
88 // **************************************************************
89 template<typename TRAITS,typename LO,typename GO,typename NodeT>
90 class GatherSolution_Tpetra<panzer::Traits::Residual,TRAITS,LO,GO,NodeT>
91  : public panzer::EvaluatorWithBaseImpl<TRAITS>,
92  public PHX::EvaluatorDerived<panzer::Traits::Residual, TRAITS>,
94 
95 
96 public:
97 
99  globalIndexer_(indexer) {}
100 
102  const Teuchos::ParameterList& p);
103 
104  void postRegistrationSetup(typename TRAITS::SetupData d,
106 
107  void preEvaluate(typename TRAITS::PreEvalData d);
108 
109  void evaluateFields(typename TRAITS::EvalData d);
110 
113 
114  // for testing purposes
115  const PHX::FieldTag & getFieldTag(int i) const
116  { TEUCHOS_ASSERT(i < Teuchos::as<int>(gatherFields_.size())); return gatherFields_[i].fieldTag(); }
117 
118 private:
119 
120  typedef typename panzer::Traits::Residual EvalT;
122 
123  // maps the local (field,element,basis) triplet to a global ID
124  // for scattering
126  std::vector<int> fieldIds_; // field IDs needing mapping
127 
128  std::vector< PHX::MDField<ScalarT,Cell,NODE> > gatherFields_;
129 
130  std::vector<std::string> indexerNames_;
132  std::string globalDataKey_; // what global data does this fill?
133 
135 
136  // Fields for storing tangent components dx/dp of solution vector x
137  // These are not actually used by the residual specialization of this evaluator,
138  // even if they are supplied, but it is useful to declare them as dependencies anyway
139  // when saving the tangent components to the output file
141  std::vector< std::vector< PHX::MDField<const ScalarT,Cell,NODE> > > tangentFields_;
142 
143  Kokkos::View<int**,PHX::Device> scratch_lids_;
144  std::vector<Kokkos::View<int*,PHX::Device> > scratch_offsets_;
145 
147 };
148 
149 // **************************************************************
150 // Tangent
151 // **************************************************************
152 template<typename TRAITS,typename LO,typename GO,typename NodeT>
153 class GatherSolution_Tpetra<panzer::Traits::Tangent,TRAITS,LO,GO,NodeT>
154  : public panzer::EvaluatorWithBaseImpl<TRAITS>,
155  public PHX::EvaluatorDerived<panzer::Traits::Tangent, TRAITS>,
157 
158 
159 public:
160 
162  globalIndexer_(indexer) {}
163 
165  const Teuchos::ParameterList& p);
166 
167  void postRegistrationSetup(typename TRAITS::SetupData d,
169 
170  void preEvaluate(typename TRAITS::PreEvalData d);
171 
172  void evaluateFields(typename TRAITS::EvalData d);
173 
176 
177 private:
178 
179  typedef typename panzer::Traits::Tangent EvalT;
181  typedef typename panzer::Traits::RealType RealT;
182 
183  // maps the local (field,element,basis) triplet to a global ID
184  // for scattering
186  std::vector<int> fieldIds_; // field IDs needing mapping
187 
188  std::vector< PHX::MDField<ScalarT,Cell,NODE> > gatherFields_;
189 
190  std::vector<std::string> indexerNames_;
192  std::string globalDataKey_; // what global data does this fill?
193 
195 
196  // Fields for storing tangent components dx/dp of solution vector x
198  std::vector< std::vector< PHX::MDField<const RealT,Cell,NODE> > > tangentFields_;
199 
201 };
202 
203 // **************************************************************
204 // Jacobian
205 // **************************************************************
206 template<typename TRAITS,typename LO,typename GO,typename NodeT>
207 class GatherSolution_Tpetra<panzer::Traits::Jacobian,TRAITS,LO,GO,NodeT>
208  : public panzer::EvaluatorWithBaseImpl<TRAITS>,
209  public PHX::EvaluatorDerived<panzer::Traits::Jacobian, TRAITS>,
211 
212 public:
214  globalIndexer_(indexer) {}
215 
217  const Teuchos::ParameterList& p);
218 
219  void postRegistrationSetup(typename TRAITS::SetupData d,
221 
222  void preEvaluate(typename TRAITS::PreEvalData d);
223 
224  void evaluateFields(typename TRAITS::EvalData d);
225 
228 
229  KOKKOS_INLINE_FUNCTION
230  void operator()(const int cell) const;
231 
232 
233  // No seeding of the AD fuctor
234  struct NoSeed {};
235  KOKKOS_INLINE_FUNCTION
236  void operator()(const NoSeed,const int cell) const;
237 
238 private:
239 
240  typedef typename panzer::Traits::Jacobian EvalT;
242 
243  // maps the local (field,element,basis) triplet to a global ID
244  // for scattering
246  std::vector<int> fieldIds_; // field IDs needing mapping
247 
248  std::vector< PHX::MDField<ScalarT,Cell,NODE> > gatherFields_;
249 
250  std::vector<std::string> indexerNames_;
252  bool disableSensitivities_; // This disables sensitivities absolutely
253  std::string sensitivitiesName_; // This sets which gather operations have sensitivities
254  bool applySensitivities_; // This is a local variable that is used by evaluateFields
255  // to turn on/off a certain set of sensitivities
256  std::string globalDataKey_; // what global data does this fill?
257  int gatherSeedIndex_; // what gather seed in the workset to use
258  // if less than zero then use alpha or beta
259  // as appropriate
260 
263 
265 
266  Kokkos::View<int**,PHX::Device> scratch_lids_;
267  std::vector<Kokkos::View<int*,PHX::Device> > scratch_offsets_;
268 
269  // functor data
270  struct {
271  // input values
272  Kokkos::View<const LO**,PHX::Device> lids; // local indices for unknowns
273  Kokkos::View<const int*,PHX::Device> offsets; // how to get a particular field
274  Kokkos::View<const double**, Kokkos::LayoutLeft,PHX::Device> x_data;
275  double seed_value; // AD seed information
276 
277  // output fields
278  PHX::MDField<ScalarT,Cell,NODE> field;
279  } functor_data;
280 };
281 
282 }
283 
284 #ifdef Panzer_BUILD_HESSIAN_SUPPORT
286 #endif
287 
288 // **************************************************************
289 #endif
Teuchos::RCP< const TpetraLinearObjContainer< double, LO, GO, NodeT > > tpetraContainer_
Teuchos::RCP< const TpetraLinearObjContainer< double, LO, GO, NodeT > > tpetraContainer_
virtual Teuchos::RCP< CloneableEvaluator > clone(const Teuchos::ParameterList &pl) const
Teuchos::RCP< typename TpetraLinearObjContainer< double, LO, GO, NodeT >::VectorType > x_vector
GatherSolution_Tpetra(const Teuchos::RCP< const panzer::UniqueGlobalIndexer< LO, GO > > &indexer)
GatherSolution_Tpetra(const Teuchos::RCP< const panzer::UniqueGlobalIndexer< LO, GO > > &indexer)
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)
Wrapper to PHX::EvaluatorWithBaseImpl that implements Panzer-specific helpers.
Gathers solution values from the Newton solution vector into the nodal fields of the field manager...
virtual Teuchos::RCP< CloneableEvaluator > clone(const Teuchos::ParameterList &pl) const
Teuchos::RCP< const TpetraLinearObjContainer< double, LO, GO, NodeT > > tpetraContainer_
std::vector< std::vector< PHX::MDField< const ScalarT, Cell, NODE > > > tangentFields_
GatherSolution_Tpetra(const Teuchos::RCP< const panzer::UniqueGlobalIndexer< LO, GO > > &indexer)
virtual Teuchos::RCP< CloneableEvaluator > clone(const Teuchos::ParameterList &pl) const
#define TEUCHOS_ASSERT(assertion_test)
Non-templated empty base class for template managers.
std::vector< std::vector< PHX::MDField< const RealT, Cell, NODE > > > tangentFields_