46 #ifndef MUELU_AGGREGATIONPHASE3ALGORITHM_KOKKOS_DEF_HPP 47 #define MUELU_AGGREGATIONPHASE3ALGORITHM_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" 67 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
68 void AggregationPhase3Algorithm_kokkos<LocalOrdinal, GlobalOrdinal, Node>::BuildAggregates(
const ParameterList& params,
const LWGraph_kokkos& graph, Aggregates_kokkos& aggregates, std::vector<unsigned>& aggStat,
LO& numNonAggregatedNodes)
const {
69 Monitor m(*
this,
"BuildAggregates");
71 bool error_on_isolated =
false;
72 if(params.isParameter(
"aggregation: error on nodes with no on-rank neighbors"))
73 params.get<
bool>(
"aggregation: error on nodes with no on-rank neighbors");
75 const LO numRows = graph.GetNodeNumVertices();
76 const int myRank = graph.GetComm()->getRank();
78 ArrayRCP<LO> vertex2AggId = aggregates.GetVertex2AggId()->getDataNonConst(0);
79 ArrayRCP<LO> procWinner = aggregates.GetProcWinner() ->getDataNonConst(0);
81 LO numLocalAggregates = aggregates.GetNumAggregates();
83 for (
LO i = 0; i < numRows; i++) {
87 auto neighOfINode = graph.getNeighborVertices(i);
91 bool isNewAggregate =
false;
92 for (
int j = 0; j < as<int>(neighOfINode.length); j++) {
93 LO neigh = neighOfINode(j);
95 if (neigh != i && graph.isLocalNeighborVertex(neigh) && aggStat[neigh] ==
READY) {
96 isNewAggregate =
true;
99 vertex2AggId[neigh] = numLocalAggregates;
100 procWinner [neigh] = myRank;
102 numNonAggregatedNodes--;
106 if (isNewAggregate) {
108 aggregates.SetIsRoot(i);
109 vertex2AggId[i] = numLocalAggregates++;
117 for (; j < as<int>(neighOfINode.length); j++) {
118 LO neigh = neighOfINode(j);
121 if (graph.isLocalNeighborVertex(neigh) && aggStat[neigh] ==
AGGREGATED)
125 if (j < as<int>(neighOfINode.length)) {
127 vertex2AggId[i] = vertex2AggId[neighOfINode(j)];
128 }
else if (error_on_isolated) {
130 std::ostringstream oss;
131 oss<<
"MueLu::AggregationPhase3Algorithm::BuildAggregates: MueLu has detected a non-Dirichlet node that has no on-rank neighbors and is terminating (by user request). "<<std::endl;
132 oss<<
"If this error is being generated at level 0, this is due to an initial partitioning problem in your matrix."<<std::endl;
133 oss<<
"If this error is being generated at any other level, try turning on repartitioning, which may fix this problem."<<std::endl;
134 throw Exceptions::RuntimeError(oss.str());
137 this->GetOStream(
Warnings1) <<
"Found singleton: " << i << std::endl;
139 aggregates.SetIsRoot(i);
140 vertex2AggId[i] = numLocalAggregates++;
146 procWinner[i] = myRank;
147 numNonAggregatedNodes--;
152 aggregates.SetNumAggregates(numLocalAggregates);
157 #endif // HAVE_MUELU_KOKKOS_REFACTOR 158 #endif // MUELU_AGGREGATIONPHASE3ALGORITHM_KOKKOS_DEF_HPP
Namespace for MueLu classes and methods.