Panzer Version of the Day
Loading...
Searching...
No Matches
Panzer_GatherSolution_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_GATHER_SOLUTION_TPETRA_DECL_HPP
44#define PANZER_EVALUATOR_GATHER_SOLUTION_TPETRA_DECL_HPP
45
46#include "Phalanx_config.hpp"
47#include "Phalanx_Evaluator_Macros.hpp"
48#include "Phalanx_MDField.hpp"
49#include "Phalanx_KokkosViewOfViews.hpp"
50
51#include "Teuchos_ParameterList.hpp"
52
53#include "PanzerDiscFE_config.hpp"
54#include "Panzer_Dimension.hpp"
55#include "Panzer_Traits.hpp"
58
59#include"Panzer_NodeType.hpp"
60
62
64
65namespace panzer {
66
67class GlobalIndexer; //forward declaration
68
76template<typename EvalT, typename Traits,typename LO,typename GO,typename NodeT=panzer::TpetraNodeType>
78
79// **************************************************************
80// **************************************************************
81// * Specializations
82// **************************************************************
83// **************************************************************
84
85
86// **************************************************************
87// Residual
88// **************************************************************
89template<typename TRAITS,typename LO,typename GO,typename NodeT>
91 : public panzer::EvaluatorWithBaseImpl<TRAITS>,
92 public PHX::EvaluatorDerived<panzer::Traits::Residual, TRAITS>,
94
95
96public:
97
98 GatherSolution_Tpetra(const Teuchos::RCP<const panzer::GlobalIndexer> & indexer) :
99 globalIndexer_(indexer) {}
100
101 GatherSolution_Tpetra(const Teuchos::RCP<const panzer::GlobalIndexer> & indexer,
102 const Teuchos::ParameterList& p);
103
104 void postRegistrationSetup(typename TRAITS::SetupData d,
106
107 void preEvaluate(typename TRAITS::PreEvalData d);
108
109 void evaluateFields(typename TRAITS::EvalData d);
110
111 virtual Teuchos::RCP<CloneableEvaluator> clone(const Teuchos::ParameterList & pl) const
112 { return Teuchos::rcp(new GatherSolution_Tpetra<panzer::Traits::Residual,TRAITS,LO,GO,NodeT>(globalIndexer_,pl)); }
113
114 // for testing purposes
115 const PHX::FieldTag & getFieldTag(int i) const
116 { TEUCHOS_ASSERT(i < Teuchos::as<int>(gatherFields_.size())); return gatherFields_[i].fieldTag(); }
117
118private:
119
122
123 // maps the local (field,element,basis) triplet to a global ID
124 // for scattering
125 Teuchos::RCP<const panzer::GlobalIndexer> globalIndexer_;
126 std::vector<int> fieldIds_; // field IDs needing mapping
127
128 std::vector< PHX::MDField<ScalarT,Cell,NODE> > gatherFields_;
129
130 std::vector<std::string> indexerNames_;
132 std::string globalDataKey_; // what global data does this fill?
133
134 Teuchos::RCP<const TpetraLinearObjContainer<double,LO,GO,NodeT> > tpetraContainer_;
135
136 // Fields for storing tangent components dx/dp of solution vector x
137 // These are not actually used by the residual specialization of this evaluator,
138 // even if they are supplied, but it is useful to declare them as dependencies anyway
139 // when saving the tangent components to the output file
141 std::vector< std::vector< PHX::MDField<const ScalarT,Cell,NODE> > > tangentFields_;
142
143 PHX::View<int**> scratch_lids_;
144 std::vector<PHX::View<int*> > scratch_offsets_;
145
147};
148
149// **************************************************************
150// Tangent
151// **************************************************************
152template<typename TRAITS,typename LO,typename GO,typename NodeT>
154 : public panzer::EvaluatorWithBaseImpl<TRAITS>,
155 public PHX::EvaluatorDerived<panzer::Traits::Tangent, TRAITS>,
157
158
159public:
160
161 GatherSolution_Tpetra(const Teuchos::RCP<const panzer::GlobalIndexer> & indexer) :
162 globalIndexer_(indexer) {}
163
164 GatherSolution_Tpetra(const Teuchos::RCP<const panzer::GlobalIndexer> & indexer,
165 const Teuchos::ParameterList& p);
166
167 void postRegistrationSetup(typename TRAITS::SetupData d,
169
170 void preEvaluate(typename TRAITS::PreEvalData d);
171
172 void evaluateFields(typename TRAITS::EvalData d);
173
174 virtual Teuchos::RCP<CloneableEvaluator> clone(const Teuchos::ParameterList & pl) const
175 { return Teuchos::rcp(new GatherSolution_Tpetra<panzer::Traits::Tangent,TRAITS,LO,GO,NodeT>(globalIndexer_,pl)); }
176
177private:
178
182
183 // maps the local (field,element,basis) triplet to a global ID
184 // for scattering
185 Teuchos::RCP<const panzer::GlobalIndexer> globalIndexer_;
186 std::vector<int> fieldIds_; // field IDs needing mapping
187
188 std::vector< PHX::MDField<ScalarT,Cell,NODE> > gatherFields_;
189 PHX::ViewOfViews3<1,PHX::View<ScalarT**>> gatherFieldsVoV_;
190
191 std::vector<std::string> indexerNames_;
193 std::string globalDataKey_; // what global data does this fill?
194
195 Teuchos::RCP<const TpetraLinearObjContainer<double,LO,GO,NodeT> > tpetraContainer_;
196
197 // Fields for storing tangent components dx/dp of solution vector x
199 std::vector< std::vector< PHX::MDField<const RealT,Cell,NODE> > > tangentFields_;
200 PHX::ViewOfViews3<2,PHX::View<const RealT**>> tangentFieldsVoV_;
201 PHX::View<size_t*> tangentInnerVectorSizes_;
202
204};
205
206// **************************************************************
207// Jacobian
208// **************************************************************
209template<typename TRAITS,typename LO,typename GO,typename NodeT>
211 : public panzer::EvaluatorWithBaseImpl<TRAITS>,
212 public PHX::EvaluatorDerived<panzer::Traits::Jacobian, TRAITS>,
214
215public:
216 GatherSolution_Tpetra(const Teuchos::RCP<const panzer::GlobalIndexer> & indexer) :
217 globalIndexer_(indexer) {}
218
219 GatherSolution_Tpetra(const Teuchos::RCP<const panzer::GlobalIndexer> & indexer,
220 const Teuchos::ParameterList& p);
221
222 void postRegistrationSetup(typename TRAITS::SetupData d,
224
225 void preEvaluate(typename TRAITS::PreEvalData d);
226
227 void evaluateFields(typename TRAITS::EvalData d);
228
229 virtual Teuchos::RCP<CloneableEvaluator> clone(const Teuchos::ParameterList & pl) const
230 { return Teuchos::rcp(new GatherSolution_Tpetra<panzer::Traits::Jacobian,TRAITS,LO,GO,NodeT>(globalIndexer_,pl)); }
231
232 KOKKOS_INLINE_FUNCTION
233 void operator()(const int cell) const;
234
235
236 // No seeding of the AD fuctor
237 struct NoSeed {};
238 KOKKOS_INLINE_FUNCTION
239 void operator()(const NoSeed,const int cell) const;
240
241private:
242
245
246 // maps the local (field,element,basis) triplet to a global ID
247 // for scattering
248 Teuchos::RCP<const panzer::GlobalIndexer> globalIndexer_;
249 std::vector<int> fieldIds_; // field IDs needing mapping
250
251 std::vector< PHX::MDField<ScalarT,Cell,NODE> > gatherFields_;
252
253 std::vector<std::string> indexerNames_;
255 bool disableSensitivities_; // This disables sensitivities absolutely
256 std::string sensitivitiesName_; // This sets which gather operations have sensitivities
257 bool applySensitivities_; // This is a local variable that is used by evaluateFields
258 // to turn on/off a certain set of sensitivities
259 std::string globalDataKey_; // what global data does this fill?
260 int gatherSeedIndex_; // what gather seed in the workset to use
261 // if less than zero then use alpha or beta
262 // as appropriate
263
264 Teuchos::RCP<const TpetraLinearObjContainer<double,LO,GO,NodeT> > tpetraContainer_;
265 Teuchos::RCP<typename TpetraLinearObjContainer<double,LO,GO,NodeT>::VectorType> x_vector;
266
268
269 PHX::View<int**> scratch_lids_;
270 std::vector<PHX::View<int*> > scratch_offsets_;
271
272 // functor data
273 struct {
274 // input values
275 PHX::View<const LO**> lids; // local indices for unknowns
276 PHX::View<const int*> offsets; // how to get a particular field
277 Kokkos::View<const double**, Kokkos::LayoutLeft,PHX::Device> x_data;
278 double seed_value; // AD seed information
279 int dos; // Offset for special interface bc
280
281 // output fields
282 PHX::MDField<ScalarT,Cell,NODE> field;
283 } functor_data;
284};
285
286}
287
288#ifdef Panzer_BUILD_HESSIAN_SUPPORT
290#endif
291
292// **************************************************************
293#endif
Non-templated empty base class for template managers.
Wrapper to PHX::EvaluatorWithBaseImpl that implements Panzer-specific helpers.
Teuchos::RCP< const TpetraLinearObjContainer< double, LO, GO, NodeT > > tpetraContainer_
virtual Teuchos::RCP< CloneableEvaluator > clone(const Teuchos::ParameterList &pl) const
Teuchos::RCP< typename TpetraLinearObjContainer< double, LO, GO, NodeT >::VectorType > x_vector
std::vector< std::vector< PHX::MDField< const ScalarT, Cell, NODE > > > tangentFields_
virtual Teuchos::RCP< CloneableEvaluator > clone(const Teuchos::ParameterList &pl) const
Teuchos::RCP< const TpetraLinearObjContainer< double, LO, GO, NodeT > > tpetraContainer_
virtual Teuchos::RCP< CloneableEvaluator > clone(const Teuchos::ParameterList &pl) const
Teuchos::RCP< const TpetraLinearObjContainer< double, LO, GO, NodeT > > tpetraContainer_
std::vector< std::vector< PHX::MDField< const RealT, Cell, NODE > > > tangentFields_
Gathers solution values from the Newton solution vector into the nodal fields of the field manager.