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 class GlobalIndexer; //forward declaration
67 
75 template<typename EvalT, typename Traits,typename LO,typename GO,typename NodeT=panzer::TpetraNodeType>
77 
78 // **************************************************************
79 // **************************************************************
80 // * Specializations
81 // **************************************************************
82 // **************************************************************
83 
84 
85 // **************************************************************
86 // Residual
87 // **************************************************************
88 template<typename TRAITS,typename LO,typename GO,typename NodeT>
89 class GatherSolution_Tpetra<panzer::Traits::Residual,TRAITS,LO,GO,NodeT>
90  : public panzer::EvaluatorWithBaseImpl<TRAITS>,
91  public PHX::EvaluatorDerived<panzer::Traits::Residual, TRAITS>,
93 
94 
95 public:
96 
98  globalIndexer_(indexer) {}
99 
101  const Teuchos::ParameterList& p);
102 
103  void postRegistrationSetup(typename TRAITS::SetupData d,
105 
106  void preEvaluate(typename TRAITS::PreEvalData d);
107 
108  void evaluateFields(typename TRAITS::EvalData d);
109 
112 
113  // for testing purposes
114  const PHX::FieldTag & getFieldTag(int i) const
115  { TEUCHOS_ASSERT(i < Teuchos::as<int>(gatherFields_.size())); return gatherFields_[i].fieldTag(); }
116 
117 private:
118 
119  typedef typename panzer::Traits::Residual EvalT;
121 
122  // maps the local (field,element,basis) triplet to a global ID
123  // for scattering
125  std::vector<int> fieldIds_; // field IDs needing mapping
126 
127  std::vector< PHX::MDField<ScalarT,Cell,NODE> > gatherFields_;
128 
129  std::vector<std::string> indexerNames_;
131  std::string globalDataKey_; // what global data does this fill?
132 
134 
135  // Fields for storing tangent components dx/dp of solution vector x
136  // These are not actually used by the residual specialization of this evaluator,
137  // even if they are supplied, but it is useful to declare them as dependencies anyway
138  // when saving the tangent components to the output file
140  std::vector< std::vector< PHX::MDField<const ScalarT,Cell,NODE> > > tangentFields_;
141 
142  Kokkos::View<int**,PHX::Device> scratch_lids_;
143  std::vector<Kokkos::View<int*,PHX::Device> > scratch_offsets_;
144 
146 };
147 
148 // **************************************************************
149 // Tangent
150 // **************************************************************
151 template<typename TRAITS,typename LO,typename GO,typename NodeT>
152 class GatherSolution_Tpetra<panzer::Traits::Tangent,TRAITS,LO,GO,NodeT>
153  : public panzer::EvaluatorWithBaseImpl<TRAITS>,
154  public PHX::EvaluatorDerived<panzer::Traits::Tangent, TRAITS>,
156 
157 
158 public:
159 
161  globalIndexer_(indexer) {}
162 
164  const Teuchos::ParameterList& p);
165 
166  void postRegistrationSetup(typename TRAITS::SetupData d,
168 
169  void preEvaluate(typename TRAITS::PreEvalData d);
170 
171  void evaluateFields(typename TRAITS::EvalData d);
172 
175 
176 private:
177 
178  typedef typename panzer::Traits::Tangent EvalT;
180  typedef typename panzer::Traits::RealType RealT;
181 
182  // maps the local (field,element,basis) triplet to a global ID
183  // for scattering
185  std::vector<int> fieldIds_; // field IDs needing mapping
186 
187  std::vector< PHX::MDField<ScalarT,Cell,NODE> > gatherFields_;
188 
189  std::vector<std::string> indexerNames_;
191  std::string globalDataKey_; // what global data does this fill?
192 
194 
195  // Fields for storing tangent components dx/dp of solution vector x
197  std::vector< std::vector< PHX::MDField<const RealT,Cell,NODE> > > tangentFields_;
198 
200 };
201 
202 // **************************************************************
203 // Jacobian
204 // **************************************************************
205 template<typename TRAITS,typename LO,typename GO,typename NodeT>
206 class GatherSolution_Tpetra<panzer::Traits::Jacobian,TRAITS,LO,GO,NodeT>
207  : public panzer::EvaluatorWithBaseImpl<TRAITS>,
208  public PHX::EvaluatorDerived<panzer::Traits::Jacobian, TRAITS>,
210 
211 public:
213  globalIndexer_(indexer) {}
214 
216  const Teuchos::ParameterList& p);
217 
218  void postRegistrationSetup(typename TRAITS::SetupData d,
220 
221  void preEvaluate(typename TRAITS::PreEvalData d);
222 
223  void evaluateFields(typename TRAITS::EvalData d);
224 
227 
228  KOKKOS_INLINE_FUNCTION
229  void operator()(const int cell) const;
230 
231 
232  // No seeding of the AD fuctor
233  struct NoSeed {};
234  KOKKOS_INLINE_FUNCTION
235  void operator()(const NoSeed,const int cell) const;
236 
237 private:
238 
239  typedef typename panzer::Traits::Jacobian EvalT;
241 
242  // maps the local (field,element,basis) triplet to a global ID
243  // for scattering
245  std::vector<int> fieldIds_; // field IDs needing mapping
246 
247  std::vector< PHX::MDField<ScalarT,Cell,NODE> > gatherFields_;
248 
249  std::vector<std::string> indexerNames_;
251  bool disableSensitivities_; // This disables sensitivities absolutely
252  std::string sensitivitiesName_; // This sets which gather operations have sensitivities
253  bool applySensitivities_; // This is a local variable that is used by evaluateFields
254  // to turn on/off a certain set of sensitivities
255  std::string globalDataKey_; // what global data does this fill?
256  int gatherSeedIndex_; // what gather seed in the workset to use
257  // if less than zero then use alpha or beta
258  // as appropriate
259 
262 
264 
265  Kokkos::View<int**,PHX::Device> scratch_lids_;
266  std::vector<Kokkos::View<int*,PHX::Device> > scratch_offsets_;
267 
268  // functor data
269  struct {
270  // input values
271  Kokkos::View<const LO**,PHX::Device> lids; // local indices for unknowns
272  Kokkos::View<const int*,PHX::Device> offsets; // how to get a particular field
273  Kokkos::View<const double**, Kokkos::LayoutLeft,PHX::Device> x_data;
274  double seed_value; // AD seed information
275 
276  // output fields
277  PHX::MDField<ScalarT,Cell,NODE> field;
278  } functor_data;
279 };
280 
281 }
282 
283 #ifdef Panzer_BUILD_HESSIAN_SUPPORT
285 #endif
286 
287 // **************************************************************
288 #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
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_
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_