Panzer  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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 
20 
21 #include "PanzerDiscFE_config.hpp"
22 #include "Panzer_Dimension.hpp"
23 #include "Panzer_Traits.hpp"
26 
28 
29 namespace Thyra {
30  template <typename ScalarT> class ProductVectorBase;
31 }
32 
33 namespace panzer {
34 
35 class BlockedDOFManager;
36 class GlobalIndexer;
37 
46 template <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>,
51 public:
52  typedef typename EvalT::ScalarT ScalarT;
54  { }
55 
57  const Teuchos::ParameterList& p);
58 
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 // **************************************************************
79 template <typename TRAITS,typename LO,typename GO,typename NodeT>
81  : public panzer::EvaluatorWithBaseImpl<TRAITS>,
82  public PHX::EvaluatorDerived<panzer::Traits::Residual, TRAITS>,
84 
85 public:
87  : globalIndexer_(indexer) {}
88 
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 
101 
102 private:
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
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
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"
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 
157  std::string globalDataKey_; // what global data does this fill?
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 // **************************************************************
175 template <typename TRAITS,typename LO,typename GO,typename NodeT>
177  : public panzer::EvaluatorWithBaseImpl<TRAITS>,
178  public PHX::EvaluatorDerived<panzer::Traits::Jacobian, TRAITS>,
180 
181 public:
183  : globalIndexer_(indexer) {}
184 
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 
197 
198 private:
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
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
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"
230 
231  std::size_t side_subcell_dim_;
232  std::size_t local_side_id_;
233 
235  std::string globalDataKey_; // what global data does this fill?
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 // **************************************************************
267 template <typename TRAITS,typename LO,typename GO,typename NodeT>
269  : public panzer::EvaluatorWithBaseImpl<TRAITS>,
270  public PHX::EvaluatorDerived<panzer::Traits::Tangent, TRAITS>,
272 
273 public:
275  : globalIndexer_(indexer) {}
276 
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 
289 
290 private:
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
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
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"
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 
345  std::string globalDataKey_; // what global data does this fill?
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
359 
361 };
362 
363 }
364 
365 #ifdef Panzer_BUILD_HESSIAN_SUPPORT
367 #endif
368 
369 // **************************************************************
370 #endif
PHX::ViewOfViews< 2, Kokkos::View< RealType **, Kokkos::LayoutLeft, PHX::Device > > dfdpFieldsVoV_
ScatterDirichletResidual_BlockedTpetra(const Teuchos::RCP< const BlockedDOFManager > &)
bool checkApplyBC_
If set to true, allows runtime disabling of dirichlet BCs on node-by-node basis.
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)
Wrapper to PHX::EvaluatorWithBaseImpl that implements Panzer-specific helpers.
virtual Teuchos::RCP< CloneableEvaluator > clone(const Teuchos::ParameterList &pl) const
bool checkApplyBC_
If set to true, allows runtime disabling of dirichlet BCs on node-by-node basis.
PHX::View< LO * > blockOffsets_
The offset values of the blocked DOFs per element. Size of number of blocks in the product vector + 1...
virtual void preEvaluate(typename Traits::PreEvalData d)=0
bool checkApplyBC_
If set to true, allows runtime disabling of dirichlet BCs on node-by-node basis.
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.
#define TEUCHOS_ASSERT(assertion_test)
void postRegistrationSetup(typename TRAITS::SetupData, PHX::FieldManager< TRAITS > &)
Non-templated empty base class for template managers.