Panzer Version of the Day
Loading...
Searching...
No Matches
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
19#include "Teuchos_ParameterList.hpp"
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
33namespace panzer {
34
35class GlobalIndexer; //forward declaration
36
44template<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
64template<typename TRAITS,typename LO,typename GO,typename NodeT>
66 : public panzer::EvaluatorWithBaseImpl<TRAITS>,
67 public PHX::EvaluatorDerived<panzer::Traits::Residual, TRAITS>,
69
70
71public:
72
74 GatherSolution_Tpetra(const Teuchos::RCP<const panzer::GlobalIndexer> & indexer) :
75 globalIndexer_(indexer) {}
76
78 GatherSolution_Tpetra(const Teuchos::RCP<const panzer::GlobalIndexer> & indexer,
79 const Teuchos::ParameterList& p);
80
82 void postRegistrationSetup(typename TRAITS::SetupData d,
84
86 void preEvaluate(typename TRAITS::PreEvalData d);
87
89 void evaluateFields(typename TRAITS::EvalData d);
90
92 virtual Teuchos::RCP<CloneableEvaluator> clone(const Teuchos::ParameterList & pl) const
93 { return Teuchos::rcp(new GatherSolution_Tpetra<panzer::Traits::Residual,TRAITS,LO,GO,NodeT>(globalIndexer_,pl)); }
94
95 // for testing purposes
97 const PHX::FieldTag & getFieldTag(int i) const
98 { TEUCHOS_ASSERT(i < Teuchos::as<int>(gatherFields_.size())); return gatherFields_[i].fieldTag(); }
99
100private:
101
104
105 // maps the local (field,element,basis) triplet to a global ID
106 // for scattering
107 Teuchos::RCP<const panzer::GlobalIndexer> globalIndexer_;
108 std::vector<int> fieldIds_; // field IDs needing mapping
109
110 std::vector< PHX::MDField<ScalarT,Cell,NODE> > gatherFields_;
111
112 std::vector<std::string> indexerNames_;
114 std::string globalDataKey_; // what global data does this fill?
115
116 Teuchos::RCP<const TpetraLinearObjContainer<double,LO,GO,NodeT> > tpetraContainer_;
117
118 // Fields for storing tangent components dx/dp of solution vector x
119 // These are not actually used by the residual specialization of this evaluator,
120 // even if they are supplied, but it is useful to declare them as dependencies anyway
121 // when saving the tangent components to the output file
123 std::vector< std::vector< PHX::MDField<const ScalarT,Cell,NODE> > > tangentFields_;
124
125 PHX::View<int**> scratch_lids_;
126 std::vector<PHX::View<int*> > scratch_offsets_;
127
129};
130
131// **************************************************************
132// Tangent
133// **************************************************************
134
142template<typename TRAITS,typename LO,typename GO,typename NodeT>
144 : public panzer::EvaluatorWithBaseImpl<TRAITS>,
145 public PHX::EvaluatorDerived<panzer::Traits::Tangent, TRAITS>,
147
148
149public:
150
152 GatherSolution_Tpetra(const Teuchos::RCP<const panzer::GlobalIndexer> & indexer) :
153 globalIndexer_(indexer) {}
154
156 GatherSolution_Tpetra(const Teuchos::RCP<const panzer::GlobalIndexer> & indexer,
157 const Teuchos::ParameterList& p);
158
160 void postRegistrationSetup(typename TRAITS::SetupData d,
162
164 void preEvaluate(typename TRAITS::PreEvalData d);
165
167 void evaluateFields(typename TRAITS::EvalData d);
168
170 virtual Teuchos::RCP<CloneableEvaluator> clone(const Teuchos::ParameterList & pl) const
171 { return Teuchos::rcp(new GatherSolution_Tpetra<panzer::Traits::Tangent,TRAITS,LO,GO,NodeT>(globalIndexer_,pl)); }
172
173private:
174
178
179 // maps the local (field,element,basis) triplet to a global ID
180 // for scattering
181 Teuchos::RCP<const panzer::GlobalIndexer> globalIndexer_;
182 std::vector<int> fieldIds_; // field IDs needing mapping
183
184 std::vector< PHX::MDField<ScalarT,Cell,NODE> > gatherFields_;
185 PHX::ViewOfViews<1,PHX::View<ScalarT**>> gatherFieldsVoV_;
186
187 std::vector<std::string> indexerNames_;
189 std::string globalDataKey_; // what global data does this fill?
190
191 Teuchos::RCP<const TpetraLinearObjContainer<double,LO,GO,NodeT> > tpetraContainer_;
192
193 // Fields for storing tangent components dx/dp of solution vector x
195 std::vector< std::vector< PHX::MDField<const RealT,Cell,NODE> > > tangentFields_;
196 PHX::ViewOfViews<2,PHX::View<const RealT**>> tangentFieldsVoV_;
197 PHX::View<size_t*> tangentInnerVectorSizes_;
198
200};
201
202// **************************************************************
203// Jacobian
204// **************************************************************
205
213template<typename TRAITS,typename LO,typename GO,typename NodeT>
215 : public panzer::EvaluatorWithBaseImpl<TRAITS>,
216 public PHX::EvaluatorDerived<panzer::Traits::Jacobian, TRAITS>,
218
219public:
221 GatherSolution_Tpetra(const Teuchos::RCP<const panzer::GlobalIndexer> & indexer) :
222 globalIndexer_(indexer) {}
223
225 GatherSolution_Tpetra(const Teuchos::RCP<const panzer::GlobalIndexer> & indexer,
226 const Teuchos::ParameterList& p);
227
229 void postRegistrationSetup(typename TRAITS::SetupData d,
231
233 void preEvaluate(typename TRAITS::PreEvalData d);
234
236 void evaluateFields(typename TRAITS::EvalData d);
237
239 virtual Teuchos::RCP<CloneableEvaluator> clone(const Teuchos::ParameterList & pl) const
240 { return Teuchos::rcp(new GatherSolution_Tpetra<panzer::Traits::Jacobian,TRAITS,LO,GO,NodeT>(globalIndexer_,pl)); }
241
243 KOKKOS_INLINE_FUNCTION
244 void operator()(const int cell) const;
245
246
248 struct NoSeed {};
250 KOKKOS_INLINE_FUNCTION
251 void operator()(const NoSeed,const int cell) const;
252
253private:
254
257
258 // maps the local (field,element,basis) triplet to a global ID
259 // for scattering
260 Teuchos::RCP<const panzer::GlobalIndexer> globalIndexer_;
261 std::vector<int> fieldIds_; // field IDs needing mapping
262
263 std::vector< PHX::MDField<ScalarT,Cell,NODE> > gatherFields_;
264
265 std::vector<std::string> indexerNames_;
267 bool disableSensitivities_; // This disables sensitivities absolutely
268 std::string sensitivitiesName_; // This sets which gather operations have sensitivities
269 bool applySensitivities_; // This is a local variable that is used by evaluateFields
270 // to turn on/off a certain set of sensitivities
271 std::string globalDataKey_; // what global data does this fill?
272 int gatherSeedIndex_; // what gather seed in the workset to use
273 // if less than zero then use alpha or beta
274 // as appropriate
275
276 Teuchos::RCP<const TpetraLinearObjContainer<double,LO,GO,NodeT> > tpetraContainer_;
277 Teuchos::RCP<typename TpetraLinearObjContainer<double,LO,GO,NodeT>::VectorType> x_vector;
278
280
281 PHX::View<int**> scratch_lids_;
282 std::vector<PHX::View<int*> > scratch_offsets_;
283
284 // functor data
285 struct {
286 // input values
287 PHX::View<const LO**> lids; // local indices for unknowns
288 PHX::View<const int*> offsets; // how to get a particular field
289 Kokkos::View<const double**, Kokkos::LayoutLeft,PHX::Device> x_data;
290 double seed_value; // AD seed information
291 int dos; // Offset for special interface bc
292
293 // output fields
294 PHX::MDField<ScalarT,Cell,NODE> field;
295 } functor_data;
296};
297
298}
299
300#ifdef Panzer_BUILD_HESSIAN_SUPPORT
302#endif
303
304// **************************************************************
305#endif
Non-templated empty base class for template managers.
Wrapper to PHX::EvaluatorWithBaseImpl that implements Panzer-specific helpers.
GatherSolution_Tpetra(const Teuchos::RCP< const panzer::GlobalIndexer > &indexer)
Construct with a global indexer only; solution/parameter names must be set later (e....
Teuchos::RCP< const TpetraLinearObjContainer< double, LO, GO, NodeT > > tpetraContainer_
virtual Teuchos::RCP< CloneableEvaluator > clone(const Teuchos::ParameterList &pl) const
Creates a copy of this evaluator configured from a new ParameterList, sharing the same global indexer...
Teuchos::RCP< typename TpetraLinearObjContainer< double, LO, GO, NodeT >::VectorType > x_vector
GatherSolution_Tpetra(const Teuchos::RCP< const panzer::GlobalIndexer > &indexer)
Construct with a global indexer only; solution/parameter names must be set later (e....
std::vector< std::vector< PHX::MDField< const ScalarT, Cell, NODE > > > tangentFields_
const PHX::FieldTag & getFieldTag(int i) const
Returns the FieldTag of the i-th gathered field. For testing purposes.
virtual Teuchos::RCP< CloneableEvaluator > clone(const Teuchos::ParameterList &pl) const
Creates a copy of this evaluator configured from a new ParameterList, sharing the same global indexer...
Teuchos::RCP< const TpetraLinearObjContainer< double, LO, GO, NodeT > > tpetraContainer_
virtual Teuchos::RCP< CloneableEvaluator > clone(const Teuchos::ParameterList &pl) const
Creates a copy of this evaluator configured from a new ParameterList, sharing the same global indexer...
Teuchos::RCP< const TpetraLinearObjContainer< double, LO, GO, NodeT > > tpetraContainer_
std::vector< std::vector< PHX::MDField< const RealT, Cell, NODE > > > tangentFields_
GatherSolution_Tpetra(const Teuchos::RCP< const panzer::GlobalIndexer > &indexer)
Construct with a global indexer only; solution/parameter names must be set later (e....
Gathers solution values from the Newton solution vector into the nodal fields of the field manager.
Evaluation type for computing the residual and its Jacobian, using FadType as the scalar type.
Evaluation type for computing the residual only, using RealType as the scalar type.
Evaluation type for computing directional derivatives (e.g. parameter sensitivities),...
double RealType
Scalar type used for the Residual evaluation type (plain double).