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 // Resolved in preEvaluate(), which accepts either a linear object container
119 // or a read-only ghosted vector under the global data key. Distributed
120 // parameters are only ever supplied as the latter.
121 Teuchos::RCP<const typename TpetraLinearObjContainer<double,LO,GO,NodeT>::MultiVectorType> x_vector;
122
123 // Fields for storing tangent components dx/dp of solution vector x
124 // These are not actually used by the residual specialization of this evaluator,
125 // even if they are supplied, but it is useful to declare them as dependencies anyway
126 // when saving the tangent components to the output file
128 std::vector< std::vector< PHX::MDField<const ScalarT,Cell,NODE> > > tangentFields_;
129
130 PHX::View<int**> scratch_lids_;
131 std::vector<PHX::View<int*> > scratch_offsets_;
132
134};
135
136// **************************************************************
137// Tangent
138// **************************************************************
139
147template<typename TRAITS,typename LO,typename GO,typename NodeT>
149 : public panzer::EvaluatorWithBaseImpl<TRAITS>,
150 public PHX::EvaluatorDerived<panzer::Traits::Tangent, TRAITS>,
152
153
154public:
155
157 GatherSolution_Tpetra(const Teuchos::RCP<const panzer::GlobalIndexer> & indexer) :
158 globalIndexer_(indexer) {}
159
161 GatherSolution_Tpetra(const Teuchos::RCP<const panzer::GlobalIndexer> & indexer,
162 const Teuchos::ParameterList& p);
163
165 void postRegistrationSetup(typename TRAITS::SetupData d,
167
169 void preEvaluate(typename TRAITS::PreEvalData d);
170
172 void evaluateFields(typename TRAITS::EvalData d);
173
175 virtual Teuchos::RCP<CloneableEvaluator> clone(const Teuchos::ParameterList & pl) const
176 { return Teuchos::rcp(new GatherSolution_Tpetra<panzer::Traits::Tangent,TRAITS,LO,GO,NodeT>(globalIndexer_,pl)); }
177
178private:
179
183
184 // maps the local (field,element,basis) triplet to a global ID
185 // for scattering
186 Teuchos::RCP<const panzer::GlobalIndexer> globalIndexer_;
187 std::vector<int> fieldIds_; // field IDs needing mapping
188
189 std::vector< PHX::MDField<ScalarT,Cell,NODE> > gatherFields_;
190 PHX::ViewOfViews<1,PHX::View<ScalarT**>> gatherFieldsVoV_;
191
192 std::vector<std::string> indexerNames_;
194 std::string globalDataKey_; // what global data does this fill?
195
196 Teuchos::RCP<const TpetraLinearObjContainer<double,LO,GO,NodeT> > tpetraContainer_;
197
198 // Resolved in preEvaluate(), which accepts either a linear object container
199 // or a read-only ghosted vector under the global data key. Distributed
200 // parameters are only ever supplied as the latter.
201 Teuchos::RCP<const typename TpetraLinearObjContainer<double,LO,GO,NodeT>::MultiVectorType> x_vector;
202
203 // Fields for storing tangent components dx/dp of solution vector x
205 std::vector< std::vector< PHX::MDField<const RealT,Cell,NODE> > > tangentFields_;
206 PHX::ViewOfViews<2,PHX::View<const RealT**>> tangentFieldsVoV_;
207 PHX::View<size_t*> tangentInnerVectorSizes_;
208
210};
211
212// **************************************************************
213// Jacobian
214// **************************************************************
215
223template<typename TRAITS,typename LO,typename GO,typename NodeT>
225 : public panzer::EvaluatorWithBaseImpl<TRAITS>,
226 public PHX::EvaluatorDerived<panzer::Traits::Jacobian, TRAITS>,
228
229public:
231 GatherSolution_Tpetra(const Teuchos::RCP<const panzer::GlobalIndexer> & indexer) :
232 globalIndexer_(indexer) {}
233
235 GatherSolution_Tpetra(const Teuchos::RCP<const panzer::GlobalIndexer> & indexer,
236 const Teuchos::ParameterList& p);
237
239 void postRegistrationSetup(typename TRAITS::SetupData d,
241
243 void preEvaluate(typename TRAITS::PreEvalData d);
244
246 void evaluateFields(typename TRAITS::EvalData d);
247
249 virtual Teuchos::RCP<CloneableEvaluator> clone(const Teuchos::ParameterList & pl) const
250 { return Teuchos::rcp(new GatherSolution_Tpetra<panzer::Traits::Jacobian,TRAITS,LO,GO,NodeT>(globalIndexer_,pl)); }
251
264 KOKKOS_INLINE_FUNCTION
265 void operator()(const int cell) const;
266
267
268
269
270private:
271
274
275 // maps the local (field,element,basis) triplet to a global ID
276 // for scattering
277 Teuchos::RCP<const panzer::GlobalIndexer> globalIndexer_;
278 std::vector<int> fieldIds_; // field IDs needing mapping
279
280 std::vector< PHX::MDField<ScalarT,Cell,NODE> > gatherFields_;
281
282 std::vector<std::string> indexerNames_;
284 bool disableSensitivities_; // This disables sensitivities absolutely
285 std::string sensitivitiesName_; // This sets which gather operations have sensitivities
286 bool applySensitivities_; // This is a local variable that is used by evaluateFields
287 // to turn on/off a certain set of sensitivities
288 std::string globalDataKey_; // what global data does this fill?
289 int gatherSeedIndex_; // what gather seed in the workset to use
290 // if less than zero then use alpha or beta
291 // as appropriate
292
293 Teuchos::RCP<const TpetraLinearObjContainer<double,LO,GO,NodeT> > tpetraContainer_;
294 Teuchos::RCP<typename TpetraLinearObjContainer<double,LO,GO,NodeT>::MultiVectorType> x_vector;
295
297
298 PHX::View<int**> scratch_lids_;
299 std::vector<PHX::View<int*> > scratch_offsets_;
300
301 // functor data
302 struct {
303 // input values
304 PHX::View<const LO**> lids; // local indices for unknowns
305 PHX::View<const int*> offsets; // how to get a particular field
306 Kokkos::View<const double**, Kokkos::LayoutLeft,PHX::Device> x_data;
307 double seed_value; // AD seed information
308 int dos; // Offset for special interface bc
309
310 // output fields
311 PHX::MDField<ScalarT,Cell,NODE> field;
312 } functor_data;
313};
314
315}
316
317#ifdef Panzer_BUILD_HESSIAN_SUPPORT
319#endif
320
321// **************************************************************
322#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 >::MultiVectorType > x_vector
Teuchos::RCP< const typename TpetraLinearObjContainer< double, LO, GO, NodeT >::MultiVectorType > 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_
Teuchos::RCP< const typename TpetraLinearObjContainer< double, LO, GO, NodeT >::MultiVectorType > x_vector
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).