MueLu Version of the Day
Loading...
Searching...
No Matches
MueLu_Aggregates_decl.hpp
Go to the documentation of this file.
1// @HEADER
2// *****************************************************************************
3// MueLu: A package for multigrid based preconditioning
4//
5// Copyright 2012 NTESS and the MueLu contributors.
6// SPDX-License-Identifier: BSD-3-Clause
7// *****************************************************************************
8// @HEADER
9
10#ifndef MUELU_AGGREGATES_DECL_HPP
11#define MUELU_AGGREGATES_DECL_HPP
12
13#include "MueLu_ConfigDefs.hpp"
14
15#include <Kokkos_StaticCrsGraph.hpp>
16
18
19#include <Xpetra_Map_fwd.hpp>
20#include <Xpetra_Vector_fwd.hpp>
21#include <Xpetra_VectorFactory_fwd.hpp>
22#include <Xpetra_MultiVector_fwd.hpp>
23
24#include "MueLu_BaseClass.hpp"
25
26#include "MueLu_LWGraph_kokkos.hpp"
27
28#include "MueLu_LWGraph.hpp"
29#include "MueLu_IndexManager.hpp"
30#include "MueLu_IndexManager_kokkos.hpp"
31
32#define MUELU_UNAGGREGATED -1 /* indicates that a node is unassigned to */
33 /* any aggregate. */
34
35#define MUELU_UNASSIGNED -1 /* indicates a vertex is not yet claimed */
36 /* by a processor during aggregation. */
37 /* Note, it is possible at */
38 /* this stage that some processors may have*/
39 /* claimed their copy of a vertex for one */
40 /* of their aggregates. However, some */
41 /* arbitration still needs to occur. */
42 /* The corresponding procWinner[]'s remain */
43 /* as MUELU_UNASSIGNED until */
44 /* ArbitrateAndCommunicate() is */
45 /* invoked to arbitrate. */
46
47/*****************************************************************************
48
49****************************************************************************/
50
51namespace MueLu {
52
68template <class LocalOrdinal, class GlobalOrdinal, class Node>
69class Aggregates : public BaseClass {
70 public:
73 using execution_space = typename Node::execution_space;
74 using node_type = Node;
75 using device_type = typename Node::device_type;
76 using range_type = Kokkos::RangePolicy<local_ordinal_type, execution_space>;
77 using LO_view = Kokkos::View<local_ordinal_type*, device_type>;
78
79 using aggregates_sizes_type = Kokkos::View<LocalOrdinal*, device_type>;
80
81 private:
82#undef MUELU_AGGREGATES_SHORT
84
85 public:
86 // Defining types that require the short names included above
88 using colors_view_type = Kokkos::View<typename local_graph_type::entries_type::data_type,
89 typename local_graph_type::device_type::memory_space>;
90
98 Aggregates(const LWGraph& graph);
99
108
114 Aggregates(const RCP<const Map>& map);
115
119 virtual ~Aggregates() {}
120
122
123
127 RCP<IndexManager_kokkos>& GetIndexManagerKokkos() { return geoDataKokkos_; }
128
132 void SetIndexManagerKokkos(RCP<IndexManager_kokkos>& geoDataKokkos) { geoDataKokkos_ = geoDataKokkos; }
133
137 RCP<IndexManager>& GetIndexManager() { return geoData_; }
138
142 void SetIndexManager(RCP<IndexManager>& geoData) { geoData_ = geoData; }
143
148
152 void SetGraphColors(colors_view_type graphColors) { graphColors_ = graphColors; }
153
157
160 void SetGraphNumColors(const LO graphNumColors) { graphNumColors_ = graphNumColors; }
161
163
168 void SetNumAggregates(LO nAggregates) { numAggregates_ = nAggregates; }
169
174 void SetNumGlobalAggregates(GO nGlobalAggregates) { numGlobalAggregates_ = nGlobalAggregates; }
175
177 KOKKOS_INLINE_FUNCTION LO GetNumAggregates() const {
178 return numAggregates_;
179 }
180
182 KOKKOS_INLINE_FUNCTION void AggregatesCrossProcessors(const bool& flag) {
184 }
185
190 KOKKOS_INLINE_FUNCTION bool AggregatesCrossProcessors() const {
192 }
193
198 RCP<LOMultiVector>& GetVertex2AggIdNonConst() { return vertex2AggId_; }
199
204 RCP<LOVector>& GetProcWinnerNonConst() { return procWinner_; }
209 const RCP<LOMultiVector>& GetVertex2AggId() const { return vertex2AggId_; }
210
215 const RCP<LOVector>& GetProcWinner() const { return procWinner_; }
216
218 inline bool IsRoot(LO i) const { return isRoot_[i]; }
219
224 inline void SetIsRoot(LO i, bool value = true) { isRoot_[i] = value; }
225
226 const RCP<const Map> GetMap() const;
227
237 typename aggregates_sizes_type::const_type ComputeAggregateSizes(bool forceRecompute = false) const;
238
248 Teuchos::ArrayRCP<LocalOrdinal> ComputeAggregateSizesArrayRCP(bool forceRecompute = false) const;
249
251
256 void ComputeNodesInAggregate(LO_view& aggPtr, LO_view& aggNodes, LO_view& unaggregated) const;
257
259 // If # of global aggregates is unknown, this method does coummunication and internally record the value
261
263
264
266 std::string description() const;
267
269 // using MueLu::Describable::describe; // overloading, not hiding
270 void print(Teuchos::FancyOStream& out, const Teuchos::EVerbosityLevel verbLevel = verbLevel_default) const;
271
272 private:
275
280 RCP<LOMultiVector> vertex2AggId_;
281
286 RCP<LOVector> procWinner_;
287
291 RCP<IndexManager_kokkos> geoDataKokkos_;
292
296 RCP<IndexManager> geoData_;
297
302
307
309 Teuchos::ArrayRCP<bool> isRoot_;
310
313
316
321 mutable
322 typename aggregates_sizes_type::HostMirror aggregateSizesHost_;
323
326};
327
328} // namespace MueLu
329
330#define MUELU_AGGREGATES_SHORT
331#endif // MUELU_AGGREGATES_DECL_HPP
MueLu::DefaultLocalOrdinal LocalOrdinal
MueLu::DefaultGlobalOrdinal GlobalOrdinal
MueLu::DefaultNode Node
Aggregates(const RCP< const Map > &map)
Constructor for Aggregates structure.
typename LWGraph_kokkos::local_graph_type local_graph_type
KOKKOS_INLINE_FUNCTION void AggregatesCrossProcessors(const bool &flag)
Record whether aggregates include DOFs from other processes.
Kokkos::View< typename local_graph_type::entries_type::data_type, typename local_graph_type::device_type::memory_space > colors_view_type
void ComputeNodesInAggregate(LO_view &aggPtr, LO_view &aggNodes, LO_view &unaggregated) const
Generates a compressed list of nodes in each aggregate, where the entries in aggNodes[aggPtr[i]] up t...
void SetGraphNumColors(const LO graphNumColors)
Set the number of colors needed by the distance 2 coloring.
Teuchos::ArrayRCP< LocalOrdinal > ComputeAggregateSizesArrayRCP(bool forceRecompute=false) const
Compute sizes of aggregates.
aggregates_sizes_type::const_type ComputeAggregateSizes(bool forceRecompute=false) const
Compute sizes of aggregates.
void SetNumGlobalAggregates(GO nGlobalAggregates)
Set number of global aggregates on current processor.
RCP< LOVector > & GetProcWinnerNonConst()
Returns nonconstant vector that maps local node IDs to owning processor IDs.
RCP< LOMultiVector > & GetVertex2AggIdNonConst()
Returns a nonconstant vector that maps local node IDs to local aggregates IDs.
KOKKOS_INLINE_FUNCTION bool AggregatesCrossProcessors() const
Return false if and only if no aggregates include DOFs from other processes.
void print(Teuchos::FancyOStream &out, const Teuchos::EVerbosityLevel verbLevel=verbLevel_default) const
Print the object with some verbosity level to an FancyOStream object.
typename Node::execution_space execution_space
LO GetGraphNumColors()
Get the number of colors needed by the distance 2 coloring.
KOKKOS_INLINE_FUNCTION LO GetNumAggregates() const
void SetIndexManagerKokkos(RCP< IndexManager_kokkos > &geoDataKokkos)
Set the index manager used by structured aggregation algorithms. This has to be done by the aggregati...
typename Node::device_type device_type
RCP< IndexManager_kokkos > & GetIndexManagerKokkos()
Get the index manager used by structured aggregation algorithms. This has to be done by the aggregati...
local_graph_type GetGraph() const
GlobalOrdinal global_ordinal_type
Aggregates(const LWGraph &graph)
Standard constructor for Aggregates structure.
Kokkos::RangePolicy< local_ordinal_type, execution_space > range_type
const RCP< const Map > GetMap() const
returns (overlapping) map of aggregate/node distribution
GO GetNumGlobalAggregatesComputeIfNeeded()
Get global number of aggregates.
void SetIsRoot(LO i, bool value=true)
Set root node information.
RCP< IndexManager > & GetIndexManager()
Get the index manager used by various aggregation algorithms. This has to be done by the aggregation ...
bool IsRoot(LO i) const
Returns true if node with given local node id is marked to be a root node.
std::string description() const
Return a simple one-line description of this object.
Aggregates(LWGraph_kokkos graph)
Standard constructor for Aggregates structure.
Kokkos::View< LocalOrdinal *, device_type > aggregates_sizes_type
Kokkos::View< local_ordinal_type *, device_type > LO_view
const RCP< LOMultiVector > & GetVertex2AggId() const
Returns constant vector that maps local node IDs to local aggregates IDs.
colors_view_type & GetGraphColors()
Get a distance 2 coloring of the underlying graph. The coloring is computed and set during Phase1 of ...
virtual ~Aggregates()
Destructor.
const RCP< LOVector > & GetProcWinner() const
Returns constant vector that maps local node IDs to owning processor IDs.
void SetGraphColors(colors_view_type graphColors)
Set a distance 2 coloring of the underlying graph. The coloring is computed and set during Phase1 of ...
void SetIndexManager(RCP< IndexManager > &geoData)
Set the index manager used by various aggregation algorithms. This has to be done by the aggregation ...
void SetNumAggregates(LO nAggregates)
Set number of local aggregates on current processor.
Base class for MueLu classes.
typename std::conditional< OnHost, typename local_graph_device_type::HostMirror, local_graph_device_type >::type local_graph_type
Lightweight MueLu representation of a compressed row storage graph.
Lightweight MueLu representation of a compressed row storage graph.
Namespace for MueLu classes and methods.