10#ifndef MUELU_DROPPINGCOMMON_HPP
11#define MUELU_DROPPINGCOMMON_HPP
15#include "Kokkos_Core.hpp"
16#if KOKKOS_VERSION >= 40799
17#include "KokkosKernels_ArithTraits.hpp"
19#include "Kokkos_ArithTraits.hpp"
21#include "Tpetra_Access.hpp"
22#include "Xpetra_Matrix.hpp"
23#include "Xpetra_VectorFactory.hpp"
24#include "MueLu_Utilities.hpp"
41template <
class local_ordinal_type>
46 KOKKOS_FORCEINLINE_FUNCTION
55template <
class local_matrix_type>
74 KOKKOS_FORCEINLINE_FUNCTION
76 auto row =
A.rowConst(rlid);
77 const size_t offset =
A.graph.row_map(rlid);
81 auto clid = row.colidx(k);
93template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
96 using local_matrix_type =
typename Xpetra::Matrix<Scalar, LocalOrdinal, GlobalOrdinal, Node>::local_matrix_device_type;
112 A = A_.getLocalMatrixDevice();
113 auto boundaryNodesColumn =
typename boundary_nodes_view::non_const_type(
"boundaryNodesColumn", A_.getColMap()->getLocalNumElements());
114 auto boundaryNodesDomain =
typename boundary_nodes_view::non_const_type(
"boundaryNodesDomain", A_.getDomainMap()->getLocalNumElements());
119 KOKKOS_FORCEINLINE_FUNCTION
121 auto row =
A.rowConst(rlid);
122 const size_t offset =
A.graph.row_map(rlid);
125 auto clid = row.colidx(k);
137template <
class local_matrix_type>
159 KOKKOS_FORCEINLINE_FUNCTION
161 auto row =
A.rowConst(rlid);
162 const size_t offset =
A.graph.row_map(rlid);
166 auto clid = row.colidx(k);
178template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
181 using local_matrix_type =
typename Xpetra::Matrix<Scalar, LocalOrdinal, GlobalOrdinal, Node>::local_matrix_device_type;
202 A = A_.getLocalMatrixDevice();
203 auto boundaryNodesColumn =
typename boundary_nodes_view::non_const_type(
"boundaryNodesColumn", A_.getColMap()->getLocalNumElements());
204 auto boundaryNodesDomain =
typename boundary_nodes_view::non_const_type(
"boundaryNodesDomain", A_.getDomainMap()->getLocalNumElements());
209 KOKKOS_FORCEINLINE_FUNCTION
211 auto row =
A.rowConst(rlid);
212 const size_t offset =
A.graph.row_map(rlid);
215 auto clid = row.colidx(k);
228template <
class local_matrix_type>
244 KOKKOS_FORCEINLINE_FUNCTION
246 auto row =
A.rowConst(rlid);
247 const size_t offset =
A.graph.row_map(rlid);
249 auto clid = row.colidx(k);
262template <
class local_matrix_type>
278 KOKKOS_FORCEINLINE_FUNCTION
280 auto row =
A.rowConst(rlid);
281 const size_t offset =
A.graph.row_map(rlid);
283 auto clid = row.colidx(k);
284 if (clid >=
A.numRows()) {
295template <
class local_matrix_type>
315 KOKKOS_FORCEINLINE_FUNCTION
317 auto row =
A.rowConst(rlid);
318 const size_t offset =
A.graph.row_map(rlid);
320 auto clid = row.colidx(k);
321 if ((
results(offset + k) ==
KEEP) && (rlid != clid))
326 auto clid = row.colidx(k);
339template <
class local_matrix_type>
362 KOKKOS_FORCEINLINE_FUNCTION
364 auto row =
A.rowConst(rlid);
365 const size_t offset =
A.graph.row_map(rlid);
367 auto clid = row.colidx(k);
368 if ((
results(offset + k) ==
KEEP) && (rlid != clid))
374 auto clid = row.colidx(k);
387template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
390 using matrix_type = Xpetra::Matrix<Scalar, LocalOrdinal, GlobalOrdinal, Node>;
409 :
A(A_.getLocalMatrixDevice())
410 ,
point_to_block(point_to_block_.getLocalViewDevice(Tpetra::Access::ReadOnly))
412 auto importer = A_.getCrsGraph()->getImporter();
414 if (!importer.is_null()) {
415 ghosted_point_to_blockMV = Xpetra::VectorFactory<LocalOrdinal, LocalOrdinal, GlobalOrdinal, Node>::Build(importer->getTargetMap());
422 KOKKOS_FORCEINLINE_FUNCTION
424 auto row =
A.rowConst(rlid);
425 const size_t offset =
A.graph.row_map(rlid);
427 auto clid = row.colidx(k);
441template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
444 using matrix_type = Xpetra::Matrix<Scalar, LocalOrdinal, GlobalOrdinal, Node>;
467 :
A(A_.getLocalMatrixDevice())
468 ,
point_to_block(point_to_block_.getLocalViewDevice(Tpetra::Access::ReadOnly))
472 if (!importer.is_null()) {
473 ghosted_point_to_blockMV = Xpetra::VectorFactory<LocalOrdinal, LocalOrdinal, GlobalOrdinal, Node>::Build(importer->getTargetMap());
480 KOKKOS_FORCEINLINE_FUNCTION
482 auto row =
A.rowConst(rlid);
483 const size_t offset =
A.graph.row_map(rlid);
486 auto clid = row.colidx(k);
501template <
class local_matrix_type>
519 KOKKOS_FORCEINLINE_FUNCTION
521 auto row =
A.rowConst(rlid);
522 const size_t offset =
A.graph.row_map(rlid);
525 Kokkos::printf(
"No dropping decision was taken for entry (%d, %d)\n", rlid, row.colidx(k));
536template <
class local_matrix_type>
552 KOKKOS_FORCEINLINE_FUNCTION
554 auto row =
A.rowConst(rlid);
555 const size_t offset =
A.graph.row_map(rlid);
558 auto clid = row.colidx(k);
559 if (clid >=
A.numRows())
561 auto row2 =
A.rowConst(clid);
562 const size_t offset2 =
A.graph.row_map(clid);
564 auto clid2 = row2.colidx(k2);
576template <
class view_type,
class comparator_type>
577KOKKOS_INLINE_FUNCTION
void serialHeapSort(view_type& v, comparator_type comparator) {
578 auto N = v.extent(0);
579 size_t start = N / 2;
591 while (2 * root + 1 < end) {
592 size_t child = 2 * root + 1;
593 if ((child + 1 < end) and (comparator(v(child), v(child + 1))))
596 if (comparator(v(root), v(child))) {
642#define MUELU_ETI_SLGN_SoC(CLASSNAME, SC, LO, GO, NO) \
643 template class CLASSNAME<SC, LO, GO, NO, MueLu::Misc::SmoothedAggregationMeasure>; \
644 template class CLASSNAME<SC, LO, GO, NO, MueLu::Misc::SignedRugeStuebenMeasure>; \
645 template class CLASSNAME<SC, LO, GO, NO, MueLu::Misc::SignedSmoothedAggregationMeasure>; \
646 template class CLASSNAME<SC, LO, GO, NO, MueLu::Misc::UnscaledMeasure>;
Functor that drops all entries that are not on the block diagonal.
Teuchos::RCP< block_indices_type > ghosted_point_to_blockMV
typename matrix_type::local_matrix_device_type local_matrix_type
Xpetra::MultiVector< LocalOrdinal, LocalOrdinal, GlobalOrdinal, Node > block_indices_type
typename local_matrix_type::value_type scalar_type
local_block_indices_view_type point_to_block
Xpetra::Matrix< Scalar, LocalOrdinal, GlobalOrdinal, Node > matrix_type
local_block_indices_view_type ghosted_point_to_block
typename block_indices_type::dual_view_type_const::t_dev local_block_indices_view_type
KOKKOS_FORCEINLINE_FUNCTION void operator()(local_ordinal_type rlid) const
typename local_matrix_type::memory_space memory_space
typename local_matrix_type::ordinal_type local_ordinal_type
Kokkos::View< DecisionType *, memory_space > results_view
BlockDiagonalizeFunctor(matrix_type &A_, block_indices_type &point_to_block_, results_view &results_)
Functor that drops all entries that are not on the block diagonal.
Xpetra::Vector< LocalOrdinal, LocalOrdinal, GlobalOrdinal, Node > block_indices_type
id_translation_type col_translation
typename local_matrix_type::memory_space memory_space
Xpetra::Import< LocalOrdinal, GlobalOrdinal, Node > importer_type
typename block_indices_type::dual_view_type_const::t_dev local_block_indices_view_type
Xpetra::Matrix< Scalar, LocalOrdinal, GlobalOrdinal, Node > matrix_type
BlockDiagonalizeVectorFunctor(matrix_type &A_, block_indices_type &point_to_block_, const RCP< const importer_type > &importer, results_view &results_, id_translation_type row_translation_, id_translation_type col_translation_)
id_translation_type row_translation
typename local_matrix_type::value_type scalar_type
KOKKOS_FORCEINLINE_FUNCTION void operator()(local_ordinal_type rlid) const
Kokkos::View< DecisionType *, memory_space > results_view
local_block_indices_view_type point_to_block
typename local_matrix_type::ordinal_type local_ordinal_type
Teuchos::RCP< block_indices_type > ghosted_point_to_blockMV
Kokkos::View< local_ordinal_type *, memory_space > id_translation_type
typename matrix_type::local_matrix_device_type local_matrix_type
local_block_indices_view_type ghosted_point_to_block
Functor that checks that all entries have been marked.
Kokkos::View< DecisionType *, memory_space > results_view
KOKKOS_FORCEINLINE_FUNCTION void operator()(local_ordinal_type rlid) const
DebugFunctor(local_matrix_type &A_, results_view &results_)
typename local_matrix_type::ordinal_type local_ordinal_type
Kokkos::View< bool *, memory_space > boundary_nodes_view
typename local_matrix_type::value_type scalar_type
typename local_matrix_type::memory_space memory_space
Functor that drops off-rank entries.
KOKKOS_FORCEINLINE_FUNCTION void operator()(local_ordinal_type rlid) const
Kokkos::View< DecisionType *, memory_space > results_view
typename local_matrix_type::ordinal_type local_ordinal_type
typename local_matrix_type::memory_space memory_space
typename local_matrix_type::value_type scalar_type
DropOffRankFunctor(local_matrix_type &A_, results_view &results_)
Functor that marks diagonal as kept, unless the are already marked as boundary.
Kokkos::View< DecisionType *, memory_space > results_view
typename local_matrix_type::memory_space memory_space
KeepDiagonalFunctor(local_matrix_type &A_, results_view &results_)
typename local_matrix_type::ordinal_type local_ordinal_type
typename local_matrix_type::value_type scalar_type
KOKKOS_FORCEINLINE_FUNCTION void operator()(local_ordinal_type rlid) const
Functor that marks singletons (all off-diagonal entries in a row are dropped) as boundary.
Kokkos::View< DecisionType *, memory_space > results_view
KOKKOS_FORCEINLINE_FUNCTION void operator()(local_ordinal_type rlid) const
typename local_matrix_type::value_type scalar_type
MarkSingletonFunctor(local_matrix_type &A_, boundary_nodes_view boundaryNodes_, results_view &results_)
typename local_matrix_type::memory_space memory_space
boundary_nodes_view boundaryNodes
typename local_matrix_type::ordinal_type local_ordinal_type
Kokkos::View< bool *, memory_space > boundary_nodes_view
Functor that marks singletons (all off-diagonal entries in a row are dropped) as boundary.
MarkSingletonVectorFunctor(local_matrix_type &A_, block_indices_view_type point_to_block_, boundary_nodes_view boundaryNodes_, results_view &results_)
Kokkos::View< DecisionType *, memory_space > results_view
KOKKOS_FORCEINLINE_FUNCTION void operator()(local_ordinal_type rlid) const
typename local_matrix_type::value_type scalar_type
Kokkos::View< local_ordinal_type *, memory_space > block_indices_view_type
typename local_matrix_type::ordinal_type local_ordinal_type
Kokkos::View< bool *, memory_space > boundary_nodes_view
typename local_matrix_type::memory_space memory_space
block_indices_view_type point_to_block
boundary_nodes_view boundaryNodes
KOKKOS_FORCEINLINE_FUNCTION void operator()(local_ordinal_type rlid) const
Functor that drops boundary nodes for a blockSize == 1 problem.
typename local_matrix_type::ordinal_type local_ordinal_type
typename local_matrix_type::memory_space memory_space
Kokkos::View< const bool *, memory_space > boundary_nodes_view
boundary_nodes_view boundaryNodes
typename local_matrix_type::value_type scalar_type
Kokkos::View< DecisionType *, memory_space > results_view
PointwiseDropBoundaryFunctor(local_matrix_type &A_, boundary_nodes_view boundaryNodes_, results_view &results_)
KOKKOS_FORCEINLINE_FUNCTION void operator()(local_ordinal_type rlid) const
Functor that drops boundary nodes for a blockSize == 1 problem.
Kokkos::View< DecisionType *, memory_space > results_view
boundary_nodes_view boundaryNodes
typename Xpetra::Matrix< Scalar, LocalOrdinal, GlobalOrdinal, Node >::local_matrix_device_type local_matrix_type
KOKKOS_FORCEINLINE_FUNCTION void operator()(local_ordinal_type rlid) const
typename local_matrix_type::value_type scalar_type
boundary_nodes_view boundaryNodesCol
typename local_matrix_type::ordinal_type local_ordinal_type
Kokkos::View< bool *, memory_space > boundary_nodes_view
typename local_matrix_type::memory_space memory_space
PointwiseSymmetricDropBoundaryFunctor(Xpetra::Matrix< Scalar, LocalOrdinal, GlobalOrdinal, Node > &A_, boundary_nodes_view boundaryNodes_, results_view &results_)
Functor that symmetrizes the dropping decisions.
typename local_matrix_type::value_type scalar_type
SymmetrizeFunctor(local_matrix_type &A_, results_view &results_)
Kokkos::View< DecisionType *, memory_space > results_view
typename local_matrix_type::memory_space memory_space
typename local_matrix_type::ordinal_type local_ordinal_type
KOKKOS_FORCEINLINE_FUNCTION void operator()(local_ordinal_type rlid) const
Functor that drops boundary nodes for a blockSize > 1 problem.
VectorDropBoundaryFunctor(local_matrix_type &A_, block_indices_view_type point_to_block_, boundary_nodes_view boundaryNodes_, results_view &results_)
block_indices_view_type point_to_block
Kokkos::View< local_ordinal_type *, memory_space > block_indices_view_type
Kokkos::View< const bool *, memory_space > boundary_nodes_view
typename local_matrix_type::memory_space memory_space
KOKKOS_FORCEINLINE_FUNCTION void operator()(local_ordinal_type rlid) const
typename local_matrix_type::ordinal_type local_ordinal_type
Kokkos::View< DecisionType *, memory_space > results_view
boundary_nodes_view boundaryNodes
typename local_matrix_type::value_type scalar_type
Functor that drops boundary nodes for a blockSize > 1 problem.
boundary_nodes_view boundaryNodes
block_indices_view_type point_to_block
typename local_matrix_type::value_type scalar_type
typename local_matrix_type::memory_space memory_space
typename Xpetra::Matrix< Scalar, LocalOrdinal, GlobalOrdinal, Node >::local_matrix_device_type local_matrix_type
KOKKOS_FORCEINLINE_FUNCTION void operator()(local_ordinal_type rlid) const
Kokkos::View< bool *, memory_space > boundary_nodes_view
Kokkos::View< DecisionType *, memory_space > results_view
boundary_nodes_view boundaryNodesCol
VectorSymmetricDropBoundaryFunctor(Xpetra::Matrix< Scalar, LocalOrdinal, GlobalOrdinal, Node > &A_, block_indices_view_type point_to_block_, block_indices_view_type ghosted_point_to_block_, boundary_nodes_view boundaryNodes_, results_view &results_)
Kokkos::View< local_ordinal_type *, memory_space > block_indices_view_type
typename local_matrix_type::ordinal_type local_ordinal_type
block_indices_view_type ghosted_point_to_block
static void DetectDirichletColsAndDomains(const Xpetra::Matrix< Scalar, LocalOrdinal, GlobalOrdinal, Node > &A, const Teuchos::ArrayRCP< bool > &dirichletRows, Teuchos::ArrayRCP< bool > dirichletCols, Teuchos::ArrayRCP< bool > dirichletDomain)
Detects Dirichlet columns & domains from a list of Dirichlet rows.
KOKKOS_INLINE_FUNCTION void serialHeapSort(view_type &v, comparator_type comparator)
@ SignedSmoothedAggregationMeasure
@ SignedRugeStuebenMeasure
@ SmoothedAggregationMeasure
Namespace for MueLu classes and methods.