Panzer  Version of the Day
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 
50 #include "Teuchos_ParameterList.hpp"
51 
52 #include "PanzerDiscFE_config.hpp"
53 #include "Panzer_Dimension.hpp"
54 #include "Panzer_Traits.hpp"
56 
58 
59 class Tpetra_Vector;
60 class Tpetra_CrsMatrix;
61 
62 namespace panzer {
63 
64 template <typename ScalarT,typename LocalOrdinalT,typename GlobalOrdinalT,typename NodeT>
66 
67 template <typename LocalOrdinalT,typename GlobalOrdinalT>
68 class UniqueGlobalIndexer; //forward declaration
69 
70 template <typename LocalOrdinalT,typename GlobalOrdinalT>
71 class BlockedDOFManager; //forward declaration
72 
80 template <typename EvalT,typename TRAITS,typename S,typename LO,typename GO,typename NodeT=panzer::TpetraNodeType>
82  : public panzer::EvaluatorWithBaseImpl<TRAITS>,
83  public PHX::EvaluatorDerived<panzer::Traits::Residual, TRAITS>,
85 public:
86  typedef typename EvalT::ScalarT ScalarT;
87 
88  GatherSolution_BlockedTpetra(const Teuchos::RCP<const BlockedDOFManager<LO,GO> > & indexer)
89  { }
90 
91  GatherSolution_BlockedTpetra(const Teuchos::RCP<const BlockedDOFManager<LO,GO> > & gidProviders,
92  const Teuchos::ParameterList& p);
93 
94  virtual Teuchos::RCP<CloneableEvaluator> clone(const Teuchos::ParameterList & pl) const
95  { return Teuchos::rcp(new GatherSolution_BlockedTpetra<EvalT,TRAITS,S,LO,GO>(Teuchos::null,pl)); }
96 
97  void postRegistrationSetup(typename TRAITS::SetupData d, PHX::FieldManager<TRAITS>& vm)
98  { }
99 
100  void evaluateFields(typename TRAITS::EvalData d)
101  { std::cout << "unspecialized version of \"GatherSolution_BlockedTpetra::evaluateFields\" on \""+PHX::typeAsString<EvalT>()+"\" should not be used!" << std::endl;
102  TEUCHOS_ASSERT(false); }
103 };
104 
105 // **************************************************************
106 // **************************************************************
107 // * Specializations
108 // **************************************************************
109 // **************************************************************
110 
111 
112 // **************************************************************
113 // Residual
114 // **************************************************************
115 template <typename TRAITS,typename S,typename LO,typename GO,typename NodeT>
117  : public panzer::EvaluatorWithBaseImpl<TRAITS>,
118  public PHX::EvaluatorDerived<panzer::Traits::Residual, TRAITS>,
120 
121 
122 public:
123 
124  GatherSolution_BlockedTpetra(const Teuchos::RCP<const BlockedDOFManager<LO,GO> > & indexer)
125  : gidIndexer_(indexer) {}
126 
127  GatherSolution_BlockedTpetra(const Teuchos::RCP<const BlockedDOFManager<LO,GO> > & indexer,
128  const Teuchos::ParameterList& p);
129 
130  void postRegistrationSetup(typename TRAITS::SetupData d,
132 
133  void preEvaluate(typename TRAITS::PreEvalData d);
134 
135  void evaluateFields(typename TRAITS::EvalData d);
136 
137  virtual Teuchos::RCP<CloneableEvaluator> clone(const Teuchos::ParameterList & pl) const
138  { return Teuchos::rcp(new GatherSolution_BlockedTpetra<panzer::Traits::Residual,TRAITS,S,LO,GO>(gidIndexer_,pl)); }
139 
140 
141 private:
142  typedef typename panzer::Traits::Residual EvalT;
144 
146  typedef Tpetra::Vector<S,LO,GO,NodeT> VectorType;
147  typedef Tpetra::CrsMatrix<S,LO,GO,NodeT> CrsMatrixType;
148  typedef Tpetra::CrsGraph<LO,GO,NodeT> CrsGraphType;
149  typedef Tpetra::Map<LO,GO,NodeT> MapType;
150  typedef Tpetra::Import<LO,GO,NodeT> ImportType;
151  typedef Tpetra::Export<LO,GO,NodeT> ExportType;
152 
153  // maps the local (field,element,basis) triplet to a global ID
154  // for scattering
155  Teuchos::RCP<const BlockedDOFManager<LO,GO> > gidIndexer_;
156 
157  std::vector<int> fieldIds_; // field IDs needing mapping
158 
159  std::vector< PHX::MDField<ScalarT,Cell,NODE> > gatherFields_;
160 
161  std::vector<std::string> indexerNames_;
163  std::string globalDataKey_; // what global data does this fill?
164 
165  Teuchos::RCP<const BlockedTpetraLinearObjContainer<S,LO,GO,NodeT> > blockedContainer_;
166 
167  // Fields for storing tangent components dx/dp of solution vector x
168  // These are not actually used by the residual specialization of this evaluator,
169  // even if they are supplied, but it is useful to declare them as dependencies anyway
170  // when saving the tangent components to the output file
172  std::vector< std::vector< PHX::MDField<const ScalarT,Cell,NODE> > > tangentFields_;
173 
175 };
176 
177 // **************************************************************
178 // Tangent
179 // **************************************************************
180 template <typename TRAITS,typename S,typename LO,typename GO,typename NodeT>
182  : public panzer::EvaluatorWithBaseImpl<TRAITS>,
183  public PHX::EvaluatorDerived<panzer::Traits::Tangent, TRAITS>,
185 
186 
187 public:
188 
189  GatherSolution_BlockedTpetra(const Teuchos::RCP<const BlockedDOFManager<LO,GO> > & indexer)
190  : gidIndexer_(indexer) {}
191 
192  GatherSolution_BlockedTpetra(const Teuchos::RCP<const BlockedDOFManager<LO,GO> > & indexer,
193  const Teuchos::ParameterList& p);
194 
195  void postRegistrationSetup(typename TRAITS::SetupData d,
197 
198  void preEvaluate(typename TRAITS::PreEvalData d);
199 
200  void evaluateFields(typename TRAITS::EvalData d);
201 
202  virtual Teuchos::RCP<CloneableEvaluator> clone(const Teuchos::ParameterList & pl) const
203  { return Teuchos::rcp(new GatherSolution_BlockedTpetra<panzer::Traits::Tangent,TRAITS,S,LO,GO>(gidIndexer_,pl)); }
204 
205 
206 private:
207  typedef typename panzer::Traits::Tangent EvalT;
209  //typedef typename panzer::Traits::RealType RealT;
210 
212  typedef Tpetra::Vector<S,LO,GO,NodeT> VectorType;
213  typedef Tpetra::CrsMatrix<S,LO,GO,NodeT> CrsMatrixType;
214  typedef Tpetra::CrsGraph<LO,GO,NodeT> CrsGraphType;
215  typedef Tpetra::Map<LO,GO,NodeT> MapType;
216  typedef Tpetra::Import<LO,GO,NodeT> ImportType;
217  typedef Tpetra::Export<LO,GO,NodeT> ExportType;
218 
219  // maps the local (field,element,basis) triplet to a global ID
220  // for scattering
221  Teuchos::RCP<const BlockedDOFManager<LO,GO> > gidIndexer_;
222 
223  std::vector<int> fieldIds_; // field IDs needing mapping
224 
225  std::vector< PHX::MDField<ScalarT,Cell,NODE> > gatherFields_;
226 
227  std::vector<std::string> indexerNames_;
229  std::string globalDataKey_; // what global data does this fill?
230 
231  Teuchos::RCP<const BlockedTpetraLinearObjContainer<S,LO,GO,NodeT> > blockedContainer_;
232 
233  // Fields for storing tangent components dx/dp of solution vector x
235  std::vector< std::vector< PHX::MDField<const ScalarT,Cell,NODE> > > tangentFields_;
236 
238 };
239 
240 // **************************************************************
241 // Jacobian
242 // **************************************************************
243 template <typename TRAITS,typename S,typename LO,typename GO,typename NodeT>
245  : public panzer::EvaluatorWithBaseImpl<TRAITS>,
246  public PHX::EvaluatorDerived<panzer::Traits::Jacobian, TRAITS>,
248 
249 public:
250  GatherSolution_BlockedTpetra(const Teuchos::RCP<const BlockedDOFManager<LO,GO> > & indexer)
251  : gidIndexer_(indexer) {}
252 
253  GatherSolution_BlockedTpetra(const Teuchos::RCP<const BlockedDOFManager<LO,GO> > & indexer,
254  const Teuchos::ParameterList& p);
255 
256  void postRegistrationSetup(typename TRAITS::SetupData d,
258 
259  void preEvaluate(typename TRAITS::PreEvalData d);
260 
261  void evaluateFields(typename TRAITS::EvalData d);
262 
263  virtual Teuchos::RCP<CloneableEvaluator> clone(const Teuchos::ParameterList & pl) const
264  { return Teuchos::rcp(new GatherSolution_BlockedTpetra<panzer::Traits::Jacobian,TRAITS,S,LO,GO>(gidIndexer_,pl)); }
265 
266 private:
267  typedef typename panzer::Traits::Jacobian EvalT;
269 
271  typedef Tpetra::Vector<S,LO,GO,NodeT> VectorType;
272  typedef Tpetra::CrsMatrix<S,LO,GO,NodeT> CrsMatrixType;
273  typedef Tpetra::CrsGraph<LO,GO,NodeT> CrsGraphType;
274  typedef Tpetra::Map<LO,GO,NodeT> MapType;
275  typedef Tpetra::Import<LO,GO,NodeT> ImportType;
276  typedef Tpetra::Export<LO,GO,NodeT> ExportType;
277 
278  // maps the local (field,element,basis) triplet to a global ID
279  // for scattering
280  Teuchos::RCP<const BlockedDOFManager<LO,GO> > gidIndexer_;
281 
282  std::vector<int> fieldIds_; // field IDs needing mapping
283 
284  std::vector< PHX::MDField<ScalarT,Cell,NODE> > gatherFields_;
285 
286  std::vector<std::string> indexerNames_;
289  std::string globalDataKey_; // what global data does this fill?
290 
291  Teuchos::RCP<const BlockedTpetraLinearObjContainer<S,LO,GO,NodeT> > blockedContainer_;
292 
294 };
295 
296 }
297 
299 
300 #ifdef Panzer_BUILD_HESSIAN_SUPPORT
302 #endif
303 
304 // **************************************************************
305 #endif
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_
virtual Teuchos::RCP< CloneableEvaluator > clone(const Teuchos::ParameterList &pl) const
virtual Teuchos::RCP< CloneableEvaluator > clone(const Teuchos::ParameterList &pl) const
Gathers solution values from the Newton solution vector into the nodal fields of the field manager...
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
virtual Teuchos::RCP< CloneableEvaluator > clone(const Teuchos::ParameterList &pl) const
Teuchos::RCP< const BlockedTpetraLinearObjContainer< S, LO, GO, NodeT > > blockedContainer_
Non-templated empty base class for template managers.