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 matchMLbehavior = params.get<
bool>(
"aggregation: match ML phase2a");
73 const int myRank = graph.
GetComm()->getRank();
75 ArrayRCP<LO> vertex2AggId = aggregates.
GetVertex2AggId()->getDataNonConst(0);
76 ArrayRCP<LO> procWinner = aggregates.
GetProcWinner() ->getDataNonConst(0);
80 LO numLocalNodes = procWinner.size();
81 LO numLocalAggregated = numLocalNodes - numNonAggregatedNodes;
83 const double aggFactor = params.get<
double>(
"aggregation: phase2a agg factor");
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 if (matchMLbehavior) {
98 aggList[aggSize++] = rootCandidate;
105 for (
int j = 0; j < neighOfINode.size(); j++) {
106 LO neigh = neighOfINode[j];
108 if (neigh != rootCandidate) {
115 if (aggSize < as<size_t>(maxNodesPerAggregate))
116 aggList[aggSize++] = neigh;
124 if (aggSize > as<size_t>(minNodesPerAggregate) &&
125 (aggSize > factor*numNeighbors)) {
129 aggIndex = numLocalAggregates++;
131 for (
size_t k = 0; k < aggSize; k++) {
133 vertex2AggId[aggList[k]] = aggIndex;
134 procWinner [aggList[k]] = myRank;
137 numNonAggregatedNodes -= aggSize;
Container class for aggregation information.
void SetIsRoot(LO i, bool value=true)
Set root node information.
const RCP< LOMultiVector > & GetVertex2AggId() const
Returns constant vector that maps local node IDs to local aggregates IDs.
const RCP< LOVector > & GetProcWinner() const
Returns constant vector that maps local node IDs to owning processor IDs.
LO GetNumAggregates() const
returns the number of aggregates of the current processor. Note: could/should be renamed to GetNumLoc...
void SetNumAggregates(LO nAggregates)
Set number of local aggregates on current processor.
void BuildAggregates(const ParameterList ¶ms, const GraphBase &graph, Aggregates &aggregates, std::vector< unsigned > &aggStat, LO &numNonAggregatedNodes) const
Local aggregation.
MueLu representation of a graph.
virtual const RCP< const Teuchos::Comm< int > > GetComm() const =0
virtual bool isLocalNeighborVertex(LocalOrdinal v) const =0
Return true if vertex with local id 'v' is on current process.
virtual Teuchos::ArrayView< const LocalOrdinal > getNeighborVertices(LocalOrdinal v) const =0
Return the list of vertices adjacent to the vertex 'v'.
virtual size_t getLocalMaxNumRowEntries() const =0
virtual size_t GetNodeNumVertices() const =0
Return number of vertices owned by the calling node.
Timer to be used in non-factories.
Namespace for MueLu classes and methods.