63 const Teuchos::ParameterList &pL = GetParameterList();
64 RCP<Matrix> originalAc = Get<RCP<Matrix> >(coarseLevel,
"A");
68 bool inPlace = pL.get<
bool>(
"repartition: use subcommunicators in place");
71 RCP<const Map> newMap = Get<RCP<const Map> >(coarseLevel,
"InPlaceMap");
73 originalAc->removeEmptyProcessesInPlace(newMap);
76 if (newMap.is_null()) originalAc = Teuchos::null;
78 Set(coarseLevel,
"A", originalAc);
82 RCP<const Import> rebalanceImporter = Get<RCP<const Import> >(coarseLevel,
"Importer");
84 if (rebalanceImporter != Teuchos::null) {
85 RCP<Matrix> rebalancedAc;
88 RCP<const Map> targetMap = rebalanceImporter->getTargetMap();
90 ParameterList XpetraList;
91 if (pL.get<
bool>(
"repartition: use subcommunicators") ==
true) {
92 GetOStream(
Runtime0) <<
"Replacing maps with a subcommunicator" << std::endl;
93 XpetraList.set(
"Restrict Communicator",
true);
96 XpetraList.set(
"Timer Label",
"MueLu::RebalanceAc-" + Teuchos::toString(coarseLevel.
GetLevelID()));
98 SubFactoryMonitor subM2(*
this,
"Rebalancing existing Ac: MatrixFactory::Build", coarseLevel);
99 rebalancedAc = MatrixFactory::Build(originalAc, *rebalanceImporter, *rebalanceImporter, targetMap, targetMap, rcp(&XpetraList,
false));
102 if (!rebalancedAc.is_null()) {
103 rebalancedAc->SetFixedBlockSize(originalAc->GetFixedBlockSize());
104 std::ostringstream oss;
106 rebalancedAc->setObjectLabel(oss.str());
108 Set(coarseLevel,
"A", rebalancedAc);
110 if (!rebalancedAc.is_null() && IsPrint(
Statistics2)) {
111 int oldRank = SetProcRankVerbose(rebalancedAc->getRowMap()->getComm()->getRank());
113 RCP<ParameterList> params = rcp(
new ParameterList());
114 params->set(
"printLoadBalancingInfo",
true);
115 params->set(
"printCommInfo",
true);
118 SetProcRankVerbose(oldRank);
123 GetOStream(
Runtime1) <<
"No rebalancing" << std::endl;
124 Set(coarseLevel,
"A", originalAc);
127 if (rebalanceFacts_.begin() != rebalanceFacts_.end()) {
131 for (std::vector<RCP<const FactoryBase> >::const_iterator it = rebalanceFacts_.begin(); it != rebalanceFacts_.end(); ++it) {
132 GetOStream(
Runtime0) <<
"RebalanceAc: call rebalance factory " << (*it).get() <<
": " << (*it)->description() << std::endl;
133 (*it)->CallBuild(coarseLevel);