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 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;
Container class for aggregation information.
void BuildAggregates(const ParameterList ¶ms, const GraphBase &graph, Aggregates &aggregates, std::vector< unsigned > &aggStat, LO &numNonAggregatedNodes) const
Local aggregation.
virtual size_t GetNodeNumVertices() const =0
Return number of vertices owned by the calling node.
One-liner description of what is happening.
Namespace for MueLu classes and methods.
void SetIsRoot(LO i, bool value=true)
Set root node information.
virtual bool isLocalNeighborVertex(LocalOrdinal v) const =0
Return true if vertex with local id 'v' is on current process.
virtual const RCP< const Teuchos::Comm< int > > GetComm() const =0
MueLu representation of a graph.
Timer to be used in non-factories.
LO GetNumAggregates() const
returns the number of aggregates of the current processor. Note: could/should be renamed to GetNumLoc...
const RCP< LOMultiVector > & GetVertex2AggId() const
Returns constant vector that maps local node IDs to local aggregates IDs.
Exception throws to report errors in the internal logical of the program.
const RCP< LOVector > & GetProcWinner() const
Returns constant vector that maps local node IDs to owning processor IDs.
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.