Panzer  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Panzer_GatherSolution_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_GATHER_SOLUTION_BLOCKEDTPETRA_DECL_HPP
44 #define PANZER_EVALUATOR_GATHER_SOLUTION_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"
56 
58 
59 namespace panzer {
60 
61 template <typename ScalarT,typename LocalOrdinalT,typename GlobalOrdinalT,typename NodeT>
63 
64 template <typename LocalOrdinalT,typename GlobalOrdinalT>
65 class UniqueGlobalIndexer; //forward declaration
66 
67 template <typename LocalOrdinalT,typename GlobalOrdinalT>
68 class BlockedDOFManager; //forward declaration
69 
77 template <typename EvalT,typename TRAITS,typename S,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;
84 
86  { }
87 
89  const Teuchos::ParameterList& p);
90 
92  { return Teuchos::rcp(new GatherSolution_BlockedTpetra<EvalT,TRAITS,S,LO,GO>(Teuchos::null,pl)); }
93 
94  void postRegistrationSetup(typename TRAITS::SetupData d, PHX::FieldManager<TRAITS>& vm)
95  { }
96 
97  void evaluateFields(typename TRAITS::EvalData d)
98  { std::cout << "unspecialized version of \"GatherSolution_BlockedTpetra::evaluateFields\" on \""+PHX::typeAsString<EvalT>()+"\" should not be used!" << std::endl;
99  TEUCHOS_ASSERT(false); }
100 };
101 
102 // **************************************************************
103 // **************************************************************
104 // * Specializations
105 // **************************************************************
106 // **************************************************************
107 
108 
109 // **************************************************************
110 // Residual
111 // **************************************************************
112 template <typename TRAITS,typename S,typename LO,typename GO,typename NodeT>
113 class GatherSolution_BlockedTpetra<panzer::Traits::Residual,TRAITS,S,LO,GO,NodeT>
114  : public panzer::EvaluatorWithBaseImpl<TRAITS>,
115  public PHX::EvaluatorDerived<panzer::Traits::Residual, TRAITS>,
117 
118 
119 public:
120 
122  : globalIndexer_(indexer) {}
123 
125  const Teuchos::ParameterList& p);
126 
127  void postRegistrationSetup(typename TRAITS::SetupData d,
129 
130  void preEvaluate(typename TRAITS::PreEvalData d);
131 
132  void evaluateFields(typename TRAITS::EvalData d);
133 
136 
137 
138 private:
139  typedef typename panzer::Traits::Residual EvalT;
141 
143  typedef Tpetra::Vector<S,LO,GO,NodeT> VectorType;
144  typedef Tpetra::CrsMatrix<S,LO,GO,NodeT> CrsMatrixType;
145  typedef Tpetra::CrsGraph<LO,GO,NodeT> CrsGraphType;
146  typedef Tpetra::Map<LO,GO,NodeT> MapType;
147  typedef Tpetra::Import<LO,GO,NodeT> ImportType;
148  typedef Tpetra::Export<LO,GO,NodeT> ExportType;
149 
151  // scattering
153 
155  std::vector<int> fieldIds_;
156 
158  std::vector<Teuchos::RCP<const panzer::UniqueGlobalIndexer<LO,GO>>> fieldGlobalIndexers_;
159 
162  std::vector<int> productVectorBlockIndex_;
163 
164  std::vector< PHX::MDField<ScalarT,Cell,NODE> > gatherFields_;
165 
166  std::vector<std::string> indexerNames_;
168  std::string globalDataKey_; // what global data does this fill?
169 
171 
172  // Fields for storing tangent components dx/dp of solution vector x
173  // These are not actually used by the residual specialization of this evaluator,
174  // even if they are supplied, but it is useful to declare them as dependencies anyway
175  // when saving the tangent components to the output file
177  std::vector< std::vector< PHX::MDField<const ScalarT,Cell,NODE> > > tangentFields_;
178 
180  Kokkos::View<LO**,PHX::Device> worksetLIDs_;
181 
183  std::vector<Kokkos::View<int*,PHX::Device>> fieldOffsets_;
184 
186 };
187 
188 // **************************************************************
189 // Tangent
190 // **************************************************************
191 template <typename TRAITS,typename S,typename LO,typename GO,typename NodeT>
192 class GatherSolution_BlockedTpetra<panzer::Traits::Tangent,TRAITS,S,LO,GO,NodeT>
193  : public panzer::EvaluatorWithBaseImpl<TRAITS>,
194  public PHX::EvaluatorDerived<panzer::Traits::Tangent, TRAITS>,
196 
197 
198 public:
199 
201  : gidIndexer_(indexer) {}
202 
204  const Teuchos::ParameterList& p);
205 
206  void postRegistrationSetup(typename TRAITS::SetupData d,
208 
209  void preEvaluate(typename TRAITS::PreEvalData d);
210 
211  void evaluateFields(typename TRAITS::EvalData d);
212 
215 
216 
217 private:
218  typedef typename panzer::Traits::Tangent EvalT;
220  //typedef typename panzer::Traits::RealType RealT;
221 
223  typedef Tpetra::Vector<S,LO,GO,NodeT> VectorType;
224  typedef Tpetra::CrsMatrix<S,LO,GO,NodeT> CrsMatrixType;
225  typedef Tpetra::CrsGraph<LO,GO,NodeT> CrsGraphType;
226  typedef Tpetra::Map<LO,GO,NodeT> MapType;
227  typedef Tpetra::Import<LO,GO,NodeT> ImportType;
228  typedef Tpetra::Export<LO,GO,NodeT> ExportType;
229 
230  // maps the local (field,element,basis) triplet to a global ID
231  // for scattering
233 
234  std::vector<int> fieldIds_; // field IDs needing mapping
235 
236  std::vector< PHX::MDField<ScalarT,Cell,NODE> > gatherFields_;
237 
238  std::vector<std::string> indexerNames_;
240  std::string globalDataKey_; // what global data does this fill?
241 
243 
244  // Fields for storing tangent components dx/dp of solution vector x
246  std::vector< std::vector< PHX::MDField<const ScalarT,Cell,NODE> > > tangentFields_;
247 
249 };
250 
251 // **************************************************************
252 // Jacobian
253 // **************************************************************
254 template <typename TRAITS,typename S,typename LO,typename GO,typename NodeT>
255 class GatherSolution_BlockedTpetra<panzer::Traits::Jacobian,TRAITS,S,LO,GO,NodeT>
256  : public panzer::EvaluatorWithBaseImpl<TRAITS>,
257  public PHX::EvaluatorDerived<panzer::Traits::Jacobian, TRAITS>,
259 
260 public:
262  : globalIndexer_(indexer) {}
263 
265  const Teuchos::ParameterList& p);
266 
267  void postRegistrationSetup(typename TRAITS::SetupData d,
269 
270  void preEvaluate(typename TRAITS::PreEvalData d);
271 
272  void evaluateFields(typename TRAITS::EvalData d);
273 
276 
277 private:
278  typedef typename panzer::Traits::Jacobian EvalT;
280  typedef typename TRAITS::RealType RealType;
281 
283  typedef Tpetra::Vector<S,LO,GO,NodeT> VectorType;
284  typedef Tpetra::CrsMatrix<S,LO,GO,NodeT> CrsMatrixType;
285  typedef Tpetra::CrsGraph<LO,GO,NodeT> CrsGraphType;
286  typedef Tpetra::Map<LO,GO,NodeT> MapType;
287  typedef Tpetra::Import<LO,GO,NodeT> ImportType;
288  typedef Tpetra::Export<LO,GO,NodeT> ExportType;
289 
290  // maps the local (field,element,basis) triplet to a global ID
291  // for scattering
293 
294  std::vector<int> fieldIds_; // field IDs needing mapping
295 
298  std::vector<int> productVectorBlockIndex_;
299 
300  std::vector< PHX::MDField<ScalarT,Cell,NODE> > gatherFields_;
301 
302  std::vector<std::string> indexerNames_;
305  std::string globalDataKey_; // what global data does this fill?
306 
308 
310  Kokkos::View<LO**,PHX::Device> worksetLIDs_;
311 
313  std::vector<Kokkos::View<int*,PHX::Device>> fieldOffsets_;
314 
316  Kokkos::View<LO*,PHX::Device> blockOffsets_;
317 
319 };
320 
321 }
322 
324 
325 #ifdef Panzer_BUILD_HESSIAN_SUPPORT
327 #endif
328 
329 // **************************************************************
330 #endif
std::vector< Kokkos::View< int *, PHX::Device > > fieldOffsets_
Offset into the cell lids for each field.
virtual Teuchos::RCP< CloneableEvaluator > clone(const Teuchos::ParameterList &pl) const
virtual Teuchos::RCP< CloneableEvaluator > clone(const Teuchos::ParameterList &pl) const
GatherSolution_BlockedTpetra(const Teuchos::RCP< const BlockedDOFManager< LO, GO > > &indexer)
void postRegistrationSetup(typename TRAITS::SetupData d, PHX::FieldManager< TRAITS > &vm)
Teuchos::RCP< const BlockedTpetraLinearObjContainer< S, LO, GO, NodeT > > blockedContainer_
Gathers solution values from the Newton solution vector into the nodal fields of the field manager...
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)
Teuchos::RCP< const BlockedTpetraLinearObjContainer< S, LO, GO, NodeT > > blockedContainer_
Wrapper to PHX::EvaluatorWithBaseImpl that implements Panzer-specific helpers.
virtual Teuchos::RCP< CloneableEvaluator > clone(const Teuchos::ParameterList &pl) const
std::vector< int > fieldIds_
Field IDs in the local product vector block (not global field id)
std::vector< Teuchos::RCP< const panzer::UniqueGlobalIndexer< LO, GO > > > fieldGlobalIndexers_
Vector of global indexers, one for each field to gather, respectively.
virtual Teuchos::RCP< CloneableEvaluator > clone(const Teuchos::ParameterList &pl) const
Teuchos::RCP< const BlockedDOFManager< LO, GO > > globalIndexer_
Maps the local (field,element,basis) triplet to a global ID for.
Teuchos::RCP< const BlockedTpetraLinearObjContainer< S, LO, GO, NodeT > > blockedContainer_
#define TEUCHOS_ASSERT(assertion_test)
Kokkos::View< LO *, PHX::Device > blockOffsets_
The offset values of the blocked DOFs per element. Size of number of blocks in the product vector + 1...
std::vector< Kokkos::View< int *, PHX::Device > > fieldOffsets_
Offset into the cell lids for each field. Size of number of fields to scatter.
Non-templated empty base class for template managers.