Panzer  Version of the Day
Panzer_ScatterDirichletResidual_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_DIRICHLET_RESIDUAL_TPETRA_DECL_HPP
44 #define PANZER_EVALUATOR_SCATTER_DIRICHLET_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 
62 namespace panzer {
63 
64 template <typename LocalOrdinalT,typename GlobalOrdinalT>
65 class UniqueGlobalIndexer;
66 
75 template<typename EvalT, typename Traits,typename LO,typename GO,typename NodeT=panzer::TpetraNodeType>
77 
78 // **************************************************************
79 // **************************************************************
80 // * Specializations
81 // **************************************************************
82 // **************************************************************
83 
84 
85 // **************************************************************
86 // Residual
87 // **************************************************************
88 template<typename TRAITS,typename LO,typename GO,typename NodeT>
90  : public panzer::EvaluatorWithBaseImpl<TRAITS>,
91  public PHX::EvaluatorDerived<panzer::Traits::Residual, TRAITS>,
93 
94 public:
95  ScatterDirichletResidual_Tpetra(const Teuchos::RCP<const UniqueGlobalIndexer<LO,GO> > & indexer)
96  : globalIndexer_(indexer) {}
97 
98  ScatterDirichletResidual_Tpetra(const Teuchos::RCP<const UniqueGlobalIndexer<LO,GO> > & indexer,
99  const Teuchos::ParameterList& p);
100 
101  void postRegistrationSetup(typename TRAITS::SetupData d,
103 
104  void preEvaluate(typename TRAITS::PreEvalData d);
105 
106  void evaluateFields(typename TRAITS::EvalData workset);
107 
108  virtual Teuchos::RCP<CloneableEvaluator> clone(const Teuchos::ParameterList & pl) const
109  { return Teuchos::rcp(new ScatterDirichletResidual_Tpetra<panzer::Traits::Residual,TRAITS,LO,GO>(globalIndexer_,pl)); }
110 
111 private:
114 
115  // dummy field so that the evaluator will have something to do
116  Teuchos::RCP<PHX::FieldTag> scatterHolder_;
117 
118  // fields that need to be scattered will be put in this vector
119  std::vector< PHX::MDField<const ScalarT,Cell,NODE> > scatterFields_;
120 
121  // maps the local (field,element,basis) triplet to a global ID
122  // for scattering
123  Teuchos::RCP<const panzer::UniqueGlobalIndexer<LO,GO> > globalIndexer_;
124  std::vector<int> fieldIds_; // field IDs needing mapping
125 
126  // This maps the scattered field names to the DOF manager field
127  // For instance a Navier-Stokes map might look like
128  // fieldMap_["RESIDUAL_Velocity"] --> "Velocity"
129  // fieldMap_["RESIDUAL_Pressure"] --> "Pressure"
130  Teuchos::RCP<const std::map<std::string,std::string> > fieldMap_;
131 
132  std::size_t num_nodes;
133 
134  std::size_t side_subcell_dim_;
135  std::size_t local_side_id_;
136 
138 
139  Teuchos::RCP<typename LOC::VectorType> dirichletCounter_;
140 
141  std::string globalDataKey_; // what global data does this fill?
142  Teuchos::RCP<const LOC> tpetraContainer_;
143 
146 
147  // If set to true, scattering an initial condition
149 
150  // Allows runtime disabling of dirichlet BCs on node-by-node basis
151  std::vector< PHX::MDField<const bool,Cell,NODE> > applyBC_;
152 };
153 
154 // **************************************************************
155 // Tangent
156 // **************************************************************
157 template<typename TRAITS,typename LO,typename GO,typename NodeT>
159  : public panzer::EvaluatorWithBaseImpl<TRAITS>,
160  public PHX::EvaluatorDerived<panzer::Traits::Tangent, TRAITS>,
162 
163 public:
164  ScatterDirichletResidual_Tpetra(const Teuchos::RCP<const UniqueGlobalIndexer<LO,GO> > & indexer)
165  : globalIndexer_(indexer) {}
166 
167  ScatterDirichletResidual_Tpetra(const Teuchos::RCP<const UniqueGlobalIndexer<LO,GO> > & indexer,
168  const Teuchos::ParameterList& p);
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 
177  virtual Teuchos::RCP<CloneableEvaluator> clone(const Teuchos::ParameterList & pl) const
178  { return Teuchos::rcp(new ScatterDirichletResidual_Tpetra<panzer::Traits::Tangent,TRAITS,LO,GO>(globalIndexer_,pl)); }
179 
180 private:
183 
184  // dummy field so that the evaluator will have something to do
185  Teuchos::RCP<PHX::FieldTag> scatterHolder_;
186 
187  // fields that need to be scattered will be put in this vector
188  std::vector< PHX::MDField<const ScalarT,Cell,NODE> > scatterFields_;
189 
190  // maps the local (field,element,basis) triplet to a global ID
191  // for scattering
192  Teuchos::RCP<const panzer::UniqueGlobalIndexer<LO,GO> > globalIndexer_;
193  std::vector<int> fieldIds_; // field IDs needing mapping
194 
195  // This maps the scattered field names to the DOF manager field
196  // For instance a Navier-Stokes map might look like
197  // fieldMap_["RESIDUAL_Velocity"] --> "Velocity"
198  // fieldMap_["RESIDUAL_Pressure"] --> "Pressure"
199  Teuchos::RCP<const std::map<std::string,std::string> > fieldMap_;
200 
201  std::size_t num_nodes;
202 
203  std::size_t side_subcell_dim_;
204  std::size_t local_side_id_;
205 
207 
208  Teuchos::RCP<typename LOC::VectorType> dirichletCounter_;
209 
210  std::string globalDataKey_; // what global data does this fill?
211  Teuchos::RCP<const LOC> tpetraContainer_;
212  std::vector< Teuchos::ArrayRCP<double> > dfdp_vectors_;
213 
216 
217  // If set to true, scattering an initial condition
219 
220  // Allows runtime disabling of dirichlet BCs on node-by-node basis
221  std::vector< PHX::MDField<const bool,Cell,NODE> > applyBC_;
222 };
223 
224 // **************************************************************
225 // Jacobian
226 // **************************************************************
227 template<typename TRAITS,typename LO,typename GO,typename NodeT>
229  : public panzer::EvaluatorWithBaseImpl<TRAITS>,
230  public PHX::EvaluatorDerived<panzer::Traits::Jacobian, TRAITS>,
232 
233 public:
234  ScatterDirichletResidual_Tpetra(const Teuchos::RCP<const UniqueGlobalIndexer<LO,GO> > & indexer)
235  : globalIndexer_(indexer) {}
236 
237  ScatterDirichletResidual_Tpetra(const Teuchos::RCP<const UniqueGlobalIndexer<LO,GO> > & indexer,
238  const Teuchos::ParameterList& p);
239 
240  void preEvaluate(typename TRAITS::PreEvalData d);
241 
242  void postRegistrationSetup(typename TRAITS::SetupData d,
244 
245  void evaluateFields(typename TRAITS::EvalData workset);
246 
247  virtual Teuchos::RCP<CloneableEvaluator> clone(const Teuchos::ParameterList & pl) const
248  { return Teuchos::rcp(new ScatterDirichletResidual_Tpetra<panzer::Traits::Jacobian,TRAITS,LO,GO>(globalIndexer_,pl)); }
249 
250 private:
251 
254 
255  // dummy field so that the evaluator will have something to do
256  Teuchos::RCP<PHX::FieldTag> scatterHolder_;
257 
258  // fields that need to be scattered will be put in this vector
259  std::vector< PHX::MDField<const ScalarT,Cell,NODE> > scatterFields_;
260 
261  // maps the local (field,element,basis) triplet to a global ID
262  // for scattering
263  Teuchos::RCP<const panzer::UniqueGlobalIndexer<LO,GO> > globalIndexer_;
264  std::vector<int> fieldIds_; // field IDs needing mapping
265 
266  // This maps the scattered field names to the DOF manager field
267  // For instance a Navier-Stokes map might look like
268  // fieldMap_["RESIDUAL_Velocity"] --> "Velocity"
269  // fieldMap_["RESIDUAL_Pressure"] --> "Pressure"
270  Teuchos::RCP<const std::map<std::string,std::string> > fieldMap_;
271 
272  std::size_t num_nodes;
273  std::size_t num_eq;
274 
275  std::size_t side_subcell_dim_;
276  std::size_t local_side_id_;
277 
278  Teuchos::RCP<typename LOC::VectorType> dirichletCounter_;
279 
281 
282  std::string globalDataKey_; // what global data does this fill?
283  Teuchos::RCP<const TpetraLinearObjContainer<double,LO,GO,NodeT> > tpetraContainer_;
284 
287 
288  // Allows runtime disabling of dirichlet BCs on node-by-node basis
289  std::vector< PHX::MDField<const bool,Cell,NODE> > applyBC_;
290 };
291 
292 }
293 
294 // optionally include hessian support
295 #ifdef Panzer_BUILD_HESSIAN_SUPPORT
297 #endif
298 
299 // **************************************************************
300 #endif
virtual Teuchos::RCP< CloneableEvaluator > clone(const Teuchos::ParameterList &pl) const
virtual Teuchos::RCP< CloneableEvaluator > clone(const Teuchos::ParameterList &pl) const
virtual Teuchos::RCP< CloneableEvaluator > clone(const Teuchos::ParameterList &pl) const
Wrapper to PHX::EvaluatorWithBaseImpl that implements Panzer-specific helpers.
Pushes residual values into the residual vector for a Newton-based solve.
bool checkApplyBC_
If set to true, allows runtime disabling of dirichlet BCs on node-by-node basis.
bool checkApplyBC_
If set to true, allows runtime disabling of dirichlet BCs on node-by-node basis.
bool checkApplyBC_
If set to true, allows runtime disabling of dirichlet BCs on node-by-node basis.
Non-templated empty base class for template managers.