Panzer  Version of the Day
Panzer_ScatterResidual_Epetra_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_EPETRA_DECL_HPP
44 #define PANZER_EVALUATOR_SCATTER_RESIDUAL_EPETRA_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 class Epetra_Vector;
60 class Epetra_CrsMatrix;
61 
62 namespace panzer {
63 
64 class EpetraLinearObjContainer;
65 
66 template <typename LocalOrdinalT,typename GlobalOrdinalT>
67 class UniqueGlobalIndexer;
68 
86 template<typename EvalT, typename TRAITS,typename LO,typename GO> class ScatterResidual_Epetra;
87 
88 // **************************************************************
89 // **************************************************************
90 // * Specializations
91 // **************************************************************
92 // **************************************************************
93 
94 
95 // **************************************************************
96 // Residual
97 // **************************************************************
98 template<typename TRAITS,typename LO,typename GO>
100  : public panzer::EvaluatorWithBaseImpl<TRAITS>,
101  public PHX::EvaluatorDerived<panzer::Traits::Residual, TRAITS>,
103 
104 public:
106  const Teuchos::RCP<const panzer::UniqueGlobalIndexer<LO,GO> > & cIndexer=Teuchos::null,
107  bool useDiscreteAdjoint=false)
108  : globalIndexer_(indexer),useDiscreteAdjoint_(useDiscreteAdjoint) {}
109 
111  const Teuchos::RCP<const panzer::UniqueGlobalIndexer<LO,GO> > & cIndexer,
112  const Teuchos::ParameterList& p,bool=false);
113 
114  void postRegistrationSetup(typename TRAITS::SetupData d,
116 
117  void preEvaluate(typename TRAITS::PreEvalData d);
118 
119  void evaluateFields(typename TRAITS::EvalData workset);
120 
122  { return Teuchos::rcp(new ScatterResidual_Epetra<panzer::Traits::Residual,TRAITS,LO,GO>(globalIndexer_,Teuchos::null,pl)); }
123 
124 private:
126 
127  // dummy field so that the evaluator will have something to do
129 
130  // fields that need to be scattered will be put in this vector
131  std::vector< PHX::MDField<ScalarT,Cell,NODE> > scatterFields_;
132 
133  // maps the local (field,element,basis) triplet to a global ID
134  // for scattering
136  std::vector<int> fieldIds_; // field IDs needing mapping
137 
138  // This maps the scattered field names to the DOF manager field
139  // For instance a Navier-Stokes map might look like
140  // fieldMap_["RESIDUAL_Velocity"] --> "Velocity"
141  // fieldMap_["RESIDUAL_Pressure"] --> "Pressure"
143 
144  std::string globalDataKey_; // what global data does this fill?
145 
147 
149 };
150 
151 // **************************************************************
152 // Tangent
153 // **************************************************************
154 template<typename TRAITS,typename LO,typename GO>
156  : public panzer::EvaluatorWithBaseImpl<TRAITS>,
157  public PHX::EvaluatorDerived<panzer::Traits::Tangent, TRAITS>,
159 
160 public:
162  const Teuchos::RCP<const panzer::UniqueGlobalIndexer<LO,GO> > & cIndexer=Teuchos::null,
163  bool useDiscreteAdjoint=false)
164  : globalIndexer_(indexer),useDiscreteAdjoint_(useDiscreteAdjoint) {}
165 
167  const Teuchos::RCP<const panzer::UniqueGlobalIndexer<LO,GO> > & cIndexer,
168  const Teuchos::ParameterList& p,bool=false);
169 
170  void postRegistrationSetup(typename TRAITS::SetupData d,
172 
173  void preEvaluate(typename TRAITS::PreEvalData d);
174 
175  void evaluateFields(typename TRAITS::EvalData workset);
176 
178  { return Teuchos::rcp(new ScatterResidual_Epetra<panzer::Traits::Tangent,TRAITS,LO,GO>(globalIndexer_,Teuchos::null,pl)); }
179 
180 private:
182 
183  // dummy field so that the evaluator will have something to do
185 
186  // fields that need to be scattered will be put in this vector
187  std::vector< PHX::MDField<ScalarT,Cell,NODE> > scatterFields_;
188 
189  // maps the local (field,element,basis) triplet to a global ID
190  // for scattering
192  std::vector<int> fieldIds_; // field IDs needing mapping
193 
194  // This maps the scattered field names to the DOF manager field
195  // For instance a Navier-Stokes map might look like
196  // fieldMap_["RESIDUAL_Velocity"] --> "Velocity"
197  // fieldMap_["RESIDUAL_Pressure"] --> "Pressure"
199 
200  std::vector<Teuchos::RCP<Epetra_Vector> > dfdp_vectors_;
201 
203 };
204 
205 // **************************************************************
206 // Jacobian
207 // **************************************************************
208 template<typename TRAITS,typename LO,typename GO>
210  : public panzer::EvaluatorWithBaseImpl<TRAITS>,
211  public PHX::EvaluatorDerived<panzer::Traits::Jacobian, TRAITS>,
213 
214 public:
215 
217  const Teuchos::RCP<const panzer::UniqueGlobalIndexer<LO,GO> > & cIndexer=Teuchos::null,
218  bool useDiscreteAdjoint=false)
219  : globalIndexer_(indexer), colGlobalIndexer_(cIndexer), useDiscreteAdjoint_(useDiscreteAdjoint) {}
220 
222  const Teuchos::RCP<const panzer::UniqueGlobalIndexer<LO,GO> > & cIndexer,
223  const Teuchos::ParameterList& pl,bool useDiscreteAdjoint=false);
224 
225  void postRegistrationSetup(typename TRAITS::SetupData d,
227 
228  void preEvaluate(typename TRAITS::PreEvalData d);
229 
230  void evaluateFields(typename TRAITS::EvalData workset);
231 
233  { return Teuchos::rcp(new ScatterResidual_Epetra<panzer::Traits::Jacobian,TRAITS,LO,GO>(globalIndexer_,colGlobalIndexer_,pl,useDiscreteAdjoint_)); }
234 
235 private:
236 
238 
239  // dummy field so that the evaluator will have something to do
241 
242  // fields that need to be scattered will be put in this vector
243  std::vector< PHX::MDField<ScalarT,Cell,NODE> > scatterFields_;
244 
245  // maps the local (field,element,basis) triplet to a global ID
246  // for scattering
248  std::vector<int> fieldIds_; // field IDs needing mapping
249 
250  // This maps the scattered field names to the DOF manager field
251  // For instance a Navier-Stokes map might look like
252  // fieldMap_["RESIDUAL_Velocity"] --> "Velocity"
253  // fieldMap_["RESIDUAL_Pressure"] --> "Pressure"
255 
256  std::string globalDataKey_; // what global data does this fill?
257 
259 
261 
263 
264 };
265 
266 }
267 
268 // optionally include hessian support
269 #ifdef Panzer_BUILD_HESSIAN_SUPPORT
271 #endif
272 
273 // **************************************************************
274 #endif
virtual Teuchos::RCP< CloneableEvaluator > clone(const Teuchos::ParameterList &pl) const
ScatterResidual_Epetra(const Teuchos::RCP< const panzer::UniqueGlobalIndexer< LO, GO > > &indexer, const Teuchos::RCP< const panzer::UniqueGlobalIndexer< LO, GO > > &cIndexer=Teuchos::null, bool useDiscreteAdjoint=false)
virtual Teuchos::RCP< CloneableEvaluator > clone(const Teuchos::ParameterList &pl) const
ScatterResidual_Epetra(const Teuchos::RCP< const panzer::UniqueGlobalIndexer< LO, GO > > &indexer, const Teuchos::RCP< const panzer::UniqueGlobalIndexer< LO, GO > > &cIndexer=Teuchos::null, bool useDiscreteAdjoint=false)
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)
Wrapper to PHX::EvaluatorWithBaseImpl that implements Panzer-specific helpers.
Pushes residual values into the residual vector for a Newton-based solve.
ScatterResidual_Epetra(const Teuchos::RCP< const panzer::UniqueGlobalIndexer< LO, GO > > &indexer, const Teuchos::RCP< const panzer::UniqueGlobalIndexer< LO, GO > > &cIndexer=Teuchos::null, bool useDiscreteAdjoint=false)
virtual Teuchos::RCP< CloneableEvaluator > clone(const Teuchos::ParameterList &pl) const
Non-templated empty base class for template managers.