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 "Xpetra_Access.hpp"
24 #include "MueLu_Utilities.hpp"
41 template <
class local_ordinal_type>
46 KOKKOS_FORCEINLINE_FUNCTION
55 template <
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);
93 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
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);
137 template <
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);
178 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
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);
228 template <
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);
262 template <
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()) {
295 template <
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);
339 template <
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);
387 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
408 :
A(A_.getLocalMatrixDevice())
409 ,
point_to_block(point_to_block_.getLocalViewDevice(Xpetra::Access::ReadOnly))
413 if (!importer.is_null()) {
415 ghosted_point_to_blockMV->doImport(point_to_block_, *importer,
Xpetra::INSERT);
421 KOKKOS_FORCEINLINE_FUNCTION
423 auto row =
A.rowConst(rlid);
424 const size_t offset =
A.graph.row_map(rlid);
426 auto clid = row.colidx(k);
440 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
466 :
A(A_.getLocalMatrixDevice())
467 ,
point_to_block(point_to_block_.getLocalViewDevice(Xpetra::Access::ReadOnly))
479 KOKKOS_FORCEINLINE_FUNCTION
481 auto row =
A.rowConst(rlid);
482 const size_t offset =
A.graph.row_map(rlid);
485 auto clid = row.colidx(k);
500 template <
class local_matrix_type>
518 KOKKOS_FORCEINLINE_FUNCTION
520 auto row =
A.rowConst(rlid);
521 const size_t offset =
A.graph.row_map(rlid);
524 Kokkos::printf(
"No dropping decision was taken for entry (%d, %d)\n", rlid, row.colidx(k));
535 template <
class local_matrix_type>
551 KOKKOS_FORCEINLINE_FUNCTION
553 auto row =
A.rowConst(rlid);
554 const size_t offset =
A.graph.row_map(rlid);
557 auto clid = row.colidx(k);
558 if (clid >=
A.numRows())
560 auto row2 =
A.rowConst(clid);
561 const size_t offset2 =
A.graph.row_map(clid);
563 auto clid2 = row2.colidx(k2);
575 template <
class view_type,
class comparator_type>
576 KOKKOS_INLINE_FUNCTION
void serialHeapSort(view_type& v, comparator_type comparator) {
577 auto N = v.extent(0);
578 size_t start = N / 2;
590 while (2 * root + 1 < end) {
591 size_t child = 2 * root + 1;
592 if ((child + 1 < end) and (comparator(v(child), v(child + 1))))
595 if (comparator(v(root), v(child))) {
641 #define MUELU_ETI_SLGN_SoC(CLASSNAME, SC, LO, GO, NO) \
642 template class CLASSNAME<SC, LO, GO, NO, MueLu::Misc::SmoothedAggregationMeasure>; \
643 template class CLASSNAME<SC, LO, GO, NO, MueLu::Misc::SignedRugeStuebenMeasure>; \
644 template class CLASSNAME<SC, LO, GO, NO, MueLu::Misc::SignedSmoothedAggregationMeasure>; \
645 template class CLASSNAME<SC, LO, GO, NO, MueLu::Misc::UnscaledMeasure>;
typename matrix_type::local_matrix_type local_matrix_type
PointwiseSymmetricDropBoundaryFunctor(Xpetra::Matrix< Scalar, LocalOrdinal, GlobalOrdinal, Node > &A_, boundary_nodes_view boundaryNodes_, results_view &results_)
typename Xpetra::Matrix< Scalar, LocalOrdinal, GlobalOrdinal, Node >::local_matrix_type local_matrix_type
Kokkos::View< local_ordinal_type *, memory_space > block_indices_view_type
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_FORCEINLINE_FUNCTION void operator()(local_ordinal_type rlid) const
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::value_type scalar_type
boundary_nodes_view boundaryNodesCol
DebugFunctor(local_matrix_type &A_, results_view &results_)
block_indices_view_type point_to_block
typename local_matrix_type::ordinal_type local_ordinal_type
typename local_matrix_type::memory_space memory_space
KOKKOS_FORCEINLINE_FUNCTION void operator()(local_ordinal_type rlid) const
typename local_matrix_type::memory_space memory_space
typename local_matrix_type::memory_space memory_space
typename local_matrix_type::ordinal_type local_ordinal_type
Kokkos::View< DecisionType *, memory_space > results_view
block_indices_view_type ghosted_point_to_block
typename local_matrix_type::value_type scalar_type
typename local_matrix_type::value_type scalar_type
Functor that drops boundary nodes for a blockSize > 1 problem.
local_block_indices_view_type point_to_block
boundary_nodes_view boundaryNodes
Kokkos::View< DecisionType *, memory_space > results_view
typename local_matrix_type::value_type scalar_type
Functor that marks singletons (all off-diagonal entries in a row are dropped) as boundary.
typename local_matrix_type::ordinal_type local_ordinal_type
typename local_matrix_type::memory_space memory_space
BlockDiagonalizeFunctor(matrix_type &A_, block_indices_type &point_to_block_, results_view &results_)
typename local_matrix_type::value_type scalar_type
typename local_matrix_type::memory_space memory_space
typename local_matrix_type::ordinal_type local_ordinal_type
local_block_indices_view_type ghosted_point_to_block
typename local_matrix_type::ordinal_type local_ordinal_type
Kokkos::View< DecisionType *, memory_space > results_view
local_block_indices_view_type point_to_block
Functor that checks that all entries have been marked.
typename local_matrix_type::memory_space memory_space
Kokkos::View< bool *, memory_space > boundary_nodes_view
Functor that drops boundary nodes for a blockSize == 1 problem.
typename local_matrix_type::ordinal_type local_ordinal_type
Kokkos::View< bool *, memory_space > boundary_nodes_view
KOKKOS_FORCEINLINE_FUNCTION void operator()(local_ordinal_type rlid) const
Kokkos::View< DecisionType *, memory_space > results_view
typename local_matrix_type::memory_space memory_space
boundary_nodes_view boundaryNodesCol
virtual Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > getTargetMap() const =0
Functor that marks singletons (all off-diagonal entries in a row are dropped) as boundary.
typename local_matrix_type::value_type scalar_type
typename Xpetra::Matrix< Scalar, LocalOrdinal, GlobalOrdinal, Node >::local_matrix_type local_matrix_type
Kokkos::View< DecisionType *, memory_space > results_view
typename local_matrix_type::ordinal_type local_ordinal_type
Kokkos::View< DecisionType *, memory_space > results_view
boundary_nodes_view boundaryNodes
typename local_matrix_type::ordinal_type local_ordinal_type
VectorDropBoundaryFunctor(local_matrix_type &A_, block_indices_view_type point_to_block_, boundary_nodes_view boundaryNodes_, results_view &results_)
DropOffRankFunctor(local_matrix_type &A_, results_view &results_)
typename block_indices_type::dual_view_type_const::t_dev local_block_indices_view_type
KOKKOS_INLINE_FUNCTION void serialHeapSort(view_type &v, comparator_type comparator)
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_)
typename local_matrix_type::value_type scalar_type
Teuchos::RCP< block_indices_type > ghosted_point_to_blockMV
Functor that symmetrizes the dropping decisions.
Functor that drops boundary nodes for a blockSize == 1 problem.
Functor that drops off-rank entries.
typename local_matrix_type::memory_space memory_space
block_indices_view_type point_to_block
Kokkos::View< DecisionType *, memory_space > results_view
typename local_matrix_type::memory_space memory_space
id_translation_type row_translation
Kokkos::View< const bool *, memory_space > boundary_nodes_view
KOKKOS_FORCEINLINE_FUNCTION void operator()(local_ordinal_type rlid) const
typename local_matrix_type::memory_space memory_space
boundary_nodes_view boundaryNodes
KOKKOS_FORCEINLINE_FUNCTION void operator()(local_ordinal_type rlid) const
typename local_matrix_type::ordinal_type local_ordinal_type
local_block_indices_view_type ghosted_point_to_block
Kokkos::View< bool *, memory_space > boundary_nodes_view
boundary_nodes_view boundaryNodes
KOKKOS_FORCEINLINE_FUNCTION void operator()(local_ordinal_type rlid) const
typename matrix_type::local_matrix_type local_matrix_type
typename local_matrix_type::memory_space memory_space
KOKKOS_FORCEINLINE_FUNCTION void operator()(local_ordinal_type rlid) const
Functor that drops all entries that are not on the block diagonal.
Functor that marks diagonal as kept, unless the are already marked as boundary.
Kokkos::View< DecisionType *, memory_space > results_view
KOKKOS_FORCEINLINE_FUNCTION void operator()(local_ordinal_type rlid) const
KOKKOS_FORCEINLINE_FUNCTION void operator()(local_ordinal_type rlid) const
static RCP< Vector > Build(const Teuchos::RCP< const Map > &map, bool zeroOut=true)
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_)
MarkSingletonFunctor(local_matrix_type &A_, boundary_nodes_view boundaryNodes_, results_view &results_)
typename local_matrix_type::value_type scalar_type
typename local_matrix_type::ordinal_type local_ordinal_type
typename local_matrix_type::value_type scalar_type
block_indices_view_type point_to_block
virtual RCP< const CrsGraph > getCrsGraph() const =0
KOKKOS_FORCEINLINE_FUNCTION void operator()(local_ordinal_type rlid) const
boundary_nodes_view boundaryNodes
typename local_matrix_type::memory_space memory_space
Kokkos::View< local_ordinal_type *, memory_space > id_translation_type
Functor that drops boundary nodes for a blockSize > 1 problem.
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
KOKKOS_FORCEINLINE_FUNCTION void operator()(local_ordinal_type rlid) const
Kokkos::View< bool *, memory_space > boundary_nodes_view
SymmetrizeFunctor(local_matrix_type &A_, results_view &results_)
Kokkos::View< DecisionType *, memory_space > results_view
MarkSingletonVectorFunctor(local_matrix_type &A_, block_indices_view_type point_to_block_, boundary_nodes_view boundaryNodes_, results_view &results_)
Kokkos::View< const bool *, memory_space > boundary_nodes_view
PointwiseDropBoundaryFunctor(local_matrix_type &A_, boundary_nodes_view boundaryNodes_, results_view &results_)
Kokkos::View< DecisionType *, memory_space > results_view
Functor that drops all entries that are not on the block diagonal.
Kokkos::View< bool *, memory_space > boundary_nodes_view
Kokkos::View< DecisionType *, memory_space > results_view
id_translation_type col_translation
typename local_matrix_type::ordinal_type local_ordinal_type
Kokkos::View< local_ordinal_type *, memory_space > block_indices_view_type
Kokkos::View< local_ordinal_type *, memory_space > block_indices_view_type
typename local_matrix_type::value_type scalar_type
KeepDiagonalFunctor(local_matrix_type &A_, results_view &results_)
Kokkos::View< DecisionType *, memory_space > results_view
virtual Teuchos::RCP< const Map > getDomainMap() const =0
typename local_matrix_type::value_type scalar_type
boundary_nodes_view boundaryNodes