46 #ifndef MUELU_AGGREGATIONPHASE2BALGORITHM_DEF_HPP_
47 #define MUELU_AGGREGATIONPHASE2BALGORITHM_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");
70 const int myRank = graph.
GetComm()->getRank();
77 const int defaultConnectWeight = 100;
78 const int penaltyConnectWeight = 10;
80 std::vector<int> aggWeight (numLocalAggregates, 0);
81 std::vector<int> connectWeight(numRows, defaultConnectWeight);
82 std::vector<int> aggPenalties (numRows, 0);
90 for (
int k = 0; k < 2; k++) {
91 for (LO i = 0; i < numRows; i++) {
92 if (aggStat[i] !=
READY)
97 for (
int j = 0; j < neighOfINode.
size(); j++) {
98 LO neigh = neighOfINode[j];
102 aggWeight[vertex2AggId[neigh]] += connectWeight[neigh];
105 int bestScore = -100000;
107 int bestConnect = -1;
109 for (
int j = 0; j < neighOfINode.
size(); j++) {
110 LO neigh = neighOfINode[j];
113 int aggId = vertex2AggId[neigh];
114 int score = aggWeight[aggId] - aggPenalties[aggId];
116 if (score > bestScore) {
119 bestConnect = connectWeight[neigh];
121 }
else if (aggId == bestAggId && connectWeight[neigh] > bestConnect) {
122 bestConnect = connectWeight[neigh];
126 aggWeight[aggId] = 0;
130 if (bestScore >= 0) {
132 vertex2AggId[i] = bestAggId;
133 procWinner [i] = myRank;
135 numNonAggregatedNodes--;
137 aggPenalties[bestAggId]++;
138 connectWeight[i] = bestConnect - penaltyConnectWeight;
const RCP< LOVector > & GetProcWinner() const
Returns constant vector that maps local node IDs to owning processor IDs.
Container class for aggregation information.
virtual size_t GetNodeNumVertices() const =0
Return number of vertices owned by the calling node.
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.
void BuildAggregates(const ParameterList ¶ms, const GraphBase &graph, Aggregates &aggregates, std::vector< unsigned > &aggStat, LO &numNonAggregatedNodes) const
Local aggregation.
virtual Teuchos::ArrayView< const LocalOrdinal > getNeighborVertices(LocalOrdinal v) const =0
Return the list of vertices adjacent to the vertex 'v'.