47 #ifndef MUELU_AGGREGATES_KOKKOS_DEF_HPP 48 #define MUELU_AGGREGATES_KOKKOS_DEF_HPP 50 #include <Xpetra_Map.hpp> 51 #include <Xpetra_Vector.hpp> 52 #include <Xpetra_VectorFactory.hpp> 54 #include "MueLu_Graph.hpp" 61 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
62 Aggregates_kokkos<LocalOrdinal, GlobalOrdinal, Node>::Aggregates_kokkos(
const GraphBase & graph) {
65 vertex2AggId_ = LOVectorFactory::Build(graph.GetImportMap());
68 procWinner_ = LOVectorFactory::Build(graph.GetImportMap());
71 isRoot_ = Teuchos::ArrayRCP<bool>(graph.GetImportMap()->getNodeNumElements(),
false);
74 aggregatesIncludeGhosts_ =
true;
78 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
79 Aggregates_kokkos<LocalOrdinal, GlobalOrdinal, Node>::Aggregates_kokkos(
const RCP<const Map> & map) {
82 vertex2AggId_ = LOVectorFactory::Build(map);
85 procWinner_ = LOVectorFactory::Build(map);
88 isRoot_ = Teuchos::ArrayRCP<bool>(map->getNodeNumElements(),
false);
91 aggregatesIncludeGhosts_ =
true;
95 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
96 Teuchos::ArrayRCP<LocalOrdinal> Aggregates_kokkos<LocalOrdinal, GlobalOrdinal, Node>::ComputeAggregateSizes(
bool forceRecompute,
bool cacheSizes)
const {
98 if (aggregateSizes_ != Teuchos::null && !forceRecompute) {
100 return aggregateSizes_;
105 aggregateSizes_ = Teuchos::null;
107 Teuchos::ArrayRCP<LO> aggregateSizes;
108 aggregateSizes = Teuchos::ArrayRCP<LO>(nAggregates_,0);
109 int myPid = vertex2AggId_->getMap()->getComm()->getRank();
110 Teuchos::ArrayRCP<LO> procWinner = procWinner_->getDataNonConst(0);
111 Teuchos::ArrayRCP<LO> vertex2AggId = vertex2AggId_->getDataNonConst(0);
112 LO size = procWinner.size();
115 for (LO k = 0; k < size; ++k ) {
116 if (procWinner[k] == myPid) aggregateSizes[vertex2AggId[k]]++;
120 aggregateSizes_ = aggregateSizes;
122 return aggregateSizes;
127 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
128 std::string Aggregates_kokkos<LocalOrdinal, GlobalOrdinal, Node>::description()
const {
129 std::ostringstream out;
131 out <<
"{nGlobalAggregates = " << GetNumGlobalAggregates() <<
"}";
135 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
136 void Aggregates_kokkos<LocalOrdinal, GlobalOrdinal, Node>::print(Teuchos::FancyOStream &out,
const Teuchos::EVerbosityLevel verbLevel)
const {
140 out0 <<
"Global number of aggregates: " << GetNumGlobalAggregates() << std::endl;
144 template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
145 GlobalOrdinal Aggregates_kokkos<LocalOrdinal, GlobalOrdinal, Node>::GetNumGlobalAggregates()
const {
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>
152 const RCP<const Xpetra::Map<LocalOrdinal,GlobalOrdinal, Node> > Aggregates_kokkos<LocalOrdinal, GlobalOrdinal, Node>::GetMap()
const {
153 return vertex2AggId_->getMap();
158 #endif // MUELU_AGGREGATES_KOKKOS_DEF_HPP
Namespace for MueLu classes and methods.
Print statistics that do not involve significant additional computation.
#define MueLu_sumAll(rcpComm, in, out)
#define MUELU_UNAGGREGATED
#define MUELU_DESCRIBE
Helper macro for implementing Describable::describe() for BaseClass objects.
virtual std::string description() const
Return a simple one-line description of this object.