diff --git a/packages/muelu/src/Graph/UncoupledAggregation/MueLu_AggregationPhase2aAlgorithm_def.hpp b/packages/muelu/src/Graph/UncoupledAggregation/MueLu_AggregationPhase2aAlgorithm_def.hpp index 2a48e0c194bf..ee98c9b0182b 100644 --- a/packages/muelu/src/Graph/UncoupledAggregation/MueLu_AggregationPhase2aAlgorithm_def.hpp +++ b/packages/muelu/src/Graph/UncoupledAggregation/MueLu_AggregationPhase2aAlgorithm_def.hpp @@ -106,7 +106,7 @@ namespace MueLu { // to count all aggregated neighbour nodes for the aggregation criteria // NOTE: We check here for the maximum aggregation size. If we would do it below // with all the other check too big aggregates would not be accepted at all. - if (aggSize < as(maxNodesPerAggregate)) + if (aggSize < as(maxNodesPerAggregate-1)) aggList[aggSize++] = neigh; } @@ -122,13 +122,17 @@ namespace MueLu { aggregates.SetIsRoot(rootCandidate); aggIndex = numLocalAggregates++; + // Add the root. + aggStat [rootCandidate] = AGGREGATED; + vertex2AggId[rootCandidate] = aggIndex; + procWinner [rootCandidate] = myRank; for (size_t k = 0; k < aggSize; k++) { aggStat [aggList[k]] = AGGREGATED; vertex2AggId[aggList[k]] = aggIndex; procWinner [aggList[k]] = myRank; } - numNonAggregatedNodes -= aggSize; + numNonAggregatedNodes -= aggSize+1; } } diff --git a/packages/muelu/src/Graph/UncoupledAggregation/MueLu_AggregationPhase2aAlgorithm_kokkos_def.hpp b/packages/muelu/src/Graph/UncoupledAggregation/MueLu_AggregationPhase2aAlgorithm_kokkos_def.hpp index d9484c7bb1f1..437c32485cfb 100644 --- a/packages/muelu/src/Graph/UncoupledAggregation/MueLu_AggregationPhase2aAlgorithm_kokkos_def.hpp +++ b/packages/muelu/src/Graph/UncoupledAggregation/MueLu_AggregationPhase2aAlgorithm_kokkos_def.hpp @@ -133,20 +133,13 @@ namespace MueLu { // Loop over neighbors to count how many nodes could join // the new aggregate - // Note on 2019-11-22, LBV: - // The rootCandidate is not taken into account and in fact - // not aggregatesd later on. To change that we want to - // modify: - // if(aggSize < maxNodesPerAggregate) - // to: - // if(aggSize < maxNodesPerAggregate - 1) LO numNeighbors = 0; for(int j = 0; j < neighbors.length; ++j) { LO neigh = neighbors(j); if(neigh != rootCandidate) { if(graph.isLocalNeighborVertex(neigh) && (aggStat(neigh) == READY) && - (aggSize < maxNodesPerAggregate)) { + (aggSize < maxNodesPerAggregate-1)) { ++aggSize; } ++numNeighbors; @@ -155,8 +148,6 @@ namespace MueLu { // If a sufficient number of nodes can join the new aggregate // then we actually create the aggregate. - // Note on 2019-11-22, LBV: - // Same changes as described in the note above could be applied if(aggSize > minNodesPerAggregate && aggSize > factor*numNeighbors) { @@ -165,6 +156,14 @@ namespace MueLu { atomic_fetch_add(&numLocalAggregates(), 1); LO numAggregated = 0; + + // Add the root. + aggStat(rootCandidate) = AGGREGATED; + vertex2AggId(rootCandidate, 0) = aggIndex; + procWinner(rootCandidate, 0) = myRank; + ++numAggregated; + --lNumNonAggregatedNodes; + for(int neighIdx = 0; neighIdx < neighbors.length; ++neighIdx) { LO neigh = neighbors(neighIdx); if(neigh != rootCandidate) {