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 = 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 
139  RCP<IndexManager>& GetIndexManager() { return geoData_; }
140 
145  void SetIndexManager(RCP<IndexManager> & geoData) { geoData_ = geoData; }
146 
148  void AggregatesCrossProcessors(const bool &flag) {aggregatesIncludeGhosts_ = flag;};
149 
155 
160  RCP<LOMultiVector> & GetVertex2AggIdNonConst() { return vertex2AggId_; }
161 
166  RCP<LOVector> & GetProcWinnerNonConst() { return procWinner_; }
171  const RCP<LOMultiVector> & GetVertex2AggId() const { return vertex2AggId_; }
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 
218  RCP<LOMultiVector> vertex2AggId_;
219 
224  RCP<LOVector> procWinner_;
225 
229  RCP<IndexManager> geoData_;
230 
231  Teuchos::ArrayRCP<bool> isRoot_;//< IsRoot[i] indicates whether vertex i is a root node.
232 
235 
237  mutable Teuchos::ArrayRCP<LO> aggregateSizes_;
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
MueLu_ConfigDefs.hpp
MueLu::Aggregates::GetProcWinner
const RCP< LOVector > & GetProcWinner() const
Returns constant vector that maps local node IDs to owning processor IDs.
Definition: MueLu_Aggregates_decl.hpp:177
MueLu::Aggregates::AggregatesCrossProcessors
void AggregatesCrossProcessors(const bool &flag)
Record whether aggregates include DOFs from other processes.
Definition: MueLu_Aggregates_decl.hpp:148
MueLu::Aggregates::SetIndexManager
void SetIndexManager(RCP< IndexManager > &geoData)
Get the index manager used by structured aggregation algorithms.
Definition: MueLu_Aggregates_decl.hpp:145
MueLu::Aggregates::GetProcWinnerNonConst
RCP< LOVector > & GetProcWinnerNonConst()
Returns nonconsant vector that maps local node IDs to owning processor IDs.
Definition: MueLu_Aggregates_decl.hpp:166
MueLu::Aggregates::isRoot_
Teuchos::ArrayRCP< bool > isRoot_
Definition: MueLu_Aggregates_decl.hpp:231
MueLu::Aggregates::description
std::string description() const
Return a simple one-line description of this object.
Definition: MueLu_Aggregates_def.hpp:130
MueLu::Aggregates::~Aggregates
virtual ~Aggregates()
Destructor.
Definition: MueLu_Aggregates_decl.hpp:125
MueLu::Aggregates::GetMap
const RCP< const Map > GetMap() const
returns (overlapping) map of aggregate/node distribution
Definition: MueLu_Aggregates_def.hpp:153
MueLu::Aggregates::AggregatesCrossProcessors
bool AggregatesCrossProcessors() const
Return false if and only if no aggregates include DOFs from other processes.
Definition: MueLu_Aggregates_decl.hpp:154
MueLu::Aggregates::geoData_
RCP< IndexManager > geoData_
Definition: MueLu_Aggregates_decl.hpp:229
MueLu::Aggregates::aggregatesIncludeGhosts_
bool aggregatesIncludeGhosts_
Set to false iff aggregates do not include any DOFs belong to other processes.
Definition: MueLu_Aggregates_decl.hpp:234
MueLu::Aggregates::SetIsRoot
void SetIsRoot(LO i, bool value=true)
Set root node information.
Definition: MueLu_Aggregates_decl.hpp:186
MueLu::Aggregates::GetVertex2AggIdNonConst
RCP< LOMultiVector > & GetVertex2AggIdNonConst()
Returns a nonconstant vector that maps local node IDs to local aggregates IDs.
Definition: MueLu_Aggregates_decl.hpp:160
MueLu::Aggregates::IsRoot
bool IsRoot(LO i) const
Returns true if node with given local node id is marked to be a root node.
Definition: MueLu_Aggregates_decl.hpp:180
MueLu
Namespace for MueLu classes and methods.
Definition: MueLu_BrickAggregationFactory_decl.hpp:76
MueLu::Aggregates::aggregateSizes_
Teuchos::ArrayRCP< LO > aggregateSizes_
Array of sizes of each local aggregate.
Definition: MueLu_Aggregates_decl.hpp:237
MueLu::Aggregates::GetNumGlobalAggregates
GO GetNumGlobalAggregates() const
Get global number of aggregates.
Definition: MueLu_Aggregates_def.hpp:146
MueLu::BaseClass
Base class for MueLu classes.
Definition: MueLu_BaseClass.hpp:61
MueLu::GraphBase
MueLu representation of a graph.
Definition: MueLu_GraphBase.hpp:67
MueLu_Aggregates_fwd.hpp
MueLu::Aggregates::GetVertex2AggId
const RCP< LOMultiVector > & GetVertex2AggId() const
Returns constant vector that maps local node IDs to local aggregates IDs.
Definition: MueLu_Aggregates_decl.hpp:171
MueLu::Aggregates::procWinner_
RCP< LOVector > procWinner_
Definition: MueLu_Aggregates_decl.hpp:224
MueLu::Aggregates::nAggregates_
LO nAggregates_
Number of aggregates on this processor.
Definition: MueLu_Aggregates_decl.hpp:212
MueLu::Aggregates::GetIndexManager
RCP< IndexManager > & GetIndexManager()
Get the index manager used by structured aggregation algorithms.
Definition: MueLu_Aggregates_decl.hpp:139
MueLu::Aggregates
Container class for aggregation information.
Definition: MueLu_Aggregates_decl.hpp:100
MueLu::Aggregates::GetNumAggregates
LO GetNumAggregates() const
returns the number of aggregates of the current processor. Note: could/should be renamed to GetNumLoc...
Definition: MueLu_Aggregates_decl.hpp:127
MueLu::Aggregates::ComputeAggregateSizes
Teuchos::ArrayRCP< LO > ComputeAggregateSizes(bool forceRecompute=false) const
Compute sizes of aggregates.
Definition: MueLu_Aggregates_def.hpp:99
MueLu_Graph_fwd.hpp
MueLu::Aggregates::print
void print(Teuchos::FancyOStream &out, const Teuchos::EVerbosityLevel verbLevel=verbLevel_default) const
Print the object with some verbosity level to an FancyOStream object.
Definition: MueLu_Aggregates_def.hpp:138
MueLu::Aggregates::vertex2AggId_
RCP< LOMultiVector > vertex2AggId_
Definition: MueLu_Aggregates_decl.hpp:218
MueLu_GraphBase.hpp
MueLu_UseShortNamesOrdinal.hpp
MueLu::Aggregates::SetNumAggregates
void SetNumAggregates(LO nAggregates)
Set number of local aggregates on current processor.
Definition: MueLu_Aggregates_decl.hpp:133
MueLu::Aggregates::Aggregates
Aggregates(const GraphBase &graph)
Standard constructor for Aggregates structure.
Definition: MueLu_Aggregates_def.hpp:65
MueLu_BaseClass.hpp