46 #ifndef MUELU_REBALANCEACFACTORY_DEF_HPP
47 #define MUELU_REBALANCEACFACTORY_DEF_HPP
51 #include <Xpetra_CrsMatrixWrap.hpp>
58 #include "MueLu_PerfUtils.hpp"
59 #include "MueLu_RAPFactory.hpp"
63 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
67 #define SET_VALID_ENTRY(name) validParamList->setEntry(name, MasterList::getEntry(name))
70 #undef SET_VALID_ENTRY
76 return validParamList;
79 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
81 Input(coarseLevel,
"A");
83 if (pL.
isParameter(
"repartition: use subcommunicators in place") && pL.
get<
bool>(
"repartition: use subcommunicators in place") ==
true) {
84 Input(coarseLevel,
"InPlaceMap");
86 Input(coarseLevel,
"Importer");
89 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
94 RCP<Matrix> originalAc = Get<RCP<Matrix> >(coarseLevel,
"A");
98 bool inPlace = pL.
get<
bool>(
"repartition: use subcommunicators in place");
101 RCP<const Map> newMap = Get<RCP<const Map> >(coarseLevel,
"InPlaceMap");
103 originalAc->removeEmptyProcessesInPlace(newMap);
106 if (newMap.
is_null()) originalAc = Teuchos::null;
108 Set(coarseLevel,
"A", originalAc);
112 RCP<const Import> rebalanceImporter = Get<RCP<const Import> >(coarseLevel,
"Importer");
114 if (rebalanceImporter != Teuchos::null) {
121 if (pL.
get<
bool>(
"repartition: use subcommunicators") ==
true) {
122 GetOStream(
Runtime0) <<
"Replacing maps with a subcommunicator" << std::endl;
123 XpetraList.
set(
"Restrict Communicator",
true);
126 XpetraList.
set(
"Timer Label",
"MueLu::RebalanceAc-" +
Teuchos::toString(coarseLevel.GetLevelID()));
128 SubFactoryMonitor subM2(*
this,
"Rebalancing existing Ac: MatrixFactory::Build", coarseLevel);
129 rebalancedAc = MatrixFactory::Build(originalAc, *rebalanceImporter, *rebalanceImporter, targetMap, targetMap,
rcp(&XpetraList,
false));
133 rebalancedAc->SetFixedBlockSize(originalAc->GetFixedBlockSize());
134 std::ostringstream oss;
135 oss <<
"A_" << coarseLevel.GetLevelID();
136 rebalancedAc->setObjectLabel(oss.str());
138 Set(coarseLevel,
"A", rebalancedAc);
141 int oldRank = SetProcRankVerbose(rebalancedAc->getRowMap()->getComm()->getRank());
144 params->set(
"printLoadBalancingInfo",
true);
145 params->set(
"printCommInfo",
true);
148 SetProcRankVerbose(oldRank);
153 GetOStream(
Runtime1) <<
"No rebalancing" << std::endl;
154 Set(coarseLevel,
"A", originalAc);
157 if (rebalanceFacts_.begin() != rebalanceFacts_.end()) {
161 for (std::vector<
RCP<const FactoryBase> >::const_iterator it = rebalanceFacts_.begin(); it != rebalanceFacts_.end(); ++it) {
162 GetOStream(
Runtime0) <<
"RebalanceAc: call rebalance factory " << (*it).get() <<
": " << (*it)->description() << std::endl;
163 (*it)->CallBuild(coarseLevel);
168 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
174 rebalanceFacts_.push_back(factory);
179 #endif // MUELU_REBALANCEACFACTORY_DEF_HPP
T & get(const std::string &name, T def_value)
ParameterList & set(std::string const &name, T const &value, std::string const &docString="", RCP< const ParameterEntryValidator > const &validator=null)
Timer to be used in factories. Similar to Monitor but with additional timers.
One-liner description of what is happening.
RCP< const ParameterList > GetValidParameterList() const
Return a const parameter list of valid parameters that setParameterList() will accept.
Print even more statistics.
bool isParameter(const std::string &name) const
void AddRebalanceFactory(const RCP< const FactoryBase > &factory)
Add rebalancing factory in the end of list of rebalancing factories in RebalanceAcFactory.
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)
Class that holds all level-specific information.
#define SET_VALID_ENTRY(name)
Timer to be used in factories. Similar to SubMonitor but adds a timer level by level.
static std::string PrintMatrixInfo(const Matrix &A, const std::string &msgTag, RCP< const Teuchos::ParameterList > params=Teuchos::null)
void Build(Level &fineLevel, Level &coarseLevel) const
Build an object with this factory.
void DeclareInput(Level &fineLevel, Level &coarseLevel) const
Input.
Description of what is happening (more verbose)
std::string toString(const T &t)