Panzer Version of the Day
Loading...
Searching...
No Matches
Panzer_ScatterDirichletResidual_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_SCATTER_DIRICHLET_RESIDUAL_TPETRA_DECL_HPP
12#define PANZER_EVALUATOR_SCATTER_DIRICHLET_RESIDUAL_TPETRA_DECL_HPP
13
14#include <utility>
15#include <type_traits>
16#include "Phalanx_config.hpp"
17#include "Phalanx_Evaluator_Macros.hpp"
18#include "Phalanx_MDField.hpp"
19#include "Phalanx_KokkosViewOfViews.hpp"
20
21#include "Teuchos_ParameterList.hpp"
22
23#include "PanzerDiscFE_config.hpp"
24#include "Panzer_Dimension.hpp"
25#include "Panzer_Traits.hpp"
28
29#include "Panzer_NodeType.hpp"
30
32
33namespace panzer {
34
35class GlobalIndexer;
36
45template<typename EvalT, typename Traits,typename LO,typename GO,typename NodeT=panzer::TpetraNodeType>
47
48// **************************************************************
49// **************************************************************
50// * Specializations
51// **************************************************************
52// **************************************************************
53
54
55// **************************************************************
56// Residual
57// **************************************************************
58template<typename TRAITS,typename LO,typename GO,typename NodeT>
60 : public panzer::EvaluatorWithBaseImpl<TRAITS>,
61 public PHX::EvaluatorDerived<panzer::Traits::Residual, TRAITS>,
63
64public:
65 ScatterDirichletResidual_Tpetra(const Teuchos::RCP<const GlobalIndexer> & indexer)
66 : globalIndexer_(indexer) {}
67
68 ScatterDirichletResidual_Tpetra(const Teuchos::RCP<const GlobalIndexer> & indexer,
69 const Teuchos::ParameterList& p);
70
71 void postRegistrationSetup(typename TRAITS::SetupData d,
73
74 void preEvaluate(typename TRAITS::PreEvalData d);
75
76 void evaluateFields(typename TRAITS::EvalData workset);
77
78 virtual Teuchos::RCP<CloneableEvaluator> clone(const Teuchos::ParameterList & pl) const
79 { return Teuchos::rcp(new ScatterDirichletResidual_Tpetra<panzer::Traits::Residual,TRAITS,LO,GO>(globalIndexer_,pl)); }
80
81private:
84
85 // dummy field so that the evaluator will have something to do
86 Teuchos::RCP<PHX::FieldTag> scatterHolder_;
87
88 // fields that need to be scattered will be put in this vector
89 std::vector< PHX::MDField<const ScalarT,Cell,NODE> > scatterFields_;
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 // This maps the scattered field names to the DOF manager field
97 // For instance a Navier-Stokes map might look like
98 // fieldMap_["RESIDUAL_Velocity"] --> "Velocity"
99 // fieldMap_["RESIDUAL_Pressure"] --> "Pressure"
100 Teuchos::RCP<const std::map<std::string,std::string> > fieldMap_;
101
102 std::size_t side_subcell_dim_;
103 std::size_t local_side_id_;
104
106
107 Teuchos::RCP<typename LOC::MultiVectorType> dirichletCounter_;
108
109 std::string globalDataKey_; // what global data does this fill?
110 Teuchos::RCP<const LOC> tpetraContainer_;
111
114
115 // If set to true, scattering an initial condition
117
118 // Allows runtime disabling of dirichlet BCs on node-by-node basis
119 std::vector< PHX::MDField<const bool,Cell,NODE> > applyBC_;
120
121 PHX::View<int**> scratch_lids_;
122 std::vector<PHX::View<int*> > scratch_offsets_;
123 std::vector<PHX::View<int*> > scratch_basisIds_;
124};
125
126// **************************************************************
127// Tangent
128// **************************************************************
129template<typename TRAITS,typename LO,typename GO,typename NodeT>
131 : public panzer::EvaluatorWithBaseImpl<TRAITS>,
132 public PHX::EvaluatorDerived<panzer::Traits::Tangent, TRAITS>,
134
135public:
136 ScatterDirichletResidual_Tpetra(const Teuchos::RCP<const GlobalIndexer> & indexer)
137 : globalIndexer_(indexer) {}
138
139 ScatterDirichletResidual_Tpetra(const Teuchos::RCP<const GlobalIndexer> & indexer,
140 const Teuchos::ParameterList& p);
141
142 void postRegistrationSetup(typename TRAITS::SetupData d,
144
145 void preEvaluate(typename TRAITS::PreEvalData d);
146
147 void evaluateFields(typename TRAITS::EvalData workset);
148
149 virtual Teuchos::RCP<CloneableEvaluator> clone(const Teuchos::ParameterList & pl) const
150 { return Teuchos::rcp(new ScatterDirichletResidual_Tpetra<panzer::Traits::Tangent,TRAITS,LO,GO>(globalIndexer_,pl)); }
151
152private:
156
157 // dummy field so that the evaluator will have something to do
158 Teuchos::RCP<PHX::FieldTag> scatterHolder_;
159
160 // fields that need to be scattered will be put in this vector
161 std::vector< PHX::MDField<const ScalarT,Cell,NODE> > scatterFields_;
162
163 // maps the local (field,element,basis) triplet to a global ID
164 // for scattering
165 Teuchos::RCP<const panzer::GlobalIndexer> globalIndexer_;
166 std::vector<int> fieldIds_; // field IDs needing mapping
167
168 // This maps the scattered field names to the DOF manager field
169 // For instance a Navier-Stokes map might look like
170 // fieldMap_["RESIDUAL_Velocity"] --> "Velocity"
171 // fieldMap_["RESIDUAL_Pressure"] --> "Pressure"
172 Teuchos::RCP<const std::map<std::string,std::string> > fieldMap_;
173
174 std::size_t side_subcell_dim_;
175 std::size_t local_side_id_;
176
178
179 Teuchos::RCP<typename LOC::MultiVectorType> dirichletCounter_;
180
181 std::string globalDataKey_; // what global data does this fill?
182 Teuchos::RCP<const LOC> tpetraContainer_;
183 std::vector< Teuchos::ArrayRCP<double> > dfdp_vectors_;
184
187
188 // If set to true, scattering an initial condition
190
191 // Allows runtime disabling of dirichlet BCs on node-by-node basis
192 std::vector< PHX::MDField<const bool,Cell,NODE> > applyBC_;
193
194 PHX::View<int**> scratch_lids_;
195 std::vector<PHX::View<int*> > scratch_offsets_;
196 std::vector<PHX::View<int*> > scratch_basisIds_;
197
199 PHX::ViewOfViews<1,Kokkos::View<RealT**,Kokkos::LayoutLeft,PHX::Device>> dfdpFieldsVoV_;
200
204 std::vector<Teuchos::RCP<typename LOC::MultiVectorType> > dfdpVectors_;
205};
206
207// **************************************************************
208// Jacobian
209// **************************************************************
210template<typename TRAITS,typename LO,typename GO,typename NodeT>
212 : public panzer::EvaluatorWithBaseImpl<TRAITS>,
213 public PHX::EvaluatorDerived<panzer::Traits::Jacobian, TRAITS>,
215
216public:
217 ScatterDirichletResidual_Tpetra(const Teuchos::RCP<const GlobalIndexer> & indexer)
218 : globalIndexer_(indexer) {}
219
220 ScatterDirichletResidual_Tpetra(const Teuchos::RCP<const GlobalIndexer> & indexer,
221 const Teuchos::ParameterList& p);
222
223 void preEvaluate(typename TRAITS::PreEvalData d);
224
225 void postRegistrationSetup(typename TRAITS::SetupData d,
227
228 void evaluateFields(typename TRAITS::EvalData workset);
229
230 virtual Teuchos::RCP<CloneableEvaluator> clone(const Teuchos::ParameterList & pl) const
231 { return Teuchos::rcp(new ScatterDirichletResidual_Tpetra<panzer::Traits::Jacobian,TRAITS,LO,GO>(globalIndexer_,pl)); }
232
233private:
234
237
238 // dummy field so that the evaluator will have something to do
239 Teuchos::RCP<PHX::FieldTag> scatterHolder_;
240
241 // fields that need to be scattered will be put in this vector
242 std::vector< PHX::MDField<const ScalarT,Cell,NODE> > scatterFields_;
243
244 // maps the local (field,element,basis) triplet to a global ID
245 // for scattering
246 Teuchos::RCP<const panzer::GlobalIndexer> globalIndexer_;
247 std::vector<int> fieldIds_; // field IDs needing mapping
248
249 // This maps the scattered field names to the DOF manager field
250 // For instance a Navier-Stokes map might look like
251 // fieldMap_["RESIDUAL_Velocity"] --> "Velocity"
252 // fieldMap_["RESIDUAL_Pressure"] --> "Pressure"
253 Teuchos::RCP<const std::map<std::string,std::string> > fieldMap_;
254
255 std::size_t num_nodes;
256 std::size_t num_eq;
257
258 std::size_t side_subcell_dim_;
259 std::size_t local_side_id_;
260
261 Teuchos::RCP<typename LOC::MultiVectorType> dirichletCounter_;
262
264
265 std::string globalDataKey_; // what global data does this fill?
266 Teuchos::RCP<const TpetraLinearObjContainer<double,LO,GO,NodeT> > tpetraContainer_;
267
270
271 // Allows runtime disabling of dirichlet BCs on node-by-node basis
272 std::vector< PHX::MDField<const bool,Cell,NODE> > applyBC_;
273
278 using LIDsDeviceView = Kokkos::View<const panzer::LocalOrdinal**,Kokkos::LayoutRight,PHX::Device>;
279 using ScatterFieldDeviceView = typename PHX::MDField<const ScalarT,Cell,NODE>::array_type;
280
281 // create_mirror_view() returns the source view itself when it is already in
282 // the requested space, so let it name its own result rather than assuming
283 // host_mirror_type.
284 static constexpr bool lidsAreHostResident_ =
285 std::is_same<typename LIDsDeviceView::memory_space,Kokkos::HostSpace>::value;
286
287 decltype(Kokkos::create_mirror_view(Kokkos::HostSpace(),std::declval<LIDsDeviceView>())) lids_h_;
288 std::vector<decltype(Kokkos::create_mirror_view(std::declval<ScatterFieldDeviceView>()))> scatterFields_h_;
289 typename LOC::CrsMatrixType::nonconst_local_inds_host_view_type rowIndices_;
290 typename LOC::CrsMatrixType::nonconst_values_host_view_type rowValues_;
291 std::vector<double> jacRow_;
292};
293
294}
295
296// optionally include hessian support
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.
virtual Teuchos::RCP< CloneableEvaluator > clone(const Teuchos::ParameterList &pl) const
bool checkApplyBC_
If set to true, allows runtime disabling of dirichlet BCs on node-by-node basis.
Kokkos::View< const panzer::LocalOrdinal **, Kokkos::LayoutRight, PHX::Device > LIDsDeviceView
std::vector< decltype(Kokkos::create_mirror_view(std::declval< ScatterFieldDeviceView >()))> scatterFields_h_
virtual Teuchos::RCP< CloneableEvaluator > clone(const Teuchos::ParameterList &pl) const
bool checkApplyBC_
If set to true, allows runtime disabling of dirichlet BCs on node-by-node basis.
virtual Teuchos::RCP< CloneableEvaluator > clone(const Teuchos::ParameterList &pl) const
PHX::ViewOfViews< 1, Kokkos::View< RealT **, Kokkos::LayoutLeft, PHX::Device > > dfdpFieldsVoV_
Storage for the tangent data.
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.
Tpetra-backed implementation of LinearObjContainer.
Evaluation type for computing the residual and its Jacobian, using FadType as the scalar type.
Evaluation type for computing the residual only, using RealType as the scalar type.
Evaluation type for computing directional derivatives (e.g. parameter sensitivities),...
double RealType
Scalar type used for the Residual evaluation type (plain double).