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 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();
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--;
Container class for aggregation information.
void BuildAggregates(const ParameterList ¶ms, const GraphBase &graph, Aggregates &aggregates, std::vector< unsigned > &aggStat, LO &numNonAggregatedNodes) const
Local aggregation.
T & get(const std::string &name, T def_value)
virtual size_t GetNodeNumVertices() const =0
Return number of vertices owned by the calling node.
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...
bool isParameter(const std::string &name) const
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.