Panzer Version of the Day
Loading...
Searching...
No Matches
Panzer_ScatterResidual_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_SCATTER_RESIDUAL_BLOCKEDTPETRA_DECL_HPP
12#define PANZER_EVALUATOR_SCATTER_RESIDUAL_BLOCKEDTPETRA_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
28
29namespace panzer {
30
31// Forward declarations
32class BlockedDOFManager;
33class GlobalIndexer;
34
39template <typename EvalT,typename TRAITS,typename LO,typename GO,typename NodeT=panzer::TpetraNodeType>
41 : public panzer::EvaluatorWithBaseImpl<TRAITS>,
42 public PHX::EvaluatorDerived<panzer::Traits::Residual, TRAITS>,
44public:
45 typedef typename EvalT::ScalarT ScalarT;
46
47 ScatterResidual_BlockedTpetra(const Teuchos::RCP<const BlockedDOFManager> & /* indexer */)
48 { }
49 ScatterResidual_BlockedTpetra(const Teuchos::RCP<const BlockedDOFManager> & gidProviders,
50 const Teuchos::ParameterList& p);
51
52 virtual Teuchos::RCP<CloneableEvaluator> clone(const Teuchos::ParameterList & pl) const
53 { return Teuchos::rcp(new ScatterResidual_BlockedTpetra<EvalT,TRAITS,LO,GO,NodeT>(Teuchos::null,pl)); }
54
55 void postRegistrationSetup(typename TRAITS::SetupData /* d */, PHX::FieldManager<TRAITS>& /* vm */)
56 { }
57 void evaluateFields(typename TRAITS::EvalData /* d */)
58 { std::cout << "unspecialized version of \"ScatterResidual_BlockedTpetra::evaluateFields\" on \""+PHX::print<EvalT>()+"\" should not be used!" << std::endl;
59 TEUCHOS_ASSERT(false); }
60};
61
62// **************************************************************
63// **************************************************************
64// * Specializations
65// **************************************************************
66// **************************************************************
67
68
69// **************************************************************
70// Residual
71// **************************************************************
72template <typename TRAITS,typename LO,typename GO,typename NodeT>
74 : public panzer::EvaluatorWithBaseImpl<TRAITS>,
75 public PHX::EvaluatorDerived<panzer::Traits::Residual, TRAITS>,
77
78public:
79 ScatterResidual_BlockedTpetra(const Teuchos::RCP<const BlockedDOFManager> & indexer)
80 : globalIndexer_(indexer) {}
81
82 ScatterResidual_BlockedTpetra(const Teuchos::RCP<const BlockedDOFManager> & indexer,
83 const Teuchos::ParameterList& p);
84
85 void postRegistrationSetup(typename TRAITS::SetupData d,
87
88 void preEvaluate(typename TRAITS::PreEvalData d);
89
90 void evaluateFields(typename TRAITS::EvalData workset);
91
92 virtual Teuchos::RCP<CloneableEvaluator> clone(const Teuchos::ParameterList & pl) const
93 { return Teuchos::rcp(new ScatterResidual_BlockedTpetra<panzer::Traits::Residual,TRAITS,LO,GO,NodeT>(globalIndexer_,pl)); }
94
95private:
97 typedef typename TRAITS::RealType RealType;
98
100 typedef Tpetra::Vector<RealType,LO,GO,NodeT> VectorType;
101 typedef Tpetra::CrsMatrix<RealType,LO,GO,NodeT> CrsMatrixType;
102 typedef Tpetra::CrsGraph<LO,GO,NodeT> CrsGraphType;
103 typedef Tpetra::Map<LO,GO,NodeT> MapType;
104 typedef Tpetra::Import<LO,GO,NodeT> ImportType;
105 typedef Tpetra::Export<LO,GO,NodeT> ExportType;
106
108 Teuchos::RCP<PHX::FieldTag> scatterHolder_;
109
111 std::vector< PHX::MDField<const ScalarT,Cell,NODE> > scatterFields_;
112
114 Teuchos::RCP<const BlockedDOFManager> globalIndexer_;
115
117 std::vector<Teuchos::RCP<const panzer::GlobalIndexer>> fieldGlobalIndexers_;
118
120 std::vector<int> fieldIds_;
121
124 std::vector<int> productVectorBlockIndex_;
125
126 // This maps the scattered field names to the DOF manager field
127 // For instance a Navier-Stokes map might look like
128 // fieldMap_["RESIDUAL_Velocity"] --> "Velocity"
129 // fieldMap_["RESIDUAL_Pressure"] --> "Pressure"
130 Teuchos::RCP<const std::map<std::string,std::string> > fieldMap_;
131
132 std::string globalDataKey_; // what global data does this fill?
133 Teuchos::RCP<const BlockedTpetraLinearObjContainer<RealType,LO,GO,NodeT> > blockedContainer_;
134
136 PHX::View<LO**> worksetLIDs_;
137
139 std::vector<PHX::View<int*>> fieldOffsets_;
140
142};
143
144// **************************************************************
145// Jacobian
146// **************************************************************
147
148template <typename TRAITS,typename LO,typename GO,typename NodeT>
150 : public panzer::EvaluatorWithBaseImpl<TRAITS>,
151 public PHX::EvaluatorDerived<panzer::Traits::Jacobian, TRAITS>,
153
154public:
155
176 ScatterResidual_BlockedTpetra(const Teuchos::RCP<const BlockedDOFManager> & indexer)
177 : globalIndexer_(indexer) {}
178
179 ScatterResidual_BlockedTpetra(const Teuchos::RCP<const BlockedDOFManager> & indexer,
180 const Teuchos::ParameterList& p);
181
182 void postRegistrationSetup(typename TRAITS::SetupData d,
184
185 void preEvaluate(typename TRAITS::PreEvalData d);
186
187 void evaluateFields(typename TRAITS::EvalData workset);
188
189 virtual Teuchos::RCP<CloneableEvaluator> clone(const Teuchos::ParameterList & pl) const
190 { return Teuchos::rcp(new ScatterResidual_BlockedTpetra<panzer::Traits::Jacobian,TRAITS,LO,GO,NodeT>(globalIndexer_,pl)); }
191
192private:
194 typedef typename TRAITS::RealType RealType;
195
197 typedef Tpetra::Operator<RealType,LO,GO,NodeT> OperatorType;
198 typedef Tpetra::CrsMatrix<RealType,LO,GO,NodeT> CrsMatrixType;
199 typedef Tpetra::Map<LO,GO,NodeT> MapType;
200
201 typedef Thyra::TpetraLinearOp<RealType,LO,GO,NodeT> ThyraLinearOp;
202
203 // dummy field so that the evaluator will have something to do
204 Teuchos::RCP<PHX::FieldTag> scatterHolder_;
205
206 // fields that need to be scattered will be put in this vector
207 std::vector< PHX::MDField<const ScalarT,Cell,NODE> > scatterFields_;
208
209 // maps the local (field,element,basis) triplet to a global ID
210 // for scattering
211 Teuchos::RCP<const BlockedDOFManager> globalIndexer_;
212
213 std::vector<int> fieldIds_; // field IDs needing mapping
214
217 std::vector<int> productVectorBlockIndex_;
218
219 // This maps the scattered field names to the DOF manager field
220 // For instance a Navier-Stokes map might look like
221 // fieldMap_["RESIDUAL_Velocity"] --> "Velocity"
222 // fieldMap_["RESIDUAL_Pressure"] --> "Pressure"
223 Teuchos::RCP<const std::map<std::string,std::string> > fieldMap_;
224
225 std::string globalDataKey_; // what global data does this fill?
226 Teuchos::RCP<const BlockedTpetraLinearObjContainer<RealType,LO,GO,NodeT> > blockedContainer_;
227
229 Kokkos::View<LO**, Kokkos::LayoutRight, PHX::Device> worksetLIDs_;
230
232 Kokkos::View<typename Sacado::ScalarType<ScalarT>::type**, Kokkos::LayoutRight, PHX::Device> workset_vals_;
233
235 std::vector<PHX::View<int*>> fieldOffsets_;
236
238 PHX::View<LO*> blockOffsets_;
239
241};
242
243// **************************************************************
244// Tangent
245// **************************************************************
246template <typename TRAITS,typename LO,typename GO,typename NodeT>
248 : public panzer::EvaluatorWithBaseImpl<TRAITS>,
249 public PHX::EvaluatorDerived<panzer::Traits::Residual, TRAITS>,
251
252public:
253 ScatterResidual_BlockedTpetra(const Teuchos::RCP<const BlockedDOFManager> & indexer)
254 : globalIndexer_(indexer) {}
255
256 ScatterResidual_BlockedTpetra(const Teuchos::RCP<const BlockedDOFManager> & indexer,
257 const Teuchos::ParameterList& p);
258
259 void postRegistrationSetup(typename TRAITS::SetupData d,
261
262 void preEvaluate(typename TRAITS::PreEvalData d);
263
264 void evaluateFields(typename TRAITS::EvalData workset);
265
266 virtual Teuchos::RCP<CloneableEvaluator> clone(const Teuchos::ParameterList & pl) const
267 { return Teuchos::rcp(new ScatterResidual_BlockedTpetra<panzer::Traits::Tangent,TRAITS,LO,GO,NodeT>(globalIndexer_,pl)); }
268
269private:
271 typedef typename TRAITS::RealType RealType;
272
274 typedef Tpetra::Vector<RealType,LO,GO,NodeT> VectorType;
275 typedef Tpetra::CrsMatrix<RealType,LO,GO,NodeT> CrsMatrixType;
276 typedef Tpetra::CrsGraph<LO,GO,NodeT> CrsGraphType;
277 typedef Tpetra::Map<LO,GO,NodeT> MapType;
278 typedef Tpetra::Import<LO,GO,NodeT> ImportType;
279 typedef Tpetra::Export<LO,GO,NodeT> ExportType;
280
282 Teuchos::RCP<PHX::FieldTag> scatterHolder_;
283
285 std::vector< PHX::MDField<const ScalarT,Cell,NODE> > scatterFields_;
286
288 Teuchos::RCP<const BlockedDOFManager> globalIndexer_;
289
291 std::vector<Teuchos::RCP<const panzer::GlobalIndexer>> fieldGlobalIndexers_;
292
294 std::vector<int> fieldIds_;
295
298 std::vector<int> productVectorBlockIndex_;
299
300 // This maps the scattered field names to the DOF manager field
301 // For instance a Navier-Stokes map might look like
302 // fieldMap_["RESIDUAL_Velocity"] --> "Velocity"
303 // fieldMap_["RESIDUAL_Pressure"] --> "Pressure"
304 Teuchos::RCP<const std::map<std::string,std::string> > fieldMap_;
305
306 std::string globalDataKey_; // what global data does this fill?
307 Teuchos::RCP<const BlockedTpetraLinearObjContainer<RealType,LO,GO,NodeT> > blockedContainer_;
308
310 PHX::ViewOfViews<2,Kokkos::View<RealType**,Kokkos::LayoutLeft,PHX::Device>> dfdpFieldsVoV_;
311
313 PHX::View<LO**> worksetLIDs_;
314
316 std::vector<PHX::View<int*>> fieldOffsets_;
317
319};
320
321}
322
323#ifdef Panzer_BUILD_HESSIAN_SUPPORT
325#endif
326
327// **************************************************************
328#endif
Non-templated empty base class for template managers.
Wrapper to PHX::EvaluatorWithBaseImpl that implements Panzer-specific helpers.
Kokkos::View< typename Sacado::ScalarType< ScalarT >::type **, Kokkos::LayoutRight, PHX::Device > workset_vals_
Scratch space for local values.
virtual Teuchos::RCP< CloneableEvaluator > clone(const Teuchos::ParameterList &pl) const
std::vector< PHX::View< int * > > fieldOffsets_
Offset into the cell lids for each field. Size of number of fields to scatter.
Teuchos::RCP< const BlockedTpetraLinearObjContainer< RealType, LO, GO, NodeT > > blockedContainer_
PHX::View< LO * > blockOffsets_
The offset values of the blocked DOFs per element. Size of number of blocks in the product vector + 1...
Kokkos::View< LO **, Kokkos::LayoutRight, PHX::Device > worksetLIDs_
Local indices for unknowns.
Teuchos::RCP< const BlockedDOFManager > globalIndexer_
Maps the local (field,element,basis) triplet to a global ID for scattering.
std::vector< PHX::View< int * > > fieldOffsets_
Offset into the cell lids for each field.
std::vector< int > fieldIds_
Field IDs in the local product vector block (not global field id)
virtual Teuchos::RCP< CloneableEvaluator > clone(const Teuchos::ParameterList &pl) const
Teuchos::RCP< PHX::FieldTag > scatterHolder_
Dummy evalauted field so that the evaluator will have something to do.
std::vector< Teuchos::RCP< const panzer::GlobalIndexer > > fieldGlobalIndexers_
Vector of global indexers, one for each scattered field respectively.
std::vector< PHX::MDField< const ScalarT, Cell, NODE > > scatterFields_
Fields that need to be scattered will be put in this vector.
Teuchos::RCP< const BlockedTpetraLinearObjContainer< RealType, 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 scattering.
std::vector< PHX::View< int * > > fieldOffsets_
Offset into the cell lids for each field.
PHX::ViewOfViews< 2, Kokkos::View< RealType **, Kokkos::LayoutLeft, PHX::Device > > dfdpFieldsVoV_
Storage for the tangent data.
Teuchos::RCP< PHX::FieldTag > scatterHolder_
Dummy evalauted field so that the evaluator will have something to do.
std::vector< int > fieldIds_
Field IDs in the local product vector block (not global field id)
std::vector< Teuchos::RCP< const panzer::GlobalIndexer > > fieldGlobalIndexers_
Vector of global indexers, one for each scattered field respectively.
std::vector< PHX::MDField< const ScalarT, Cell, NODE > > scatterFields_
Fields that need to be scattered will be put in this vector.
Teuchos::RCP< const BlockedTpetraLinearObjContainer< RealType, LO, GO, NodeT > > blockedContainer_
Pushes residual values into the residual vector for a Newton-based solve.
virtual Teuchos::RCP< CloneableEvaluator > clone(const Teuchos::ParameterList &pl) const
void postRegistrationSetup(typename TRAITS::SetupData, PHX::FieldManager< TRAITS > &)
ScatterResidual_BlockedTpetra(const Teuchos::RCP< const BlockedDOFManager > &)
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),...