68 LO& numNonAggregatedNodes)
const {
69 Monitor m(*
this,
"BuildAggregates");
71 std::string orderingStr = params.get<std::string>(
"aggregation: ordering");
72 int maxNeighAlreadySelected = params.get<
int> (
"aggregation: max selected neighbors");
73 int minNodesPerAggregate = params.get<
int> (
"aggregation: min agg size");
74 int maxNodesPerAggregate = params.get<
int> (
"aggregation: max agg size");
77 "MueLu::UncoupledAggregationAlgorithm::BuildAggregates: minNodesPerAggregate must be smaller or equal to MaxNodePerAggregate!");
85 if (orderingStr ==
"natural") ordering = O_NATURAL;
86 if (orderingStr ==
"random" ) ordering = O_RANDOM;
87 if (orderingStr ==
"graph" ) ordering = O_GRAPH;
90 const int myRank = graph.
GetComm()->getRank();
92 ArrayRCP<LO> vertex2AggId = aggregates.
GetVertex2AggId()->getDataNonConst(0);
93 ArrayRCP<LO> procWinner = aggregates.
GetProcWinner() ->getDataNonConst(0);
97 ArrayRCP<LO> randomVector;
98 if (ordering == O_RANDOM) {
99 randomVector = arcp<LO>(numRows);
100 for (LO i = 0; i < numRows; i++)
102 RandomReorder(randomVector);
109 std::queue<LO> graphOrderQueue;
112 for (LO i = 0; i < numRows; i++) {
114 LO rootCandidate = 0;
115 if (ordering == O_NATURAL) rootCandidate = i;
116 else if (ordering == O_RANDOM) rootCandidate = randomVector[i];
117 else if (ordering == O_GRAPH) {
119 if (graphOrderQueue.size() == 0) {
121 for (LO jnode = 0; jnode < numRows; jnode++)
122 if (aggStat[jnode] ==
READY) {
123 graphOrderQueue.push(jnode);
127 if (graphOrderQueue.size() == 0) {
131 rootCandidate = graphOrderQueue.front();
132 graphOrderQueue.pop();
135 if (aggStat[rootCandidate] !=
READY)
140 aggList[aggSize++] = rootCandidate;
148 if ((ordering == O_NATURAL || ordering == O_RANDOM) &&
149 neighOfINode.size() < minNodesPerAggregate) {
153 LO numAggregatedNeighbours = 0;
155 for (
int j = 0; j < neighOfINode.size(); j++) {
156 LO neigh = neighOfINode[j];
160 if (aggStat[neigh] ==
READY || aggStat[neigh] ==
NOTSEL) {
169 if (aggSize < as<size_t>(maxNodesPerAggregate))
170 aggList[aggSize++] = neigh;
173 numAggregatedNeighbours++;
179 if ((numAggregatedNeighbours <= maxNeighAlreadySelected) &&
180 (aggSize >= as<size_t>(minNodesPerAggregate))) {
184 aggIndex = numLocalAggregates++;
186 for (
size_t k = 0; k < aggSize; k++) {
188 vertex2AggId[aggList[k]] = aggIndex;
189 procWinner [aggList[k]] = myRank;
192 numNonAggregatedNodes -= aggSize;
196 aggStat[rootCandidate] =
NOTSEL;
203 if (ordering == O_GRAPH) {
208 for (
size_t k = 0; k < aggSize; k++) {
211 for (
int j = 0; j < neighOfJNode.size(); j++) {
212 LO neigh = neighOfJNode[j];
215 graphOrderQueue.push(neigh);
223 for (LO i = 0; i < numRows; i++)