33 const Teuchos::RCP<const panzer::GlobalIndexer> & indexer,
34 const Teuchos::ParameterList& p)
35 : globalIndexer_(indexer)
36 , useTimeDerivativeSolutionVector_(false)
37 , globalDataKey_(
"Tangent Gather Container")
39 const std::vector<std::string>& names =
40 *(p.get< Teuchos::RCP< std::vector<std::string> > >(
"DOF Names"));
42 indexerNames_ = p.get< Teuchos::RCP< std::vector<std::string> > >(
"Indexer Names");
45 Teuchos::RCP<const panzer::PureBasis> basis;
46 if(p.isType< Teuchos::RCP<panzer::PureBasis> >(
"Basis"))
47 basis = p.get< Teuchos::RCP<panzer::PureBasis> >(
"Basis");
49 basis = p.get< Teuchos::RCP<const panzer::PureBasis> >(
"Basis");
52 for (std::size_t fd = 0; fd < names.size(); ++fd) {
54 PHX::MDField<ScalarT,Cell,NODE>(names[fd],basis->functional);
62 if (p.isType<
bool>(
"Use Time Derivative Solution Vector"))
65 if (p.isType<std::string>(
"Global Data Key"))
68 this->setName(
"Gather Tangent");
77 TEUCHOS_ASSERT(gatherFields_.size() == indexerNames_->size());
79 fieldIds_.resize(gatherFields_.size());
81 gatherFieldsVoV_.initialize(
"GatherSolution_Teptra<Tangent>",gatherFields_.size());
83 for (std::size_t fd = 0; fd < gatherFields_.size(); ++fd) {
84 const std::string& fieldName = (*indexerNames_)[fd];
85 fieldIds_[fd] = globalIndexer_->getFieldNum(fieldName);
86 gatherFieldsVoV_.addView(gatherFields_[fd].get_static_view(),fd);
89 gatherFieldsVoV_.syncHostToDevice();
91 indexerNames_ = Teuchos::null;
100 using Teuchos::rcp_dynamic_cast;
105 if (!d.gedc->containsDataObject(globalDataKey_))
108 RCP<GlobalEvaluationData> ged = d.gedc->getDataObject(globalDataKey_);
112 RCP<LOC> tpetraContainer = rcp_dynamic_cast<LOC>(ged);
113 RCP<LOCPair_GlobalEvaluationData> loc_pair =
114 rcp_dynamic_cast<LOCPair_GlobalEvaluationData>(ged);
116 if(loc_pair!=Teuchos::null)
117 tpetraContainer = rcp_dynamic_cast<LOC>(loc_pair->getGhostedLOC(),
true);
119 if(tpetraContainer!=Teuchos::null) {
120 if (useTimeDerivativeSolutionVector_)
121 x_vector_ = tpetraContainer->get_dxdt_mv();
123 x_vector_ = tpetraContainer->get_x_mv();
132 RCP<RO_GED> ro_ged = rcp_dynamic_cast<RO_GED>(ged,
true);
133 x_vector_ = ro_ged->getGhostedVector_Tpetra();
144 if (x_vector_ == Teuchos::null)
148 std::string blockId = this->wda(workset).block_id;
152 auto cellLocalIdsKokkos = this->wda(workset).getLocalCellIDs();
153 auto lids = globalIndexer_->getLIDs();
154 auto vov = Teuchos::rcp_dynamic_cast<const panzer::DOFManager>(globalIndexer_,
true)->getGIDFieldOffsetsKokkos(blockId,fieldIds_);
155 auto gidFieldOffsets = vov.getViewDevice();
156 auto gatherFieldsDevice = gatherFieldsVoV_.getViewDevice();
157 auto x_view = x->getLocalViewDevice(Tpetra::Access::ReadWrite);
158 Kokkos::MDRangePolicy<PHX::Device::execution_space,Kokkos::Rank<2>> policy({0,0},{cellLocalIdsKokkos.extent(0),gidFieldOffsets.extent(0)});
159 Kokkos::parallel_for(
"GatherSolutionTpetra<Tangent>",policy,KOKKOS_LAMBDA(
const int worksetCellIndex,
const int fieldIndex) {
160 for(std::size_t basis=0;basis<gidFieldOffsets(fieldIndex).extent(0);basis++) {
161 int offset = gidFieldOffsets(fieldIndex)(basis);
162 LO lid =
lids(cellLocalIdsKokkos(worksetCellIndex),offset);
163 auto& gf_ref = (gatherFieldsDevice[fieldIndex])(worksetCellIndex,basis);
164 gf_ref = x_view(lid,0);