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 // 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_GATHER_SOLUTION_TPETRA_DECL_HPP
12 #define PANZER_EVALUATOR_GATHER_SOLUTION_TPETRA_DECL_HPP
13 
14 #include "Phalanx_config.hpp"
15 #include "Phalanx_Evaluator_Macros.hpp"
16 #include "Phalanx_MDField.hpp"
17 #include "Phalanx_KokkosViewOfViews.hpp"
18 
20 
21 #include "PanzerDiscFE_config.hpp"
22 #include "Panzer_Dimension.hpp"
23 #include "Panzer_Traits.hpp"
26 
27 #include"Panzer_NodeType.hpp"
28 
30 
32 
33 namespace panzer {
34 
35 class GlobalIndexer; //forward declaration
36 
44 template<typename EvalT, typename Traits,typename LO,typename GO,typename NodeT=panzer::TpetraNodeType>
46 
47 // **************************************************************
48 // **************************************************************
49 // * Specializations
50 // **************************************************************
51 // **************************************************************
52 
53 
54 // **************************************************************
55 // Residual
56 // **************************************************************
57 template<typename TRAITS,typename LO,typename GO,typename NodeT>
58 class GatherSolution_Tpetra<panzer::Traits::Residual,TRAITS,LO,GO,NodeT>
59  : public panzer::EvaluatorWithBaseImpl<TRAITS>,
60  public PHX::EvaluatorDerived<panzer::Traits::Residual, TRAITS>,
62 
63 
64 public:
65 
67  globalIndexer_(indexer) {}
68 
70  const Teuchos::ParameterList& p);
71 
72  void postRegistrationSetup(typename TRAITS::SetupData d,
74 
75  void preEvaluate(typename TRAITS::PreEvalData d);
76 
77  void evaluateFields(typename TRAITS::EvalData d);
78 
81 
82  // for testing purposes
83  const PHX::FieldTag & getFieldTag(int i) const
84  { TEUCHOS_ASSERT(i < Teuchos::as<int>(gatherFields_.size())); return gatherFields_[i].fieldTag(); }
85 
86 private:
87 
88  typedef typename panzer::Traits::Residual EvalT;
90 
91  // maps the local (field,element,basis) triplet to a global ID
92  // for scattering
94  std::vector<int> fieldIds_; // field IDs needing mapping
95 
96  std::vector< PHX::MDField<ScalarT,Cell,NODE> > gatherFields_;
97 
98  std::vector<std::string> indexerNames_;
100  std::string globalDataKey_; // what global data does this fill?
101 
103 
104  // Fields for storing tangent components dx/dp of solution vector x
105  // These are not actually used by the residual specialization of this evaluator,
106  // even if they are supplied, but it is useful to declare them as dependencies anyway
107  // when saving the tangent components to the output file
109  std::vector< std::vector< PHX::MDField<const ScalarT,Cell,NODE> > > tangentFields_;
110 
111  PHX::View<int**> scratch_lids_;
112  std::vector<PHX::View<int*> > scratch_offsets_;
113 
115 };
116 
117 // **************************************************************
118 // Tangent
119 // **************************************************************
120 template<typename TRAITS,typename LO,typename GO,typename NodeT>
121 class GatherSolution_Tpetra<panzer::Traits::Tangent,TRAITS,LO,GO,NodeT>
122  : public panzer::EvaluatorWithBaseImpl<TRAITS>,
123  public PHX::EvaluatorDerived<panzer::Traits::Tangent, TRAITS>,
125 
126 
127 public:
128 
130  globalIndexer_(indexer) {}
131 
133  const Teuchos::ParameterList& p);
134 
135  void postRegistrationSetup(typename TRAITS::SetupData d,
137 
138  void preEvaluate(typename TRAITS::PreEvalData d);
139 
140  void evaluateFields(typename TRAITS::EvalData d);
141 
144 
145 private:
146 
147  typedef typename panzer::Traits::Tangent EvalT;
149  typedef typename panzer::Traits::RealType RealT;
150 
151  // maps the local (field,element,basis) triplet to a global ID
152  // for scattering
154  std::vector<int> fieldIds_; // field IDs needing mapping
155 
156  std::vector< PHX::MDField<ScalarT,Cell,NODE> > gatherFields_;
158 
159  std::vector<std::string> indexerNames_;
161  std::string globalDataKey_; // what global data does this fill?
162 
164 
165  // Fields for storing tangent components dx/dp of solution vector x
167  std::vector< std::vector< PHX::MDField<const RealT,Cell,NODE> > > tangentFields_;
169  PHX::View<size_t*> tangentInnerVectorSizes_;
170 
172 };
173 
174 // **************************************************************
175 // Jacobian
176 // **************************************************************
177 template<typename TRAITS,typename LO,typename GO,typename NodeT>
178 class GatherSolution_Tpetra<panzer::Traits::Jacobian,TRAITS,LO,GO,NodeT>
179  : public panzer::EvaluatorWithBaseImpl<TRAITS>,
180  public PHX::EvaluatorDerived<panzer::Traits::Jacobian, TRAITS>,
182 
183 public:
185  globalIndexer_(indexer) {}
186 
188  const Teuchos::ParameterList& p);
189 
190  void postRegistrationSetup(typename TRAITS::SetupData d,
192 
193  void preEvaluate(typename TRAITS::PreEvalData d);
194 
195  void evaluateFields(typename TRAITS::EvalData d);
196 
199 
200  KOKKOS_INLINE_FUNCTION
201  void operator()(const int cell) const;
202 
203 
204  // No seeding of the AD fuctor
205  struct NoSeed {};
206  KOKKOS_INLINE_FUNCTION
207  void operator()(const NoSeed,const int cell) const;
208 
209 private:
210 
211  typedef typename panzer::Traits::Jacobian EvalT;
213 
214  // maps the local (field,element,basis) triplet to a global ID
215  // for scattering
217  std::vector<int> fieldIds_; // field IDs needing mapping
218 
219  std::vector< PHX::MDField<ScalarT,Cell,NODE> > gatherFields_;
220 
221  std::vector<std::string> indexerNames_;
223  bool disableSensitivities_; // This disables sensitivities absolutely
224  std::string sensitivitiesName_; // This sets which gather operations have sensitivities
225  bool applySensitivities_; // This is a local variable that is used by evaluateFields
226  // to turn on/off a certain set of sensitivities
227  std::string globalDataKey_; // what global data does this fill?
228  int gatherSeedIndex_; // what gather seed in the workset to use
229  // if less than zero then use alpha or beta
230  // as appropriate
231 
234 
236 
237  PHX::View<int**> scratch_lids_;
238  std::vector<PHX::View<int*> > scratch_offsets_;
239 
240  // functor data
241  struct {
242  // input values
243  PHX::View<const LO**> lids; // local indices for unknowns
244  PHX::View<const int*> offsets; // how to get a particular field
246  double seed_value; // AD seed information
247  int dos; // Offset for special interface bc
248 
249  // output fields
251  } functor_data;
252 };
253 
254 }
255 
256 #ifdef Panzer_BUILD_HESSIAN_SUPPORT
258 #endif
259 
260 // **************************************************************
261 #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_