MueLu  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
MueLu_VectorDroppingDistanceLaplacian_decl.hpp
Go to the documentation of this file.
1 // @HEADER
2 // *****************************************************************************
3 // MueLu: A package for multigrid based preconditioning
4 //
5 // Copyright 2012 NTESS and the MueLu contributors.
6 // SPDX-License-Identifier: BSD-3-Clause
7 // *****************************************************************************
8 // @HEADER
9 
10 #ifndef MUELU_VECTORDROPPINGDISTANCELAPLACIAN_DECL_HPP
11 #define MUELU_VECTORDROPPINGDISTANCELAPLACIAN_DECL_HPP
12 
16 #include "MueLu_CutDrop.hpp"
17 #include "MueLu_DroppingCommon.hpp"
20 #include "MueLu_Utilities.hpp"
21 
22 namespace MueLu {
23 
24 template <class Scalar, class LocalOrdinal, class GlobalOrdinal, class Node, Misc::StrengthMeasure SoC>
25 class VectorDroppingDistanceLaplacian : public VectorDroppingBase<Scalar, LocalOrdinal, GlobalOrdinal, Node> {
26  public:
30  using local_matrix_type = typename crs_matrix_type::local_matrix_type;
31  using local_graph_type = typename GraphType::local_graph_type;
32  using rowptr_type = typename local_graph_type::row_map_type::non_const_type;
33  using device_type = typename Node::device_type;
34  using memory_space = typename device_type::memory_space;
35  using results_view = Kokkos::View<DecisionType*, memory_space>;
39  using nnz_count_type = Kokkos::pair<LocalOrdinal, LocalOrdinal>;
40  using block_indices_view_type = typename Kokkos::View<LocalOrdinal*, typename Node::device_type>;
41 
42  template <class DistanceFunctorType>
44  matrix_type& mergedA,
45  typename matrix_type::local_ordinal_type blkPartSize,
46  block_indices_view_type& rowTranslation,
47  block_indices_view_type& colTranslation,
48  results_view& results,
49  rowptr_type& filtered_rowptr,
50  rowptr_type& graph_rowptr,
51  nnz_count_type& nnz,
52  boundary_nodes_type& boundaryNodes,
53  const std::string& droppingMethod,
54  const magnitudeType threshold,
55  const bool aggregationMayCreateDirichlet,
56  const bool symmetrizeDroppedGraph,
57  const bool useBlocking,
58  DistanceFunctorType& dist2,
59  Level& level,
60  const Factory& factory) {
61  auto lclA = A.getLocalMatrixDevice();
62  auto preserve_diagonals = Misc::KeepDiagonalFunctor(lclA, results);
63  auto mark_singletons_as_boundary = Misc::MarkSingletonVectorFunctor(lclA, rowTranslation, boundaryNodes, results);
64 
65  if (droppingMethod == "point-wise") {
66  auto dist_laplacian_dropping = DistanceLaplacian::make_vector_drop_functor<SoC>(A, mergedA, threshold, dist2, results, rowTranslation, colTranslation);
67 
68  if (aggregationMayCreateDirichlet) {
69  if (symmetrizeDroppedGraph) {
70  auto drop_boundaries = Misc::VectorSymmetricDropBoundaryFunctor(mergedA, rowTranslation, colTranslation, boundaryNodes, results);
71  VectorDroppingDistanceLaplacian::runDroppingFunctors(A, mergedA, blkPartSize, rowTranslation, colTranslation, results, filtered_rowptr, graph_rowptr, nnz, useBlocking, level, factory,
72  dist_laplacian_dropping,
73  drop_boundaries,
74  preserve_diagonals,
75  mark_singletons_as_boundary);
76  } else {
77  auto drop_boundaries = Misc::VectorDropBoundaryFunctor(lclA, rowTranslation, boundaryNodes, results);
78  VectorDroppingDistanceLaplacian::runDroppingFunctors(A, mergedA, blkPartSize, rowTranslation, colTranslation, results, filtered_rowptr, graph_rowptr, nnz, useBlocking, level, factory,
79  dist_laplacian_dropping,
80  drop_boundaries,
81  preserve_diagonals,
82  mark_singletons_as_boundary);
83  }
84  } else {
85  if (symmetrizeDroppedGraph) {
86  auto drop_boundaries = Misc::VectorSymmetricDropBoundaryFunctor(mergedA, rowTranslation, colTranslation, boundaryNodes, results);
87  VectorDroppingDistanceLaplacian::runDroppingFunctors(A, mergedA, blkPartSize, rowTranslation, colTranslation, results, filtered_rowptr, graph_rowptr, nnz, useBlocking, level, factory,
88  dist_laplacian_dropping,
89  drop_boundaries,
90  preserve_diagonals);
91  } else {
92  auto drop_boundaries = Misc::VectorDropBoundaryFunctor(lclA, rowTranslation, boundaryNodes, results);
93  VectorDroppingDistanceLaplacian::runDroppingFunctors(A, mergedA, blkPartSize, rowTranslation, colTranslation, results, filtered_rowptr, graph_rowptr, nnz, useBlocking, level, factory,
94  dist_laplacian_dropping,
95  drop_boundaries,
96  preserve_diagonals);
97  }
98  }
99  } else if (droppingMethod == "cut-drop") {
100  auto comparison = CutDrop::make_dlap_comparison_functor<SoC>(A, dist2, results);
101  auto cut_drop = CutDrop::CutDropFunctor(comparison, threshold);
102 
103  if (symmetrizeDroppedGraph) {
104  auto drop_boundaries = Misc::VectorSymmetricDropBoundaryFunctor(mergedA, rowTranslation, colTranslation, boundaryNodes, results);
105  VectorDroppingDistanceLaplacian::runDroppingFunctors(A, mergedA, blkPartSize, rowTranslation, colTranslation, results, filtered_rowptr, graph_rowptr, nnz, useBlocking, level, factory,
106  drop_boundaries,
107  preserve_diagonals,
108  cut_drop);
109  } else {
110  auto drop_boundaries = Misc::VectorDropBoundaryFunctor(lclA, rowTranslation, boundaryNodes, results);
111  VectorDroppingDistanceLaplacian::runDroppingFunctors(A, mergedA, blkPartSize, rowTranslation, colTranslation, results, filtered_rowptr, graph_rowptr, nnz, useBlocking, level, factory,
112  drop_boundaries,
113  preserve_diagonals,
114  cut_drop);
115  }
116  }
117  }
118 
120  matrix_type& mergedA,
121  LocalOrdinal blkPartSize,
122  block_indices_view_type& rowTranslation,
123  block_indices_view_type& colTranslation,
124  results_view& results,
125  rowptr_type& filtered_rowptr,
126  rowptr_type& graph_rowptr,
127  nnz_count_type& nnz,
128  boundary_nodes_type& boundaryNodes,
129  const std::string& droppingMethod,
130  const magnitudeType threshold,
131  const bool aggregationMayCreateDirichlet,
132  const bool symmetrizeDroppedGraph,
133  const bool useBlocking,
134  const std::string& distanceLaplacianMetric,
135  Teuchos::Array<double>& dlap_weights,
136  LocalOrdinal interleaved_blocksize,
137  Level& level,
138  const Factory& factory);
139 };
140 
141 } // namespace MueLu
142 #endif
MueLu::DefaultLocalOrdinal LocalOrdinal
static void runDroppingFunctors_on_dlap_inner(matrix_type &A, matrix_type &mergedA, typename matrix_type::local_ordinal_type blkPartSize, block_indices_view_type &rowTranslation, block_indices_view_type &colTranslation, results_view &results, rowptr_type &filtered_rowptr, rowptr_type &graph_rowptr, nnz_count_type &nnz, boundary_nodes_type &boundaryNodes, const std::string &droppingMethod, const magnitudeType threshold, const bool aggregationMayCreateDirichlet, const bool symmetrizeDroppedGraph, const bool useBlocking, DistanceFunctorType &dist2, Level &level, const Factory &factory)
typename device_type::memory_space memory_space
Functor that drops boundary nodes for a blockSize &gt; 1 problem.
typename Teuchos::ScalarTraits< Scalar >::magnitudeType magnitudeType
Functor that marks singletons (all off-diagonal entries in a row are dropped) as boundary.
Kokkos::View< DecisionType *, memory_space > results_view
typename Node::device_type device_type
typename GraphType::local_graph_type local_graph_type
Kokkos::View< DecisionType *, memory_space > results_view
Class that holds all level-specific information.
Definition: MueLu_Level.hpp:63
typename local_graph_type::row_map_type::non_const_type rowptr_type
typename local_graph_type::row_map_type::non_const_type rowptr_type
Kokkos::pair< LocalOrdinal, LocalOrdinal > nnz_count_type
Order each row by a criterion, compare the ratio of values and drop all entries once the ratio is bel...
static void runDroppingFunctors_on_dlap(matrix_type &A, matrix_type &mergedA, LocalOrdinal blkPartSize, block_indices_view_type &rowTranslation, block_indices_view_type &colTranslation, results_view &results, rowptr_type &filtered_rowptr, rowptr_type &graph_rowptr, nnz_count_type &nnz, boundary_nodes_type &boundaryNodes, const std::string &droppingMethod, const magnitudeType threshold, const bool aggregationMayCreateDirichlet, const bool symmetrizeDroppedGraph, const bool useBlocking, const std::string &distanceLaplacianMetric, Teuchos::Array< double > &dlap_weights, LocalOrdinal interleaved_blocksize, Level &level, const Factory &factory)
Functor that marks diagonal as kept, unless the are already marked as boundary.
static void runDroppingFunctors(matrix_type &A, matrix_type &mergedA, typename matrix_type::local_ordinal_type &blkPartSize, block_indices_view_type &rowTranslation, block_indices_view_type &colTranslation, results_view &results, rowptr_type &filtered_rowptr, rowptr_type &graph_rowptr, nnz_count_type &nnz, const bool useBlocking, Level &level, const Factory &factory, Functors &...functors)
typename crs_matrix_type::local_matrix_type local_matrix_type
Functor that drops boundary nodes for a blockSize &gt; 1 problem.
typename Kokkos::View< LocalOrdinal *, typename Node::device_type > block_indices_view_type
Xpetra::Matrix< Scalar, LocalOrdinal, GlobalOrdinal, Node > matrix_type
Kokkos::pair< LocalOrdinal, LocalOrdinal > nnz_count_type
typename Kokkos::View< LocalOrdinal *, typename Node::device_type > block_indices_view_type
typename MueLu::LWGraph_kokkos< LocalOrdinal, GlobalOrdinal, Node >::boundary_nodes_type boundary_nodes_type