MueLu  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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>
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 = int, class GlobalOrdinal = LocalOrdinal, class Node = KokkosClassic::DefaultNode::DefaultNodeType>
100  class Aggregates : public BaseClass {
101 #undef MUELU_AGGREGATES_SHORT
103 
104  public:
105 
113  Aggregates(const GraphBase & graph);
114 
120  Aggregates(const RCP<const Map> & map);
121 
125  virtual ~Aggregates() { }
126 
127  LO GetNumAggregates() const { return nAggregates_; }
128 
133  void SetNumAggregates(LO nAggregates) { nAggregates_ = nAggregates; }
134 
140 
145  void SetIndexManager(RCP<IndexManager> & geoData) { geoData_ = geoData; }
146 
148  void AggregatesCrossProcessors(const bool &flag) {aggregatesIncludeGhosts_ = flag;};
149 
155 
161 
172 
177  const RCP<LOVector> & GetProcWinner() const { return procWinner_; }
178 
180  bool IsRoot(LO i) const { return isRoot_[i]; }
181 
186  void SetIsRoot(LO i, bool value=true) { isRoot_[i] = value; }
187 
188  const RCP<const Map> GetMap() const;
189 
199  Teuchos::ArrayRCP<LO> ComputeAggregateSizes(bool forceRecompute = false) const;
200 
202 
203 
205  std::string description() const;
206 
208  //using MueLu::Describable::describe; // overloading, not hiding
209  void print(Teuchos::FancyOStream &out, const Teuchos::EVerbosityLevel verbLevel = verbLevel_default) const;
210 
211  private:
213 
219 
225 
230 
231  Teuchos::ArrayRCP<bool> isRoot_;//< IsRoot[i] indicates whether vertex i is a root node.
232 
235 
238 
240  // 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.
241  GO GetNumGlobalAggregates() const;
242  };
243 
244 } //namespace MueLu
245 
246 #define MUELU_AGGREGATES_SHORT
247 #endif // MUELU_AGGREGATES_DECL_HPP
Teuchos::ArrayRCP< LO > aggregateSizes_
Array of sizes of each local aggregate.
virtual ~Aggregates()
Destructor.
const RCP< LOVector > & GetProcWinner() const
Returns constant vector that maps local node IDs to owning processor IDs.
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 AggregatesCrossProcessors() const
Return false if and only if no aggregates include DOFs from other processes.
GlobalOrdinal GO
const RCP< const Map > GetMap() const
returns (overlapping) map of aggregate/node distribution
LocalOrdinal LO
void SetIndexManager(RCP< IndexManager > &geoData)
Get the index manager used by structured aggregation algorithms.
void SetIsRoot(LO i, bool value=true)
Set root node information.
Teuchos::ArrayRCP< LO > ComputeAggregateSizes(bool forceRecompute=false) const
Compute sizes of aggregates.
GO GetNumGlobalAggregates() const
Get global number of aggregates.
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.
LO nAggregates_
Number of aggregates on this processor.
RCP< LOVector > & GetProcWinnerNonConst()
Returns nonconsant vector that maps local node IDs to owning processor IDs.
LO GetNumAggregates() const
returns the number of aggregates of the current processor. Note: could/should be renamed to GetNumLoc...
Teuchos::ArrayRCP< bool > isRoot_
const RCP< LOMultiVector > & GetVertex2AggId() const
Returns constant vector that maps local node IDs to local aggregates IDs.
static const EVerbosityLevel verbLevel_default
MueLu representation of a graph.
Base class for MueLu classes.
RCP< LOMultiVector > vertex2AggId_
bool IsRoot(LO i) const
Returns true if node with given local node id is marked to be a root node.
void print(Teuchos::FancyOStream &out, const Teuchos::EVerbosityLevel verbLevel=verbLevel_default) const
Print the object with some verbosity level to an FancyOStream object.
std::string description() const
Return a simple one-line description of this object.
void AggregatesCrossProcessors(const bool &flag)
Record whether aggregates include DOFs from other processes.
void SetNumAggregates(LO nAggregates)
Set number of local aggregates on current processor.