10#ifndef MUELU_PRESERVEDIRICHLETAGGREGATIONALGORITHM_DEF_HPP_
11#define MUELU_PRESERVEDIRICHLETAGGREGATIONALGORITHM_DEF_HPP_
13#include <Teuchos_Comm.hpp>
14#include <Teuchos_CommHelpers.hpp>
16#include <Xpetra_Vector.hpp>
20#include "MueLu_LWGraph.hpp"
21#include "MueLu_Aggregates.hpp"
27template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
29 Monitor m(*
this,
"BuildAggregatesNonKokkos");
31 bool preserve = params.get<
bool>(
"aggregation: preserve Dirichlet points");
34 const int myRank = graph.
GetComm()->getRank();
36 ArrayRCP<LO> vertex2AggId = aggregates.
GetVertex2AggId()->getDataNonConst(0);
37 ArrayRCP<LO> procWinner = aggregates.
GetProcWinner()->getDataNonConst(0);
41 for (LO i = 0; i < numRows; i++)
44 numNonAggregatedNodes--;
49 vertex2AggId[i] = numLocalAggregates++;
50 procWinner[i] = myRank;
58template <
class LocalOrdinal,
class GlobalOrdinal,
class Node>
64 LO& numNonAggregatedNodes)
const {
68 Monitor m(*
this,
"BuildAggregates");
73 const bool preserve = params.get<
bool>(
"aggregation: preserve Dirichlet points");
77 const int myRank = graph.
GetComm()->getRank();
80 auto vertex2AggId = aggregates.
GetVertex2AggId()->getLocalViewDevice(Tpetra::Access::ReadWrite);
81 auto procWinner = aggregates.
GetProcWinner()->getLocalViewDevice(Tpetra::Access::ReadWrite);
84 Kokkos::View<LO, device_type> aggCount(
"aggCount");
89 "MueLu - PreserveDirichlet: tagging ignored nodes",
90 Kokkos::RangePolicy<local_ordinal_type, execution_space>(0, numNodes),
91 KOKKOS_LAMBDA(
const local_ordinal_type nodeIdx) {
94 const LO aggIdx = Kokkos::atomic_fetch_add(&aggCount(), 1);
99 vertex2AggId(nodeIdx, 0) = aggIdx;
100 procWinner(nodeIdx, 0) = myRank;
104 typename Kokkos::View<LO, device_type>::host_mirror_type aggCount_h = Kokkos::create_mirror_view(aggCount);
105 Kokkos::deep_copy(aggCount_h, aggCount);
Container class for aggregation information.
KOKKOS_INLINE_FUNCTION LO GetNumAggregates() const
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.
void SetNumAggregates(LO nAggregates)
Set number of local aggregates on current processor.
Kokkos::View< unsigned *, typename LWGraphHostType::device_type > AggStatHostType
Kokkos::View< unsigned *, typename LWGraphType::device_type > AggStatType
KOKKOS_INLINE_FUNCTION size_type GetNodeNumVertices() const
Return number of graph vertices.
typename device_type::execution_space execution_space
typename std::conditional< OnHost, Kokkos::Device< Kokkos::Serial, Kokkos::HostSpace >, typename Node::device_type >::type device_type
const RCP< const Teuchos::Comm< int > > GetComm() const
LocalOrdinal local_ordinal_type
Lightweight MueLu representation of a compressed row storage graph.
Lightweight MueLu representation of a compressed row storage graph.
Timer to be used in non-factories.
void BuildAggregatesNonKokkos(const Teuchos::ParameterList ¶ms, const LWGraph &graph, Aggregates &aggregates, typename AggregationAlgorithmBase< LocalOrdinal, GlobalOrdinal, Node >::AggStatHostType &aggStat, LO &numNonAggregatedNodes) const
Local aggregation.
void BuildAggregates(const Teuchos::ParameterList ¶ms, const LWGraph_kokkos &graph, Aggregates &aggregates, typename AggregationAlgorithmBase< LocalOrdinal, GlobalOrdinal, Node >::AggStatType &aggStat, LO &numNonAggregatedNodes) const
Namespace for MueLu classes and methods.