Panzer Version of the Day
Loading...
Searching...
No Matches
Panzer_GatherSolution_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_GATHER_SOLUTION_BLOCKEDTPETRA_DECL_HPP
44#define PANZER_EVALUATOR_GATHER_SOLUTION_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"
56
58
59namespace panzer {
60
61template <typename ScalarT,typename LocalOrdinalT,typename GlobalOrdinalT,typename NodeT>
62class BlockedTpetraLinearObjContainer;
63
64class GlobalIndexer;
65class BlockedDOFManager;
66
74template <typename EvalT,typename TRAITS,typename S,typename LO,typename GO,typename NodeT=panzer::TpetraNodeType>
76 : public panzer::EvaluatorWithBaseImpl<TRAITS>,
77 public PHX::EvaluatorDerived<panzer::Traits::Residual, TRAITS>,
79public:
80 typedef typename EvalT::ScalarT ScalarT;
81
82 GatherSolution_BlockedTpetra(const Teuchos::RCP<const BlockedDOFManager> & indexer)
83 { }
84
85 GatherSolution_BlockedTpetra(const Teuchos::RCP<const BlockedDOFManager> & gidProviders,
86 const Teuchos::ParameterList& p);
87
88 virtual Teuchos::RCP<CloneableEvaluator> clone(const Teuchos::ParameterList & pl) const
89 { return Teuchos::rcp(new GatherSolution_BlockedTpetra<EvalT,TRAITS,S,LO,GO>(Teuchos::null,pl)); }
90
91 void postRegistrationSetup(typename TRAITS::SetupData d, PHX::FieldManager<TRAITS>& vm)
92 { }
93
94 void evaluateFields(typename TRAITS::EvalData d)
95 { std::cout << "unspecialized version of \"GatherSolution_BlockedTpetra::evaluateFields\" on \""+PHX::print<EvalT>()+"\" should not be used!" << std::endl;
96 TEUCHOS_ASSERT(false); }
97};
98
99// **************************************************************
100// **************************************************************
101// * Specializations
102// **************************************************************
103// **************************************************************
104
105
106// **************************************************************
107// Residual
108// **************************************************************
109template <typename TRAITS,typename S,typename LO,typename GO,typename NodeT>
111 : public panzer::EvaluatorWithBaseImpl<TRAITS>,
112 public PHX::EvaluatorDerived<panzer::Traits::Residual, TRAITS>,
114
115
116public:
117
118 GatherSolution_BlockedTpetra(const Teuchos::RCP<const BlockedDOFManager> & indexer)
119 : globalIndexer_(indexer) {}
120
121 GatherSolution_BlockedTpetra(const Teuchos::RCP<const BlockedDOFManager> & indexer,
122 const Teuchos::ParameterList& p);
123
124 void postRegistrationSetup(typename TRAITS::SetupData d,
126
127 void preEvaluate(typename TRAITS::PreEvalData d);
128
129 void evaluateFields(typename TRAITS::EvalData d);
130
131 virtual Teuchos::RCP<CloneableEvaluator> clone(const Teuchos::ParameterList & pl) const
132 { return Teuchos::rcp(new GatherSolution_BlockedTpetra<panzer::Traits::Residual,TRAITS,S,LO,GO>(globalIndexer_,pl)); }
133
134
135private:
138
140 typedef Tpetra::Vector<S,LO,GO,NodeT> VectorType;
141 typedef Tpetra::CrsMatrix<S,LO,GO,NodeT> CrsMatrixType;
142 typedef Tpetra::CrsGraph<LO,GO,NodeT> CrsGraphType;
143 typedef Tpetra::Map<LO,GO,NodeT> MapType;
144 typedef Tpetra::Import<LO,GO,NodeT> ImportType;
145 typedef Tpetra::Export<LO,GO,NodeT> ExportType;
146
148 // scattering
149 Teuchos::RCP<const BlockedDOFManager> globalIndexer_;
150
152 std::vector<int> fieldIds_;
153
155 std::vector<Teuchos::RCP<const panzer::GlobalIndexer>> fieldGlobalIndexers_;
156
159 std::vector<int> productVectorBlockIndex_;
160
161 std::vector< PHX::MDField<ScalarT,Cell,NODE> > gatherFields_;
162
163 std::vector<std::string> indexerNames_;
165 std::string globalDataKey_; // what global data does this fill?
166
167 Teuchos::RCP<const BlockedTpetraLinearObjContainer<S,LO,GO,NodeT> > blockedContainer_;
168
169 // Fields for storing tangent components dx/dp of solution vector x
170 // These are not actually used by the residual specialization of this evaluator,
171 // even if they are supplied, but it is useful to declare them as dependencies anyway
172 // when saving the tangent components to the output file
174 std::vector< std::vector< PHX::MDField<const ScalarT,Cell,NODE> > > tangentFields_;
175
177 PHX::View<LO**> worksetLIDs_;
178
180 std::vector<PHX::View<int*>> fieldOffsets_;
181
183};
184
185// **************************************************************
186// Tangent
187// **************************************************************
188template <typename TRAITS,typename S,typename LO,typename GO,typename NodeT>
190 : public panzer::EvaluatorWithBaseImpl<TRAITS>,
191 public PHX::EvaluatorDerived<panzer::Traits::Tangent, TRAITS>,
193
194
195public:
196
197 GatherSolution_BlockedTpetra(const Teuchos::RCP<const BlockedDOFManager> & indexer)
198 : gidIndexer_(indexer) {}
199
200 GatherSolution_BlockedTpetra(const Teuchos::RCP<const BlockedDOFManager> & indexer,
201 const Teuchos::ParameterList& p);
202
203 void postRegistrationSetup(typename TRAITS::SetupData d,
205
206 void preEvaluate(typename TRAITS::PreEvalData d);
207
208 void evaluateFields(typename TRAITS::EvalData d);
209
210 virtual Teuchos::RCP<CloneableEvaluator> clone(const Teuchos::ParameterList & pl) const
211 { return Teuchos::rcp(new GatherSolution_BlockedTpetra<panzer::Traits::Tangent,TRAITS,S,LO,GO>(gidIndexer_,pl)); }
212
213
214private:
217 //typedef typename panzer::Traits::RealType RealT;
218
220 typedef Tpetra::Vector<S,LO,GO,NodeT> VectorType;
221 typedef Tpetra::CrsMatrix<S,LO,GO,NodeT> CrsMatrixType;
222 typedef Tpetra::CrsGraph<LO,GO,NodeT> CrsGraphType;
223 typedef Tpetra::Map<LO,GO,NodeT> MapType;
224 typedef Tpetra::Import<LO,GO,NodeT> ImportType;
225 typedef Tpetra::Export<LO,GO,NodeT> ExportType;
226
227 // maps the local (field,element,basis) triplet to a global ID
228 // for scattering
229 Teuchos::RCP<const BlockedDOFManager> gidIndexer_;
230
231 std::vector<int> fieldIds_; // field IDs needing mapping
232
233 std::vector< PHX::MDField<ScalarT,Cell,NODE> > gatherFields_;
234
235 std::vector<std::string> indexerNames_;
237 std::string globalDataKey_; // what global data does this fill?
238
239 Teuchos::RCP<const BlockedTpetraLinearObjContainer<S,LO,GO,NodeT> > blockedContainer_;
240
241 // Fields for storing tangent components dx/dp of solution vector x
243 std::vector< std::vector< PHX::MDField<const ScalarT,Cell,NODE> > > tangentFields_;
244
246};
247
248// **************************************************************
249// Jacobian
250// **************************************************************
251template <typename TRAITS,typename S,typename LO,typename GO,typename NodeT>
253 : public panzer::EvaluatorWithBaseImpl<TRAITS>,
254 public PHX::EvaluatorDerived<panzer::Traits::Jacobian, TRAITS>,
256
257public:
258 GatherSolution_BlockedTpetra(const Teuchos::RCP<const BlockedDOFManager> & indexer)
259 : globalIndexer_(indexer) {}
260
261 GatherSolution_BlockedTpetra(const Teuchos::RCP<const BlockedDOFManager> & indexer,
262 const Teuchos::ParameterList& p);
263
264 void postRegistrationSetup(typename TRAITS::SetupData d,
266
267 void preEvaluate(typename TRAITS::PreEvalData d);
268
269 void evaluateFields(typename TRAITS::EvalData d);
270
271 virtual Teuchos::RCP<CloneableEvaluator> clone(const Teuchos::ParameterList & pl) const
272 { return Teuchos::rcp(new GatherSolution_BlockedTpetra<panzer::Traits::Jacobian,TRAITS,S,LO,GO>(globalIndexer_,pl)); }
273
274private:
277 typedef typename TRAITS::RealType RealType;
278
280 typedef Tpetra::Vector<S,LO,GO,NodeT> VectorType;
281 typedef Tpetra::CrsMatrix<S,LO,GO,NodeT> CrsMatrixType;
282 typedef Tpetra::CrsGraph<LO,GO,NodeT> CrsGraphType;
283 typedef Tpetra::Map<LO,GO,NodeT> MapType;
284 typedef Tpetra::Import<LO,GO,NodeT> ImportType;
285 typedef Tpetra::Export<LO,GO,NodeT> ExportType;
286
287 // maps the local (field,element,basis) triplet to a global ID
288 // for scattering
289 Teuchos::RCP<const BlockedDOFManager> globalIndexer_;
290
291 std::vector<int> fieldIds_; // field IDs needing mapping
292
295 std::vector<int> productVectorBlockIndex_;
296
297 std::vector< PHX::MDField<ScalarT,Cell,NODE> > gatherFields_;
298
299 std::vector<std::string> indexerNames_;
302 std::string globalDataKey_; // what global data does this fill?
303
304 Teuchos::RCP<const BlockedTpetraLinearObjContainer<S,LO,GO,NodeT> > blockedContainer_;
305
307 PHX::View<LO**> worksetLIDs_;
308
310 std::vector<PHX::View<int*>> fieldOffsets_;
311
313 PHX::View<LO*> blockOffsets_;
314
316};
317
318}
319
321
322#ifdef Panzer_BUILD_HESSIAN_SUPPORT
324#endif
325
326// **************************************************************
327#endif
Non-templated empty base class for template managers.
Wrapper to PHX::EvaluatorWithBaseImpl that implements Panzer-specific helpers.
Teuchos::RCP< const BlockedTpetraLinearObjContainer< S, LO, GO, NodeT > > blockedContainer_
virtual Teuchos::RCP< CloneableEvaluator > clone(const Teuchos::ParameterList &pl) const
PHX::View< LO * > blockOffsets_
The offset values of the blocked DOFs per element. Size of number of blocks in the product vector + 1...
std::vector< PHX::View< int * > > fieldOffsets_
Offset into the cell lids for each field. Size of number of fields to scatter.
std::vector< PHX::View< int * > > fieldOffsets_
Offset into the cell lids for each field.
Teuchos::RCP< const BlockedTpetraLinearObjContainer< S, LO, GO, NodeT > > blockedContainer_
virtual Teuchos::RCP< CloneableEvaluator > clone(const Teuchos::ParameterList &pl) const
Teuchos::RCP< const BlockedDOFManager > globalIndexer_
Maps the local (field,element,basis) triplet to a global ID for.
std::vector< Teuchos::RCP< const panzer::GlobalIndexer > > fieldGlobalIndexers_
Vector of global indexers, one for each field to gather, respectively.
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< const BlockedTpetraLinearObjContainer< S, LO, GO, NodeT > > blockedContainer_
Gathers solution values from the Newton solution vector into the nodal fields of the field manager.
virtual Teuchos::RCP< CloneableEvaluator > clone(const Teuchos::ParameterList &pl) const
void postRegistrationSetup(typename TRAITS::SetupData d, PHX::FieldManager< TRAITS > &vm)
GatherSolution_BlockedTpetra(const Teuchos::RCP< const BlockedDOFManager > &indexer)