67 Monitor m(*
this,
"BuildAggregates");
69 bool makeNonAdjAggs =
false;
70 bool error_on_isolated =
false;
71 if(params.isParameter(
"aggregation: error on nodes with no on-rank neighbors"))
72 error_on_isolated = params.get<
bool>(
"aggregation: error on nodes with no on-rank neighbors");
73 if(params.isParameter(
"aggregation: phase3 avoid singletons"))
74 makeNonAdjAggs = params.get<
bool>(
"aggregation: phase3 avoid singletons");
76 size_t numSingletons=0;
79 const int myRank = graph.
GetComm()->getRank();
81 ArrayRCP<LO> vertex2AggId = aggregates.
GetVertex2AggId()->getDataNonConst(0);
82 ArrayRCP<LO> procWinner = aggregates.
GetProcWinner() ->getDataNonConst(0);
86 for (LO i = 0; i < numRows; i++) {
94 bool isNewAggregate =
false;
95 bool failedToAggregate =
true;
96 for (
int j = 0; j < neighOfINode.size(); j++) {
97 LO neigh = neighOfINode[j];
100 isNewAggregate =
true;
103 vertex2AggId[neigh] = numLocalAggregates;
104 procWinner [neigh] = myRank;
106 numNonAggregatedNodes--;
110 if (isNewAggregate) {
113 procWinner [i] = myRank;
114 numNonAggregatedNodes--;
116 vertex2AggId[i] = numLocalAggregates++;
118 failedToAggregate =
false;
125 for (; j < neighOfINode.size(); j++) {
126 LO neigh = neighOfINode[j];
133 if (j < neighOfINode.size()) {
135 vertex2AggId[i] = vertex2AggId[neighOfINode[j]];
136 numNonAggregatedNodes--;
137 failedToAggregate =
false;
141 if (failedToAggregate && makeNonAdjAggs) {
151 for (LO ii = 0; ii < numRows; ii++) {
152 if ( (ii != i) && (aggStat[ii] !=
IGNORED) ) {
153 failedToAggregate =
false;
155 procWinner[i]= myRank;
158 vertex2AggId[i] = vertex2AggId[ii];
160 vertex2AggId[i] = numLocalAggregates;
161 vertex2AggId[ii] = numLocalAggregates;
163 procWinner [ii] = myRank;
164 numNonAggregatedNodes--;
166 numLocalAggregates++;
168 numNonAggregatedNodes--;
173 if (failedToAggregate) {
174 if (error_on_isolated) {
176 std::ostringstream oss;
177 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;
178 oss<<
"If this error is being generated at level 0, this is due to an initial partitioning problem in your matrix."<<std::endl;
179 oss<<
"If this error is being generated at any other level, try turning on repartitioning, which may fix this problem."<<std::endl;
187 vertex2AggId[i] = numLocalAggregates++;
188 numNonAggregatedNodes--;
194 procWinner[i] = myRank;
199 if(numSingletons > 0)
200 this->GetOStream(
Runtime0)<<
" WARNING Rank "<<myRank<<
" singletons :"<<numSingletons<<
" (phase)"<<std::endl;