94 const Teuchos::ParameterList & pL = GetParameterList();
95 RCP<Matrix> originalAc = Get< RCP<Matrix> >(coarseLevel,
"A");
99 bool inPlace = pL.get<
bool>(
"repartition: use subcommunicators in place");
102 RCP<const Map> newMap = Get< RCP<const Map> >(coarseLevel,
"InPlaceMap");
104 originalAc->removeEmptyProcessesInPlace(newMap);
107 if(newMap.is_null()) originalAc = Teuchos::null;
109 Set(coarseLevel,
"A", originalAc);
114 RCP<const Import> rebalanceImporter = Get< RCP<const Import> >(coarseLevel,
"Importer");
116 if (rebalanceImporter != Teuchos::null) {
117 RCP<Matrix> rebalancedAc;
120 RCP<const Map> targetMap = rebalanceImporter->getTargetMap();
122 ParameterList XpetraList;
123 if (pL.get<
bool>(
"repartition: use subcommunicators") ==
true) {
124 GetOStream(
Runtime0) <<
"Replacing maps with a subcommunicator" << std::endl;
125 XpetraList.set(
"Restrict Communicator",
true);
128 XpetraList.set(
"Timer Label",
"MueLu::RebalanceAc-" + Teuchos::toString(coarseLevel.
GetLevelID()));
129 rebalancedAc = MatrixFactory::Build(originalAc, *rebalanceImporter, *rebalanceImporter, targetMap, targetMap, rcp(&XpetraList,
false));
131 if (!rebalancedAc.is_null()) {
132 rebalancedAc->SetFixedBlockSize(originalAc->GetFixedBlockSize());
133 std::ostringstream oss; oss <<
"A_" << coarseLevel.
GetLevelID(); rebalancedAc->setObjectLabel(oss.str());
135 Set(coarseLevel,
"A", rebalancedAc);
137 if (!rebalancedAc.is_null() && IsPrint(
Statistics2)) {
138 int oldRank = SetProcRankVerbose(rebalancedAc->getRowMap()->getComm()->getRank());
140 RCP<ParameterList> params = rcp(
new ParameterList());
141 params->set(
"printLoadBalancingInfo",
true);
142 params->set(
"printCommInfo",
true);
145 SetProcRankVerbose(oldRank);
150 GetOStream(
Runtime1) <<
"No rebalancing" << std::endl;
151 Set(coarseLevel,
"A", originalAc);
154 if (rebalanceFacts_.begin() != rebalanceFacts_.end()) {
158 for (std::vector<RCP<const FactoryBase> >::const_iterator it = rebalanceFacts_.begin(); it != rebalanceFacts_.end(); ++it) {
159 GetOStream(
Runtime0) <<
"RebalanceAc: call rebalance factory " << (*it).get() <<
": " << (*it)->description() << std::endl;
160 (*it)->CallBuild(coarseLevel);