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_MultiVector.hpp> 52 #include <Xpetra_BlockedMultiVector.hpp> 53 #include <Xpetra_BlockedVector.hpp> 54 #include <Xpetra_VectorFactory.hpp> 55 #include <Xpetra_MultiVectorFactory.hpp> 58 #include "MueLu_Graph.hpp" 64 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
68 vertex2AggId_ = LOMultiVectorFactory::Build(graph.
GetImportMap(), 1);
71 procWinner_ = LOVectorFactory::Build(graph.
GetImportMap());
74 isRoot_ = Teuchos::ArrayRCP<bool>(graph.
GetImportMap()->getNodeNumElements(),
false);
77 aggregatesIncludeGhosts_ =
true;
81 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
85 vertex2AggId_ = LOMultiVectorFactory::Build(map, 1);
88 procWinner_ = LOVectorFactory::Build(map);
91 isRoot_ = Teuchos::ArrayRCP<bool>(map->getNodeNumElements(),
false);
94 aggregatesIncludeGhosts_ =
true;
98 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
101 if (aggregateSizes_ != Teuchos::null && !forceRecompute) {
103 return aggregateSizes_;
108 aggregateSizes_ = Teuchos::null;
110 Teuchos::ArrayRCP<LO> aggregateSizes;
111 aggregateSizes = Teuchos::ArrayRCP<LO>(nAggregates_,0);
112 int myPid = vertex2AggId_->getMap()->getComm()->getRank();
113 Teuchos::ArrayRCP<LO> procWinner = procWinner_->getDataNonConst(0);
114 Teuchos::ArrayRCP<LO> vertex2AggId = vertex2AggId_->getDataNonConst(0);
115 LO size = procWinner.size();
118 for (LO k = 0; k < size; ++k ) {
119 if (procWinner[k] == myPid) aggregateSizes[vertex2AggId[k]]++;
122 aggregateSizes_ = aggregateSizes;
124 return aggregateSizes;
129 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
131 std::ostringstream out;
133 out <<
"{nGlobalAggregates = " << GetNumGlobalAggregates() <<
"}";
137 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
142 out0 <<
"Global number of aggregates: " << GetNumGlobalAggregates() << std::endl;
145 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
147 LO nAggregates = GetNumAggregates();
148 GO nGlobalAggregates;
MueLu_sumAll(vertex2AggId_->getMap()->getComm(), (GO)nAggregates, nGlobalAggregates);
149 return nGlobalAggregates;
152 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
154 return vertex2AggId_->getMap();
159 #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.
MueLu::DefaultGlobalOrdinal GlobalOrdinal
#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=false) const
Compute sizes of aggregates.