MueLu Version of the Day
Loading...
Searching...
No Matches
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"
18#include "MueLu_Utilities.hpp"
19#include "MueLu_LWGraph_kokkos.hpp"
20
21namespace MueLu {
22
23template <class Scalar, class LocalOrdinal, class GlobalOrdinal, class Node, Misc::StrengthMeasure SoC>
24class ScalarDroppingDistanceLaplacian : public ScalarDroppingBase<Scalar, LocalOrdinal, GlobalOrdinal, Node> {
25 public:
26 using matrix_type = Xpetra::Matrix<Scalar, LocalOrdinal, GlobalOrdinal, Node>;
27 using crs_matrix_type = Xpetra::CrsMatrix<Scalar, LocalOrdinal, GlobalOrdinal, Node>;
28 using GraphType = Xpetra::CrsGraph<LocalOrdinal, GlobalOrdinal, Node>;
29 using local_matrix_type = typename crs_matrix_type::local_matrix_device_type;
30 using local_graph_type = typename GraphType::local_graph_device_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>;
37 using magnitudeType = typename Teuchos::ScalarTraits<Scalar>::magnitudeType;
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
MueLu::DefaultLocalOrdinal LocalOrdinal
Order each row by a criterion, compare the ratio of values and drop all entries once the ratio is bel...
Lightweight MueLu representation of a compressed row storage graph.
Class that holds all level-specific information.
Functor that marks diagonal as kept, unless the are already marked as boundary.
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.
Functor that drops boundary nodes for a blockSize == 1 problem.
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 GraphType::local_graph_device_type local_graph_type
typename MueLu::LWGraph_kokkos< LocalOrdinal, GlobalOrdinal, Node >::boundary_nodes_type boundary_nodes_type
Xpetra::CrsGraph< LocalOrdinal, GlobalOrdinal, Node > GraphType
Xpetra::Matrix< Scalar, LocalOrdinal, GlobalOrdinal, Node > matrix_type
typename crs_matrix_type::local_matrix_device_type local_matrix_type
typename local_matrix_type::values_type::non_const_type values_type
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)
Xpetra::CrsMatrix< Scalar, LocalOrdinal, GlobalOrdinal, Node > crs_matrix_type
typename local_graph_type::entries_type::non_const_type entries_type
typename Teuchos::ScalarTraits< Scalar >::magnitudeType magnitudeType
Kokkos::View< DecisionType *, memory_space > results_view
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)
typename local_graph_type::row_map_type::non_const_type rowptr_type
Namespace for MueLu classes and methods.