46 #ifndef MUELU_AGGREGATIONPHASE2AALGORITHM_DEF_HPP_
47 #define MUELU_AGGREGATIONPHASE2AALGORITHM_DEF_HPP_
50 #include <Teuchos_Comm.hpp>
51 #include <Teuchos_CommHelpers.hpp>
53 #include <Xpetra_Vector.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");
70 bool includeRootInAgg = params.
get<
bool>(
"aggregation: phase2a include root");
73 const int myRank = graph.
GetComm()->getRank();
80 LO numLocalNodes = procWinner.
size();
81 LO numLocalAggregated = numLocalNodes - numNonAggregatedNodes;
83 const double aggFactor = 0.5;
84 double factor = as<double>(numLocalAggregated)/(numLocalNodes+1);
85 factor = pow(factor, aggFactor);
91 for (LO rootCandidate = 0; rootCandidate < numRows; rootCandidate++) {
92 if (aggStat[rootCandidate] !=
READY)
97 aggList[aggSize++] = rootCandidate;
102 for (
int j = 0; j < neighOfINode.
size(); j++) {
103 LO neigh = neighOfINode[j];
105 if (neigh != rootCandidate) {
112 if (aggSize < as<size_t>(maxNodesPerAggregate))
113 aggList[aggSize++] = neigh;
121 if (aggSize > as<size_t>(minNodesPerAggregate) &&
122 ((includeRootInAgg && aggSize-1 > factor*numNeighbors) ||
123 (!includeRootInAgg && aggSize > factor*numNeighbors))) {
127 aggIndex = numLocalAggregates++;
129 for (
size_t k = 0; k < aggSize; k++) {
131 vertex2AggId[aggList[k]] = aggIndex;
132 procWinner [aggList[k]] = myRank;
135 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.