Panzer Version of the Day
Loading...
Searching...
No Matches
Panzer_ScatterDirichletResidual_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_DIRICHLET_RESIDUAL_BLOCKEDTPETRA_HPP
44#define PANZER_EVALUATOR_SCATTER_DIRICHLET_RESIDUAL_BLOCKEDTPETRA_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
60namespace Thyra {
61 template <typename ScalarT> class ProductVectorBase;
62}
63
64namespace panzer {
65
66class BlockedDOFManager;
67class GlobalIndexer;
68
77template <typename EvalT,typename TRAITS,typename LO,typename GO,typename NodeT=panzer::TpetraNodeType>
79 : public panzer::EvaluatorWithBaseImpl<TRAITS>,
80 public PHX::EvaluatorDerived<panzer::Traits::Residual, TRAITS>,
82public:
83 typedef typename EvalT::ScalarT ScalarT;
84 ScatterDirichletResidual_BlockedTpetra(const Teuchos::RCP<const BlockedDOFManager> & /* indexer */)
85 { }
86
87 ScatterDirichletResidual_BlockedTpetra(const Teuchos::RCP<const BlockedDOFManager> & gidProviders,
88 const Teuchos::ParameterList& p);
89
90 virtual Teuchos::RCP<CloneableEvaluator> clone(const Teuchos::ParameterList & pl) const
91 { return Teuchos::rcp(new ScatterDirichletResidual_BlockedTpetra<EvalT,TRAITS,LO,GO,NodeT>(Teuchos::null,pl)); }
92
93 void postRegistrationSetup(typename TRAITS::SetupData /* d */, PHX::FieldManager<TRAITS>& /* vm */)
94 { }
95 void evaluateFields(typename TRAITS::EvalData /* d */)
96 { std::cout << "unspecialized version of \"ScatterDirichletResidual_BlockedTpetra::evaluateFields\" on \""+PHX::print<EvalT>()+"\" should not be used!" << std::endl;
97 TEUCHOS_ASSERT(false); }
98};
99
100// **************************************************************
101// **************************************************************
102// * Specializations
103// **************************************************************
104// **************************************************************
105
106
107// **************************************************************
108// Residual
109// **************************************************************
110template <typename TRAITS,typename LO,typename GO,typename NodeT>
112 : public panzer::EvaluatorWithBaseImpl<TRAITS>,
113 public PHX::EvaluatorDerived<panzer::Traits::Residual, TRAITS>,
115
116public:
117 ScatterDirichletResidual_BlockedTpetra(const Teuchos::RCP<const BlockedDOFManager> & indexer)
118 : globalIndexer_(indexer) {}
119
120 ScatterDirichletResidual_BlockedTpetra(const Teuchos::RCP<const BlockedDOFManager> & indexer,
121 const Teuchos::ParameterList& p);
122
123 void postRegistrationSetup(typename TRAITS::SetupData d,
125
126 void preEvaluate(typename TRAITS::PreEvalData d);
127
128 void evaluateFields(typename TRAITS::EvalData workset);
129
130 virtual Teuchos::RCP<CloneableEvaluator> clone(const Teuchos::ParameterList & pl) const
132
133private:
135 typedef typename TRAITS::RealType RealType;
136
138 typedef Tpetra::Vector<RealType,LO,GO,NodeT> VectorType;
139 typedef Tpetra::CrsMatrix<RealType,LO,GO,NodeT> CrsMatrixType;
140 typedef Tpetra::CrsGraph<LO,GO,NodeT> CrsGraphType;
141 typedef Tpetra::Map<LO,GO,NodeT> MapType;
142 typedef Tpetra::Import<LO,GO,NodeT> ImportType;
143 typedef Tpetra::Export<LO,GO,NodeT> ExportType;
144
145 // dummy field so that the evaluator will have something to do
146 Teuchos::RCP<PHX::FieldTag> scatterHolder_;
147
148 // fields that need to be scattered will be put in this vector
149 std::vector< PHX::MDField<const ScalarT,Cell,NODE> > scatterFields_;
150
151 // maps the local (field,element,basis) triplet to a global ID
152 // for scattering
153 Teuchos::RCP<const panzer::BlockedDOFManager> globalIndexer_;
154
158 std::vector<Teuchos::RCP<const panzer::GlobalIndexer>> fieldGlobalIndexers_;
159
161 std::vector<int> fieldIds_;
162
165 std::vector<int> productVectorBlockIndex_;
166
167 // This maps the scattered field names to the DOF manager field
168 // For instance a Navier-Stokes map might look like
169 // fieldMap_["RESIDUAL_Velocity"] --> "Velocity"
170 // fieldMap_["RESIDUAL_Pressure"] --> "Pressure"
171 Teuchos::RCP<const std::map<std::string,std::string> > fieldMap_;
172
174 PHX::View<LO**> worksetLIDs_;
175
177 std::vector<PHX::View<int*>> fieldOffsets_;
178
182 std::vector<PHX::View<int*>> basisIndexForMDFieldOffsets_;
183
184 std::size_t side_subcell_dim_;
185 std::size_t local_side_id_;
186
187 Teuchos::RCP<Thyra::ProductVectorBase<double> > dirichletCounter_;
188 std::string globalDataKey_; // what global data does this fill?
189 Teuchos::RCP<const BlockedTpetraLinearObjContainer<RealType,LO,GO,NodeT> > blockedContainer_;
190
193
194 // If set to true, scattering an initial condition
196
197 // Allows runtime disabling of dirichlet BCs on node-by-node basis
198 std::vector< PHX::MDField<const bool,Cell,NODE> > applyBC_;
199
201};
202
203// **************************************************************
204// Jacobian
205// **************************************************************
206template <typename TRAITS,typename LO,typename GO,typename NodeT>
208 : public panzer::EvaluatorWithBaseImpl<TRAITS>,
209 public PHX::EvaluatorDerived<panzer::Traits::Jacobian, TRAITS>,
211
212public:
213 ScatterDirichletResidual_BlockedTpetra(const Teuchos::RCP<const BlockedDOFManager> & indexer)
214 : globalIndexer_(indexer) {}
215
216 ScatterDirichletResidual_BlockedTpetra(const Teuchos::RCP<const BlockedDOFManager> & indexer,
217 const Teuchos::ParameterList& p);
218
219 void preEvaluate(typename TRAITS::PreEvalData d);
220
221 void postRegistrationSetup(typename TRAITS::SetupData d,
223
224 void evaluateFields(typename TRAITS::EvalData workset);
225
226 virtual Teuchos::RCP<CloneableEvaluator> clone(const Teuchos::ParameterList & pl) const
228
229private:
231 typedef typename TRAITS::RealType RealType;
232
234 typedef Tpetra::Operator<RealType,LO,GO,NodeT> OperatorType;
235 typedef Tpetra::CrsMatrix<RealType,LO,GO,NodeT> CrsMatrixType;
236 typedef Tpetra::Map<LO,GO,NodeT> MapType;
237
238 typedef Thyra::TpetraLinearOp<RealType,LO,GO,NodeT> ThyraLinearOp;
239
240 // dummy field so that the evaluator will have something to do
241 Teuchos::RCP<PHX::FieldTag> scatterHolder_;
242
243 // fields that need to be scattered will be put in this vector
244 std::vector< PHX::MDField<const ScalarT,Cell,NODE> > scatterFields_;
245
246 // maps the local (field,element,basis) triplet to a global ID
247 // for scattering
248 Teuchos::RCP<const panzer::BlockedDOFManager> globalIndexer_;
249
250 std::vector<int> fieldIds_; // field IDs needing mapping
251
254 std::vector<int> productVectorBlockIndex_;
255
256 // This maps the scattered field names to the DOF manager field
257 // For instance a Navier-Stokes map might look like
258 // fieldMap_["RESIDUAL_Velocity"] --> "Velocity"
259 // fieldMap_["RESIDUAL_Pressure"] --> "Pressure"
260 Teuchos::RCP<const std::map<std::string,std::string> > fieldMap_;
261
262 std::size_t side_subcell_dim_;
263 std::size_t local_side_id_;
264
265 Teuchos::RCP<Thyra::ProductVectorBase<double> > dirichletCounter_;
266 std::string globalDataKey_; // what global data does this fill?
267 Teuchos::RCP<const BlockedTpetraLinearObjContainer<RealType,LO,GO,NodeT> > blockedContainer_;
268
270 PHX::View<LO**> worksetLIDs_;
271
273 std::vector<PHX::View<int*>> fieldOffsets_;
274
278 std::vector<PHX::View<int*>> basisIndexForMDFieldOffsets_;
279
281 PHX::View<LO*> blockOffsets_;
282
285
286 // Allows runtime disabling of dirichlet BCs on node-by-node basis
287 std::vector< PHX::MDField<const bool,Cell,NODE> > applyBC_;
288
290 static constexpr int maxDerivativeArraySize_ = 256;
291
293};
294
295}
296
297#ifdef Panzer_BUILD_HESSIAN_SUPPORT
299#endif
300
301// **************************************************************
302#endif
Non-templated empty base class for template managers.
Wrapper to PHX::EvaluatorWithBaseImpl that implements Panzer-specific helpers.
PHX::View< LO * > blockOffsets_
The offset values of the blocked DOFs per element. Size of number of blocks in the product vector + 1...
bool checkApplyBC_
If set to true, allows runtime disabling of dirichlet BCs on node-by-node basis.
std::vector< PHX::View< int * > > fieldOffsets_
Offset into the cell lids for each field. Size of number of fields to scatter.
bool checkApplyBC_
If set to true, allows runtime disabling of dirichlet BCs on node-by-node basis.
Pushes residual values into the residual vector for a Newton-based solve.
virtual Teuchos::RCP< CloneableEvaluator > clone(const Teuchos::ParameterList &pl) const
ScatterDirichletResidual_BlockedTpetra(const Teuchos::RCP< const BlockedDOFManager > &)
void postRegistrationSetup(typename TRAITS::SetupData, PHX::FieldManager< TRAITS > &)