MueLu  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
MueLu_VectorDroppingClassical_def.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_VECTORDROPPINGCLASSICAL_DEF_HPP
11 #define MUELU_VECTORDROPPINGCLASSICAL_DEF_HPP
12 
14 
15 namespace MueLu {
16 template <class Scalar, class LocalOrdinal, class GlobalOrdinal, class Node, Misc::StrengthMeasure SoC>
18  matrix_type& mergedA,
19  LocalOrdinal blkPartSize,
20  block_indices_view_type& rowTranslation,
21  block_indices_view_type& colTranslation,
22  results_view& results,
23  rowptr_type& filtered_rowptr,
24  rowptr_type& graph_rowptr,
25  nnz_count_type& nnz,
26  boundary_nodes_type& boundaryNodes,
27  const std::string& droppingMethod,
28  const magnitudeType threshold,
29  const bool aggregationMayCreateDirichlet,
30  const bool symmetrizeDroppedGraph,
31  const bool useBlocking,
32  Level& level,
33  const Factory& factory) {
34  auto lclA = A.getLocalMatrixDevice();
35  auto preserve_diagonals = Misc::KeepDiagonalFunctor(lclA, results);
36  auto mark_singletons_as_boundary = Misc::MarkSingletonVectorFunctor(lclA, rowTranslation, boundaryNodes, results);
37 
38  if (droppingMethod == "point-wise") {
39  auto dropping = ClassicalDropping::make_drop_functor<SoC>(A, threshold, results);
40 
41  if (aggregationMayCreateDirichlet) {
42  if (symmetrizeDroppedGraph) {
43  auto drop_boundaries = Misc::VectorSymmetricDropBoundaryFunctor(mergedA, rowTranslation, colTranslation, boundaryNodes, results);
44  VectorDroppingClassical::runDroppingFunctors(A, mergedA, blkPartSize, rowTranslation, colTranslation, results, filtered_rowptr, graph_rowptr, nnz, useBlocking, level, factory,
45  dropping,
46  drop_boundaries,
47  preserve_diagonals,
48  mark_singletons_as_boundary);
49  } else {
50  auto drop_boundaries = Misc::VectorDropBoundaryFunctor(lclA, rowTranslation, boundaryNodes, results);
51  VectorDroppingClassical::runDroppingFunctors(A, mergedA, blkPartSize, rowTranslation, colTranslation, results, filtered_rowptr, graph_rowptr, nnz, useBlocking, level, factory,
52  dropping,
53  drop_boundaries,
54  preserve_diagonals,
55  mark_singletons_as_boundary);
56  }
57  } else {
58  if (symmetrizeDroppedGraph) {
59  auto drop_boundaries = Misc::VectorSymmetricDropBoundaryFunctor(mergedA, rowTranslation, colTranslation, boundaryNodes, results);
60  VectorDroppingClassical::runDroppingFunctors(A, mergedA, blkPartSize, rowTranslation, colTranslation, results, filtered_rowptr, graph_rowptr, nnz, useBlocking, level, factory,
61  dropping,
62  drop_boundaries,
63  preserve_diagonals);
64  } else {
65  auto drop_boundaries = Misc::VectorDropBoundaryFunctor(lclA, rowTranslation, boundaryNodes, results);
66  VectorDroppingClassical::runDroppingFunctors(A, mergedA, blkPartSize, rowTranslation, colTranslation, results, filtered_rowptr, graph_rowptr, nnz, useBlocking, level, factory,
67  dropping,
68  drop_boundaries,
69  preserve_diagonals);
70  }
71  }
72  } else if (droppingMethod == "cut-drop") {
73  auto comparison = CutDrop::make_comparison_functor<SoC>(A, results);
74  auto cut_drop = CutDrop::CutDropFunctor(comparison, threshold);
75 
76  if (symmetrizeDroppedGraph) {
77  auto drop_boundaries = Misc::VectorSymmetricDropBoundaryFunctor(mergedA, rowTranslation, colTranslation, boundaryNodes, results);
78  VectorDroppingClassical::runDroppingFunctors(A, mergedA, blkPartSize, rowTranslation, colTranslation, results, filtered_rowptr, graph_rowptr, nnz, useBlocking, level, factory,
79  drop_boundaries,
80  preserve_diagonals,
81  cut_drop);
82  } else {
83  auto drop_boundaries = Misc::VectorDropBoundaryFunctor(lclA, rowTranslation, boundaryNodes, results);
84  VectorDroppingClassical::runDroppingFunctors(A, mergedA, blkPartSize, rowTranslation, colTranslation, results, filtered_rowptr, graph_rowptr, nnz, useBlocking, level, factory,
85  drop_boundaries,
86  preserve_diagonals,
87  cut_drop);
88  }
89  }
90 }
91 } // namespace MueLu
92 
93 #define MUELU_ETI_GROUP(SC, LO, GO, NO) \
94  MUELU_ETI_SLGN_SoC(MueLu::VectorDroppingClassical, SC, LO, GO, NO)
95 
96 #endif
MueLu::DefaultLocalOrdinal LocalOrdinal
Functor that drops boundary nodes for a blockSize &gt; 1 problem.
Functor that marks singletons (all off-diagonal entries in a row are dropped) as boundary.
Kokkos::View< DecisionType *, memory_space > results_view
typename Teuchos::ScalarTraits< Scalar >::magnitudeType magnitudeType
Class that holds all level-specific information.
Definition: MueLu_Level.hpp:63
static void runDroppingFunctors_on_A(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, Level &level, const Factory &factory)
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...
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)
Functor that drops boundary nodes for a blockSize &gt; 1 problem.
typename MueLu::LWGraph_kokkos< LocalOrdinal, GlobalOrdinal, Node >::boundary_nodes_type boundary_nodes_type
typename Kokkos::View< LocalOrdinal *, typename Node::device_type > block_indices_view_type