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 class GlobalIndexer;
65 class BlockedDOFManager;
66 
74 template <typename EvalT,typename TRAITS,typename S,typename LO,typename GO,typename NodeT=panzer::TpetraNodeType>
76  : public panzer::EvaluatorWithBaseImpl<TRAITS>,
77  public PHX::EvaluatorDerived<panzer::Traits::Residual, TRAITS>,
79 public:
80  typedef typename EvalT::ScalarT ScalarT;
81 
83  { }
84 
86  const Teuchos::ParameterList& p);
87 
89  { return Teuchos::rcp(new GatherSolution_BlockedTpetra<EvalT,TRAITS,S,LO,GO>(Teuchos::null,pl)); }
90 
91  void postRegistrationSetup(typename TRAITS::SetupData d, PHX::FieldManager<TRAITS>& vm)
92  { }
93 
94  void evaluateFields(typename TRAITS::EvalData d)
95  { std::cout << "unspecialized version of \"GatherSolution_BlockedTpetra::evaluateFields\" on \""+PHX::print<EvalT>()+"\" should not be used!" << std::endl;
96  TEUCHOS_ASSERT(false); }
97 };
98 
99 // **************************************************************
100 // **************************************************************
101 // * Specializations
102 // **************************************************************
103 // **************************************************************
104 
105 
106 // **************************************************************
107 // Residual
108 // **************************************************************
109 template <typename TRAITS,typename S,typename LO,typename GO,typename NodeT>
110 class GatherSolution_BlockedTpetra<panzer::Traits::Residual,TRAITS,S,LO,GO,NodeT>
111  : public panzer::EvaluatorWithBaseImpl<TRAITS>,
112  public PHX::EvaluatorDerived<panzer::Traits::Residual, TRAITS>,
114 
115 
116 public:
117 
119  : globalIndexer_(indexer) {}
120 
122  const Teuchos::ParameterList& p);
123 
124  void postRegistrationSetup(typename TRAITS::SetupData d,
126 
127  void preEvaluate(typename TRAITS::PreEvalData d);
128 
129  void evaluateFields(typename TRAITS::EvalData d);
130 
133 
134 
135 private:
136  typedef typename panzer::Traits::Residual EvalT;
138 
140  typedef Tpetra::Vector<S,LO,GO,NodeT> VectorType;
141  typedef Tpetra::CrsMatrix<S,LO,GO,NodeT> CrsMatrixType;
142  typedef Tpetra::CrsGraph<LO,GO,NodeT> CrsGraphType;
143  typedef Tpetra::Map<LO,GO,NodeT> MapType;
144  typedef Tpetra::Import<LO,GO,NodeT> ImportType;
145  typedef Tpetra::Export<LO,GO,NodeT> ExportType;
146 
148  // scattering
150 
152  std::vector<int> fieldIds_;
153 
155  std::vector<Teuchos::RCP<const panzer::GlobalIndexer>> fieldGlobalIndexers_;
156 
159  std::vector<int> productVectorBlockIndex_;
160 
161  std::vector< PHX::MDField<ScalarT,Cell,NODE> > gatherFields_;
162 
163  std::vector<std::string> indexerNames_;
165  std::string globalDataKey_; // what global data does this fill?
166 
168 
169  // Fields for storing tangent components dx/dp of solution vector x
170  // These are not actually used by the residual specialization of this evaluator,
171  // even if they are supplied, but it is useful to declare them as dependencies anyway
172  // when saving the tangent components to the output file
174  std::vector< std::vector< PHX::MDField<const ScalarT,Cell,NODE> > > tangentFields_;
175 
177  PHX::View<LO**> worksetLIDs_;
178 
180  std::vector<PHX::View<int*>> fieldOffsets_;
181 
183 };
184 
185 // **************************************************************
186 // Tangent
187 // **************************************************************
188 template <typename TRAITS,typename S,typename LO,typename GO,typename NodeT>
189 class GatherSolution_BlockedTpetra<panzer::Traits::Tangent,TRAITS,S,LO,GO,NodeT>
190  : public panzer::EvaluatorWithBaseImpl<TRAITS>,
191  public PHX::EvaluatorDerived<panzer::Traits::Tangent, TRAITS>,
193 
194 
195 public:
196 
198  : gidIndexer_(indexer) {}
199 
201  const Teuchos::ParameterList& p);
202 
203  void postRegistrationSetup(typename TRAITS::SetupData d,
205 
206  void preEvaluate(typename TRAITS::PreEvalData d);
207 
208  void evaluateFields(typename TRAITS::EvalData d);
209 
212 
213 
214 private:
215  typedef typename panzer::Traits::Tangent EvalT;
217  //typedef typename panzer::Traits::RealType RealT;
218 
220  typedef Tpetra::Vector<S,LO,GO,NodeT> VectorType;
221  typedef Tpetra::CrsMatrix<S,LO,GO,NodeT> CrsMatrixType;
222  typedef Tpetra::CrsGraph<LO,GO,NodeT> CrsGraphType;
223  typedef Tpetra::Map<LO,GO,NodeT> MapType;
224  typedef Tpetra::Import<LO,GO,NodeT> ImportType;
225  typedef Tpetra::Export<LO,GO,NodeT> ExportType;
226 
227  // maps the local (field,element,basis) triplet to a global ID
228  // for scattering
230 
231  std::vector<int> fieldIds_; // field IDs needing mapping
232 
233  std::vector< PHX::MDField<ScalarT,Cell,NODE> > gatherFields_;
234 
235  std::vector<std::string> indexerNames_;
237  std::string globalDataKey_; // what global data does this fill?
238 
240 
241  // Fields for storing tangent components dx/dp of solution vector x
243  std::vector< std::vector< PHX::MDField<const ScalarT,Cell,NODE> > > tangentFields_;
244 
246 };
247 
248 // **************************************************************
249 // Jacobian
250 // **************************************************************
251 template <typename TRAITS,typename S,typename LO,typename GO,typename NodeT>
252 class GatherSolution_BlockedTpetra<panzer::Traits::Jacobian,TRAITS,S,LO,GO,NodeT>
253  : public panzer::EvaluatorWithBaseImpl<TRAITS>,
254  public PHX::EvaluatorDerived<panzer::Traits::Jacobian, TRAITS>,
256 
257 public:
259  : globalIndexer_(indexer) {}
260 
262  const Teuchos::ParameterList& p);
263 
264  void postRegistrationSetup(typename TRAITS::SetupData d,
266 
267  void preEvaluate(typename TRAITS::PreEvalData d);
268 
269  void evaluateFields(typename TRAITS::EvalData d);
270 
273 
274 private:
275  typedef typename panzer::Traits::Jacobian EvalT;
277  typedef typename TRAITS::RealType RealType;
278 
280  typedef Tpetra::Vector<S,LO,GO,NodeT> VectorType;
281  typedef Tpetra::CrsMatrix<S,LO,GO,NodeT> CrsMatrixType;
282  typedef Tpetra::CrsGraph<LO,GO,NodeT> CrsGraphType;
283  typedef Tpetra::Map<LO,GO,NodeT> MapType;
284  typedef Tpetra::Import<LO,GO,NodeT> ImportType;
285  typedef Tpetra::Export<LO,GO,NodeT> ExportType;
286 
287  // maps the local (field,element,basis) triplet to a global ID
288  // for scattering
290 
291  std::vector<int> fieldIds_; // field IDs needing mapping
292 
295  std::vector<int> productVectorBlockIndex_;
296 
297  std::vector< PHX::MDField<ScalarT,Cell,NODE> > gatherFields_;
298 
299  std::vector<std::string> indexerNames_;
302  std::string globalDataKey_; // what global data does this fill?
303 
305 
307  PHX::View<LO**> worksetLIDs_;
308 
310  std::vector<PHX::View<int*>> fieldOffsets_;
311 
313  PHX::View<LO*> blockOffsets_;
314 
316 };
317 
318 }
319 
321 
322 #ifdef Panzer_BUILD_HESSIAN_SUPPORT
324 #endif
325 
326 // **************************************************************
327 #endif
GatherSolution_BlockedTpetra(const Teuchos::RCP< const BlockedDOFManager > &indexer)
std::vector< Teuchos::RCP< const panzer::GlobalIndexer > > fieldGlobalIndexers_
Vector of global indexers, one for each field to gather, respectively.
virtual Teuchos::RCP< CloneableEvaluator > clone(const Teuchos::ParameterList &pl) const
virtual Teuchos::RCP< CloneableEvaluator > clone(const Teuchos::ParameterList &pl) const
void postRegistrationSetup(typename TRAITS::SetupData d, PHX::FieldManager< TRAITS > &vm)
Teuchos::RCP< const BlockedTpetraLinearObjContainer< S, LO, GO, NodeT > > blockedContainer_
PHX::View< LO * > blockOffsets_
The offset values of the blocked DOFs per element. Size of number of blocks in the product vector + 1...
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< PHX::View< int * > > fieldOffsets_
Offset into the cell lids for each field. Size of number of fields to scatter.
std::vector< PHX::View< int * > > fieldOffsets_
Offset into the cell lids for each field.
std::vector< int > fieldIds_
Field IDs in the local product vector block (not global field id)
virtual void preEvaluate(typename Traits::PreEvalData d)=0
virtual Teuchos::RCP< CloneableEvaluator > clone(const Teuchos::ParameterList &pl) const
Teuchos::RCP< const BlockedDOFManager > 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)
Non-templated empty base class for template managers.