Panzer Version of the Day
Loading...
Searching...
No Matches
Panzer_ScatterDirichletResidual_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_DIRICHLET_RESIDUAL_BLOCKEDTPETRA_HPP
12#define PANZER_EVALUATOR_SCATTER_DIRICHLET_RESIDUAL_BLOCKEDTPETRA_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 Thyra {
30 template <typename ScalarT> class ProductVectorBase;
31}
32
33namespace panzer {
34
35class BlockedDOFManager;
36class GlobalIndexer;
37
46template <typename EvalT,typename TRAITS,typename LO,typename GO,typename NodeT=panzer::TpetraNodeType>
48 : public panzer::EvaluatorWithBaseImpl<TRAITS>,
49 public PHX::EvaluatorDerived<panzer::Traits::Residual, TRAITS>,
51public:
52 typedef typename EvalT::ScalarT ScalarT;
53 ScatterDirichletResidual_BlockedTpetra(const Teuchos::RCP<const BlockedDOFManager> & /* indexer */)
54 { }
55
56 ScatterDirichletResidual_BlockedTpetra(const Teuchos::RCP<const BlockedDOFManager> & gidProviders,
57 const Teuchos::ParameterList& p);
58
59 virtual Teuchos::RCP<CloneableEvaluator> clone(const Teuchos::ParameterList & pl) const
60 { return Teuchos::rcp(new ScatterDirichletResidual_BlockedTpetra<EvalT,TRAITS,LO,GO,NodeT>(Teuchos::null,pl)); }
61
62 void postRegistrationSetup(typename TRAITS::SetupData /* d */, PHX::FieldManager<TRAITS>& /* vm */)
63 { }
64 void evaluateFields(typename TRAITS::EvalData /* d */)
65 { std::cout << "unspecialized version of \"ScatterDirichletResidual_BlockedTpetra::evaluateFields\" on \""+PHX::print<EvalT>()+"\" should not be used!" << std::endl;
66 TEUCHOS_ASSERT(false); }
67};
68
69// **************************************************************
70// **************************************************************
71// * Specializations
72// **************************************************************
73// **************************************************************
74
75
76// **************************************************************
77// Residual
78// **************************************************************
79template <typename TRAITS,typename LO,typename GO,typename NodeT>
81 : public panzer::EvaluatorWithBaseImpl<TRAITS>,
82 public PHX::EvaluatorDerived<panzer::Traits::Residual, TRAITS>,
84
85public:
86 ScatterDirichletResidual_BlockedTpetra(const Teuchos::RCP<const BlockedDOFManager> & indexer)
87 : globalIndexer_(indexer) {}
88
89 ScatterDirichletResidual_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 workset);
98
99 virtual Teuchos::RCP<CloneableEvaluator> clone(const Teuchos::ParameterList & pl) const
101
102private:
104 typedef typename TRAITS::RealType RealType;
105
107 typedef Tpetra::Vector<RealType,LO,GO,NodeT> VectorType;
108 typedef Tpetra::CrsMatrix<RealType,LO,GO,NodeT> CrsMatrixType;
109 typedef Tpetra::CrsGraph<LO,GO,NodeT> CrsGraphType;
110 typedef Tpetra::Map<LO,GO,NodeT> MapType;
111 typedef Tpetra::Import<LO,GO,NodeT> ImportType;
112 typedef Tpetra::Export<LO,GO,NodeT> ExportType;
113
114 // dummy field so that the evaluator will have something to do
115 Teuchos::RCP<PHX::FieldTag> scatterHolder_;
116
117 // fields that need to be scattered will be put in this vector
118 std::vector< PHX::MDField<const ScalarT,Cell,NODE> > scatterFields_;
119
120 // maps the local (field,element,basis) triplet to a global ID
121 // for scattering
122 Teuchos::RCP<const panzer::BlockedDOFManager> globalIndexer_;
123
127 std::vector<Teuchos::RCP<const panzer::GlobalIndexer>> fieldGlobalIndexers_;
128
130 std::vector<int> fieldIds_;
131
134 std::vector<int> productVectorBlockIndex_;
135
136 // This maps the scattered field names to the DOF manager field
137 // For instance a Navier-Stokes map might look like
138 // fieldMap_["RESIDUAL_Velocity"] --> "Velocity"
139 // fieldMap_["RESIDUAL_Pressure"] --> "Pressure"
140 Teuchos::RCP<const std::map<std::string,std::string> > fieldMap_;
141
143 PHX::View<LO**> worksetLIDs_;
144
146 std::vector<PHX::View<int*>> fieldOffsets_;
147
151 std::vector<PHX::View<int*>> basisIndexForMDFieldOffsets_;
152
153 std::size_t side_subcell_dim_;
154 std::size_t local_side_id_;
155
156 Teuchos::RCP<Thyra::ProductVectorBase<double> > dirichletCounter_;
157 std::string globalDataKey_; // what global data does this fill?
158 Teuchos::RCP<const BlockedTpetraLinearObjContainer<RealType,LO,GO,NodeT> > blockedContainer_;
159
162
163 // If set to true, scattering an initial condition
165
166 // Allows runtime disabling of dirichlet BCs on node-by-node basis
167 std::vector< PHX::MDField<const bool,Cell,NODE> > applyBC_;
168
170};
171
172// **************************************************************
173// Jacobian
174// **************************************************************
175template <typename TRAITS,typename LO,typename GO,typename NodeT>
177 : public panzer::EvaluatorWithBaseImpl<TRAITS>,
178 public PHX::EvaluatorDerived<panzer::Traits::Jacobian, TRAITS>,
180
181public:
182 ScatterDirichletResidual_BlockedTpetra(const Teuchos::RCP<const BlockedDOFManager> & indexer)
183 : globalIndexer_(indexer) {}
184
185 ScatterDirichletResidual_BlockedTpetra(const Teuchos::RCP<const BlockedDOFManager> & indexer,
186 const Teuchos::ParameterList& p);
187
188 void preEvaluate(typename TRAITS::PreEvalData d);
189
190 void postRegistrationSetup(typename TRAITS::SetupData d,
192
193 void evaluateFields(typename TRAITS::EvalData workset);
194
195 virtual Teuchos::RCP<CloneableEvaluator> clone(const Teuchos::ParameterList & pl) const
197
198private:
200 typedef typename TRAITS::RealType RealType;
201
203 typedef Tpetra::Operator<RealType,LO,GO,NodeT> OperatorType;
204 typedef Tpetra::CrsMatrix<RealType,LO,GO,NodeT> CrsMatrixType;
205 typedef Tpetra::Map<LO,GO,NodeT> MapType;
206
207 typedef Thyra::TpetraLinearOp<RealType,LO,GO,NodeT> ThyraLinearOp;
208
209 // dummy field so that the evaluator will have something to do
210 Teuchos::RCP<PHX::FieldTag> scatterHolder_;
211
212 // fields that need to be scattered will be put in this vector
213 std::vector< PHX::MDField<const ScalarT,Cell,NODE> > scatterFields_;
214
215 // maps the local (field,element,basis) triplet to a global ID
216 // for scattering
217 Teuchos::RCP<const panzer::BlockedDOFManager> globalIndexer_;
218
219 std::vector<int> fieldIds_; // field IDs needing mapping
220
223 std::vector<int> productVectorBlockIndex_;
224
225 // This maps the scattered field names to the DOF manager field
226 // For instance a Navier-Stokes map might look like
227 // fieldMap_["RESIDUAL_Velocity"] --> "Velocity"
228 // fieldMap_["RESIDUAL_Pressure"] --> "Pressure"
229 Teuchos::RCP<const std::map<std::string,std::string> > fieldMap_;
230
231 std::size_t side_subcell_dim_;
232 std::size_t local_side_id_;
233
234 Teuchos::RCP<Thyra::ProductVectorBase<double> > dirichletCounter_;
235 std::string globalDataKey_; // what global data does this fill?
236 Teuchos::RCP<const BlockedTpetraLinearObjContainer<RealType,LO,GO,NodeT> > blockedContainer_;
237
239 PHX::View<LO**> worksetLIDs_;
240
242 std::vector<PHX::View<int*>> fieldOffsets_;
243
247 std::vector<PHX::View<int*>> basisIndexForMDFieldOffsets_;
248
250 PHX::View<LO*> blockOffsets_;
251
254
255 // Allows runtime disabling of dirichlet BCs on node-by-node basis
256 std::vector< PHX::MDField<const bool,Cell,NODE> > applyBC_;
257
259 static constexpr int maxDerivativeArraySize_ = 256;
260
262};
263
264// **************************************************************
265// Tangent
266// **************************************************************
267template <typename TRAITS,typename LO,typename GO,typename NodeT>
269 : public panzer::EvaluatorWithBaseImpl<TRAITS>,
270 public PHX::EvaluatorDerived<panzer::Traits::Tangent, TRAITS>,
272
273public:
274 ScatterDirichletResidual_BlockedTpetra(const Teuchos::RCP<const BlockedDOFManager> & indexer)
275 : globalIndexer_(indexer) {}
276
277 ScatterDirichletResidual_BlockedTpetra(const Teuchos::RCP<const BlockedDOFManager> & indexer,
278 const Teuchos::ParameterList& p);
279
280 void postRegistrationSetup(typename TRAITS::SetupData d,
282
283 void preEvaluate(typename TRAITS::PreEvalData d);
284
285 void evaluateFields(typename TRAITS::EvalData workset);
286
287 virtual Teuchos::RCP<CloneableEvaluator> clone(const Teuchos::ParameterList & pl) const
289
290private:
292 typedef typename TRAITS::RealType RealType;
293
295 typedef Tpetra::Vector<RealType,LO,GO,NodeT> VectorType;
296 typedef Tpetra::CrsMatrix<RealType,LO,GO,NodeT> CrsMatrixType;
297 typedef Tpetra::CrsGraph<LO,GO,NodeT> CrsGraphType;
298 typedef Tpetra::Map<LO,GO,NodeT> MapType;
299 typedef Tpetra::Import<LO,GO,NodeT> ImportType;
300 typedef Tpetra::Export<LO,GO,NodeT> ExportType;
301
302 // dummy field so that the evaluator will have something to do
303 Teuchos::RCP<PHX::FieldTag> scatterHolder_;
304
305 // fields that need to be scattered will be put in this vector
306 std::vector< PHX::MDField<const ScalarT,Cell,NODE> > scatterFields_;
307
308 // maps the local (field,element,basis) triplet to a global ID
309 // for scattering
310 Teuchos::RCP<const panzer::BlockedDOFManager> globalIndexer_;
311
315 std::vector<Teuchos::RCP<const panzer::GlobalIndexer>> fieldGlobalIndexers_;
316
318 std::vector<int> fieldIds_;
319
322 std::vector<int> productVectorBlockIndex_;
323
324 // This maps the scattered field names to the DOF manager field
325 // For instance a Navier-Stokes map might look like
326 // fieldMap_["RESIDUAL_Velocity"] --> "Velocity"
327 // fieldMap_["RESIDUAL_Pressure"] --> "Pressure"
328 Teuchos::RCP<const std::map<std::string,std::string> > fieldMap_;
329
331 PHX::View<LO**> worksetLIDs_;
332
334 std::vector<PHX::View<int*>> fieldOffsets_;
335
339 std::vector<PHX::View<int*>> basisIndexForMDFieldOffsets_;
340
341 std::size_t side_subcell_dim_;
342 std::size_t local_side_id_;
343
344 Teuchos::RCP<Thyra::ProductVectorBase<double> > dirichletCounter_;
345 std::string globalDataKey_; // what global data does this fill?
346 Teuchos::RCP<const BlockedTpetraLinearObjContainer<RealType,LO,GO,NodeT> > blockedContainer_;
347
350
351 // If set to true, scattering an initial condition
353
354 // Allows runtime disabling of dirichlet BCs on node-by-node basis
355 std::vector< PHX::MDField<const bool,Cell,NODE> > applyBC_;
356
357 // Storage for the tangent data
358 PHX::ViewOfViews<2,Kokkos::View<RealType**,Kokkos::LayoutLeft,PHX::Device>> dfdpFieldsVoV_;
359
361};
362
363}
364
365#ifdef Panzer_BUILD_HESSIAN_SUPPORT
367#endif
368
369// **************************************************************
370#endif
Non-templated empty base class for template managers.
Wrapper to PHX::EvaluatorWithBaseImpl that implements Panzer-specific helpers.
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.
Pushes residual values into the residual vector for a Newton-based solve.
virtual Teuchos::RCP< CloneableEvaluator > clone(const Teuchos::ParameterList &pl) const
ScatterDirichletResidual_BlockedTpetra(const Teuchos::RCP< const BlockedDOFManager > &)
void postRegistrationSetup(typename TRAITS::SetupData, PHX::FieldManager< TRAITS > &)
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),...