Panzer Version of the Day
Loading...
Searching...
No Matches
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
60namespace panzer {
61
62// Forward declarations
63class BlockedDOFManager;
64class GlobalIndexer;
65
70template <typename EvalT,typename TRAITS,typename LO,typename GO,typename NodeT=panzer::TpetraNodeType>
72 : public panzer::EvaluatorWithBaseImpl<TRAITS>,
73 public PHX::EvaluatorDerived<panzer::Traits::Residual, TRAITS>,
75public:
76 typedef typename EvalT::ScalarT ScalarT;
77
78 ScatterResidual_BlockedTpetra(const Teuchos::RCP<const BlockedDOFManager> & /* indexer */)
79 { }
80 ScatterResidual_BlockedTpetra(const Teuchos::RCP<const BlockedDOFManager> & gidProviders,
81 const Teuchos::ParameterList& p);
82
83 virtual Teuchos::RCP<CloneableEvaluator> clone(const Teuchos::ParameterList & pl) const
84 { return Teuchos::rcp(new ScatterResidual_BlockedTpetra<EvalT,TRAITS,LO,GO,NodeT>(Teuchos::null,pl)); }
85
86 void postRegistrationSetup(typename TRAITS::SetupData /* d */, PHX::FieldManager<TRAITS>& /* vm */)
87 { }
88 void evaluateFields(typename TRAITS::EvalData /* d */)
89 { std::cout << "unspecialized version of \"ScatterResidual_BlockedTpetra::evaluateFields\" on \""+PHX::print<EvalT>()+"\" should not be used!" << std::endl;
90 TEUCHOS_ASSERT(false); }
91};
92
93// **************************************************************
94// **************************************************************
95// * Specializations
96// **************************************************************
97// **************************************************************
98
99
100// **************************************************************
101// Residual
102// **************************************************************
103template <typename TRAITS,typename LO,typename GO,typename NodeT>
105 : public panzer::EvaluatorWithBaseImpl<TRAITS>,
106 public PHX::EvaluatorDerived<panzer::Traits::Residual, TRAITS>,
108
109public:
110 ScatterResidual_BlockedTpetra(const Teuchos::RCP<const BlockedDOFManager> & indexer)
111 : globalIndexer_(indexer) {}
112
113 ScatterResidual_BlockedTpetra(const Teuchos::RCP<const BlockedDOFManager> & indexer,
114 const Teuchos::ParameterList& p);
115
116 void postRegistrationSetup(typename TRAITS::SetupData d,
118
119 void preEvaluate(typename TRAITS::PreEvalData d);
120
121 void evaluateFields(typename TRAITS::EvalData workset);
122
123 virtual Teuchos::RCP<CloneableEvaluator> clone(const Teuchos::ParameterList & pl) const
124 { return Teuchos::rcp(new ScatterResidual_BlockedTpetra<panzer::Traits::Residual,TRAITS,LO,GO,NodeT>(globalIndexer_,pl)); }
125
126private:
128 typedef typename TRAITS::RealType RealType;
129
131 typedef Tpetra::Vector<RealType,LO,GO,NodeT> VectorType;
132 typedef Tpetra::CrsMatrix<RealType,LO,GO,NodeT> CrsMatrixType;
133 typedef Tpetra::CrsGraph<LO,GO,NodeT> CrsGraphType;
134 typedef Tpetra::Map<LO,GO,NodeT> MapType;
135 typedef Tpetra::Import<LO,GO,NodeT> ImportType;
136 typedef Tpetra::Export<LO,GO,NodeT> ExportType;
137
139 Teuchos::RCP<PHX::FieldTag> scatterHolder_;
140
142 std::vector< PHX::MDField<const ScalarT,Cell,NODE> > scatterFields_;
143
145 Teuchos::RCP<const BlockedDOFManager> globalIndexer_;
146
148 std::vector<Teuchos::RCP<const panzer::GlobalIndexer>> fieldGlobalIndexers_;
149
151 std::vector<int> fieldIds_;
152
155 std::vector<int> productVectorBlockIndex_;
156
157 // This maps the scattered field names to the DOF manager field
158 // For instance a Navier-Stokes map might look like
159 // fieldMap_["RESIDUAL_Velocity"] --> "Velocity"
160 // fieldMap_["RESIDUAL_Pressure"] --> "Pressure"
161 Teuchos::RCP<const std::map<std::string,std::string> > fieldMap_;
162
163 std::string globalDataKey_; // what global data does this fill?
164 Teuchos::RCP<const BlockedTpetraLinearObjContainer<RealType,LO,GO,NodeT> > blockedContainer_;
165
167 PHX::View<LO**> worksetLIDs_;
168
170 std::vector<PHX::View<int*>> fieldOffsets_;
171
173};
174
175// **************************************************************
176// Jacobian
177// **************************************************************
178
179template <typename TRAITS,typename LO,typename GO,typename NodeT>
181 : public panzer::EvaluatorWithBaseImpl<TRAITS>,
182 public PHX::EvaluatorDerived<panzer::Traits::Jacobian, TRAITS>,
184
185public:
186
207 ScatterResidual_BlockedTpetra(const Teuchos::RCP<const BlockedDOFManager> & indexer)
208 : globalIndexer_(indexer) {}
209
210 ScatterResidual_BlockedTpetra(const Teuchos::RCP<const BlockedDOFManager> & indexer,
211 const Teuchos::ParameterList& p);
212
213 void postRegistrationSetup(typename TRAITS::SetupData d,
215
216 void preEvaluate(typename TRAITS::PreEvalData d);
217
218 void evaluateFields(typename TRAITS::EvalData workset);
219
220 virtual Teuchos::RCP<CloneableEvaluator> clone(const Teuchos::ParameterList & pl) const
221 { return Teuchos::rcp(new ScatterResidual_BlockedTpetra<panzer::Traits::Jacobian,TRAITS,LO,GO,NodeT>(globalIndexer_,pl)); }
222
223private:
225 typedef typename TRAITS::RealType RealType;
226
228 typedef Tpetra::Operator<RealType,LO,GO,NodeT> OperatorType;
229 typedef Tpetra::CrsMatrix<RealType,LO,GO,NodeT> CrsMatrixType;
230 typedef Tpetra::Map<LO,GO,NodeT> MapType;
231
232 typedef Thyra::TpetraLinearOp<RealType,LO,GO,NodeT> ThyraLinearOp;
233
234 // dummy field so that the evaluator will have something to do
235 Teuchos::RCP<PHX::FieldTag> scatterHolder_;
236
237 // fields that need to be scattered will be put in this vector
238 std::vector< PHX::MDField<const ScalarT,Cell,NODE> > scatterFields_;
239
240 // maps the local (field,element,basis) triplet to a global ID
241 // for scattering
242 Teuchos::RCP<const BlockedDOFManager> globalIndexer_;
243
244 std::vector<int> fieldIds_; // field IDs needing mapping
245
248 std::vector<int> productVectorBlockIndex_;
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"
254 Teuchos::RCP<const std::map<std::string,std::string> > fieldMap_;
255
256 std::string globalDataKey_; // what global data does this fill?
257 Teuchos::RCP<const BlockedTpetraLinearObjContainer<RealType,LO,GO,NodeT> > blockedContainer_;
258
260 Kokkos::View<LO**, Kokkos::LayoutRight, PHX::Device> worksetLIDs_;
261
263 Kokkos::View<typename Sacado::ScalarType<ScalarT>::type**, Kokkos::LayoutRight, PHX::Device> workset_vals_;
264
266 std::vector<PHX::View<int*>> fieldOffsets_;
267
269 PHX::View<LO*> blockOffsets_;
270
272};
273
274}
275
276#ifdef Panzer_BUILD_HESSIAN_SUPPORT
278#endif
279
280// **************************************************************
281#endif
Non-templated empty base class for template managers.
Wrapper to PHX::EvaluatorWithBaseImpl that implements Panzer-specific helpers.
Kokkos::View< typename Sacado::ScalarType< ScalarT >::type **, Kokkos::LayoutRight, PHX::Device > workset_vals_
Scratch space for local values.
virtual Teuchos::RCP< CloneableEvaluator > clone(const Teuchos::ParameterList &pl) const
std::vector< PHX::View< int * > > fieldOffsets_
Offset into the cell lids for each field. Size of number of fields to scatter.
Teuchos::RCP< const BlockedTpetraLinearObjContainer< RealType, LO, GO, NodeT > > blockedContainer_
PHX::View< LO * > blockOffsets_
The offset values of the blocked DOFs per element. Size of number of blocks in the product vector + 1...
Kokkos::View< LO **, Kokkos::LayoutRight, PHX::Device > worksetLIDs_
Local indices for unknowns.
Teuchos::RCP< const BlockedDOFManager > globalIndexer_
Maps the local (field,element,basis) triplet to a global ID for scattering.
std::vector< PHX::View< int * > > fieldOffsets_
Offset into the cell lids for each field.
std::vector< int > fieldIds_
Field IDs in the local product vector block (not global field id)
virtual Teuchos::RCP< CloneableEvaluator > clone(const Teuchos::ParameterList &pl) const
Teuchos::RCP< PHX::FieldTag > scatterHolder_
Dummy evalauted field so that the evaluator will have something to do.
std::vector< Teuchos::RCP< const panzer::GlobalIndexer > > fieldGlobalIndexers_
Vector of global indexers, one for each scattered field respectively.
std::vector< PHX::MDField< const ScalarT, Cell, NODE > > scatterFields_
Fields that need to be scattered will be put in this vector.
Teuchos::RCP< const BlockedTpetraLinearObjContainer< RealType, LO, GO, NodeT > > blockedContainer_
Pushes residual values into the residual vector for a Newton-based solve.
virtual Teuchos::RCP< CloneableEvaluator > clone(const Teuchos::ParameterList &pl) const
void postRegistrationSetup(typename TRAITS::SetupData, PHX::FieldManager< TRAITS > &)
ScatterResidual_BlockedTpetra(const Teuchos::RCP< const BlockedDOFManager > &)