MueLu  Version of the Day
MueLu_Aggregates_kokkos_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 // Tobias Wiesner (tawiesn@sandia.gov)
43 //
44 // ***********************************************************************
45 //
46 // @HEADER
47 #ifndef MUELU_AGGREGATES_KOKKOS_DECL_HPP
48 #define MUELU_AGGREGATES_KOKKOS_DECL_HPP
49 
50 #ifdef HAVE_MUELU_KOKKOS_REFACTOR
51 
52 #include <Xpetra_Map_fwd.hpp>
53 #include <Xpetra_Vector_fwd.hpp>
54 #include <Xpetra_VectorFactory_fwd.hpp>
55 
56 #include "MueLu_ConfigDefs.hpp"
57 #include "MueLu_BaseClass.hpp"
58 #include "MueLu_Aggregates_fwd.hpp"
59 
60 #include "MueLu_Graph_fwd.hpp"
61 #include "MueLu_GraphBase.hpp"
62 
63 #define MUELU_UNAGGREGATED -1 /* indicates that a node is unassigned to */
64  /* any aggregate. */
65 
66 #define MUELU_UNASSIGNED -1 /* indicates a vertex is not yet claimed */
67  /* by a processor during aggregation. */
68  /* Note, it is possible at */
69  /* this stage that some processors may have*/
70  /* claimed their copy of a vertex for one */
71  /* of their aggregates. However, some */
72  /* arbitration still needs to occur. */
73  /* The corresponding procWinner[]'s remain */
74  /* as MUELU_UNASSIGNED until */
75  /* ArbitrateAndCommunicate() is */
76  /* invoked to arbitrate. */
77 
78 /*****************************************************************************
79 
80 ****************************************************************************/
81 
82 namespace MueLu {
83 
100  template <class LocalOrdinal = int, class GlobalOrdinal = LocalOrdinal, class Node = KokkosClassic::DefaultNode::DefaultNodeType>
101  class Aggregates_kokkos : public BaseClass {
102 #undef MUELU_AGGREGATES_KOKKOS_SHORT
104 
105  public:
106 
114  Aggregates_kokkos(const GraphBase & graph);
115 
121  Aggregates_kokkos(const RCP<const Map> & map);
122 
126  virtual ~Aggregates_kokkos() { }
127 
128  LO GetNumAggregates() const { return nAggregates_; }
129 
134  void SetNumAggregates(LO nAggregates) { nAggregates_ = nAggregates; }
135 
137  void AggregatesCrossProcessors(const bool &flag) {aggregatesIncludeGhosts_ = flag;};
138 
143  bool AggregatesCrossProcessors() const {return aggregatesIncludeGhosts_;};
144 
149  RCP<LOVector> & GetVertex2AggIdNonConst() { return vertex2AggId_; }
150 
155  RCP<LOVector> & GetProcWinnerNonConst() { return procWinner_; }
160  const RCP<LOVector> & GetVertex2AggId() const { return vertex2AggId_; }
161 
166  const RCP<LOVector> & GetProcWinner() const { return procWinner_; }
167 
169  bool IsRoot(LO i) const { return isRoot_[i]; }
170 
175  void SetIsRoot(LO i, bool value=true) { isRoot_[i] = value; }
176 
177  const RCP<const Map> GetMap() const;
178 
192  Teuchos::ArrayRCP<LO> ComputeAggregateSizes(bool forceRecompute=true, bool cacheSizes=false) const;
193 
195 
196 
198  std::string description() const;
199 
201  //using MueLu::Describable::describe; // overloading, not hiding
202  void print(Teuchos::FancyOStream &out, const Teuchos::EVerbosityLevel verbLevel = verbLevel_default) const;
203 
204  private:
205  LO nAggregates_;
206 
211  RCP<LOVector> vertex2AggId_;
212 
217  RCP<LOVector> procWinner_;
218 
219  Teuchos::ArrayRCP<bool> isRoot_;//< IsRoot[i] indicates whether vertex i is a root node.
220 
222  bool aggregatesIncludeGhosts_;
223 
225  mutable Teuchos::ArrayRCP<LO> aggregateSizes_;
226 
228  // 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.
229  GO GetNumGlobalAggregates() const;
230  };
231 
232 } //namespace MueLu
233 
234 #endif // HAVE_MUELU_KOKKOS_REFACTOR
235 
236 #define MUELU_AGGREGATES_KOKKOS_SHORT
237 #endif // MUELU_AGGREGATES_KOKKOS_DECL_HPP
Namespace for MueLu classes and methods.