60 typedef Xpetra::BlockedMap<LocalOrdinal, GlobalOrdinal, Node> BlockMap;
62 RCP<Matrix> A = Get<RCP<Matrix> >(level,
"A");
63 RCP<AmalgamationInfo> amalInfo = Get<RCP<AmalgamationInfo> >(level,
"UnAmalgamationInfo");
64 GO numParts = Get<int>(level,
"number of partitions");
66 RCP<const Map> rowMap = A->getRowMap();
67 RCP<const Map> colMap = A->getColMap();
69 if (numParts == 1 || numParts == -1) {
71 RCP<Xpetra::Vector<GO, LO, GO, NO> > decomposition = Xpetra::VectorFactory<GO, LO, GO, NO>::Build(rowMap,
true);
72 Set(level,
"AmalgamatedPartition", decomposition);
89 GO indexBase = rowMap->getIndexBase();
92 LO nStridedOffset = 0;
97 if (A->IsView(
"stridedMaps") &&
98 Teuchos::rcp_dynamic_cast<const StridedMap>(A->getRowMap(
"stridedMaps")) != Teuchos::null) {
99 Xpetra::viewLabel_t oldView = A->SwitchToView(
"stridedMaps");
100 RCP<const StridedMap> strMap = Teuchos::rcp_dynamic_cast<const StridedMap>(A->getRowMap());
101 TEUCHOS_TEST_FOR_EXCEPTION(strMap == Teuchos::null,
Exceptions::BadCast,
"MueLu::IsorropiaInterface::Build: cast to strided row map failed.");
102 blockdim = strMap->getFixedBlockSize();
103 offset = strMap->getOffset();
104 blockid = strMap->getStridedBlockId();
106 std::vector<size_t> stridingInfo = strMap->getStridingData();
107 for (
size_t j = 0; j < Teuchos::as<size_t>(blockid); j++)
108 nStridedOffset += stridingInfo[j];
114 oldView = A->SwitchToView(oldView);
117 GetOStream(
Statistics0) <<
"IsorropiaInterface::Build(): no striding information available. Use blockdim=1 with offset=0" << std::endl;
121 RCP<const Map> nodeMap = amalInfo->getNodeRowMap();
122 RCP<const BlockedMap> bnodeMap = Teuchos::rcp_dynamic_cast<const BlockedMap>(nodeMap);
123 if (!bnodeMap.is_null()) nodeMap = bnodeMap->getMap();
125 GetOStream(
Statistics0) <<
"IsorropiaInterface:Build(): nodeMap " << nodeMap->getLocalNumElements() <<
"/" << nodeMap->getGlobalNumElements() <<
" elements" << std::endl;
128 RCP<CrsGraph> crsGraph = CrsGraphFactory::Build(nodeMap, A->getLocalMaxNumRowEntries() * blockdim);
131 for (LO row = 0; row < Teuchos::as<LO>(A->getRowMap()->getLocalNumElements()); row++) {
133 GO grid = rowMap->getGlobalElement(row);
138 GO nodeId = (grid - offset - indexBase) / blockdim + indexBase;
140 size_t nnz = A->getNumEntriesInLocalRow(row);
141 Teuchos::ArrayView<const LO> indices;
142 Teuchos::ArrayView<const SC> vals;
143 A->getLocalRowView(row, indices, vals);
145 RCP<std::vector<GO> > cnodeIds = Teuchos::rcp(
new std::vector<GO>);
147 for (LO col = 0; col < Teuchos::as<LO>(nnz); col++) {
148 GO gcid = colMap->getGlobalElement(indices[col]);
150 if (vals[col] != 0.0) {
153 GO cnodeId = (gcid - offset - indexBase) / blockdim + indexBase;
154 cnodeIds->push_back(cnodeId);
159 Teuchos::ArrayRCP<GO> arr_cnodeIds = Teuchos::arcp(cnodeIds);
161 if (arr_cnodeIds.size() > 0)
162 crsGraph->insertGlobalIndices(nodeId, arr_cnodeIds());
165 crsGraph->fillComplete(nodeMap, nodeMap);
171 RCP<Xpetra::Vector<GO, LO, GO, NO> > decomposition = Xpetra::VectorFactory<GO, LO, GO, NO>::Build(rowMap,
true);
172 Set(level,
"AmalgamatedPartition", decomposition);