MueLu  Version of the Day
MueLu_Aggregates_decl.hpp
Go to the documentation of this file.
1 // @HEADER
2 //
3 // ***********************************************************************
4 //
5 // MueLu: A package for multigrid based preconditioning
6 // Copyright 2012 Sandia Corporation
7 //
8 // Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation,
9 // the U.S. Government retains certain rights in this software.
10 //
11 // Redistribution and use in source and binary forms, with or without
12 // modification, are permitted provided that the following conditions are
13 // met:
14 //
15 // 1. Redistributions of source code must retain the above copyright
16 // notice, this list of conditions and the following disclaimer.
17 //
18 // 2. Redistributions in binary form must reproduce the above copyright
19 // notice, this list of conditions and the following disclaimer in the
20 // documentation and/or other materials provided with the distribution.
21 //
22 // 3. Neither the name of the Corporation nor the names of the
23 // contributors may be used to endorse or promote products derived from
24 // this software without specific prior written permission.
25 //
26 // THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY
27 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
28 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
29 // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE
30 // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
31 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
32 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
33 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
34 // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
35 // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
36 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
37 //
38 // Questions? Contact
39 // Jonathan Hu (jhu@sandia.gov)
40 // Andrey Prokopenko (aprokop@sandia.gov)
41 // Ray Tuminaro (rstumin@sandia.gov)
42 //
43 // ***********************************************************************
44 //
45 // @HEADER
46 #ifndef MUELU_AGGREGATES_DECL_HPP
47 #define MUELU_AGGREGATES_DECL_HPP
48 
49 #include <Xpetra_Map_fwd.hpp>
50 #include <Xpetra_Vector_fwd.hpp>
51 #include <Xpetra_VectorFactory_fwd.hpp>
52 #include <Xpetra_MultiVector_fwd.hpp>
53 
54 #include "MueLu_ConfigDefs.hpp"
55 #include "MueLu_BaseClass.hpp"
56 #include "MueLu_Aggregates_fwd.hpp"
57 
58 #include "MueLu_Graph_fwd.hpp"
59 #include "MueLu_GraphBase.hpp"
60 #include "MueLu_IndexManager.hpp"
61 
62 #define MUELU_UNAGGREGATED -1 /* indicates that a node is unassigned to */
63  /* any aggregate. */
64 
65 #define MUELU_UNASSIGNED -1 /* indicates a vertex is not yet claimed */
66  /* by a processor during aggregation. */
67  /* Note, it is possible at */
68  /* this stage that some processors may have*/
69  /* claimed their copy of a vertex for one */
70  /* of their aggregates. However, some */
71  /* arbitration still needs to occur. */
72  /* The corresponding procWinner[]'s remain */
73  /* as MUELU_UNASSIGNED until */
74  /* ArbitrateAndCommunicate() is */
75  /* invoked to arbitrate. */
76 
77 /*****************************************************************************
78 
79 ****************************************************************************/
80 
81 namespace MueLu {
82 
99  template<class LocalOrdinal = DefaultLocalOrdinal,
101  class Node = DefaultNode>
102  class Aggregates : public BaseClass {
103 #undef MUELU_AGGREGATES_SHORT
105 
106  public:
107 
115  Aggregates(const GraphBase & graph);
116 
122  Aggregates(const RCP<const Map> & map);
123 
127  virtual ~Aggregates() { }
128 
129  LO GetNumAggregates() const { return nAggregates_; }
130 
135  void SetNumAggregates(LO nAggregates) { nAggregates_ = nAggregates; }
136 
141  void SetNumGlobalAggregates(GO nGlobalAggregates) { nGlobalAggregates_ = nGlobalAggregates; }
142 
147  RCP<IndexManager>& GetIndexManager() { return geoData_; }
148 
153  void SetIndexManager(RCP<IndexManager> & geoData) { geoData_ = geoData; }
154 
156  void AggregatesCrossProcessors(const bool &flag) {aggregatesIncludeGhosts_ = flag;};
157 
163 
168  RCP<LOMultiVector> & GetVertex2AggIdNonConst() { return vertex2AggId_; }
169 
174  RCP<LOVector> & GetProcWinnerNonConst() { return procWinner_; }
179  const RCP<LOMultiVector> & GetVertex2AggId() const { return vertex2AggId_; }
180 
185  const RCP<LOVector> & GetProcWinner() const { return procWinner_; }
186 
188  bool IsRoot(LO i) const { return isRoot_[i]; }
189 
194  void SetIsRoot(LO i, bool value=true) { isRoot_[i] = value; }
195 
196 
197  const RCP<const Map> GetMap() const;
198 
208  Teuchos::ArrayRCP<LO> ComputeAggregateSizes(bool forceRecompute = false) const;
209 
214  void ComputeNodesInAggregate(Array<LO> & aggPtr, Array<LO> & aggNodes,Array<LO> & unaggregated) const;
215 
222 
224 
225 
227  std::string description() const;
228 
230  //using MueLu::Describable::describe; // overloading, not hiding
231  void print(Teuchos::FancyOStream &out, const Teuchos::EVerbosityLevel verbLevel = verbLevel_default) const;
232 
233  private:
236 
241  RCP<LOMultiVector> vertex2AggId_;
242 
247  RCP<LOVector> procWinner_;
248 
252  RCP<IndexManager> geoData_;
253 
254  Teuchos::ArrayRCP<bool> isRoot_;//< IsRoot[i] indicates whether vertex i is a root node.
255 
258 
260  mutable Teuchos::ArrayRCP<LO> aggregateSizes_;
261 
262  };
263 
264 } //namespace MueLu
265 
266 #define MUELU_AGGREGATES_SHORT
267 #endif // MUELU_AGGREGATES_DECL_HPP
std::string description() const
Return a simple one-line description of this object.
Teuchos::ArrayRCP< LO > aggregateSizes_
Array of sizes of each local aggregate.
void print(Teuchos::FancyOStream &out, const Teuchos::EVerbosityLevel verbLevel=verbLevel_default) const
Print the object with some verbosity level to an FancyOStream object.
virtual ~Aggregates()
Destructor.
MueLu::DefaultLocalOrdinal LocalOrdinal
KokkosClassic::DefaultNode::DefaultNodeType DefaultNode
RCP< IndexManager > geoData_
Container class for aggregation information.
RCP< IndexManager > & GetIndexManager()
Get the index manager used by structured aggregation algorithms.
bool aggregatesIncludeGhosts_
Set to false iff aggregates do not include any DOFs belong to other processes.
bool IsRoot(LO i) const
Returns true if node with given local node id is marked to be a root node.
GO nGlobalAggregates_
Number of global aggregates.
Namespace for MueLu classes and methods.
bool AggregatesCrossProcessors() const
Return false if and only if no aggregates include DOFs from other processes.
void SetIndexManager(RCP< IndexManager > &geoData)
Get the index manager used by structured aggregation algorithms.
MueLu::DefaultNode Node
void SetIsRoot(LO i, bool value=true)
Set root node information.
Aggregates(const GraphBase &graph)
Standard constructor for Aggregates structure.
RCP< LOMultiVector > & GetVertex2AggIdNonConst()
Returns a nonconstant vector that maps local node IDs to local aggregates IDs.
MueLu::DefaultGlobalOrdinal GlobalOrdinal
LO nAggregates_
Number of aggregates on this processor.
RCP< LOVector > & GetProcWinnerNonConst()
Returns nonconstant vector that maps local node IDs to owning processor IDs.
GO GetNumGlobalAggregatesComputeIfNeeded()
Get global number of aggregates.
Teuchos::ArrayRCP< bool > isRoot_
void SetNumGlobalAggregates(GO nGlobalAggregates)
Set number of global aggregates on current processor.
const RCP< const Map > GetMap() const
returns (overlapping) map of aggregate/node distribution
MueLu representation of a graph.
Base class for MueLu classes.
void ComputeNodesInAggregate(Array< LO > &aggPtr, Array< LO > &aggNodes, Array< LO > &unaggregated) const
Generates a compressed list of nodes in each aggregate, where the entries in aggNodes[aggPtr[i]] up t...
RCP< LOMultiVector > vertex2AggId_
LO GetNumAggregates() const
returns the number of aggregates of the current processor. Note: could/should be renamed to GetNumLoc...
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 AggregatesCrossProcessors(const bool &flag)
Record whether aggregates include DOFs from other processes.
Teuchos::ArrayRCP< LO > ComputeAggregateSizes(bool forceRecompute=false) const
Compute sizes of aggregates.
void SetNumAggregates(LO nAggregates)
Set number of local aggregates on current processor.