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>
52 
53 #include "MueLu_ConfigDefs.hpp"
54 #include "MueLu_BaseClass.hpp"
55 #include "MueLu_Aggregates_fwd.hpp"
56 
57 #include "MueLu_Graph_fwd.hpp"
58 #include "MueLu_GraphBase.hpp"
59 
60 #define MUELU_UNAGGREGATED -1 /* indicates that a node is unassigned to */
61  /* any aggregate. */
62 
63 #define MUELU_UNASSIGNED -1 /* indicates a vertex is not yet claimed */
64  /* by a processor during aggregation. */
65  /* Note, it is possible at */
66  /* this stage that some processors may have*/
67  /* claimed their copy of a vertex for one */
68  /* of their aggregates. However, some */
69  /* arbitration still needs to occur. */
70  /* The corresponding procWinner[]'s remain */
71  /* as MUELU_UNASSIGNED until */
72  /* ArbitrateAndCommunicate() is */
73  /* invoked to arbitrate. */
74 
75 /*****************************************************************************
76 
77 ****************************************************************************/
78 
79 namespace MueLu {
80 
97  template <class LocalOrdinal = int, class GlobalOrdinal = LocalOrdinal, class Node = KokkosClassic::DefaultNode::DefaultNodeType>
98  class Aggregates : public BaseClass {
99 #undef MUELU_AGGREGATES_SHORT
101 
102  public:
103 
111  Aggregates(const GraphBase & graph);
112 
118  Aggregates(const RCP<const Map> & map);
119 
123  virtual ~Aggregates() { }
124 
125  LO GetNumAggregates() const { return nAggregates_; }
126 
131  void SetNumAggregates(LO nAggregates) { nAggregates_ = nAggregates; }
132 
134  void AggregatesCrossProcessors(const bool &flag) {aggregatesIncludeGhosts_ = flag;};
135 
141 
147 
157  const RCP<LOVector> & GetVertex2AggId() const { return vertex2AggId_; }
158 
163  const RCP<LOVector> & GetProcWinner() const { return procWinner_; }
164 
166  bool IsRoot(LO i) const { return isRoot_[i]; }
167 
172  void SetIsRoot(LO i, bool value=true) { isRoot_[i] = value; }
173 
174  const RCP<const Map> GetMap() const;
175 
189  Teuchos::ArrayRCP<LO> ComputeAggregateSizes(bool forceRecompute=true, bool cacheSizes=false) const;
190 
192 
193 
195  std::string description() const;
196 
198  //using MueLu::Describable::describe; // overloading, not hiding
199  void print(Teuchos::FancyOStream &out, const Teuchos::EVerbosityLevel verbLevel = verbLevel_default) const;
200 
201  private:
203 
209 
215 
216  Teuchos::ArrayRCP<bool> isRoot_;//< IsRoot[i] indicates whether vertex i is a root node.
217 
220 
223 
225  // This method is private because it is used only for printing and because with the current implementation, communication occurs each time this method is called.
226  GO GetNumGlobalAggregates() const;
227  };
228 
229 } //namespace MueLu
230 
231 #define MUELU_AGGREGATES_SHORT
232 #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.
Container class for aggregation information.
bool aggregatesIncludeGhosts_
Set to false iff aggregates do not include any DOFs belong to other processes.
GlobalOrdinal GO
bool IsRoot(LO i) const
Returns true if node with given local node id is marked to be a root node.
LocalOrdinal LO
RCP< LOVector > & GetVertex2AggIdNonConst()
Returns a nonconstant vector that maps local node IDs to local aggregates IDs.
Namespace for MueLu classes and methods.
bool AggregatesCrossProcessors() const
Return false if and only if no aggregates include DOFs from other processes.
void SetIsRoot(LO i, bool value=true)
Set root node information.
Aggregates(const GraphBase &graph)
Standard constructor for Aggregates structure.
const RCP< LOVector > & GetVertex2AggId() const
Returns constant vector that maps local node IDs to local aggregates IDs.
GO GetNumGlobalAggregates() const
Get global number of aggregates.
LO nAggregates_
Number of aggregates on this processor.
RCP< LOVector > & GetProcWinnerNonConst()
Returns nonconsant vector that maps local node IDs to owning processor IDs.
Teuchos::ArrayRCP< bool > isRoot_
static const EVerbosityLevel verbLevel_default
const RCP< const Map > GetMap() const
returns (overlapping) map of aggregate/node distribution
MueLu representation of a graph.
Base class for MueLu classes.
LO GetNumAggregates() const
returns the number of aggregates of the current processor. Note: could/should be renamed to GetNumLoc...
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.
RCP< LOVector > vertex2AggId_
void SetNumAggregates(LO nAggregates)
Set number of local aggregates on current processor.
Teuchos::ArrayRCP< LO > ComputeAggregateSizes(bool forceRecompute=true, bool cacheSizes=false) const
Compute sizes of aggregates.