Go to the documentation of this file.
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);
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--;
const RCP< LOVector > & GetProcWinner() const
Returns constant vector that maps local node IDs to owning processor IDs.
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
virtual size_t GetNodeNumVertices() const =0
Return number of vertices owned by the calling node.
void BuildAggregates(const ParameterList ¶ms, const GraphBase &graph, Aggregates &aggregates, std::vector< unsigned > &aggStat, LO &numNonAggregatedNodes) const
Local aggregation.
void SetIsRoot(LO i, bool value=true)
Set root node information.
Namespace for MueLu classes and methods.
MueLu representation of a graph.
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.
Container class for aggregation information.
LO GetNumAggregates() const
returns the number of aggregates of the current processor. Note: could/should be renamed to GetNumLoc...
Timer to be used in non-factories.
void SetNumAggregates(LO nAggregates)
Set number of local aggregates on current processor.
virtual Teuchos::ArrayView< const LocalOrdinal > getNeighborVertices(LocalOrdinal v) const =0
Return the list of vertices adjacent to the vertex 'v'.