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 //
4 // Panzer: A partial differential equation assembly
5 // engine for strongly coupled complex multiphysics systems
6 // Copyright (2011) Sandia Corporation
7 //
8 // Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation,
9 // the U.S. Government retains certain rights in this software.
10 //
11 // Redistribution and use in source and binary forms, with or without
12 // modification, are permitted provided that the following conditions are
13 // met:
14 //
15 // 1. Redistributions of source code must retain the above copyright
16 // notice, this list of conditions and the following disclaimer.
17 //
18 // 2. Redistributions in binary form must reproduce the above copyright
19 // notice, this list of conditions and the following disclaimer in the
20 // documentation and/or other materials provided with the distribution.
21 //
22 // 3. Neither the name of the Corporation nor the names of the
23 // contributors may be used to endorse or promote products derived from
24 // this software without specific prior written permission.
25 //
26 // THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY
27 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
28 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
29 // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE
30 // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
31 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
32 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
33 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
34 // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
35 // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
36 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
37 //
38 // Questions? Contact Roger P. Pawlowski (rppawlo@sandia.gov) and
39 // Eric C. Cyr (eccyr@sandia.gov)
40 // ***********************************************************************
41 // @HEADER
42 
43 #ifndef PANZER_EVALUATOR_SCATTER_DIRICHLET_RESIDUAL_BLOCKEDTPETRA_HPP
44 #define PANZER_EVALUATOR_SCATTER_DIRICHLET_RESIDUAL_BLOCKEDTPETRA_HPP
45 
46 #include "Phalanx_config.hpp"
47 #include "Phalanx_Evaluator_Macros.hpp"
48 #include "Phalanx_MDField.hpp"
49 
51 
52 #include "PanzerDiscFE_config.hpp"
53 #include "Panzer_Dimension.hpp"
54 #include "Panzer_Traits.hpp"
57 
59 
60 namespace Thyra {
61  template <typename ScalarT> class ProductVectorBase;
62 }
63 
64 namespace panzer {
65 
66 class BlockedDOFManager;
67 class GlobalIndexer;
68 
77 template <typename EvalT,typename TRAITS,typename LO,typename GO,typename NodeT=panzer::TpetraNodeType>
79  : public panzer::EvaluatorWithBaseImpl<TRAITS>,
80  public PHX::EvaluatorDerived<panzer::Traits::Residual, TRAITS>,
82 public:
83  typedef typename EvalT::ScalarT ScalarT;
85  { }
86 
88  const Teuchos::ParameterList& p);
89 
92 
93  void postRegistrationSetup(typename TRAITS::SetupData /* d */, PHX::FieldManager<TRAITS>& /* vm */)
94  { }
95  void evaluateFields(typename TRAITS::EvalData /* d */)
96  { std::cout << "unspecialized version of \"ScatterDirichletResidual_BlockedTpetra::evaluateFields\" on \""+PHX::print<EvalT>()+"\" should not be used!" << std::endl;
97  TEUCHOS_ASSERT(false); }
98 };
99 
100 // **************************************************************
101 // **************************************************************
102 // * Specializations
103 // **************************************************************
104 // **************************************************************
105 
106 
107 // **************************************************************
108 // Residual
109 // **************************************************************
110 template <typename TRAITS,typename LO,typename GO,typename NodeT>
112  : public panzer::EvaluatorWithBaseImpl<TRAITS>,
113  public PHX::EvaluatorDerived<panzer::Traits::Residual, TRAITS>,
115 
116 public:
118  : globalIndexer_(indexer) {}
119 
121  const Teuchos::ParameterList& p);
122 
123  void postRegistrationSetup(typename TRAITS::SetupData d,
125 
126  void preEvaluate(typename TRAITS::PreEvalData d);
127 
128  void evaluateFields(typename TRAITS::EvalData workset);
129 
132 
133 private:
135  typedef typename TRAITS::RealType RealType;
136 
138  typedef Tpetra::Vector<RealType,LO,GO,NodeT> VectorType;
139  typedef Tpetra::CrsMatrix<RealType,LO,GO,NodeT> CrsMatrixType;
140  typedef Tpetra::CrsGraph<LO,GO,NodeT> CrsGraphType;
141  typedef Tpetra::Map<LO,GO,NodeT> MapType;
142  typedef Tpetra::Import<LO,GO,NodeT> ImportType;
143  typedef Tpetra::Export<LO,GO,NodeT> ExportType;
144 
145  // dummy field so that the evaluator will have something to do
147 
148  // fields that need to be scattered will be put in this vector
149  std::vector< PHX::MDField<const ScalarT,Cell,NODE> > scatterFields_;
150 
151  // maps the local (field,element,basis) triplet to a global ID
152  // for scattering
154 
158  std::vector<Teuchos::RCP<const panzer::GlobalIndexer>> fieldGlobalIndexers_;
159 
161  std::vector<int> fieldIds_;
162 
165  std::vector<int> productVectorBlockIndex_;
166 
167  // This maps the scattered field names to the DOF manager field
168  // For instance a Navier-Stokes map might look like
169  // fieldMap_["RESIDUAL_Velocity"] --> "Velocity"
170  // fieldMap_["RESIDUAL_Pressure"] --> "Pressure"
172 
174  PHX::View<LO**> worksetLIDs_;
175 
177  std::vector<PHX::View<int*>> fieldOffsets_;
178 
182  std::vector<PHX::View<int*>> basisIndexForMDFieldOffsets_;
183 
184  std::size_t side_subcell_dim_;
185  std::size_t local_side_id_;
186 
188  std::string globalDataKey_; // what global data does this fill?
190 
193 
194  // If set to true, scattering an initial condition
196 
197  // Allows runtime disabling of dirichlet BCs on node-by-node basis
198  std::vector< PHX::MDField<const bool,Cell,NODE> > applyBC_;
199 
201 };
202 
203 // **************************************************************
204 // Jacobian
205 // **************************************************************
206 template <typename TRAITS,typename LO,typename GO,typename NodeT>
208  : public panzer::EvaluatorWithBaseImpl<TRAITS>,
209  public PHX::EvaluatorDerived<panzer::Traits::Jacobian, TRAITS>,
211 
212 public:
214  : globalIndexer_(indexer) {}
215 
217  const Teuchos::ParameterList& p);
218 
219  void preEvaluate(typename TRAITS::PreEvalData d);
220 
221  void postRegistrationSetup(typename TRAITS::SetupData d,
223 
224  void evaluateFields(typename TRAITS::EvalData workset);
225 
228 
229 private:
231  typedef typename TRAITS::RealType RealType;
232 
234  typedef Tpetra::Operator<RealType,LO,GO,NodeT> OperatorType;
235  typedef Tpetra::CrsMatrix<RealType,LO,GO,NodeT> CrsMatrixType;
236  typedef Tpetra::Map<LO,GO,NodeT> MapType;
237 
238  typedef Thyra::TpetraLinearOp<RealType,LO,GO,NodeT> ThyraLinearOp;
239 
240  // dummy field so that the evaluator will have something to do
242 
243  // fields that need to be scattered will be put in this vector
244  std::vector< PHX::MDField<const ScalarT,Cell,NODE> > scatterFields_;
245 
246  // maps the local (field,element,basis) triplet to a global ID
247  // for scattering
249 
250  std::vector<int> fieldIds_; // field IDs needing mapping
251 
254  std::vector<int> productVectorBlockIndex_;
255 
256  // This maps the scattered field names to the DOF manager field
257  // For instance a Navier-Stokes map might look like
258  // fieldMap_["RESIDUAL_Velocity"] --> "Velocity"
259  // fieldMap_["RESIDUAL_Pressure"] --> "Pressure"
261 
262  std::size_t side_subcell_dim_;
263  std::size_t local_side_id_;
264 
266  std::string globalDataKey_; // what global data does this fill?
268 
270  PHX::View<LO**> worksetLIDs_;
271 
273  std::vector<PHX::View<int*>> fieldOffsets_;
274 
278  std::vector<PHX::View<int*>> basisIndexForMDFieldOffsets_;
279 
281  PHX::View<LO*> blockOffsets_;
282 
285 
286  // Allows runtime disabling of dirichlet BCs on node-by-node basis
287  std::vector< PHX::MDField<const bool,Cell,NODE> > applyBC_;
288 
290  static constexpr int maxDerivativeArraySize_ = 256;
291 
293 };
294 
295 }
296 
297 #ifdef Panzer_BUILD_HESSIAN_SUPPORT
299 #endif
300 
301 // **************************************************************
302 #endif
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
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.