Panzer  Version of the Day
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 
50 #include "Teuchos_ParameterList.hpp"
51 
52 #include "PanzerDiscFE_config.hpp"
53 #include "Panzer_Dimension.hpp"
54 #include "Panzer_Traits.hpp"
57 
59 
60 namespace panzer {
61 
62 template <typename LocalOrdinalT,typename GlobalOrdinalT>
63 class UniqueGlobalIndexer;
64 
65 template <typename LocalOrdinalT,typename GlobalOrdinalT>
66 class BlockedDOFManager; //forward declaration
67 
72 template <typename EvalT,typename TRAITS,typename LO,typename GO,typename NodeT=panzer::TpetraNodeType>
74  : public panzer::EvaluatorWithBaseImpl<TRAITS>,
75  public PHX::EvaluatorDerived<panzer::Traits::Residual, TRAITS>,
77 public:
78  typedef typename EvalT::ScalarT ScalarT;
79 
80  ScatterResidual_BlockedTpetra(const Teuchos::RCP<const BlockedDOFManager<LO,GO> > & indexer)
81  { }
82  ScatterResidual_BlockedTpetra(const Teuchos::RCP<const BlockedDOFManager<LO,GO> > & gidProviders,
83  const Teuchos::ParameterList& p);
84 
85  virtual Teuchos::RCP<CloneableEvaluator> clone(const Teuchos::ParameterList & pl) const
86  { return Teuchos::rcp(new ScatterResidual_BlockedTpetra<EvalT,TRAITS,LO,GO,NodeT>(Teuchos::null,pl)); }
87 
88  void postRegistrationSetup(typename TRAITS::SetupData d, PHX::FieldManager<TRAITS>& vm)
89  { }
90  void evaluateFields(typename TRAITS::EvalData d)
91  { std::cout << "unspecialized version of \"ScatterResidual_BlockedTpetra::evaluateFields\" on \""+PHX::typeAsString<EvalT>()+"\" should not be used!" << std::endl;
92  TEUCHOS_ASSERT(false); }
93 };
94 
95 // **************************************************************
96 // **************************************************************
97 // * Specializations
98 // **************************************************************
99 // **************************************************************
100 
101 
102 // **************************************************************
103 // Residual
104 // **************************************************************
105 template <typename TRAITS,typename LO,typename GO,typename NodeT>
107  : public panzer::EvaluatorWithBaseImpl<TRAITS>,
108  public PHX::EvaluatorDerived<panzer::Traits::Residual, TRAITS>,
110 
111 public:
112  ScatterResidual_BlockedTpetra(const Teuchos::RCP<const BlockedDOFManager<LO,GO> > & indexer)
113  : globalIndexer_(indexer) {}
114 
115  ScatterResidual_BlockedTpetra(const Teuchos::RCP<const BlockedDOFManager<LO,GO> > & indexer,
116  const Teuchos::ParameterList& p);
117 
118  void postRegistrationSetup(typename TRAITS::SetupData d,
120 
121  void preEvaluate(typename TRAITS::PreEvalData d);
122 
123  void evaluateFields(typename TRAITS::EvalData workset);
124 
125  virtual Teuchos::RCP<CloneableEvaluator> clone(const Teuchos::ParameterList & pl) const
126  { return Teuchos::rcp(new ScatterResidual_BlockedTpetra<panzer::Traits::Residual,TRAITS,LO,GO,NodeT>(globalIndexer_,pl)); }
127 
128 private:
130  typedef typename TRAITS::RealType RealType;
131 
133  typedef Tpetra::Vector<RealType,LO,GO,NodeT> VectorType;
134  typedef Tpetra::CrsMatrix<RealType,LO,GO,NodeT> CrsMatrixType;
135  typedef Tpetra::CrsGraph<LO,GO,NodeT> CrsGraphType;
136  typedef Tpetra::Map<LO,GO,NodeT> MapType;
137  typedef Tpetra::Import<LO,GO,NodeT> ImportType;
138  typedef Tpetra::Export<LO,GO,NodeT> ExportType;
139 
140  // dummy field so that the evaluator will have something to do
141  Teuchos::RCP<PHX::FieldTag> scatterHolder_;
142 
143  // fields that need to be scattered will be put in this vector
144  std::vector< PHX::MDField<const ScalarT,Cell,NODE> > scatterFields_;
145 
146  // maps the local (field,element,basis) triplet to a global ID
147  // for scattering
148  Teuchos::RCP<const BlockedDOFManager<LO,GO> > globalIndexer_;
149 
150  std::vector<int> fieldIds_; // field IDs needing mapping
151 
152  // This maps the scattered field names to the DOF manager field
153  // For instance a Navier-Stokes map might look like
154  // fieldMap_["RESIDUAL_Velocity"] --> "Velocity"
155  // fieldMap_["RESIDUAL_Pressure"] --> "Pressure"
156  Teuchos::RCP<const std::map<std::string,std::string> > fieldMap_;
157 
158  std::string globalDataKey_; // what global data does this fill?
159  Teuchos::RCP<const BlockedTpetraLinearObjContainer<RealType,LO,GO,NodeT> > blockedContainer_;
160 
162 };
163 
164 // **************************************************************
165 // Jacobian
166 // **************************************************************
167 
168 template <typename TRAITS,typename LO,typename GO,typename NodeT>
170  : public panzer::EvaluatorWithBaseImpl<TRAITS>,
171  public PHX::EvaluatorDerived<panzer::Traits::Jacobian, TRAITS>,
173 
174 public:
175 
196  ScatterResidual_BlockedTpetra(const Teuchos::RCP<const BlockedDOFManager<LO,GO> > & indexer)
197  : globalIndexer_(indexer) {}
198 
199  ScatterResidual_BlockedTpetra(const Teuchos::RCP<const BlockedDOFManager<LO,GO> > & indexer,
200  const Teuchos::ParameterList& p);
201 
202  void postRegistrationSetup(typename TRAITS::SetupData d,
204 
205  void preEvaluate(typename TRAITS::PreEvalData d);
206 
207  void evaluateFields(typename TRAITS::EvalData workset);
208 
209  virtual Teuchos::RCP<CloneableEvaluator> clone(const Teuchos::ParameterList & pl) const
210  { return Teuchos::rcp(new ScatterResidual_BlockedTpetra<panzer::Traits::Jacobian,TRAITS,LO,GO,NodeT>(globalIndexer_,pl)); }
211 
212 private:
214  typedef typename TRAITS::RealType RealType;
215 
217  typedef Tpetra::Operator<RealType,LO,GO,NodeT> OperatorType;
218  typedef Tpetra::CrsMatrix<RealType,LO,GO,NodeT> CrsMatrixType;
219  typedef Tpetra::Map<LO,GO,NodeT> MapType;
220 
221  typedef Thyra::TpetraLinearOp<RealType,LO,GO,NodeT> ThyraLinearOp;
222 
223  // dummy field so that the evaluator will have something to do
224  Teuchos::RCP<PHX::FieldTag> scatterHolder_;
225 
226  // fields that need to be scattered will be put in this vector
227  std::vector< PHX::MDField<const ScalarT,Cell,NODE> > scatterFields_;
228 
229  // maps the local (field,element,basis) triplet to a global ID
230  // for scattering
231  Teuchos::RCP<const BlockedDOFManager<LO,GO> > globalIndexer_;
232 
233  std::vector<int> fieldIds_; // field IDs needing mapping
234 
235  // This maps the scattered field names to the DOF manager field
236  // For instance a Navier-Stokes map might look like
237  // fieldMap_["RESIDUAL_Velocity"] --> "Velocity"
238  // fieldMap_["RESIDUAL_Pressure"] --> "Pressure"
239  Teuchos::RCP<const std::map<std::string,std::string> > fieldMap_;
240 
241  std::string globalDataKey_; // what global data does this fill?
242  Teuchos::RCP<const BlockedTpetraLinearObjContainer<RealType,LO,GO,NodeT> > blockedContainer_;
243 
245 };
246 
247 }
248 
249 #ifdef Panzer_BUILD_HESSIAN_SUPPORT
251 #endif
252 
253 // **************************************************************
254 #endif
Pushes residual values into the residual vector for a Newton-based solve.
virtual Teuchos::RCP< CloneableEvaluator > clone(const Teuchos::ParameterList &pl) const
virtual Teuchos::RCP< CloneableEvaluator > clone(const Teuchos::ParameterList &pl) const
ScatterResidual_BlockedTpetra(const Teuchos::RCP< const BlockedDOFManager< LO, GO > > &indexer)
Wrapper to PHX::EvaluatorWithBaseImpl that implements Panzer-specific helpers.
virtual Teuchos::RCP< CloneableEvaluator > clone(const Teuchos::ParameterList &pl) const
Teuchos::RCP< const BlockedTpetraLinearObjContainer< RealType, LO, GO, NodeT > > blockedContainer_
Teuchos::RCP< const BlockedTpetraLinearObjContainer< RealType, LO, GO, NodeT > > blockedContainer_
void postRegistrationSetup(typename TRAITS::SetupData d, PHX::FieldManager< TRAITS > &vm)
Non-templated empty base class for template managers.