46 #ifndef MUELU_AGGREGATIONPHASE2AALGORITHM_KOKKOS_DEF_HPP
47 #define MUELU_AGGREGATIONPHASE2AALGORITHM_KOKKOS_DEF_HPP
49 #ifdef HAVE_MUELU_KOKKOS_REFACTOR
51 #include <Teuchos_Comm.hpp>
52 #include <Teuchos_CommHelpers.hpp>
58 #include "MueLu_Aggregates_kokkos.hpp"
60 #include "MueLu_LWGraph_kokkos.hpp"
65 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
66 void AggregationPhase2aAlgorithm_kokkos<LocalOrdinal, GlobalOrdinal, Node>::BuildAggregates(
const ParameterList& params,
const LWGraph_kokkos& graph, Aggregates_kokkos& aggregates, std::vector<unsigned>& aggStat,
LO& numNonAggregatedNodes)
const {
67 Monitor m(*
this,
"BuildAggregates");
69 int minNodesPerAggregate = params.get<
int>(
"aggregation: min agg size");
70 int maxNodesPerAggregate = params.get<
int>(
"aggregation: max agg size");
72 const LO numRows = graph.GetNodeNumVertices();
73 const int myRank = graph.GetComm()->getRank();
75 ArrayRCP<LO> vertex2AggId = aggregates.GetVertex2AggId()->getDataNonConst(0);
76 ArrayRCP<LO> procWinner = aggregates.GetProcWinner() ->getDataNonConst(0);
78 LO numLocalAggregates = aggregates.GetNumAggregates();
80 LO numLocalNodes = procWinner.size();
81 LO numLocalAggregated = numLocalNodes - numNonAggregatedNodes;
83 const double aggFactor = 0.5;
84 double factor = as<double>(numLocalAggregated)/(numLocalNodes+1);
85 factor =
pow(factor, aggFactor);
89 std::vector<int> aggList(graph.getNodeMaxNumRowEntries());
91 for (
LO rootCandidate = 0; rootCandidate < numRows; rootCandidate++) {
92 if (aggStat[rootCandidate] !=
READY)
97 auto neighOfINode = graph.getNeighborVertices(rootCandidate);
100 for (
int j = 0; j < as<int>(neighOfINode.length); j++) {
101 LO neigh = neighOfINode(j);
103 if (neigh != rootCandidate) {
104 if (graph.isLocalNeighborVertex(neigh) && aggStat[neigh] ==
READY) {
110 if (aggSize < as<size_t>(maxNodesPerAggregate))
111 aggList[aggSize++] = neigh;
119 if (aggSize > as<size_t>(minNodesPerAggregate) &&
120 aggSize > factor*numNeighbors) {
123 aggregates.SetIsRoot(rootCandidate);
124 aggIndex = numLocalAggregates++;
126 for (
size_t k = 0; k < aggSize; k++) {
128 vertex2AggId[aggList[k]] = aggIndex;
129 procWinner [aggList[k]] = myRank;
132 numNonAggregatedNodes -= aggSize;
137 aggregates.SetNumAggregates(numLocalAggregates);
142 #endif // HAVE_MUELU_KOKKOS_REFACTOR
143 #endif // MUELU_AGGREGATIONPHASE2AALGORITHM_KOKKOS_DEF_HPP
KOKKOS_INLINE_FUNCTION Kokkos::complex< RealType > pow(const complex< RealType > &x, const RealType &e)