Panzer  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Panzer_ScatterResidual_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_RESIDUAL_BLOCKEDTPETRA_DECL_HPP
44 #define PANZER_EVALUATOR_SCATTER_RESIDUAL_BLOCKEDTPETRA_DECL_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 panzer {
61 
62 // Forward declarations
63 class BlockedDOFManager;
64 class GlobalIndexer;
65 
70 template <typename EvalT,typename TRAITS,typename LO,typename GO,typename NodeT=panzer::TpetraNodeType>
72  : public panzer::EvaluatorWithBaseImpl<TRAITS>,
73  public PHX::EvaluatorDerived<panzer::Traits::Residual, TRAITS>,
75 public:
76  typedef typename EvalT::ScalarT ScalarT;
77 
79  { }
81  const Teuchos::ParameterList& p);
82 
85 
86  void postRegistrationSetup(typename TRAITS::SetupData /* d */, PHX::FieldManager<TRAITS>& /* vm */)
87  { }
88  void evaluateFields(typename TRAITS::EvalData /* d */)
89  { std::cout << "unspecialized version of \"ScatterResidual_BlockedTpetra::evaluateFields\" on \""+PHX::print<EvalT>()+"\" should not be used!" << std::endl;
90  TEUCHOS_ASSERT(false); }
91 };
92 
93 // **************************************************************
94 // **************************************************************
95 // * Specializations
96 // **************************************************************
97 // **************************************************************
98 
99 
100 // **************************************************************
101 // Residual
102 // **************************************************************
103 template <typename TRAITS,typename LO,typename GO,typename NodeT>
104 class ScatterResidual_BlockedTpetra<panzer::Traits::Residual,TRAITS,LO,GO,NodeT>
105  : public panzer::EvaluatorWithBaseImpl<TRAITS>,
106  public PHX::EvaluatorDerived<panzer::Traits::Residual, TRAITS>,
108 
109 public:
111  : globalIndexer_(indexer) {}
112 
114  const Teuchos::ParameterList& p);
115 
116  void postRegistrationSetup(typename TRAITS::SetupData d,
118 
119  void preEvaluate(typename TRAITS::PreEvalData d);
120 
121  void evaluateFields(typename TRAITS::EvalData workset);
122 
125 
126 private:
128  typedef typename TRAITS::RealType RealType;
129 
131  typedef Tpetra::Vector<RealType,LO,GO,NodeT> VectorType;
132  typedef Tpetra::CrsMatrix<RealType,LO,GO,NodeT> CrsMatrixType;
133  typedef Tpetra::CrsGraph<LO,GO,NodeT> CrsGraphType;
134  typedef Tpetra::Map<LO,GO,NodeT> MapType;
135  typedef Tpetra::Import<LO,GO,NodeT> ImportType;
136  typedef Tpetra::Export<LO,GO,NodeT> ExportType;
137 
140 
142  std::vector< PHX::MDField<const ScalarT,Cell,NODE> > scatterFields_;
143 
146 
148  std::vector<Teuchos::RCP<const panzer::GlobalIndexer>> fieldGlobalIndexers_;
149 
151  std::vector<int> fieldIds_;
152 
155  std::vector<int> productVectorBlockIndex_;
156 
157  // This maps the scattered field names to the DOF manager field
158  // For instance a Navier-Stokes map might look like
159  // fieldMap_["RESIDUAL_Velocity"] --> "Velocity"
160  // fieldMap_["RESIDUAL_Pressure"] --> "Pressure"
162 
163  std::string globalDataKey_; // what global data does this fill?
165 
167  PHX::View<LO**> worksetLIDs_;
168 
170  std::vector<PHX::View<int*>> fieldOffsets_;
171 
173 };
174 
175 // **************************************************************
176 // Jacobian
177 // **************************************************************
178 
179 template <typename TRAITS,typename LO,typename GO,typename NodeT>
180 class ScatterResidual_BlockedTpetra<panzer::Traits::Jacobian,TRAITS,LO,GO,NodeT>
181  : public panzer::EvaluatorWithBaseImpl<TRAITS>,
182  public PHX::EvaluatorDerived<panzer::Traits::Jacobian, TRAITS>,
184 
185 public:
186 
208  : globalIndexer_(indexer) {}
209 
211  const Teuchos::ParameterList& p);
212 
213  void postRegistrationSetup(typename TRAITS::SetupData d,
215 
216  void preEvaluate(typename TRAITS::PreEvalData d);
217 
218  void evaluateFields(typename TRAITS::EvalData workset);
219 
222 
223 private:
225  typedef typename TRAITS::RealType RealType;
226 
228  typedef Tpetra::Operator<RealType,LO,GO,NodeT> OperatorType;
229  typedef Tpetra::CrsMatrix<RealType,LO,GO,NodeT> CrsMatrixType;
230  typedef Tpetra::Map<LO,GO,NodeT> MapType;
231 
232  typedef Thyra::TpetraLinearOp<RealType,LO,GO,NodeT> ThyraLinearOp;
233 
234  // dummy field so that the evaluator will have something to do
236 
237  // fields that need to be scattered will be put in this vector
238  std::vector< PHX::MDField<const ScalarT,Cell,NODE> > scatterFields_;
239 
240  // maps the local (field,element,basis) triplet to a global ID
241  // for scattering
243 
244  std::vector<int> fieldIds_; // field IDs needing mapping
245 
248  std::vector<int> productVectorBlockIndex_;
249 
250  // This maps the scattered field names to the DOF manager field
251  // For instance a Navier-Stokes map might look like
252  // fieldMap_["RESIDUAL_Velocity"] --> "Velocity"
253  // fieldMap_["RESIDUAL_Pressure"] --> "Pressure"
255 
256  std::string globalDataKey_; // what global data does this fill?
258 
261 
264 
266  std::vector<PHX::View<int*>> fieldOffsets_;
267 
269  PHX::View<LO*> blockOffsets_;
270 
272 };
273 
274 }
275 
276 #ifdef Panzer_BUILD_HESSIAN_SUPPORT
278 #endif
279 
280 // **************************************************************
281 #endif
Teuchos::RCP< PHX::FieldTag > scatterHolder_
Dummy evalauted field so that the evaluator will have something to do.
virtual Teuchos::RCP< CloneableEvaluator > clone(const Teuchos::ParameterList &pl) const
Pushes residual values into the residual vector for a Newton-based solve.
std::vector< PHX::View< int * > > fieldOffsets_
Offset into the cell lids for each field. Size of number of fields to scatter.
void postRegistrationSetup(typename TRAITS::SetupData, PHX::FieldManager< TRAITS > &)
ScatterResidual_BlockedTpetra(const Teuchos::RCP< const BlockedDOFManager > &)
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.
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)
Wrapper to PHX::EvaluatorWithBaseImpl that implements Panzer-specific helpers.
Teuchos::RCP< const BlockedTpetraLinearObjContainer< RealType, LO, GO, NodeT > > blockedContainer_
virtual void preEvaluate(typename Traits::PreEvalData d)=0
virtual Teuchos::RCP< CloneableEvaluator > clone(const Teuchos::ParameterList &pl) const
Teuchos::RCP< const BlockedTpetraLinearObjContainer< RealType, 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.
std::vector< PHX::MDField< const ScalarT, Cell, NODE > > scatterFields_
Fields that need to be scattered will be put in this vector.
#define TEUCHOS_ASSERT(assertion_test)
Non-templated empty base class for template managers.
Kokkos::View< typename Sacado::ScalarType< ScalarT >::type **, Kokkos::LayoutRight, PHX::Device > workset_vals_
Scratch space for local values.
Teuchos::RCP< const BlockedDOFManager > globalIndexer_
Maps the local (field,element,basis) triplet to a global ID for scattering.
Kokkos::View< LO **, Kokkos::LayoutRight, PHX::Device > worksetLIDs_
Local indices for unknowns.