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// Panzer: A partial differential equation assembly
4// engine for strongly coupled complex multiphysics systems
5//
6// Copyright 2011 NTESS and the Panzer contributors.
7// SPDX-License-Identifier: BSD-3-Clause
8// *****************************************************************************
9// @HEADER
10
11#ifndef PANZER_EVALUATOR_GATHER_SOLUTION_TPETRA_DECL_HPP
12#define PANZER_EVALUATOR_GATHER_SOLUTION_TPETRA_DECL_HPP
13
14#include "Phalanx_config.hpp"
15#include "Phalanx_Evaluator_Macros.hpp"
16#include "Phalanx_MDField.hpp"
17#include "Phalanx_KokkosViewOfViews.hpp"
18
19#include "Teuchos_ParameterList.hpp"
20
21#include "PanzerDiscFE_config.hpp"
22#include "Panzer_Dimension.hpp"
23#include "Panzer_Traits.hpp"
26
27#include"Panzer_NodeType.hpp"
28
30
32
33namespace panzer {
34
35class GlobalIndexer; //forward declaration
36
44template<typename EvalT, typename Traits,typename LO,typename GO,typename NodeT=panzer::TpetraNodeType>
46
47// **************************************************************
48// **************************************************************
49// * Specializations
50// **************************************************************
51// **************************************************************
52
53
54// **************************************************************
55// Residual
56// **************************************************************
57template<typename TRAITS,typename LO,typename GO,typename NodeT>
59 : public panzer::EvaluatorWithBaseImpl<TRAITS>,
60 public PHX::EvaluatorDerived<panzer::Traits::Residual, TRAITS>,
62
63
64public:
65
66 GatherSolution_Tpetra(const Teuchos::RCP<const panzer::GlobalIndexer> & indexer) :
67 globalIndexer_(indexer) {}
68
69 GatherSolution_Tpetra(const Teuchos::RCP<const panzer::GlobalIndexer> & indexer,
70 const Teuchos::ParameterList& p);
71
72 void postRegistrationSetup(typename TRAITS::SetupData d,
74
75 void preEvaluate(typename TRAITS::PreEvalData d);
76
77 void evaluateFields(typename TRAITS::EvalData d);
78
79 virtual Teuchos::RCP<CloneableEvaluator> clone(const Teuchos::ParameterList & pl) const
80 { return Teuchos::rcp(new GatherSolution_Tpetra<panzer::Traits::Residual,TRAITS,LO,GO,NodeT>(globalIndexer_,pl)); }
81
82 // for testing purposes
83 const PHX::FieldTag & getFieldTag(int i) const
84 { TEUCHOS_ASSERT(i < Teuchos::as<int>(gatherFields_.size())); return gatherFields_[i].fieldTag(); }
85
86private:
87
90
91 // maps the local (field,element,basis) triplet to a global ID
92 // for scattering
93 Teuchos::RCP<const panzer::GlobalIndexer> globalIndexer_;
94 std::vector<int> fieldIds_; // field IDs needing mapping
95
96 std::vector< PHX::MDField<ScalarT,Cell,NODE> > gatherFields_;
97
98 std::vector<std::string> indexerNames_;
100 std::string globalDataKey_; // what global data does this fill?
101
102 Teuchos::RCP<const TpetraLinearObjContainer<double,LO,GO,NodeT> > tpetraContainer_;
103
104 // Fields for storing tangent components dx/dp of solution vector x
105 // These are not actually used by the residual specialization of this evaluator,
106 // even if they are supplied, but it is useful to declare them as dependencies anyway
107 // when saving the tangent components to the output file
109 std::vector< std::vector< PHX::MDField<const ScalarT,Cell,NODE> > > tangentFields_;
110
111 PHX::View<int**> scratch_lids_;
112 std::vector<PHX::View<int*> > scratch_offsets_;
113
115};
116
117// **************************************************************
118// Tangent
119// **************************************************************
120template<typename TRAITS,typename LO,typename GO,typename NodeT>
122 : public panzer::EvaluatorWithBaseImpl<TRAITS>,
123 public PHX::EvaluatorDerived<panzer::Traits::Tangent, TRAITS>,
125
126
127public:
128
129 GatherSolution_Tpetra(const Teuchos::RCP<const panzer::GlobalIndexer> & indexer) :
130 globalIndexer_(indexer) {}
131
132 GatherSolution_Tpetra(const Teuchos::RCP<const panzer::GlobalIndexer> & indexer,
133 const Teuchos::ParameterList& p);
134
135 void postRegistrationSetup(typename TRAITS::SetupData d,
137
138 void preEvaluate(typename TRAITS::PreEvalData d);
139
140 void evaluateFields(typename TRAITS::EvalData d);
141
142 virtual Teuchos::RCP<CloneableEvaluator> clone(const Teuchos::ParameterList & pl) const
143 { return Teuchos::rcp(new GatherSolution_Tpetra<panzer::Traits::Tangent,TRAITS,LO,GO,NodeT>(globalIndexer_,pl)); }
144
145private:
146
150
151 // maps the local (field,element,basis) triplet to a global ID
152 // for scattering
153 Teuchos::RCP<const panzer::GlobalIndexer> globalIndexer_;
154 std::vector<int> fieldIds_; // field IDs needing mapping
155
156 std::vector< PHX::MDField<ScalarT,Cell,NODE> > gatherFields_;
157 PHX::ViewOfViews<1,PHX::View<ScalarT**>> gatherFieldsVoV_;
158
159 std::vector<std::string> indexerNames_;
161 std::string globalDataKey_; // what global data does this fill?
162
163 Teuchos::RCP<const TpetraLinearObjContainer<double,LO,GO,NodeT> > tpetraContainer_;
164
165 // Fields for storing tangent components dx/dp of solution vector x
167 std::vector< std::vector< PHX::MDField<const RealT,Cell,NODE> > > tangentFields_;
168 PHX::ViewOfViews<2,PHX::View<const RealT**>> tangentFieldsVoV_;
169 PHX::View<size_t*> tangentInnerVectorSizes_;
170
172};
173
174// **************************************************************
175// Jacobian
176// **************************************************************
177template<typename TRAITS,typename LO,typename GO,typename NodeT>
179 : public panzer::EvaluatorWithBaseImpl<TRAITS>,
180 public PHX::EvaluatorDerived<panzer::Traits::Jacobian, TRAITS>,
182
183public:
184 GatherSolution_Tpetra(const Teuchos::RCP<const panzer::GlobalIndexer> & indexer) :
185 globalIndexer_(indexer) {}
186
187 GatherSolution_Tpetra(const Teuchos::RCP<const panzer::GlobalIndexer> & indexer,
188 const Teuchos::ParameterList& p);
189
190 void postRegistrationSetup(typename TRAITS::SetupData d,
192
193 void preEvaluate(typename TRAITS::PreEvalData d);
194
195 void evaluateFields(typename TRAITS::EvalData d);
196
197 virtual Teuchos::RCP<CloneableEvaluator> clone(const Teuchos::ParameterList & pl) const
198 { return Teuchos::rcp(new GatherSolution_Tpetra<panzer::Traits::Jacobian,TRAITS,LO,GO,NodeT>(globalIndexer_,pl)); }
199
200 KOKKOS_INLINE_FUNCTION
201 void operator()(const int cell) const;
202
203
204 // No seeding of the AD fuctor
205 struct NoSeed {};
206 KOKKOS_INLINE_FUNCTION
207 void operator()(const NoSeed,const int cell) const;
208
209private:
210
213
214 // maps the local (field,element,basis) triplet to a global ID
215 // for scattering
216 Teuchos::RCP<const panzer::GlobalIndexer> globalIndexer_;
217 std::vector<int> fieldIds_; // field IDs needing mapping
218
219 std::vector< PHX::MDField<ScalarT,Cell,NODE> > gatherFields_;
220
221 std::vector<std::string> indexerNames_;
223 bool disableSensitivities_; // This disables sensitivities absolutely
224 std::string sensitivitiesName_; // This sets which gather operations have sensitivities
225 bool applySensitivities_; // This is a local variable that is used by evaluateFields
226 // to turn on/off a certain set of sensitivities
227 std::string globalDataKey_; // what global data does this fill?
228 int gatherSeedIndex_; // what gather seed in the workset to use
229 // if less than zero then use alpha or beta
230 // as appropriate
231
232 Teuchos::RCP<const TpetraLinearObjContainer<double,LO,GO,NodeT> > tpetraContainer_;
233 Teuchos::RCP<typename TpetraLinearObjContainer<double,LO,GO,NodeT>::VectorType> x_vector;
234
236
237 PHX::View<int**> scratch_lids_;
238 std::vector<PHX::View<int*> > scratch_offsets_;
239
240 // functor data
241 struct {
242 // input values
243 PHX::View<const LO**> lids; // local indices for unknowns
244 PHX::View<const int*> offsets; // how to get a particular field
245 Kokkos::View<const double**, Kokkos::LayoutLeft,PHX::Device> x_data;
246 double seed_value; // AD seed information
247 int dos; // Offset for special interface bc
248
249 // output fields
250 PHX::MDField<ScalarT,Cell,NODE> field;
251 } functor_data;
252};
253
254}
255
256#ifdef Panzer_BUILD_HESSIAN_SUPPORT
258#endif
259
260// **************************************************************
261#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.