45 Teuchos::RCP<Matrix> A = Get<Teuchos::RCP<Matrix> >(currentLevel,
"A");
46 Teuchos::RCP<const Teuchos::Comm<int> > comm = A->getRowMap()->getComm();
49 if (currentLevel.
IsAvailable(
"number of partitions")) {
50 GetOStream(
Warnings0) <<
"Using user-provided \"number of partitions\", the performance is unknown" << std::endl;
56 RCP<GOVector> decomposition = Teuchos::null;
59 decomposition = Get<RCP<GOVector> >(currentLevel,
"Partition");
60 ArrayRCP<const GO> decompEntries = decomposition->getData(0);
62 if (decomposition.is_null()) {
63 GetOStream(
Warnings0) <<
"No repartitioning necessary: partitions were left unchanged by the repartitioner" << std::endl;
64 Set<RCP<const Import> >(currentLevel,
"Importer", Teuchos::null);
69 Teuchos::RCP<GOVector> ret = Xpetra::VectorFactory<GO, LO, GO, NO>::Build(A->getRowMap(),
false);
70 ArrayRCP<GO> retDecompEntries = ret->getDataNonConst(0);
76 if (A->IsView(
"stridedMaps") &&
77 Teuchos::rcp_dynamic_cast<const StridedMap>(A->getRowMap(
"stridedMaps")) != Teuchos::null) {
78 Xpetra::viewLabel_t oldView = A->SwitchToView(
"stridedMaps");
79 RCP<const StridedMap> strMap = Teuchos::rcp_dynamic_cast<const StridedMap>(A->getRowMap());
80 TEUCHOS_TEST_FOR_EXCEPTION(strMap == Teuchos::null,
Exceptions::BadCast,
"MueLu::CloneRepartitionInterface::Build: cast to strided row map failed.");
82 if (stridedBlock == -1)
83 blkSize = strMap->getFixedBlockSize();
85 std::vector<size_t> strInfo = strMap->getStridingData();
86 blkSize = strInfo[stridedBlock];
88 oldView = A->SwitchToView(oldView);
89 GetOStream(
Statistics1) <<
"CloneRepartitionInterface::Build():"
90 <<
" found blockdim=" << blkSize <<
" from strided maps." << std::endl;
92 GetOStream(
Statistics1) <<
"CloneRepartitionInterface::Build(): no striding information available. Use blockdim=" << blkSize <<
" (DofsPerNode)." << std::endl;
93 blkSize = A->GetFixedBlockSize();
97 size_t inLocalLength = decomposition->getLocalLength();
98 size_t outLocalLength = A->getRowMap()->getLocalNumElements();
101 size_t numLocalNodes = outLocalLength / blkSize;
102 TEUCHOS_TEST_FOR_EXCEPTION(Teuchos::as<size_t>(outLocalLength % blkSize) != 0,
MueLu::Exceptions::RuntimeError,
"CloneRepartitionInterface: inconsistent number of local DOFs (" << outLocalLength <<
") and degrees of freedoms (" << blkSize <<
")");
104 if (numLocalNodes > 0) {
105 TEUCHOS_TEST_FOR_EXCEPTION(Teuchos::as<size_t>(inLocalLength % numLocalNodes) != 0,
MueLu::Exceptions::RuntimeError,
"CloneRepartitionInterface: inconsistent number of local DOFs (" << inLocalLength <<
") and number of local nodes (" << numLocalNodes <<
")");
106 LocalOrdinal inBlkSize = Teuchos::as<LocalOrdinal>(inLocalLength / numLocalNodes);
109 for (LO i = 0; i < Teuchos::as<LO>(numLocalNodes); i++) {
110 for (LO j = 0; j < blkSize; j++) {
111 retDecompEntries[i * blkSize + j] = Teuchos::as<GO>(decompEntries[i * inBlkSize]);
115 Set(currentLevel,
"Partition", ret);