46 #ifndef PACKAGES_MUELU_SRC_REBALANCING_MUELU_CLONEREPARTITIONINTERFACE_DEF_HPP_ 47 #define PACKAGES_MUELU_SRC_REBALANCING_MUELU_CLONEREPARTITIONINTERFACE_DEF_HPP_ 54 #include "MueLu_Utilities.hpp" 59 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
61 Teuchos::RCP<ParameterList> validParamList = rcp(
new ParameterList());
62 validParamList->set< Teuchos::RCP<const FactoryBase> >(
"A", Teuchos::null,
"Factory of the matrix A");
63 validParamList->set< Teuchos::RCP<const FactoryBase> >(
"number of partitions", Teuchos::null,
"Instance of RepartitionHeuristicFactory.");
64 validParamList->set< Teuchos::RCP<const FactoryBase> >(
"Partition", Teuchos::null,
"Factory generating the Partition array (e.g. ZoltanInterface)");
66 return validParamList;
70 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
72 Input(currentLevel,
"A");
73 Input(currentLevel,
"Partition");
76 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
81 Teuchos::RCP<Matrix> A = Get< Teuchos::RCP<Matrix> > (currentLevel,
"A");
82 Teuchos::RCP<const Teuchos::Comm< int > > comm = A->getRowMap()->getComm();
86 if (currentLevel.IsAvailable(
"number of partitions")) {
87 numPartitions = currentLevel.Get<
GO>(
"number of partitions");
88 GetOStream(
Warnings0) <<
"Using user-provided \"number of partitions\", the performance is unknown" << std::endl;
95 RCP<GOVector> decomposition = Teuchos::null;
98 decomposition = Get<RCP<GOVector> >(currentLevel,
"Partition");
99 ArrayRCP<const GO> decompEntries = decomposition->getData(0);
101 if (decomposition.is_null()) {
102 GetOStream(
Warnings0) <<
"No repartitioning necessary: partitions were left unchanged by the repartitioner" << std::endl;
103 Set<RCP<const Import> >(currentLevel,
"Importer", Teuchos::null);
109 ArrayRCP<GO> retDecompEntries = ret->getDataNonConst(0);
112 LocalOrdinal blkSize = 1;
115 if(A->IsView(
"stridedMaps") &&
116 Teuchos::rcp_dynamic_cast<
const StridedMap>(A->getRowMap(
"stridedMaps")) != Teuchos::null) {
118 RCP<const StridedMap> strMap = Teuchos::rcp_dynamic_cast<
const StridedMap>(A->getRowMap());
119 TEUCHOS_TEST_FOR_EXCEPTION(strMap == Teuchos::null,
Exceptions::BadCast,
"MueLu::CloneRepartitionInterface::Build: cast to strided row map failed.");
120 LocalOrdinal stridedBlock = strMap->getStridedBlockId();
121 if (stridedBlock == -1)
122 blkSize = strMap->getFixedBlockSize();
124 std::vector<size_t> strInfo = strMap->getStridingData();
125 blkSize = strInfo[stridedBlock];
127 oldView = A->SwitchToView(oldView);
128 GetOStream(
Statistics1) <<
"CloneRepartitionInterface::Build():" <<
" found blockdim=" << blkSize <<
" from strided maps."<< std::endl;
130 GetOStream(
Statistics1) <<
"CloneRepartitionInterface::Build(): no striding information available. Use blockdim=" << blkSize <<
" (DofsPerNode)." << std::endl;
131 blkSize = A->GetFixedBlockSize();
135 size_t inLocalLength = decomposition->getLocalLength();
136 size_t outLocalLength = A->getRowMap()->getNodeNumElements();
139 size_t numLocalNodes = outLocalLength / blkSize;
140 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 <<
")");
142 if (numLocalNodes > 0) {
143 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 <<
")");
144 LocalOrdinal inBlkSize = Teuchos::as<LocalOrdinal>(inLocalLength / numLocalNodes);
147 for(
LO i = 0; i<Teuchos::as<LO>(numLocalNodes); i++) {
148 for(
LO j = 0; j < blkSize; j++) {
149 retDecompEntries[i*blkSize + j] = Teuchos::as<GO>(decompEntries[i*inBlkSize]);
153 Set(currentLevel,
"Partition", ret);
Important warning messages (one line)
Exception indicating invalid cast attempted.
Timer to be used in factories. Similar to Monitor but with additional timers.
Namespace for MueLu classes and methods.
Print statistics that do not involve significant additional computation.
Class that holds all level-specific information.
void print(std::ostream &out, const VerbLevel verbLevel=Default) const
Printing method.
static RCP< Vector > Build(const Teuchos::RCP< const Map > &map, bool zeroOut=true)
Exception throws to report errors in the internal logical of the program.
void Build(Level &level) const
Build an object with this factory.
RCP< const ParameterList > GetValidParameterList() const
Return a const parameter list of valid parameters that setParameterList() will accept.
void DeclareInput(Level &level) const
Specifies the data that this class needs, and the factories that generate that data.