Panzer Version of the Day
Loading...
Searching...
No Matches
Panzer_GatherSolution_BlockedTpetra.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_BLOCKEDTPETRA_DECL_HPP
12#define PANZER_EVALUATOR_GATHER_SOLUTION_BLOCKEDTPETRA_DECL_HPP
13
14#include "Phalanx_config.hpp"
15#include "Phalanx_Evaluator_Macros.hpp"
16#include "Phalanx_MDField.hpp"
17
18#include "Teuchos_ParameterList.hpp"
19
20#include "PanzerDiscFE_config.hpp"
21#include "Panzer_Dimension.hpp"
22#include "Panzer_Traits.hpp"
24
26
27namespace panzer {
28
29template <typename ScalarT,typename LocalOrdinalT,typename GlobalOrdinalT,typename NodeT>
30class BlockedTpetraLinearObjContainer;
31
32class GlobalIndexer;
33class BlockedDOFManager;
34
42template <typename EvalT,typename TRAITS,typename S,typename LO,typename GO,typename NodeT=panzer::TpetraNodeType>
44 : public panzer::EvaluatorWithBaseImpl<TRAITS>,
45 public PHX::EvaluatorDerived<panzer::Traits::Residual, TRAITS>,
47public:
48 typedef typename EvalT::ScalarT ScalarT;
49
50 GatherSolution_BlockedTpetra(const Teuchos::RCP<const BlockedDOFManager> & indexer)
51 { }
52
53 GatherSolution_BlockedTpetra(const Teuchos::RCP<const BlockedDOFManager> & gidProviders,
54 const Teuchos::ParameterList& p);
55
56 virtual Teuchos::RCP<CloneableEvaluator> clone(const Teuchos::ParameterList & pl) const
57 { return Teuchos::rcp(new GatherSolution_BlockedTpetra<EvalT,TRAITS,S,LO,GO>(Teuchos::null,pl)); }
58
59 void postRegistrationSetup(typename TRAITS::SetupData d, PHX::FieldManager<TRAITS>& vm)
60 { }
61
62 void evaluateFields(typename TRAITS::EvalData d)
63 { std::cout << "unspecialized version of \"GatherSolution_BlockedTpetra::evaluateFields\" on \""+PHX::print<EvalT>()+"\" should not be used!" << std::endl;
64 TEUCHOS_ASSERT(false); }
65};
66
67// **************************************************************
68// **************************************************************
69// * Specializations
70// **************************************************************
71// **************************************************************
72
73
74// **************************************************************
75// Residual
76// **************************************************************
77template <typename TRAITS,typename S,typename LO,typename GO,typename NodeT>
79 : public panzer::EvaluatorWithBaseImpl<TRAITS>,
80 public PHX::EvaluatorDerived<panzer::Traits::Residual, TRAITS>,
82
83
84public:
85
86 GatherSolution_BlockedTpetra(const Teuchos::RCP<const BlockedDOFManager> & indexer)
87 : globalIndexer_(indexer) {}
88
89 GatherSolution_BlockedTpetra(const Teuchos::RCP<const BlockedDOFManager> & indexer,
90 const Teuchos::ParameterList& p);
91
92 void postRegistrationSetup(typename TRAITS::SetupData d,
94
95 void preEvaluate(typename TRAITS::PreEvalData d);
96
97 void evaluateFields(typename TRAITS::EvalData d);
98
99 virtual Teuchos::RCP<CloneableEvaluator> clone(const Teuchos::ParameterList & pl) const
100 { return Teuchos::rcp(new GatherSolution_BlockedTpetra<panzer::Traits::Residual,TRAITS,S,LO,GO>(globalIndexer_,pl)); }
101
102
103private:
106
108 typedef Tpetra::Vector<S,LO,GO,NodeT> VectorType;
109 typedef Tpetra::CrsMatrix<S,LO,GO,NodeT> CrsMatrixType;
110 typedef Tpetra::CrsGraph<LO,GO,NodeT> CrsGraphType;
111 typedef Tpetra::Map<LO,GO,NodeT> MapType;
112 typedef Tpetra::Import<LO,GO,NodeT> ImportType;
113 typedef Tpetra::Export<LO,GO,NodeT> ExportType;
114
116 // scattering
117 Teuchos::RCP<const BlockedDOFManager> globalIndexer_;
118
120 std::vector<int> fieldIds_;
121
123 std::vector<Teuchos::RCP<const panzer::GlobalIndexer>> fieldGlobalIndexers_;
124
127 std::vector<int> productVectorBlockIndex_;
128
129 std::vector< PHX::MDField<ScalarT,Cell,NODE> > gatherFields_;
130
131 std::vector<std::string> indexerNames_;
133 std::string globalDataKey_; // what global data does this fill?
134
135 Teuchos::RCP<const BlockedTpetraLinearObjContainer<S,LO,GO,NodeT> > blockedContainer_;
136
137 // Fields for storing tangent components dx/dp of solution vector x
138 // These are not actually used by the residual specialization of this evaluator,
139 // even if they are supplied, but it is useful to declare them as dependencies anyway
140 // when saving the tangent components to the output file
142 std::vector< std::vector< PHX::MDField<const ScalarT,Cell,NODE> > > tangentFields_;
143
145 PHX::View<LO**> worksetLIDs_;
146
148 std::vector<PHX::View<int*>> fieldOffsets_;
149
151};
152
153// **************************************************************
154// Tangent
155// **************************************************************
156template <typename TRAITS,typename S,typename LO,typename GO,typename NodeT>
158 : public panzer::EvaluatorWithBaseImpl<TRAITS>,
159 public PHX::EvaluatorDerived<panzer::Traits::Tangent, TRAITS>,
161
162
163public:
164
165 GatherSolution_BlockedTpetra(const Teuchos::RCP<const BlockedDOFManager> & indexer)
166 : globalIndexer_(indexer) {}
167
168 GatherSolution_BlockedTpetra(const Teuchos::RCP<const BlockedDOFManager> & indexer,
169 const Teuchos::ParameterList& p);
170
171 void postRegistrationSetup(typename TRAITS::SetupData d,
173
174 void preEvaluate(typename TRAITS::PreEvalData d);
175
176 void evaluateFields(typename TRAITS::EvalData d);
177
178 virtual Teuchos::RCP<CloneableEvaluator> clone(const Teuchos::ParameterList & pl) const
179 { return Teuchos::rcp(new GatherSolution_BlockedTpetra<panzer::Traits::Tangent,TRAITS,S,LO,GO>(globalIndexer_,pl)); }
180
181
182private:
186
188 typedef Tpetra::Vector<S,LO,GO,NodeT> VectorType;
189 typedef Tpetra::CrsMatrix<S,LO,GO,NodeT> CrsMatrixType;
190 typedef Tpetra::CrsGraph<LO,GO,NodeT> CrsGraphType;
191 typedef Tpetra::Map<LO,GO,NodeT> MapType;
192 typedef Tpetra::Import<LO,GO,NodeT> ImportType;
193 typedef Tpetra::Export<LO,GO,NodeT> ExportType;
194
195 // maps the local (field,element,basis) triplet to a global ID
196 // for scattering
197 Teuchos::RCP<const BlockedDOFManager> globalIndexer_;
198
199 std::vector<int> fieldIds_; // field IDs needing mapping
200
203 std::vector<int> productVectorBlockIndex_;
204
205 std::vector< PHX::MDField<ScalarT,Cell,NODE> > gatherFields_;
206
207 std::vector<std::string> indexerNames_;
209 std::string globalDataKey_; // what global data does this fill?
210
211 Teuchos::RCP<const BlockedTpetraLinearObjContainer<S,LO,GO,NodeT> > blockedContainer_;
212
214 PHX::View<LO**> worksetLIDs_;
215
217 std::vector<PHX::View<int*>> fieldOffsets_;
218
219 // Fields for storing tangent components dx/dp of solution vector x
221 std::vector< std::vector< PHX::MDField<const RealT,Cell,NODE> > > tangentFields_;
222 PHX::ViewOfViews<2,PHX::View<const RealT**>> tangentFieldsVoV_;
223
225};
226
227// **************************************************************
228// Jacobian
229// **************************************************************
230template <typename TRAITS,typename S,typename LO,typename GO,typename NodeT>
232 : public panzer::EvaluatorWithBaseImpl<TRAITS>,
233 public PHX::EvaluatorDerived<panzer::Traits::Jacobian, TRAITS>,
235
236public:
237 GatherSolution_BlockedTpetra(const Teuchos::RCP<const BlockedDOFManager> & indexer)
238 : globalIndexer_(indexer) {}
239
240 GatherSolution_BlockedTpetra(const Teuchos::RCP<const BlockedDOFManager> & indexer,
241 const Teuchos::ParameterList& p);
242
243 void postRegistrationSetup(typename TRAITS::SetupData d,
245
246 void preEvaluate(typename TRAITS::PreEvalData d);
247
248 void evaluateFields(typename TRAITS::EvalData d);
249
250 virtual Teuchos::RCP<CloneableEvaluator> clone(const Teuchos::ParameterList & pl) const
251 { return Teuchos::rcp(new GatherSolution_BlockedTpetra<panzer::Traits::Jacobian,TRAITS,S,LO,GO>(globalIndexer_,pl)); }
252
253private:
256 typedef typename TRAITS::RealType RealType;
257
259 typedef Tpetra::Vector<S,LO,GO,NodeT> VectorType;
260 typedef Tpetra::CrsMatrix<S,LO,GO,NodeT> CrsMatrixType;
261 typedef Tpetra::CrsGraph<LO,GO,NodeT> CrsGraphType;
262 typedef Tpetra::Map<LO,GO,NodeT> MapType;
263 typedef Tpetra::Import<LO,GO,NodeT> ImportType;
264 typedef Tpetra::Export<LO,GO,NodeT> ExportType;
265
266 // maps the local (field,element,basis) triplet to a global ID
267 // for scattering
268 Teuchos::RCP<const BlockedDOFManager> globalIndexer_;
269
270 std::vector<int> fieldIds_; // field IDs needing mapping
271
274 std::vector<int> productVectorBlockIndex_;
275
276 std::vector< PHX::MDField<ScalarT,Cell,NODE> > gatherFields_;
277
278 std::vector<std::string> indexerNames_;
281 std::string globalDataKey_; // what global data does this fill?
282
283 Teuchos::RCP<const BlockedTpetraLinearObjContainer<S,LO,GO,NodeT> > blockedContainer_;
284
286 PHX::View<LO**> worksetLIDs_;
287
289 std::vector<PHX::View<int*>> fieldOffsets_;
290
292 PHX::View<LO*> blockOffsets_;
293
295};
296
297}
298
300
301#ifdef Panzer_BUILD_HESSIAN_SUPPORT
303#endif
304
305// **************************************************************
306#endif
Non-templated empty base class for template managers.
Wrapper to PHX::EvaluatorWithBaseImpl that implements Panzer-specific helpers.
Teuchos::RCP< const BlockedTpetraLinearObjContainer< S, LO, GO, NodeT > > blockedContainer_
virtual Teuchos::RCP< CloneableEvaluator > clone(const Teuchos::ParameterList &pl) const
PHX::View< LO * > blockOffsets_
The offset values of the blocked DOFs per element. Size of number of blocks in the product vector + 1...
std::vector< PHX::View< int * > > fieldOffsets_
Offset into the cell lids for each field. Size of number of fields to scatter.
std::vector< PHX::View< int * > > fieldOffsets_
Offset into the cell lids for each field.
Teuchos::RCP< const BlockedTpetraLinearObjContainer< S, LO, GO, NodeT > > blockedContainer_
virtual Teuchos::RCP< CloneableEvaluator > clone(const Teuchos::ParameterList &pl) const
Teuchos::RCP< const BlockedDOFManager > globalIndexer_
Maps the local (field,element,basis) triplet to a global ID for.
std::vector< Teuchos::RCP< const panzer::GlobalIndexer > > fieldGlobalIndexers_
Vector of global indexers, one for each field to gather, respectively.
std::vector< int > fieldIds_
Field IDs in the local product vector block (not global field id)
std::vector< PHX::View< int * > > fieldOffsets_
Offset into the cell lids for each field. Size of number of fields to scatter.
virtual Teuchos::RCP< CloneableEvaluator > clone(const Teuchos::ParameterList &pl) const
Teuchos::RCP< const BlockedTpetraLinearObjContainer< S, LO, GO, NodeT > > blockedContainer_
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
void postRegistrationSetup(typename TRAITS::SetupData d, PHX::FieldManager< TRAITS > &vm)
GatherSolution_BlockedTpetra(const Teuchos::RCP< const BlockedDOFManager > &indexer)