46 #ifndef MUELU_AGGREGATIONPHASE3ALGORITHM_DEF_HPP_
47 #define MUELU_AGGREGATIONPHASE3ALGORITHM_DEF_HPP_
49 #include <Teuchos_Comm.hpp>
50 #include <Teuchos_CommHelpers.hpp>
52 #include <Xpetra_Vector.hpp>
56 #include "MueLu_Aggregates.hpp"
65 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
67 Monitor m(*
this,
"BuildAggregates");
69 bool error_on_isolated =
false;
70 if(params.isParameter(
"aggregation: error on nodes with no on-rank neighbors"))
71 params.get<
bool>(
"aggregation: error on nodes with no on-rank neighbors");
74 const int myRank = graph.
GetComm()->getRank();
76 ArrayRCP<LO> vertex2AggId = aggregates.
GetVertex2AggId()->getDataNonConst(0);
77 ArrayRCP<LO> procWinner = aggregates.
GetProcWinner() ->getDataNonConst(0);
79 LO numLocalAggregates = aggregates.GetNumAggregates();
81 for (LO i = 0; i < numRows; i++) {
89 bool isNewAggregate =
false;
90 for (
int j = 0; j < neighOfINode.size(); j++) {
91 LO neigh = neighOfINode[j];
94 isNewAggregate =
true;
97 vertex2AggId[neigh] = numLocalAggregates;
98 procWinner [neigh] = myRank;
100 numNonAggregatedNodes--;
104 if (isNewAggregate) {
107 vertex2AggId[i] = numLocalAggregates++;
115 for (; j < neighOfINode.size(); j++) {
116 LO neigh = neighOfINode[j];
123 if (j < neighOfINode.size()) {
125 vertex2AggId[i] = vertex2AggId[neighOfINode[j]];
126 }
else if (error_on_isolated) {
128 std::ostringstream oss;
129 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;
130 oss<<
"If this error is being generated at level 0, this is due to an initial partitioning problem in your matrix."<<std::endl;
131 oss<<
"If this error is being generated at any other level, try turning on repartitioning, which may fix this problem."<<std::endl;
135 this->GetOStream(
Warnings1) <<
"Found singleton: " << i << std::endl;
138 vertex2AggId[i] = numLocalAggregates++;
144 procWinner[i] = myRank;
145 numNonAggregatedNodes--;