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 #include "Phalanx_KokkosViewOfViews.hpp"
50 
52 
53 #include "PanzerDiscFE_config.hpp"
54 #include "Panzer_Dimension.hpp"
55 #include "Panzer_Traits.hpp"
58 
59 #include"Panzer_NodeType.hpp"
60 
62 
64 
65 namespace panzer {
66 
67 class GlobalIndexer; //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  PHX::View<int**> scratch_lids_;
144  std::vector<PHX::View<int*> > 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_;
190 
191  std::vector<std::string> indexerNames_;
193  std::string globalDataKey_; // what global data does this fill?
194 
196 
197  // Fields for storing tangent components dx/dp of solution vector x
199  std::vector< std::vector< PHX::MDField<const RealT,Cell,NODE> > > tangentFields_;
201  PHX::View<size_t*> tangentInnerVectorSizes_;
202 
204 };
205 
206 // **************************************************************
207 // Jacobian
208 // **************************************************************
209 template<typename TRAITS,typename LO,typename GO,typename NodeT>
210 class GatherSolution_Tpetra<panzer::Traits::Jacobian,TRAITS,LO,GO,NodeT>
211  : public panzer::EvaluatorWithBaseImpl<TRAITS>,
212  public PHX::EvaluatorDerived<panzer::Traits::Jacobian, TRAITS>,
214 
215 public:
217  globalIndexer_(indexer) {}
218 
220  const Teuchos::ParameterList& p);
221 
222  void postRegistrationSetup(typename TRAITS::SetupData d,
224 
225  void preEvaluate(typename TRAITS::PreEvalData d);
226 
227  void evaluateFields(typename TRAITS::EvalData d);
228 
231 
232  KOKKOS_INLINE_FUNCTION
233  void operator()(const int cell) const;
234 
235 
236  // No seeding of the AD fuctor
237  struct NoSeed {};
238  KOKKOS_INLINE_FUNCTION
239  void operator()(const NoSeed,const int cell) const;
240 
241 private:
242 
243  typedef typename panzer::Traits::Jacobian EvalT;
245 
246  // maps the local (field,element,basis) triplet to a global ID
247  // for scattering
249  std::vector<int> fieldIds_; // field IDs needing mapping
250 
251  std::vector< PHX::MDField<ScalarT,Cell,NODE> > gatherFields_;
252 
253  std::vector<std::string> indexerNames_;
255  bool disableSensitivities_; // This disables sensitivities absolutely
256  std::string sensitivitiesName_; // This sets which gather operations have sensitivities
257  bool applySensitivities_; // This is a local variable that is used by evaluateFields
258  // to turn on/off a certain set of sensitivities
259  std::string globalDataKey_; // what global data does this fill?
260  int gatherSeedIndex_; // what gather seed in the workset to use
261  // if less than zero then use alpha or beta
262  // as appropriate
263 
266 
268 
269  PHX::View<int**> scratch_lids_;
270  std::vector<PHX::View<int*> > scratch_offsets_;
271 
272  // functor data
273  struct {
274  // input values
275  PHX::View<const LO**> lids; // local indices for unknowns
276  PHX::View<const int*> offsets; // how to get a particular field
278  double seed_value; // AD seed information
279  int dos; // Offset for special interface bc
280 
281  // output fields
283  } functor_data;
284 };
285 
286 }
287 
288 #ifdef Panzer_BUILD_HESSIAN_SUPPORT
290 #endif
291 
292 // **************************************************************
293 #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_