MueLu  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
MueLu_ScalarDroppingDistanceLaplacian_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_SCALARDROPPINGDISTANCELAPLACIAN_DECL_HPP
11 #define MUELU_SCALARDROPPINGDISTANCELAPLACIAN_DECL_HPP
12 
14 #include "MueLu_CutDrop.hpp"
15 #include "MueLu_DroppingCommon.hpp"
18 #include "MueLu_Utilities.hpp"
19 #include "MueLu_LWGraph_kokkos.hpp"
20 
21 namespace MueLu {
22 
23 template <class Scalar, class LocalOrdinal, class GlobalOrdinal, class Node, Misc::StrengthMeasure SoC>
24 class ScalarDroppingDistanceLaplacian : public ScalarDroppingBase<Scalar, LocalOrdinal, GlobalOrdinal, Node> {
25  public:
29  using local_matrix_type = typename crs_matrix_type::local_matrix_type;
30  using local_graph_type = typename GraphType::local_graph_type;
31  using rowptr_type = typename local_graph_type::row_map_type::non_const_type;
32  using entries_type = typename local_graph_type::entries_type::non_const_type;
33  using values_type = typename local_matrix_type::values_type::non_const_type;
34  using device_type = typename Node::device_type;
35  using memory_space = typename device_type::memory_space;
36  using results_view = Kokkos::View<DecisionType*, memory_space>;
40 
41  template <class DistanceFunctorType>
43  results_view& results,
44  rowptr_type& filtered_rowptr,
45  LocalOrdinal& nnz_filtered,
46  boundary_nodes_type& boundaryNodes,
47  const std::string& droppingMethod,
48  const magnitudeType threshold,
49  const bool aggregationMayCreateDirichlet,
50  const bool symmetrizeDroppedGraph,
51  const bool useBlocking,
52  DistanceFunctorType& dist2,
53  Level& level,
54  const Factory& factory) {
55  auto lclA = A.getLocalMatrixDevice();
56  auto preserve_diagonals = Misc::KeepDiagonalFunctor(lclA, results);
57 
58  if (droppingMethod == "point-wise") {
59  auto dist_laplacian_dropping = DistanceLaplacian::make_drop_functor<SoC>(A, threshold, dist2, results);
60 
61  if (aggregationMayCreateDirichlet) {
62  auto mark_singletons_as_boundary = Misc::MarkSingletonFunctor(lclA, boundaryNodes, results);
63 
64  if (symmetrizeDroppedGraph) {
65  auto drop_boundaries = Misc::PointwiseSymmetricDropBoundaryFunctor(A, boundaryNodes, results);
66  ScalarDroppingDistanceLaplacian::runDroppingFunctors(A, results, filtered_rowptr, nnz_filtered, useBlocking, level, factory,
67  dist_laplacian_dropping,
68  drop_boundaries,
69  preserve_diagonals,
70  mark_singletons_as_boundary);
71  } else {
72  auto drop_boundaries = Misc::PointwiseDropBoundaryFunctor(lclA, boundaryNodes, results);
73  ScalarDroppingDistanceLaplacian::runDroppingFunctors(A, results, filtered_rowptr, nnz_filtered, useBlocking, level, factory,
74  dist_laplacian_dropping,
75  drop_boundaries,
76  preserve_diagonals,
77  mark_singletons_as_boundary);
78  }
79  } else {
80  if (symmetrizeDroppedGraph) {
81  auto drop_boundaries = Misc::PointwiseSymmetricDropBoundaryFunctor(A, boundaryNodes, results);
82  ScalarDroppingDistanceLaplacian::runDroppingFunctors(A, results, filtered_rowptr, nnz_filtered, useBlocking, level, factory,
83  dist_laplacian_dropping,
84  drop_boundaries,
85  preserve_diagonals);
86  } else {
87  auto drop_boundaries = Misc::PointwiseDropBoundaryFunctor(lclA, boundaryNodes, results);
88  ScalarDroppingDistanceLaplacian::runDroppingFunctors(A, results, filtered_rowptr, nnz_filtered, useBlocking, level, factory,
89  dist_laplacian_dropping,
90  drop_boundaries,
91  preserve_diagonals);
92  }
93  }
94  } else if (droppingMethod == "cut-drop") {
95  auto comparison = CutDrop::make_dlap_comparison_functor<SoC>(A, dist2, results);
96  auto cut_drop = CutDrop::CutDropFunctor(comparison, threshold);
97 
98  if (symmetrizeDroppedGraph) {
99  auto drop_boundaries = Misc::PointwiseSymmetricDropBoundaryFunctor(A, boundaryNodes, results);
100  ScalarDroppingDistanceLaplacian::runDroppingFunctors(A, results, filtered_rowptr, nnz_filtered, useBlocking, level, factory,
101  drop_boundaries,
102  preserve_diagonals,
103  cut_drop);
104  } else {
105  auto drop_boundaries = Misc::PointwiseDropBoundaryFunctor(lclA, boundaryNodes, results);
106  ScalarDroppingDistanceLaplacian::runDroppingFunctors(A, results, filtered_rowptr, nnz_filtered, useBlocking, level, factory,
107  drop_boundaries,
108  preserve_diagonals,
109  cut_drop);
110  }
111  }
112  }
113 
115  results_view& results,
116  rowptr_type& filtered_rowptr,
117  LocalOrdinal& nnz_filtered,
118  boundary_nodes_type& boundaryNodes,
119  const std::string& droppingMethod,
120  const magnitudeType threshold,
121  const bool aggregationMayCreateDirichlet,
122  const bool symmetrizeDroppedGraph,
123  const bool useBlocking,
124  const std::string& distanceLaplacianMetric,
125  Level& level,
126  const Factory& factory);
127 };
128 
129 } // namespace MueLu
130 #endif
typename local_matrix_type::values_type::non_const_type values_type
typename device_type::memory_space memory_space
MueLu::DefaultLocalOrdinal LocalOrdinal
typename Teuchos::ScalarTraits< Scalar >::magnitudeType magnitudeType
typename crs_matrix_type::local_matrix_type local_matrix_type
static void runDroppingFunctors_on_dlap_inner(matrix_type &A, results_view &results, rowptr_type &filtered_rowptr, LocalOrdinal &nnz_filtered, 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)
Kokkos::View< DecisionType *, memory_space > results_view
static void runDroppingFunctors(matrix_type &A, results_view &results, rowptr_type &filtered_rowptr, LocalOrdinal &nnz_filtered, const bool useBlocking, Level &level, const Factory &factory, Functors &...functors)
typename local_graph_type::row_map_type::non_const_type rowptr_type
typename MueLu::LWGraph_kokkos< LocalOrdinal, GlobalOrdinal, Node >::boundary_nodes_type boundary_nodes_type
Functor that drops boundary nodes for a blockSize == 1 problem.
typename Node::device_type device_type
Functor that marks singletons (all off-diagonal entries in a row are dropped) as boundary.
Functor that drops boundary nodes for a blockSize == 1 problem.
Class that holds all level-specific information.
Definition: MueLu_Level.hpp:63
Xpetra::Matrix< Scalar, LocalOrdinal, GlobalOrdinal, Node > matrix_type
Order each row by a criterion, compare the ratio of values and drop all entries once the ratio is bel...
typename GraphType::local_graph_type local_graph_type
Functor that marks diagonal as kept, unless the are already marked as boundary.
static void runDroppingFunctors_on_dlap(matrix_type &A, results_view &results, rowptr_type &filtered_rowptr, LocalOrdinal &nnz_filtered, boundary_nodes_type &boundaryNodes, const std::string &droppingMethod, const magnitudeType threshold, const bool aggregationMayCreateDirichlet, const bool symmetrizeDroppedGraph, const bool useBlocking, const std::string &distanceLaplacianMetric, Level &level, const Factory &factory)
Kokkos::View< DecisionType *, memory_space > results_view
typename local_graph_type::row_map_type::non_const_type rowptr_type
typename local_graph_type::entries_type::non_const_type entries_type