74 const Teuchos::RCP<const panzer::GlobalIndexer> & ,
75 const Teuchos::ParameterList& p)
79 std::string scatterName = p.get<std::string>(
"Scatter Name");
81 Teuchos::rcp(
new PHX::Tag<ScalarT>(scatterName,Teuchos::rcp(
new PHX::MDALayout<Dummy>(0))));
84 const std::vector<std::string>& names =
85 *(p.get< Teuchos::RCP< std::vector<std::string> > >(
"Dependent Names"));
88 fieldMap_ = p.get< Teuchos::RCP< std::map<std::string,std::string> > >(
"Dependent Map");
91 scatterIC_ = p.isParameter(
"Scatter Initial Condition") ? p.get<
bool>(
"Scatter Initial Condition") :
false;
93 Teuchos::RCP<PHX::DataLayout> dl = (!
scatterIC_) ?
94 p.get< Teuchos::RCP<panzer::PureBasis> >(
"Basis")->functional :
95 p.get< Teuchos::RCP<const panzer::PureBasis> >(
"Basis")->functional;
103 for (std::size_t eq = 0; eq < names.size(); ++eq) {
104 scatterFields_[eq] = PHX::MDField<const ScalarT,Cell,NODE>(names[eq],dl);
110 checkApplyBC_ = p.isParameter(
"Check Apply BC") ? p.get<
bool>(
"Check Apply BC") :
false;
113 for (std::size_t eq = 0; eq < names.size(); ++eq) {
114 applyBC_[eq] = PHX::MDField<const bool,Cell,NODE>(std::string(
"APPLY_BC_")+
fieldMap_->find(names[eq])->second,dl);
115 this->addDependentField(
applyBC_[eq]);
122 if (p.isType<std::string>(
"Global Data Key"))
125 this->setName(scatterName+
" Scatter Residual");
178 std::string blockId = this->
wda(workset).block_id;
179 const std::vector<std::size_t> & localCellIds = this->
wda(workset).cell_local_ids;
181 Teuchos::RCP<const EpetraLinearObjContainer> epetraContainer =
epetraContainer_;
182 Teuchos::RCP<Epetra_Vector> r = (!
scatterIC_) ?
183 epetraContainer->get_f() :
184 epetraContainer->get_x();
192 auto LIDs_h = Kokkos::create_mirror_view(LIDs);
193 Kokkos::deep_copy(LIDs_h, LIDs);
197 for(std::size_t fieldIndex = 0; fieldIndex <
scatterFields_.size(); fieldIndex++) {
200 auto field_h = Kokkos::create_mirror_view(field);
201 Kokkos::deep_copy(field_h, field);
203 for(std::size_t worksetCellIndex=0;worksetCellIndex<localCellIds.size();++worksetCellIndex) {
204 std::size_t cellLocalId = localCellIds[worksetCellIndex];
208 const std::pair<std::vector<int>,std::vector<int> > & indicePair
210 const std::vector<int> & elmtOffset = indicePair.first;
211 const std::vector<int> & basisIdMap = indicePair.second;
214 for(std::size_t basis=0;basis<elmtOffset.size();basis++) {
215 int offset = elmtOffset[basis];
216 int lid = LIDs_h(cellLocalId, offset);
220 int basisId = basisIdMap[basis];
223 if (!
applyBC_[fieldIndex](worksetCellIndex,basisId))
226 (*r)[lid] = field_h(worksetCellIndex,basisId);
230 (*dirichletCounter_)[lid] = 1.0;
234 const std::vector<int> & elmtOffset =
globalIndexer_->getGIDFieldOffsets(blockId,fieldNum);
237 for(std::size_t basis=0;basis<elmtOffset.size();basis++) {
238 int offset = elmtOffset[basis];
239 int lid = LIDs_h(cellLocalId, offset);
243 (*r)[lid] = field_h(worksetCellIndex,basis);
247 (*dirichletCounter_)[lid] = 1.0;
262 const Teuchos::RCP<const panzer::GlobalIndexer> & ,
263 const Teuchos::ParameterList& p)
267 std::string scatterName = p.get<std::string>(
"Scatter Name");
269 Teuchos::rcp(
new PHX::Tag<ScalarT>(scatterName,Teuchos::rcp(
new PHX::MDALayout<Dummy>(0))));
272 const std::vector<std::string>& names =
273 *(p.get< Teuchos::RCP< std::vector<std::string> > >(
"Dependent Names"));
276 fieldMap_ = p.get< Teuchos::RCP< std::map<std::string,std::string> > >(
"Dependent Map");
279 scatterIC_ = p.isParameter(
"Scatter Initial Condition") ? p.get<
bool>(
"Scatter Initial Condition") :
false;
281 Teuchos::RCP<PHX::DataLayout> dl = (!
scatterIC_) ?
282 p.get< Teuchos::RCP<panzer::PureBasis> >(
"Basis")->functional :
283 p.get< Teuchos::RCP<const panzer::PureBasis> >(
"Basis")->functional;
291 for (std::size_t eq = 0; eq < names.size(); ++eq) {
292 scatterFields_[eq] = PHX::MDField<const ScalarT,Cell,NODE>(names[eq],dl);
298 checkApplyBC_ = p.isParameter(
"Check Apply BC") ? p.get<
bool>(
"Check Apply BC") :
false;
301 for (std::size_t eq = 0; eq < names.size(); ++eq) {
302 applyBC_[eq] = PHX::MDField<const bool,Cell,NODE>(std::string(
"APPLY_BC_")+
fieldMap_->find(names[eq])->second,dl);
303 this->addDependentField(
applyBC_[eq]);
310 if (p.isType<std::string>(
"Global Data Key"))
313 this->setName(scatterName+
" Scatter Tangent");
345 Teuchos::RCP<LinearObjContainer> loc = Teuchos::rcp_dynamic_cast<LOCPair_GlobalEvaluationData>(d.gedc->getDataObject(
globalDataKey_),
true)->getGhostedLOC();
346 epetraContainer_ = Teuchos::rcp_dynamic_cast<EpetraLinearObjContainer>(loc);
352 Teuchos::RCP<EpetraLinearObjContainer> epetraContainer
353 = Teuchos::rcp_dynamic_cast<EpetraLinearObjContainer>(d.gedc->getDataObject(
"Dirichlet Counter"),
true);
360 using Teuchos::rcp_dynamic_cast;
363 std::vector<std::string> activeParameters =
364 rcp_dynamic_cast<ParameterList_GlobalEvaluationData>(d.gedc->getDataObject(
"PARAMETER_NAMES"))->getActiveParameters();
369 for(std::size_t i=0;i<activeParameters.size();i++) {
370 RCP<Epetra_Vector> vec = rcp_dynamic_cast<EpetraLinearObjContainer>(d.gedc->getDataObject(activeParameters[i]),
true)->get_f();
381 std::string blockId = this->
wda(workset).block_id;
382 const std::vector<std::size_t> & localCellIds = this->
wda(workset).cell_local_ids;
384 Teuchos::RCP<const EpetraLinearObjContainer> epetraContainer =
epetraContainer_;
385 Teuchos::RCP<Epetra_Vector> r = (!
scatterIC_) ?
386 epetraContainer->get_f() :
387 epetraContainer->get_x();
395 auto LIDs_h = Kokkos::create_mirror_view(LIDs);
396 Kokkos::deep_copy(LIDs_h, LIDs);
397 for(std::size_t fieldIndex = 0; fieldIndex <
scatterFields_.size(); fieldIndex++) {
399 auto scatterField_h = Kokkos::create_mirror_view(
scatterFields_[fieldIndex].get_static_view());
400 Kokkos::deep_copy(scatterField_h,
scatterFields_[fieldIndex].get_static_view());
403 for(std::size_t worksetCellIndex=0;worksetCellIndex<localCellIds.size();++worksetCellIndex) {
404 std::size_t cellLocalId = localCellIds[worksetCellIndex];
408 const std::pair<std::vector<int>,std::vector<int> > & indicePair
410 const std::vector<int> & elmtOffset = indicePair.first;
411 const std::vector<int> & basisIdMap = indicePair.second;
414 for(std::size_t basis=0;basis<elmtOffset.size();basis++) {
415 int offset = elmtOffset[basis];
416 int lid = LIDs_h(cellLocalId, offset);
420 int basisId = basisIdMap[basis];
423 if (!
applyBC_[fieldIndex](worksetCellIndex,basisId))
426 ScalarT value = scatterField_h(worksetCellIndex,basisId);
434 for(
int d=0;d<value.size();d++) {
440 (*dirichletCounter_)[lid] = 1.0;
444 const std::vector<int> & elmtOffset =
globalIndexer_->getGIDFieldOffsets(blockId,fieldNum);
447 for(std::size_t basis=0;basis<elmtOffset.size();basis++) {
448 int offset = elmtOffset[basis];
449 int lid = LIDs_h(cellLocalId, offset);
453 ScalarT value = scatterField_h(worksetCellIndex,basis);
461 for(
int d=0;d<value.size();d++) {
467 (*dirichletCounter_)[lid] = 1.0;
481 const Teuchos::RCP<const panzer::GlobalIndexer> & cIndexer,
482 const Teuchos::ParameterList& p)
488 std::string scatterName = p.get<std::string>(
"Scatter Name");
490 Teuchos::rcp(
new PHX::Tag<ScalarT>(scatterName,Teuchos::rcp(
new PHX::MDALayout<Dummy>(0))));
493 const std::vector<std::string>& names =
494 *(p.get< Teuchos::RCP< std::vector<std::string> > >(
"Dependent Names"));
497 fieldMap_ = p.get< Teuchos::RCP< std::map<std::string,std::string> > >(
"Dependent Map");
499 Teuchos::RCP<PHX::DataLayout> dl =
500 p.get< Teuchos::RCP<panzer::PureBasis> >(
"Basis")->functional;
507 for (std::size_t eq = 0; eq < names.size(); ++eq) {
508 scatterFields_[eq] = PHX::MDField<const ScalarT,Cell,NODE>(names[eq],dl);
517 for (std::size_t eq = 0; eq < names.size(); ++eq) {
518 applyBC_[eq] = PHX::MDField<const bool,Cell,NODE>(std::string(
"APPLY_BC_")+
fieldMap_->find(names[eq])->second,dl);
519 this->addDependentField(
applyBC_[eq]);
526 if (p.isType<std::string>(
"Global Data Key"))
529 if (p.isType<
bool>(
"Preserve Diagonal"))
532 this->setName(scatterName+
" Scatter Residual (Jacobian)");
565 Teuchos::RCP<LinearObjContainer> loc = Teuchos::rcp_dynamic_cast<LOCPair_GlobalEvaluationData>(d.gedc->getDataObject(
globalDataKey_),
true)->getGhostedLOC();
566 epetraContainer_ = Teuchos::rcp_dynamic_cast<EpetraLinearObjContainer>(loc,
true);
572 Teuchos::RCP<GlobalEvaluationData> dataContainer = d.gedc->getDataObject(
"Dirichlet Counter");
573 Teuchos::RCP<EpetraLinearObjContainer> epetraContainer = Teuchos::rcp_dynamic_cast<EpetraLinearObjContainer>(dataContainer,
true);
585 Kokkos::View<const int*, Kokkos::LayoutRight, PHX::Device> cLIDs, rLIDs;
588 const Teuchos::RCP<const panzer::GlobalIndexer>&
592 std::string blockId = this->
wda(workset).block_id;
593 const std::vector<std::size_t> & localCellIds = this->
wda(workset).cell_local_ids;
595 Teuchos::RCP<const EpetraLinearObjContainer> epetraContainer =
epetraContainer_;
596 TEUCHOS_ASSERT(epetraContainer!=Teuchos::null);
597 Teuchos::RCP<Epetra_Vector> r = epetraContainer->get_f();
598 Teuchos::RCP<Epetra_CrsMatrix> Jac = epetraContainer->get_A();
607 auto colLIDs = colGlobalIndexer->getLIDs();
608 auto LIDs_h = Kokkos::create_mirror_view(LIDs);
609 auto colLIDs_h = Kokkos::create_mirror_view(colLIDs);
610 Kokkos::deep_copy(LIDs_h, LIDs);
611 Kokkos::deep_copy(colLIDs_h, colLIDs);
613 std::vector<
typename decltype(
scatterFields_[0].get_static_view())::HostMirror> scatterFields_h;
615 scatterFields_h.push_back(Kokkos::create_mirror_view(
scatterFields_[i].get_static_view()));
616 Kokkos::deep_copy(scatterFields_h[i],
scatterFields_[i].get_static_view());
619 for(std::size_t worksetCellIndex=0;worksetCellIndex<localCellIds.size();++worksetCellIndex) {
620 std::size_t cellLocalId = localCellIds[worksetCellIndex];
622 gidCount = colGlobalIndexer->getElementBlockGIDCount(blockId);
625 for(std::size_t fieldIndex = 0; fieldIndex <
scatterFields_.size(); fieldIndex++) {
629 const std::pair<std::vector<int>,std::vector<int> > & indicePair
631 const std::vector<int> & elmtOffset = indicePair.first;
632 const std::vector<int> & basisIdMap = indicePair.second;
635 for(std::size_t basis=0;basis<elmtOffset.size();basis++) {
636 int offset = elmtOffset[basis];
637 int row = LIDs_h(cellLocalId, offset);
641 int basisId = basisIdMap[basis];
644 if (!
applyBC_[fieldIndex](worksetCellIndex,basisId))
650 int * rowIndices = 0;
651 double * rowValues = 0;
653 Jac->ExtractMyRowView(row,numEntries,rowValues,rowIndices);
655 for(
int i=0;i<numEntries;i++) {
657 if(row!=rowIndices[i])
666 const ScalarT scatterField = (scatterFields_h[fieldIndex])(worksetCellIndex,basisId);
669 (*r)[row] = scatterField.val();
672 (*dirichletCounter_)[row] = 1.0;
676 std::vector<double> jacRow(scatterField.size(),0.0);
679 int err = Jac->ReplaceMyValues(row, gidCount, scatterField.dx(),
680 &colLIDs_h(cellLocalId,0));
681 TEUCHOS_ASSERT(err==0);