55typename Reindex_CrsMatrix<Scalar, LocalOrdinal, GlobalOrdinal, Node>::NewType
59 this->origObj_ = origMatrix;
61 assert(origMatrix->getRowMap()->getLocalNumElements() == newRowMap_->getLocalNumElements());
63 if ((origMatrix->getDomainMap()->getGlobalNumElements() == 0) &&
64 (origMatrix->getRowMap()->getGlobalNumElements() == 0)) {
66 this->newObj_ = Teuchos::rcp<cm_t>(
new cm_t(origMatrix->getRowMap(), origMatrix->getColMap(), 0));
72 v_t cols(origMatrix->getDomainMap());
74 size_t origDomainMap_localSize = origMatrix->getDomainMap()->getLocalNumElements();
75 map_t tmpColMap(origMatrix->getDomainMap()->getGlobalNumElements(), origDomainMap_localSize, 0, origMatrix->getDomainMap()->getComm());
76 Kokkos::deep_copy(Kokkos::subview(cols.getLocalViewDevice(Tpetra::Access::OverwriteAll), Kokkos::ALL(), 0),
77 tmpColMap.getMyGlobalIndicesDevice());
80 v_t newCols(origMatrix->getColMap());
83 Teuchos::RCP<const imp_t> importer = origMatrix->getCrsGraph()->getImporter();
84 if (importer.is_null()) {
87 newCols.doImport(cols, *importer,
INSERT,
false);
91 using kv_t = Kokkos::View<GlobalOrdinal*, typename Node::device_type>;
94 auto newColsView = newCols.getLocalViewDevice(Tpetra::Access::ReadOnly);
95 newColIndices = kv_t(
"newColIndices", newColsView.extent(0));
96 Kokkos::deep_copy(newColIndices, Kokkos::subview(newColsView, Kokkos::ALL(), 0));
99 this->newColMap_ = Teuchos::RCP<map_t>(
new map_t(origMatrix->getColMap()->getGlobalNumElements(),
101 origMatrix->getColMap()->getIndexBase(),
102 origMatrix->getColMap()->getComm()));
105 typename cm_t::local_matrix_device_type tmpLocalMatrix(
"", origMatrix->getLocalMatrixDevice());
106 Teuchos::RCP<cm_t> newMatrix = Teuchos::rcp<cm_t>(
new cm_t(tmpLocalMatrix, this->newRowMap_, this->newColMap_));
108 this->newObj_ = newMatrix;
111 return this->newObj_;