46 #ifndef MUELU_AGGREGATIONPHASE2AALGORITHM_DEF_HPP_
47 #define MUELU_AGGREGATIONPHASE2AALGORITHM_DEF_HPP_
50 #include <Teuchos_Comm.hpp>
51 #include <Teuchos_CommHelpers.hpp>
58 #include "MueLu_Aggregates.hpp"
64 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
66 Monitor m(*
this,
"BuildAggregates");
68 int minNodesPerAggregate = params.
get<
int>(
"aggregation: min agg size");
69 int maxNodesPerAggregate = params.
get<
int>(
"aggregation: max agg size");
72 const int myRank = graph.
GetComm()->getRank();
79 LO numLocalNodes = procWinner.
size();
80 LO numLocalAggregated = numLocalNodes - numNonAggregatedNodes;
82 const double aggFactor = 0.5;
83 double factor = as<double>(numLocalAggregated)/(numLocalNodes+1);
84 factor = pow(factor, aggFactor);
90 for (
LO rootCandidate = 0; rootCandidate < numRows; rootCandidate++) {
91 if (aggStat[rootCandidate] !=
READY)
99 for (
int j = 0; j < neighOfINode.
size(); j++) {
100 LO neigh = neighOfINode[j];
102 if (neigh != rootCandidate) {
109 if (aggSize < as<size_t>(maxNodesPerAggregate))
110 aggList[aggSize++] = neigh;
118 if (aggSize > as<size_t>(minNodesPerAggregate) &&
119 aggSize > factor*numNeighbors) {
123 aggIndex = numLocalAggregates++;
125 for (
size_t k = 0; k < aggSize; k++) {
127 vertex2AggId[aggList[k]] = aggIndex;
128 procWinner [aggList[k]] = myRank;
131 numNonAggregatedNodes -= aggSize;
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 getNodeMaxNumRowEntries() const =0
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.
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.
void BuildAggregates(const ParameterList ¶ms, const GraphBase &graph, Aggregates &aggregates, std::vector< unsigned > &aggStat, LO &numNonAggregatedNodes) const
Local aggregation.
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.
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.