46 #ifndef MUELU_UNCOUPLEDAGGREGATIONFACTORY_DEF_HPP_
47 #define MUELU_UNCOUPLEDAGGREGATIONFACTORY_DEF_HPP_
58 #include "MueLu_InterfaceAggregationAlgorithm.hpp"
59 #include "MueLu_OnePtAggregationAlgorithm.hpp"
60 #include "MueLu_PreserveDirichletAggregationAlgorithm.hpp"
61 #include "MueLu_IsolatedNodeAggregationAlgorithm.hpp"
63 #include "MueLu_AggregationPhase1Algorithm.hpp"
64 #include "MueLu_AggregationPhase2aAlgorithm.hpp"
65 #include "MueLu_AggregationPhase2bAlgorithm.hpp"
66 #include "MueLu_AggregationPhase3Algorithm.hpp"
70 #include "MueLu_Aggregates.hpp"
73 #include "MueLu_AmalgamationInfo.hpp"
74 #include "MueLu_Utilities.hpp"
78 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
80 : bDefinitionPhase_(true)
83 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
91 #define SET_VALID_ENTRY(name) validParamList->setEntry(name, MasterList::getEntry(name))
97 rcp(
new validatorType(Teuchos::tuple<std::string>(
"natural",
"graph",
"random"),
"aggregation: ordering")));
105 SET_VALID_ENTRY(
"aggregation: error on nodes with no on-rank neighbors");
106 #undef SET_VALID_ENTRY
110 validParamList->
set<
RCP<const FactoryBase> >(
"DofsPerNode",
null,
"Generating factory for variable \'DofsPerNode\', usually the same as for \'Graph\'");
113 validParamList->
set< std::string > (
"OnePt aggregate map name",
"",
"Name of input map for single node aggregates. (default='')");
114 validParamList->
set< std::string > (
"OnePt aggregate map factory",
"",
"Generating factory of (DOF) map for single node aggregates.");
119 validParamList->
set< std::string > (
"Interface aggregate map name",
"",
"Name of input map for interface aggregates. (default='')");
120 validParamList->
set< std::string > (
"Interface aggregate map factory",
"",
"Generating factory of (DOF) map for interface aggregates.");
121 validParamList->
set<
RCP<const FactoryBase> > (
"nodeOnInterface", Teuchos::null,
"Array specifying whether or not a node is on the interface (1 or 0).");
123 return validParamList;
126 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
128 Input(currentLevel,
"Graph");
129 Input(currentLevel,
"DofsPerNode");
134 std::string mapOnePtName = pL.
get<std::string>(
"OnePt aggregate map name");
135 if (mapOnePtName.length() > 0) {
136 std::string mapOnePtFactName = pL.
get<std::string>(
"OnePt aggregate map factory");
137 if (mapOnePtFactName ==
"" || mapOnePtFactName ==
"NoFactory") {
146 if (pL.
get<
bool>(
"aggregation: use interface aggregation") ==
true){
153 "nodeOnInterface was not provided by the user on level0!");
156 Input(currentLevel,
"nodeOnInterface");
161 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
166 bDefinitionPhase_ =
false;
168 if (pL.
get<
int>(
"aggregation: max agg size") == -1)
169 pL.
set(
"aggregation: max agg size", INT_MAX);
190 std::string mapOnePtName = pL.
get<std::string>(
"OnePt aggregate map name");
192 if (mapOnePtName.length()) {
193 std::string mapOnePtFactName = pL.
get<std::string>(
"OnePt aggregate map factory");
194 if (mapOnePtFactName ==
"" || mapOnePtFactName ==
"NoFactory") {
198 OnePtMap = currentLevel.
Get<
RCP<Map> >(mapOnePtName, mapOnePtFact.
get());
203 std::string mapInterfaceName = pL.
get<std::string>(
"Interface aggregate map name");
204 RCP<Map> InterfaceMap = Teuchos::null;
210 aggregates->setObjectLabel(
"UC");
215 std::vector<unsigned> aggStat(numRows,
READY);
218 if (pL.
get<
bool>(
"aggregation: use interface aggregation") ==
true){
220 for (
LO i = 0; i < numRows; i++) {
221 if (nodeOnInterface[i])
227 if (dirichletBoundaryMap != Teuchos::null)
228 for (
LO i = 0; i < numRows; i++)
229 if (dirichletBoundaryMap[i] ==
true)
232 LO nDofsPerNode = Get<LO>(currentLevel,
"DofsPerNode");
234 if (OnePtMap != Teuchos::null) {
235 for (
LO i = 0; i < numRows; i++) {
237 GO grid = (graph->
GetDomainMap()->getGlobalElement(i)-indexBase) * nDofsPerNode + indexBase;
239 for (
LO kr = 0; kr < nDofsPerNode; kr++)
240 if (OnePtMap->isNodeGlobalElement(grid + kr))
248 GO numGlobalRows = 0;
252 LO numNonAggregatedNodes = numRows;
253 GO numGlobalAggregatedPrev = 0, numGlobalAggsPrev = 0;
254 for (
size_t a = 0; a < algos_.size(); a++) {
255 std::string phase = algos_[a]->description();
258 int oldRank = algos_[a]->SetProcRankVerbose(this->GetProcRankVerbose());
259 algos_[a]->BuildAggregates(pL, *graph, *aggregates, aggStat, numNonAggregatedNodes);
260 algos_[a]->SetProcRankVerbose(oldRank);
263 GO numLocalAggregated = numRows - numNonAggregatedNodes, numGlobalAggregated = 0;
264 GO numLocalAggs = aggregates->GetNumAggregates(), numGlobalAggs = 0;
265 MueLu_sumAll(comm, numLocalAggregated, numGlobalAggregated);
268 double aggPercent = 100*as<double>(numGlobalAggregated)/as<double>(numGlobalRows);
269 if (aggPercent > 99.99 && aggPercent < 100.00) {
276 GetOStream(
Statistics1) <<
" aggregated : " << (numGlobalAggregated - numGlobalAggregatedPrev) <<
" (phase), " << std::fixed
277 << std::setprecision(2) << numGlobalAggregated <<
"/" << numGlobalRows <<
" [" << aggPercent <<
"%] (total)\n"
278 <<
" remaining : " << numGlobalRows - numGlobalAggregated <<
"\n"
279 <<
" aggregates : " << numGlobalAggs-numGlobalAggsPrev <<
" (phase), " << numGlobalAggs <<
" (total)" << std::endl;
280 numGlobalAggregatedPrev = numGlobalAggregated;
281 numGlobalAggsPrev = numGlobalAggs;
287 aggregates->AggregatesCrossProcessors(
false);
288 aggregates->ComputeAggregateSizes(
true);
290 Set(currentLevel,
"Aggregates", aggregates);
292 GetOStream(
Statistics1) << aggregates->description() << std::endl;