43 #ifndef PANZER_GATHER_SOLUTION_EPETRA_SG_IMPL_HPP
44 #define PANZER_GATHER_SOLUTION_EPETRA_SG_IMPL_HPP
46 #include "Panzer_config.hpp"
49 #include "Teuchos_Assert.hpp"
50 #include "Phalanx_DataLayout.hpp"
56 #include "Teuchos_FancyOStream.hpp"
58 #include "Epetra_Vector.h"
59 #include "Epetra_Map.h"
65 template<
typename TRAITS,
typename LO,
typename GO>
70 : globalIndexer_(indexer)
71 , useTimeDerivativeSolutionVector_(false)
72 , globalDataKey_(
"Solution Gather Container")
74 const std::vector<std::string>& names =
82 gatherFields_.resize(names.size());
83 for (std::size_t fd = 0; fd < names.size(); ++fd) {
85 PHX::MDField<ScalarT,Cell,NODE>(names[fd],basis->functional);
86 this->addEvaluatedField(gatherFields_[fd]);
89 if (p.
isType<
bool>(
"Use Time Derivative Solution Vector"))
90 useTimeDerivativeSolutionVector_ = p.
get<
bool>(
"Use Time Derivative Solution Vector");
92 if (p.
isType<std::string>(
"Global Data Key"))
93 globalDataKey_ = p.
get<std::string>(
"Global Data Key");
95 this->setName(
"Gather Solution");
99 template<
typename TRAITS,
typename LO,
typename GO>
107 fieldIds_.resize(gatherFields_.size());
109 for (std::size_t fd = 0; fd < gatherFields_.size(); ++fd) {
112 const std::string& fieldName = (*indexerNames_)[fd];
113 fieldIds_[fd] = globalIndexer_->getFieldNum(fieldName);
116 this->utils.setFieldData(gatherFields_[fd],fm);
119 indexerNames_ = Teuchos::null;
123 template<
typename TRAITS,
typename LO,
typename GO>
132 template<
typename TRAITS,
typename LO,
typename GO>
136 std::vector<GO> GIDs;
137 std::vector<int> LIDs;
140 std::string blockId = this->wda(workset).block_id;
141 const std::vector<std::size_t> & localCellIds = this->wda(workset).cell_local_ids;
146 if (useTimeDerivativeSolutionVector_)
147 x_template = (*sgEpetraContainer_->begin())->get_dxdt();
149 x_template = (*sgEpetraContainer_->begin())->get_x();
157 for(std::size_t worksetCellIndex=0;worksetCellIndex<localCellIds.size();++worksetCellIndex) {
158 std::size_t cellLocalId = localCellIds[worksetCellIndex];
160 globalIndexer_->getElementGIDs(cellLocalId,GIDs,blockId);
163 LIDs.resize(GIDs.size());
164 for(std::size_t i=0;i<GIDs.size();i++)
165 LIDs[i] = x_template->Map().LID(GIDs[i]);
168 for (std::size_t fieldIndex=0; fieldIndex<gatherFields_.size();fieldIndex++) {
169 int fieldNum = fieldIds_[fieldIndex];
170 const std::vector<int> & elmtOffset = globalIndexer_->getGIDFieldOffsets(blockId,fieldNum);
177 PHX::MDField<ScalarT,Cell,NODE>
field = (gatherFields_[fieldIndex]);
179 field(worksetCellIndex,
basis).reset(expansion);
185 for(itr=sgEpetraContainer_->begin();itr!=sgEpetraContainer_->end();++itr,++stochIndex) {
188 if (useTimeDerivativeSolutionVector_)
189 x = (*itr)->get_dxdt();
193 field(worksetCellIndex,
basis).fastAccessCoeff(stochIndex) = (*x)[lid];
204 template<
typename TRAITS,
typename LO,
typename GO>
209 : globalIndexer_(indexer)
210 , useTimeDerivativeSolutionVector_(false)
211 , globalDataKey_(
"Solution Gather Container")
213 const std::vector<std::string>& names =
221 gatherFields_.resize(names.size());
222 for (std::size_t fd = 0; fd < names.size(); ++fd) {
223 PHX::MDField<ScalarT,Cell,NODE> f(names[fd],dl);
224 gatherFields_[fd] = f;
225 this->addEvaluatedField(gatherFields_[fd]);
228 if (p.
isType<
bool>(
"Use Time Derivative Solution Vector"))
229 useTimeDerivativeSolutionVector_ = p.
get<
bool>(
"Use Time Derivative Solution Vector");
231 if (p.
isType<std::string>(
"Global Data Key"))
232 globalDataKey_ = p.
get<std::string>(
"Global Data Key");
235 this->setName(
"Gather Solution");
239 template<
typename TRAITS,
typename LO,
typename GO>
247 fieldIds_.resize(gatherFields_.size());
249 for (std::size_t fd = 0; fd < gatherFields_.size(); ++fd) {
252 const std::string& fieldName = (*indexerNames_)[fd];
253 fieldIds_[fd] = globalIndexer_->getFieldNum(fieldName);
256 this->utils.setFieldData(gatherFields_[fd],fm);
259 indexerNames_ = Teuchos::null;
263 template<
typename TRAITS,
typename LO,
typename GO>
272 template<
typename TRAITS,
typename LO,
typename GO>
276 std::vector<GO> GIDs;
277 std::vector<int> LIDs;
280 std::string blockId = this->wda(workset).block_id;
281 const std::vector<std::size_t> & localCellIds = this->wda(workset).cell_local_ids;
286 double seed_value = 0.0;
287 if (useTimeDerivativeSolutionVector_) {
288 x_template = (*sgEpetraContainer_->begin())->get_dxdt();
289 seed_value = workset.alpha;
292 x_template = (*sgEpetraContainer_->begin())->get_x();
293 seed_value = workset.beta;
302 for(std::size_t worksetCellIndex=0;worksetCellIndex<localCellIds.size();++worksetCellIndex) {
303 std::size_t cellLocalId = localCellIds[worksetCellIndex];
305 globalIndexer_->getElementGIDs(cellLocalId,GIDs,blockId);
308 LIDs.resize(GIDs.size());
309 for(std::size_t i=0;i<GIDs.size();i++)
310 LIDs[i] = x_template->Map().LID(GIDs[i]);
313 for(std::size_t fieldIndex=0;
314 fieldIndex<gatherFields_.size();fieldIndex++) {
315 int fieldNum = fieldIds_[fieldIndex];
316 const std::vector<int> & elmtOffset = globalIndexer_->getGIDFieldOffsets(blockId,fieldNum);
323 PHX::MDField<ScalarT,Cell,NODE>
field = (gatherFields_[fieldIndex]);
329 field(worksetCellIndex,
basis).fastAccessDx(offset) = seed_value;
330 field(worksetCellIndex,
basis).val().reset(expansion);
331 field(worksetCellIndex,
basis).val().copyForWrite();
336 for(itr=sgEpetraContainer_->begin();itr!=sgEpetraContainer_->end();++itr,++stochIndex) {
339 if (useTimeDerivativeSolutionVector_)
340 x = (*itr)->get_dxdt();
344 field(worksetCellIndex,
basis).val().fastAccessCoeff(stochIndex) = (*x)[lid];
352 #endif // end HAVE_STOKHOS
Gathers solution values from the Newton solution vector into the nodal fields of the field manager...
T & get(const std::string &name, T def_value)
PHX::MDField< ScalarT, Cell, IP > field
Teuchos::RCP< const panzer::PureBasis > basis
Interpolates basis DOF values to IP DOF values.
bool isType(const std::string &name) const
panzer::Traits::SGJacobian::ScalarT ScalarT
CoeffVector::iterator iterator
#define TEUCHOS_ASSERT(assertion_test)