49 RCP<Matrix> A = Get<RCP<Matrix> >(level,
"A");
50 RCP<Xpetra::Vector<GO, LO, GO, NO> > amalgPartition = Get<RCP<Xpetra::Vector<GO, LO, GO, NO> > >(level,
"AmalgamatedPartition");
51 int numParts = Get<int>(level,
"number of partitions");
53 RCP<const Map> rowMap = A->getRowMap();
56 RCP<const Teuchos::Comm<int> > comm = A->getRowMap()->getComm();
59 if (numParts == 1 || numParts == -1) {
61 RCP<Xpetra::Vector<GO, LO, GO, NO> > decomposition = Xpetra::VectorFactory<GO, LO, GO, NO>::Build(rowMap,
true);
62 Set(level,
"Partition", decomposition);
72 ArrayRCP<GO> amalgPartitionData = amalgPartition->getDataNonConst(0);
73 RCP<const Map> nodeMap = amalgPartition->getMap();
78 LO nStridedOffset = 0;
79 LO stridedblocksize = blockdim;
83 if (A->IsView(
"stridedMaps") &&
84 Teuchos::rcp_dynamic_cast<const StridedMap>(A->getRowMap(
"stridedMaps")) != Teuchos::null) {
85 Xpetra::viewLabel_t oldView = A->SwitchToView(
"stridedMaps");
86 RCP<const StridedMap> strMap = Teuchos::rcp_dynamic_cast<const StridedMap>(A->getRowMap());
87 TEUCHOS_TEST_FOR_EXCEPTION(strMap == Teuchos::null,
Exceptions::BadCast,
"MueLu::RepartitionInterface::Build: cast to strided row map failed.");
88 blockdim = strMap->getFixedBlockSize();
89 blockid = strMap->getStridedBlockId();
91 std::vector<size_t> stridingInfo = strMap->getStridingData();
92 for (
size_t j = 0; j < Teuchos::as<size_t>(blockid); j++)
93 nStridedOffset += stridingInfo[j];
94 stridedblocksize = Teuchos::as<LocalOrdinal>(stridingInfo[blockid]);
97 stridedblocksize = blockdim;
99 oldView = A->SwitchToView(oldView);
102 GetOStream(
Statistics0, -1) <<
"RepartitionInterface::Build(): no striding information available. Use blockdim=1 with offset=0" << std::endl;
105 RCP<Xpetra::Vector<GO, LO, GO, NO> > decomposition = Xpetra::VectorFactory<GO, LO, GO, NO>::Build(rowMap,
false);
106 ArrayRCP<GO> decompEntries = decomposition->getDataNonConst(0);
108 TEUCHOS_TEST_FOR_EXCEPTION(Teuchos::as<int>(nodeMap->getLocalNumElements()) * stridedblocksize != Teuchos::as<int>(rowMap->getLocalNumElements()),
Exceptions::RuntimeError,
"Inconsistency between nodeMap and dofMap: we are supporting block maps only. No support for general strided maps, yet!");
115 for (
size_t i = 0; i < nodeMap->getLocalNumElements(); i++) {
127 for (LO j = 0; j < stridedblocksize ; j++) {
133 decompEntries[i * stridedblocksize + j] = amalgPartitionData[i];
138 Set(level,
"Partition", decomposition);