46 #ifndef MUELU_AGGREGATIONPHASE3ALGORITHM_DEF_HPP_
47 #define MUELU_AGGREGATIONPHASE3ALGORITHM_DEF_HPP_
49 #include <Teuchos_Comm.hpp>
50 #include <Teuchos_CommHelpers.hpp>
56 #include "MueLu_Aggregates.hpp"
65 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
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");
77 const int myRank = graph.
GetComm()->getRank();
84 for (
LO i = 0; i < numRows; i++) {
92 bool isNewAggregate =
false;
93 bool failedToAggregate =
true;
94 for (
int j = 0; j < neighOfINode.
size(); j++) {
95 LO neigh = neighOfINode[j];
98 isNewAggregate =
true;
101 vertex2AggId[neigh] = numLocalAggregates;
102 procWinner [neigh] = myRank;
104 numNonAggregatedNodes--;
108 if (isNewAggregate) {
111 procWinner [i] = myRank;
112 numNonAggregatedNodes--;
114 vertex2AggId[i] = numLocalAggregates++;
116 failedToAggregate =
false;
123 for (; j < neighOfINode.
size(); j++) {
124 LO neigh = neighOfINode[j];
131 if (j < neighOfINode.
size()) {
133 vertex2AggId[i] = vertex2AggId[neighOfINode[j]];
134 numNonAggregatedNodes--;
135 failedToAggregate =
false;
139 if (failedToAggregate && makeNonAdjAggs) {
149 for (
LO ii = 0; ii < numRows; ii++) {
150 if ( (ii != i) && (aggStat[ii] !=
IGNORED) ) {
151 failedToAggregate =
false;
153 procWinner[i]= myRank;
156 vertex2AggId[i] = vertex2AggId[ii];
158 vertex2AggId[i] = numLocalAggregates;
159 vertex2AggId[ii] = numLocalAggregates;
161 procWinner [ii] = myRank;
162 numNonAggregatedNodes--;
164 numLocalAggregates++;
166 numNonAggregatedNodes--;
171 if (failedToAggregate) {
172 if (error_on_isolated) {
174 std::ostringstream oss;
175 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;
176 oss<<
"If this error is being generated at level 0, this is due to an initial partitioning problem in your matrix."<<std::endl;
177 oss<<
"If this error is being generated at any other level, try turning on repartitioning, which may fix this problem."<<std::endl;
181 this->GetOStream(
Warnings1) <<
"Found singleton: " << i << std::endl;
184 vertex2AggId[i] = numLocalAggregates++;
185 numNonAggregatedNodes--;
191 procWinner[i] = myRank;
const RCP< LOVector > & GetProcWinner() const
Returns constant vector that maps local node IDs to owning processor IDs.
Container class for aggregation information.
T & get(const std::string &name, T def_value)
virtual size_t GetNodeNumVertices() const =0
Return number of vertices owned by the calling node.
void SetIsRoot(LO i, bool value=true)
Set root node information.
bool isParameter(const std::string &name) const
void BuildAggregates(const ParameterList ¶ms, const GraphBase &graph, Aggregates &aggregates, std::vector< unsigned > &aggStat, LO &numNonAggregatedNodes) const
Local aggregation.
LO GetNumAggregates() const
returns the number of aggregates of the current processor. Note: could/should be renamed to GetNumLoc...
virtual bool isLocalNeighborVertex(LocalOrdinal v) const =0
Return true if vertex with local id 'v' is on current process.
const RCP< LOMultiVector > & GetVertex2AggId() const
Returns constant vector that maps local node IDs to local aggregates IDs.
virtual const RCP< const Teuchos::Comm< int > > GetComm() const =0
MueLu representation of a graph.
Timer to be used in non-factories.
Exception throws to report errors in the internal logical of the program.
virtual Teuchos::ArrayView< const LocalOrdinal > getNeighborVertices(LocalOrdinal v) const =0
Return the list of vertices adjacent to the vertex 'v'.
void SetNumAggregates(LO nAggregates)
Set number of local aggregates on current processor.