Panzer  Version of the Day
Panzer_ScatterResidual_Tpetra_decl.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_TPETRA_DECL_HPP
44 #define PANZER_EVALUATOR_SCATTER_RESIDUAL_TPETRA_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 
58 #include "Panzer_NodeType.hpp"
59 
61 
63 
64 namespace panzer {
65 
66 template <typename LocalOrdinalT,typename GlobalOrdinalT>
67 class UniqueGlobalIndexer;
68 
77 template<typename EvalT, typename Traits,typename LO,typename GO,typename NodeT=panzer::TpetraNodeType>
79 
80 // **************************************************************
81 // **************************************************************
82 // * Specializations
83 // **************************************************************
84 // **************************************************************
85 
86 
87 // **************************************************************
88 // Residual
89 // **************************************************************
90 template<typename TRAITS,typename LO,typename GO,typename NodeT>
92  : public panzer::EvaluatorWithBaseImpl<TRAITS>,
93  public PHX::EvaluatorDerived<panzer::Traits::Residual, TRAITS>,
95 
96 public:
97  ScatterResidual_Tpetra(const Teuchos::RCP<const panzer::UniqueGlobalIndexer<LO,GO> > & indexer)
98  : globalIndexer_(indexer) {}
99 
100  ScatterResidual_Tpetra(const Teuchos::RCP<const panzer::UniqueGlobalIndexer<LO,GO> > & indexer,
101  const Teuchos::ParameterList& p);
102 
103  void postRegistrationSetup(typename TRAITS::SetupData d,
105 
106  void preEvaluate(typename TRAITS::PreEvalData d);
107 
108  void evaluateFields(typename TRAITS::EvalData workset);
109 
110  virtual Teuchos::RCP<CloneableEvaluator> clone(const Teuchos::ParameterList & pl) const
111  { return Teuchos::rcp(new ScatterResidual_Tpetra<panzer::Traits::Residual,TRAITS,LO,GO,NodeT>(globalIndexer_,pl)); }
112 
113 private:
115 
116  // dummy field so that the evaluator will have something to do
117  Teuchos::RCP<PHX::FieldTag> scatterHolder_;
118 
119  // fields that need to be scattered will be put in this vector
120  std::vector< PHX::MDField<const ScalarT,Cell,NODE> > scatterFields_;
121 
122  // maps the local (field,element,basis) triplet to a global ID
123  // for scattering
124  Teuchos::RCP<const panzer::UniqueGlobalIndexer<LO,GO> > globalIndexer_;
125  std::vector<int> fieldIds_; // field IDs needing mapping
126 
127  // This maps the scattered field names to the DOF manager field
128  // For instance a Navier-Stokes map might look like
129  // fieldMap_["RESIDUAL_Velocity"] --> "Velocity"
130  // fieldMap_["RESIDUAL_Pressure"] --> "Pressure"
131  Teuchos::RCP<const std::map<std::string,std::string> > fieldMap_;
132 
133  std::string globalDataKey_; // what global data does this fill?
134  Teuchos::RCP<const TpetraLinearObjContainer<double,LO,GO,NodeT> > tpetraContainer_;
135 
137 };
138 
139 // **************************************************************
140 // Tangent
141 // **************************************************************
142 template<typename TRAITS,typename LO,typename GO,typename NodeT>
144  : public panzer::EvaluatorWithBaseImpl<TRAITS>,
145  public PHX::EvaluatorDerived<panzer::Traits::Tangent, TRAITS>,
147 
148 public:
149  ScatterResidual_Tpetra(const Teuchos::RCP<const panzer::UniqueGlobalIndexer<LO,GO> > & indexer)
150  : globalIndexer_(indexer) {}
151 
152  ScatterResidual_Tpetra(const Teuchos::RCP<const panzer::UniqueGlobalIndexer<LO,GO> > & indexer,
153  const Teuchos::ParameterList& p);
154 
155  void postRegistrationSetup(typename TRAITS::SetupData d,
157 
158  void preEvaluate(typename TRAITS::PreEvalData d);
159 
160  void evaluateFields(typename TRAITS::EvalData workset);
161 
162  virtual Teuchos::RCP<CloneableEvaluator> clone(const Teuchos::ParameterList & pl) const
163  { return Teuchos::rcp(new ScatterResidual_Tpetra<panzer::Traits::Tangent,TRAITS,LO,GO,NodeT>(globalIndexer_,pl)); }
164 
165 private:
167 
168  // dummy field so that the evaluator will have something to do
169  Teuchos::RCP<PHX::FieldTag> scatterHolder_;
170 
171  // fields that need to be scattered will be put in this vector
172  std::vector< PHX::MDField<const ScalarT,Cell,NODE> > scatterFields_;
173 
174  // maps the local (field,element,basis) triplet to a global ID
175  // for scattering
176  Teuchos::RCP<const panzer::UniqueGlobalIndexer<LO,GO> > globalIndexer_;
177  std::vector<int> fieldIds_; // field IDs needing mapping
178 
179  // This maps the scattered field names to the DOF manager field
180  // For instance a Navier-Stokes map might look like
181  // fieldMap_["RESIDUAL_Velocity"] --> "Velocity"
182  // fieldMap_["RESIDUAL_Pressure"] --> "Pressure"
183  Teuchos::RCP<const std::map<std::string,std::string> > fieldMap_;
184 
185  std::string globalDataKey_; // what global data does this fill?
186 
187  std::vector< Teuchos::ArrayRCP<double> > dfdp_vectors_;
188 
190 };
191 
192 // **************************************************************
193 // Jacobian
194 // **************************************************************
195 template<typename TRAITS,typename LO,typename GO,typename NodeT>
197  : public panzer::EvaluatorWithBaseImpl<TRAITS>,
198  public PHX::EvaluatorDerived<panzer::Traits::Jacobian, TRAITS>,
200 
201 public:
202 
203  ScatterResidual_Tpetra(const Teuchos::RCP<const panzer::UniqueGlobalIndexer<LO,GO> > & indexer)
204  : globalIndexer_(indexer) {}
205 
206  ScatterResidual_Tpetra(const Teuchos::RCP<const panzer::UniqueGlobalIndexer<LO,GO> > & indexer,
207  const Teuchos::ParameterList& pl);
208 
209  void postRegistrationSetup(typename TRAITS::SetupData d,
211 
212  void preEvaluate(typename TRAITS::PreEvalData d);
213 
214  void evaluateFields(typename TRAITS::EvalData workset);
215 
216  virtual Teuchos::RCP<CloneableEvaluator> clone(const Teuchos::ParameterList & pl) const
217  { return Teuchos::rcp(new ScatterResidual_Tpetra<panzer::Traits::Jacobian,TRAITS,LO,GO,NodeT>(globalIndexer_,pl)); }
218 
219 private:
220 
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 panzer::UniqueGlobalIndexer<LO,GO> > globalIndexer_;
232  std::vector<int> fieldIds_; // field IDs needing mapping
233 
234  // This maps the scattered field names to the DOF manager field
235  // For instance a Navier-Stokes map might look like
236  // fieldMap_["RESIDUAL_Velocity"] --> "Velocity"
237  // fieldMap_["RESIDUAL_Pressure"] --> "Pressure"
238  Teuchos::RCP<const std::map<std::string,std::string> > fieldMap_;
239 
240  std::string globalDataKey_; // what global data does this fill?
241  Teuchos::RCP<const TpetraLinearObjContainer<double,LO,GO,NodeT> > tpetraContainer_;
242 
244 
245  Kokkos::View<int**,PHX::Device> scratch_lids_;
246  std::vector<Kokkos::View<int*,PHX::Device> > scratch_offsets_;
247 };
248 
249 }
250 
251 // optionally include hessian support
252 #ifdef Panzer_BUILD_HESSIAN_SUPPORT
254 #endif
255 
256 // **************************************************************
257 #endif
virtual Teuchos::RCP< CloneableEvaluator > clone(const Teuchos::ParameterList &pl) const
virtual Teuchos::RCP< CloneableEvaluator > clone(const Teuchos::ParameterList &pl) const
Teuchos::RCP< const TpetraLinearObjContainer< double, LO, GO, NodeT > > tpetraContainer_
ScatterResidual_Tpetra(const Teuchos::RCP< const panzer::UniqueGlobalIndexer< LO, GO > > &indexer)
Wrapper to PHX::EvaluatorWithBaseImpl that implements Panzer-specific helpers.
ScatterResidual_Tpetra(const Teuchos::RCP< const panzer::UniqueGlobalIndexer< LO, GO > > &indexer)
Pushes residual values into the residual vector for a Newton-based solve.
ScatterResidual_Tpetra(const Teuchos::RCP< const panzer::UniqueGlobalIndexer< LO, GO > > &indexer)
virtual Teuchos::RCP< CloneableEvaluator > clone(const Teuchos::ParameterList &pl) const
Non-templated empty base class for template managers.
Teuchos::RCP< const TpetraLinearObjContainer< double, LO, GO, NodeT > > tpetraContainer_