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>
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 
142 
147  void SetIndexManager(RCP<IndexManager> & geoData) { geoData_ = geoData; }
148 
150  void AggregatesCrossProcessors(const bool &flag) {aggregatesIncludeGhosts_ = flag;};
151 
157 
163 
174 
179  const RCP<LOVector> & GetProcWinner() const { return procWinner_; }
180 
182  bool IsRoot(LO i) const { return isRoot_[i]; }
183 
188  void SetIsRoot(LO i, bool value=true) { isRoot_[i] = value; }
189 
190  const RCP<const Map> GetMap() const;
191 
201  Teuchos::ArrayRCP<LO> ComputeAggregateSizes(bool forceRecompute = false) const;
202 
204 
205 
207  std::string description() const;
208 
210  //using MueLu::Describable::describe; // overloading, not hiding
211  void print(Teuchos::FancyOStream &out, const Teuchos::EVerbosityLevel verbLevel = verbLevel_default) const;
212 
213  private:
215 
221 
227 
232 
233  Teuchos::ArrayRCP<bool> isRoot_;//< IsRoot[i] indicates whether vertex i is a root node.
234 
237 
240 
242  // 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.
243  GO GetNumGlobalAggregates() const;
244  };
245 
246 } //namespace MueLu
247 
248 #define MUELU_AGGREGATES_SHORT
249 #endif // MUELU_AGGREGATES_DECL_HPP
Teuchos::ArrayRCP< LO > aggregateSizes_
Array of sizes of each local aggregate.
virtual ~Aggregates()
Destructor.
MueLu::DefaultLocalOrdinal LocalOrdinal
KokkosClassic::DefaultNode::DefaultNodeType DefaultNode
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.
const RCP< const Map > GetMap() const
returns (overlapping) map of aggregate/node distribution
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.
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.
MueLu::DefaultGlobalOrdinal GlobalOrdinal
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.