30 const Teuchos::RCP<const panzer::GlobalIndexer> & cIndexer,
31 const Teuchos::ParameterList& p)
32 : globalIndexer_(indexer)
33 , colGlobalIndexer_(cIndexer)
34 , globalDataKey_(
"Residual Scatter Container")
35 , preserveDiagonal_(false)
37 std::string scatterName = p.get<std::string>(
"Scatter Name");
39 Teuchos::rcp(
new PHX::Tag<ScalarT>(scatterName,Teuchos::rcp(
new PHX::MDALayout<Dummy>(0))));
42 const std::vector<std::string>& names =
43 *(p.get< Teuchos::RCP< std::vector<std::string> > >(
"Dependent Names"));
46 fieldMap_ = p.get< Teuchos::RCP< std::map<std::string,std::string> > >(
"Dependent Map");
48 Teuchos::RCP<PHX::DataLayout> dl =
49 p.get< Teuchos::RCP<panzer::PureBasis> >(
"Basis")->functional;
51 side_subcell_dim_ = p.get<
int>(
"Side Subcell Dimension");
52 local_side_id_ = p.get<
int>(
"Local Side ID");
55 scatterFields_.resize(names.size());
56 for (std::size_t eq = 0; eq < names.size(); ++eq) {
57 scatterFields_[eq] = PHX::MDField<const ScalarT,Cell,NODE>(names[eq],dl);
60 this->addDependentField(scatterFields_[eq]);
63 checkApplyBC_ = p.get<
bool>(
"Check Apply BC");
65 applyBC_.resize(names.size());
66 for (std::size_t eq = 0; eq < names.size(); ++eq) {
67 applyBC_[eq] = PHX::MDField<const bool,Cell,NODE>(std::string(
"APPLY_BC_")+fieldMap_->find(names[eq])->second,dl);
68 this->addDependentField(applyBC_[eq]);
73 this->addEvaluatedField(*scatterHolder_);
75 if (p.isType<std::string>(
"Global Data Key"))
76 globalDataKey_ = p.get<std::string>(
"Global Data Key");
78 if (p.isType<
bool>(
"Preserve Diagonal"))
79 preserveDiagonal_ = p.get<
bool>(
"Preserve Diagonal");
81 this->setName(scatterName+
" Scatter Residual (Hessian)");
110 epetraContainer_ = Teuchos::rcp_dynamic_cast<EpetraLinearObjContainer>(d.gedc->getDataObject(globalDataKey_));
112 if(epetraContainer_==Teuchos::null) {
114 Teuchos::RCP<LinearObjContainer> loc = Teuchos::rcp_dynamic_cast<LOCPair_GlobalEvaluationData>(d.gedc->getDataObject(globalDataKey_),
true)->getGhostedLOC();
115 epetraContainer_ = Teuchos::rcp_dynamic_cast<EpetraLinearObjContainer>(loc,
true);
117 dirichletCounter_ = Teuchos::null;
121 Teuchos::RCP<GlobalEvaluationData> dataContainer = d.gedc->getDataObject(
"Dirichlet Counter");
122 Teuchos::RCP<EpetraLinearObjContainer> epetraContainer = Teuchos::rcp_dynamic_cast<EpetraLinearObjContainer>(dataContainer,
true);
124 dirichletCounter_ = epetraContainer->get_f();
125 TEUCHOS_ASSERT(!Teuchos::is_null(dirichletCounter_));
140 PHX::View<const int*, Kokkos::LayoutRight, PHX::Device> cLIDs, rLIDs;
141 std::vector<double> jacRow;
143 bool useColumnIndexer = colGlobalIndexer_!=Teuchos::null;
146 std::string blockId = this->wda(workset).block_id;
147 const std::vector<std::size_t> & localCellIds = this->wda(workset).cell_local_ids;
149 Teuchos::RCP<const EpetraLinearObjContainer> epetraContainer = epetraContainer_;
150 TEUCHOS_ASSERT(epetraContainer!=Teuchos::null);
151 Teuchos::RCP<Epetra_CrsMatrix> Jac = epetraContainer->get_A();
158 for(std::size_t worksetCellIndex=0;worksetCellIndex<localCellIds.size();++worksetCellIndex) {
159 std::size_t cellLocalId = localCellIds[worksetCellIndex];
161 rLIDs = globalIndexer_->getElementLIDs(cellLocalId);
163 cLIDs = colGlobalIndexer_->getElementLIDs(cellLocalId);
168 for(std::size_t fieldIndex = 0; fieldIndex < scatterFields_.size(); fieldIndex++) {
169 int fieldNum = fieldIds_[fieldIndex];
172 const std::pair<std::vector<int>,std::vector<int> > & indicePair
173 = globalIndexer_->getGIDFieldOffsets_closure(blockId,fieldNum, side_subcell_dim_, local_side_id_);
174 const std::vector<int> & elmtOffset = indicePair.first;
175 const std::vector<int> & basisIdMap = indicePair.second;
178 for(std::size_t basis=0;basis<elmtOffset.size();basis++) {
179 int offset = elmtOffset[basis];
180 int row = rLIDs[offset];
184 int basisId = basisIdMap[basis];
187 if (!applyBC_[fieldIndex](worksetCellIndex,basisId))
193 int * rowIndices = 0;
194 double * rowValues = 0;
196 Jac->ExtractMyRowView(row,numEntries,rowValues,rowIndices);
198 for(
int i=0;i<numEntries;i++) {
199 if(preserveDiagonal_) {
200 if(row!=rowIndices[i])
209 const ScalarT scatterField = (scatterFields_[fieldIndex])(worksetCellIndex,basisId);
211 if(dirichletCounter_!=Teuchos::null) {
213 (*dirichletCounter_)[row] = 1.0;
217 jacRow.resize(scatterField.size());
218 for(
int sensIndex=0;sensIndex<scatterField.size();++sensIndex)
219 jacRow[sensIndex] = scatterField.fastAccessDx(sensIndex).fastAccessDx(0);
221 if(!preserveDiagonal_) {
222 int err = Jac->ReplaceMyValues(row, cLIDs.size(),
224 TEUCHOS_ASSERT(err==0);