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");
72 const int myRank = graph.
GetComm()->getRank();
74 ArrayRCP<LO> vertex2AggId = aggregates.
GetVertex2AggId()->getDataNonConst(0);
75 ArrayRCP<LO> procWinner = aggregates.
GetProcWinner() ->getDataNonConst(0);
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;
Container class for aggregation information.
virtual size_t getNodeMaxNumRowEntries() const =0
virtual size_t GetNodeNumVertices() const =0
Return number of vertices owned by the calling node.
Namespace for MueLu classes and methods.
void SetIsRoot(LO i, bool value=true)
Set root node information.
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
MueLu representation of a graph.
void BuildAggregates(const ParameterList ¶ms, const GraphBase &graph, Aggregates &aggregates, std::vector< unsigned > &aggStat, LO &numNonAggregatedNodes) const
Local aggregation.
Timer to be used in non-factories.
LO GetNumAggregates() const
returns the number of aggregates of the current processor. Note: could/should be renamed to GetNumLoc...
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.
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.