MueLu  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
MueLu_AggregationStructuredAlgorithm_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_AGGREGATIONSTRUCTUREDALGORITHM_DECL_HPP_
47 #define MUELU_AGGREGATIONSTRUCTUREDALGORITHM_DECL_HPP_
48 
49 #include "MueLu_ConfigDefs.hpp"
52 
53 #include "Xpetra_Vector.hpp"
54 
56 #include "MueLu_Aggregates_fwd.hpp"
59 #include "MueLu_LWGraph.hpp"
60 #include "MueLu_LWGraph_kokkos.hpp"
61 
62 namespace MueLu {
81 template <class LocalOrdinal = DefaultLocalOrdinal,
83  class Node = DefaultNode>
84 class AggregationStructuredAlgorithm : public MueLu::AggregationAlgorithmBase<LocalOrdinal, GlobalOrdinal, Node> {
85 #undef MUELU_AGGREGATIONSTRUCTUREDALGORITHM_SHORT
87 
88  public:
90  using non_const_row_map_type = typename local_graph_type::row_map_type::non_const_type;
91  using size_type = typename local_graph_type::size_type;
92  using entries_type = typename local_graph_type::entries_type;
93  using device_type = typename local_graph_type::device_type;
94  using execution_space = typename local_graph_type::device_type::execution_space;
95  using memory_space = typename local_graph_type::device_type::memory_space;
96 
97  using LOVectorView = decltype(std::declval<LOVector>().getDeviceLocalView(Xpetra::Access::ReadWrite));
98  using constIntTupleView = typename Kokkos::View<const int[3], device_type>;
99  using constLOTupleView = typename Kokkos::View<const LO[3], device_type>;
101 
102 
104  AggregationStructuredAlgorithm(const RCP<const FactoryBase>& /* graphFact */ = Teuchos::null) {}
105 
108 
110 
112 
113 
116  void BuildAggregatesNonKokkos(const Teuchos::ParameterList& params, const LWGraph& graph,
117  Aggregates& aggregates,
119  LO& numNonAggregatedNodes) const;
120 
123  void BuildGraphOnHost(const LWGraph& graph, RCP<IndexManager>& geoData, const LO dofsPerNode,
124  RCP<CrsGraph>& myGraph, RCP<const Map>& coarseCoordinatesFineMap,
125  RCP<const Map>& coarseCoordinatesMap) const;
126 
129  void BuildAggregates(const Teuchos::ParameterList& params,
130  const LWGraph_kokkos& graph,
131  Aggregates& aggregates,
133  LO& numNonAggregatedNodes) const;
134 
137  void BuildGraph(const LWGraph_kokkos& graph,
138  RCP<IndexManager_kokkos>& geoData,
139  const LO dofsPerNode,
140  RCP<CrsGraph>& myGraph) const;
142 
143  std::string description() const { return "Aggretation: structured algorithm"; }
144 
147  const int myRank_;
148  Kokkos::View<unsigned*, device_type> aggStat_;
151 
153  const int myRank,
154  Kokkos::View<unsigned*, device_type> aggStat,
155  LOVectorView vertex2AggID,
156  LOVectorView procWinner);
157 
158  KOKKOS_INLINE_FUNCTION
159  void operator()(const LO nodeIdx, LO& lNumAggregatedNodes) const;
160 
161  }; // struct fillAggregatesFunctor
162 
165  const int numGhostedNodes_;
172 
174  const LO numGhostedNodes, const LO dofsPerNode,
175  constIntTupleView coarseRate, constIntTupleView endRate,
176  constLOTupleView lFineNodesPerDir,
177  non_const_row_map_type rowPtr, entries_type colIndex);
178 
179  KOKKOS_INLINE_FUNCTION
180  void operator()(const LO nodeIdx) const;
181 
182  }; // struct computeGraphDataConstantFunctor
183 
192 
194  const LO dofsPerNode,
195  const int numInterpolationPoints, const LO numLocalRows,
196  constIntTupleView coarseRate, constLOTupleView lFineNodesPerDir,
197  non_const_row_map_type rowPtr);
198 
199  KOKKOS_INLINE_FUNCTION
200  void operator()(const LO rowIdx, GO& update, const bool final) const;
201  }; // struct computeGraphRowPtrFunctor
202 
205  const int numDimensions_;
206  const int numGhostedNodes_;
215 
217  const int numDimensions,
218  const LO numGhostedNodes, const LO dofsPerNode,
219  const int numInterpolationPoints,
220  constIntTupleView coarseRate, constIntTupleView endRate,
221  constLOTupleView lFineNodesPerDir,
222  constLOTupleView ghostedNodesPerDir,
223  non_const_row_map_type rowPtr, entries_type colIndex);
224 
225  KOKKOS_INLINE_FUNCTION
226  void operator()(const LO nodeIdx) const;
227 
228  }; // struct computeGraphDataLinearFunctor
229 
230  private:
231  void ComputeGraphDataConstant(const LWGraph& graph, RCP<IndexManager>& geoData,
232  const LO dofsPerNode, const int numInterpolationPoints,
233  ArrayRCP<size_t>& nnzOnRow, Array<size_t>& rowPtr,
234  Array<LO>& colIndex) const;
235 
236  void ComputeGraphDataLinear(const LWGraph& graph, RCP<IndexManager>& geoData,
237  const LO dofsPerNode, const int numInterpolationPoints,
238  ArrayRCP<size_t>& nnzOnRow, Array<size_t>& rowPtr,
239  Array<LO>& colIndex) const;
240 };
241 
242 } // namespace MueLu
243 
244 #define MUELU_AGGREGATIONSTRUCTUREDALGORITHM_SHORT
245 #endif /* MUELU_AGGREGATIONSTRUCTUREDALGORITHM_DECL_HPP_ */
Kokkos::View< unsigned *, typename LWGraphHostType::device_type > AggStatHostType
MueLu::DefaultLocalOrdinal LocalOrdinal
Lightweight MueLu representation of a compressed row storage graph.
Tpetra::KokkosClassic::DefaultNode::DefaultNodeType DefaultNode
void ComputeGraphDataConstant(const LWGraph &graph, RCP< IndexManager > &geoData, const LO dofsPerNode, const int numInterpolationPoints, ArrayRCP< size_t > &nnzOnRow, Array< size_t > &rowPtr, Array< LO > &colIndex) const
Container class for aggregation information.
typename std::conditional< OnHost, typename local_graph_device_type::HostMirror, local_graph_device_type >::type local_graph_type
fillAggregatesFunctor(RCP< IndexManager_kokkos > geoData, const int myRank, Kokkos::View< unsigned *, device_type > aggStat, LOVectorView vertex2AggID, LOVectorView procWinner)
GlobalOrdinal GO
decltype(std::declval< LOVector >().getDeviceLocalView(Xpetra::Access::ReadWrite)) LOVectorView
Algorithm for coarsening a graph with structured aggregation.
Pure virtual base class for all MueLu aggregation algorithms.
std::string description() const
Return a simple one-line description of this object.
typename Kokkos::View< const LO[3], device_type > constLOTupleView
LocalOrdinal LO
MueLu::DefaultNode Node
computeGraphRowPtrFunctor(RCP< IndexManager_kokkos > geoData, const LO dofsPerNode, const int numInterpolationPoints, const LO numLocalRows, constIntTupleView coarseRate, constLOTupleView lFineNodesPerDir, non_const_row_map_type rowPtr)
typename local_graph_type::device_type::memory_space memory_space
typename local_graph_type::device_type::execution_space execution_space
computeGraphDataLinearFunctor(RCP< IndexManager_kokkos > geoData, const int numDimensions, const LO numGhostedNodes, const LO dofsPerNode, const int numInterpolationPoints, constIntTupleView coarseRate, constIntTupleView endRate, constLOTupleView lFineNodesPerDir, constLOTupleView ghostedNodesPerDir, non_const_row_map_type rowPtr, entries_type colIndex)
MueLu::DefaultGlobalOrdinal GlobalOrdinal
void BuildGraphOnHost(const LWGraph &graph, RCP< IndexManager > &geoData, const LO dofsPerNode, RCP< CrsGraph > &myGraph, RCP< const Map > &coarseCoordinatesFineMap, RCP< const Map > &coarseCoordinatesMap) const
Local aggregation.
AggregationStructuredAlgorithm(const RCP< const FactoryBase > &=Teuchos::null)
Constructor.
void BuildAggregates(const Teuchos::ParameterList &params, const LWGraph_kokkos &graph, Aggregates &aggregates, typename AggregationAlgorithmBase< LocalOrdinal, GlobalOrdinal, Node >::AggStatType &aggStat, LO &numNonAggregatedNodes) const
Build aggregates object.
typename local_graph_type::row_map_type::non_const_type non_const_row_map_type
KOKKOS_INLINE_FUNCTION void operator()(const LO rowIdx, GO &update, const bool final) const
typename LWGraph_kokkos::local_graph_type local_graph_type
KOKKOS_INLINE_FUNCTION void operator()(const LO nodeIdx, LO &lNumAggregatedNodes) const
void BuildAggregatesNonKokkos(const Teuchos::ParameterList &params, const LWGraph &graph, Aggregates &aggregates, typename AggregationAlgorithmBase< LocalOrdinal, GlobalOrdinal, Node >::AggStatHostType &aggStat, LO &numNonAggregatedNodes) const
Local aggregation.
computeGraphDataConstantFunctor(RCP< IndexManager_kokkos > geoData, const LO numGhostedNodes, const LO dofsPerNode, constIntTupleView coarseRate, constIntTupleView endRate, constLOTupleView lFineNodesPerDir, non_const_row_map_type rowPtr, entries_type colIndex)
Lightweight MueLu representation of a compressed row storage graph.
Container class for mesh layout and indices calculation.
void ComputeGraphDataLinear(const LWGraph &graph, RCP< IndexManager > &geoData, const LO dofsPerNode, const int numInterpolationPoints, ArrayRCP< size_t > &nnzOnRow, Array< size_t > &rowPtr, Array< LO > &colIndex) const
void BuildGraph(const LWGraph_kokkos &graph, RCP< IndexManager_kokkos > &geoData, const LO dofsPerNode, RCP< CrsGraph > &myGraph) const
Build a CrsGraph instead of aggregates.
typename Kokkos::View< const int[3], device_type > constIntTupleView
Kokkos::View< unsigned *, typename LWGraphType::device_type > AggStatType