46 #ifndef MUELU_AGGREGATES_DEF_HPP 47 #define MUELU_AGGREGATES_DEF_HPP 49 #include <Xpetra_Map.hpp> 50 #include <Xpetra_Vector.hpp> 51 #include <Xpetra_BlockedMultiVector.hpp> 52 #include <Xpetra_BlockedVector.hpp> 53 #include <Xpetra_VectorFactory.hpp> 56 #include "MueLu_Graph.hpp" 62 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
66 vertex2AggId_ = LOVectorFactory::Build(graph.
GetImportMap());
69 procWinner_ = LOVectorFactory::Build(graph.
GetImportMap());
72 isRoot_ = Teuchos::ArrayRCP<bool>(graph.
GetImportMap()->getNodeNumElements(),
false);
75 aggregatesIncludeGhosts_ =
true;
79 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
83 vertex2AggId_ = LOVectorFactory::Build(map);
86 procWinner_ = LOVectorFactory::Build(map);
89 isRoot_ = Teuchos::ArrayRCP<bool>(map->getNodeNumElements(),
false);
92 aggregatesIncludeGhosts_ =
true;
96 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
99 if (aggregateSizes_ != Teuchos::null && !forceRecompute) {
101 return aggregateSizes_;
106 aggregateSizes_ = Teuchos::null;
108 Teuchos::ArrayRCP<LO> aggregateSizes;
109 aggregateSizes = Teuchos::ArrayRCP<LO>(nAggregates_,0);
110 int myPid = vertex2AggId_->getMap()->getComm()->getRank();
111 Teuchos::ArrayRCP<LO> procWinner = procWinner_->getDataNonConst(0);
112 Teuchos::ArrayRCP<LO> vertex2AggId = vertex2AggId_->getDataNonConst(0);
113 LO size = procWinner.size();
116 for (LO k = 0; k < size; ++k ) {
117 if (procWinner[k] == myPid) aggregateSizes[vertex2AggId[k]]++;
121 aggregateSizes_ = aggregateSizes;
123 return aggregateSizes;
128 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
130 std::ostringstream out;
132 out <<
"{nGlobalAggregates = " << GetNumGlobalAggregates() <<
"}";
136 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
141 out0 <<
"Global number of aggregates: " << GetNumGlobalAggregates() << std::endl;
144 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
146 LO nAggregates = GetNumAggregates();
147 GO nGlobalAggregates;
MueLu_sumAll(vertex2AggId_->getMap()->getComm(), (GO)nAggregates, nGlobalAggregates);
148 return nGlobalAggregates;
151 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
153 return vertex2AggId_->getMap();
158 #endif // MUELU_AGGREGATES_DEF_HPP
std::string description() const
Return a simple one-line description of this object.
#define MueLu_sumAll(rcpComm, in, out)
void print(Teuchos::FancyOStream &out, const Teuchos::EVerbosityLevel verbLevel=verbLevel_default) const
Print the object with some verbosity level to an FancyOStream object.
Namespace for MueLu classes and methods.
Aggregates(const GraphBase &graph)
Standard constructor for Aggregates structure.
GO GetNumGlobalAggregates() const
Get global number of aggregates.
#define MUELU_UNAGGREGATED
#define MUELU_DESCRIBE
Helper macro for implementing Describable::describe() for BaseClass objects.
const RCP< const Map > GetMap() const
returns (overlapping) map of aggregate/node distribution
MueLu representation of a graph.
virtual const RCP< const Map > GetImportMap() const =0
virtual std::string description() const
Return a simple one-line description of this object.
Teuchos::ArrayRCP< LO > ComputeAggregateSizes(bool forceRecompute=true, bool cacheSizes=false) const
Compute sizes of aggregates.