10 #ifndef MUELU_DROPPINGCOMMON_HPP
11 #define MUELU_DROPPINGCOMMON_HPP
13 #include "Kokkos_Core.hpp"
14 #include "Kokkos_ArithTraits.hpp"
15 #include "Xpetra_Access.hpp"
18 #include "MueLu_Utilities.hpp"
35 template <
class local_ordinal_type>
40 KOKKOS_FORCEINLINE_FUNCTION
49 template <
class local_matrix_type>
68 KOKKOS_FORCEINLINE_FUNCTION
70 auto row =
A.rowConst(rlid);
71 const size_t offset =
A.graph.row_map(rlid);
75 auto clid = row.colidx(k);
87 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
106 A = A_.getLocalMatrixDevice();
107 auto boundaryNodesColumn =
typename boundary_nodes_view::non_const_type(
"boundaryNodesColumn", A_.getColMap()->getLocalNumElements());
108 auto boundaryNodesDomain =
typename boundary_nodes_view::non_const_type(
"boundaryNodesDomain", A_.
getDomainMap()->getLocalNumElements());
113 KOKKOS_FORCEINLINE_FUNCTION
115 auto row =
A.rowConst(rlid);
116 const size_t offset =
A.graph.row_map(rlid);
119 auto clid = row.colidx(k);
131 template <
class local_matrix_type>
153 KOKKOS_FORCEINLINE_FUNCTION
155 auto row =
A.rowConst(rlid);
156 const size_t offset =
A.graph.row_map(rlid);
160 auto clid = row.colidx(k);
172 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
196 A = A_.getLocalMatrixDevice();
197 auto boundaryNodesColumn =
typename boundary_nodes_view::non_const_type(
"boundaryNodesColumn", A_.getColMap()->getLocalNumElements());
198 auto boundaryNodesDomain =
typename boundary_nodes_view::non_const_type(
"boundaryNodesDomain", A_.
getDomainMap()->getLocalNumElements());
203 KOKKOS_FORCEINLINE_FUNCTION
205 auto row =
A.rowConst(rlid);
206 const size_t offset =
A.graph.row_map(rlid);
209 auto clid = row.colidx(k);
222 template <
class local_matrix_type>
238 KOKKOS_FORCEINLINE_FUNCTION
240 auto row =
A.rowConst(rlid);
241 const size_t offset =
A.graph.row_map(rlid);
243 auto clid = row.colidx(k);
256 template <
class local_matrix_type>
272 KOKKOS_FORCEINLINE_FUNCTION
274 auto row =
A.rowConst(rlid);
275 const size_t offset =
A.graph.row_map(rlid);
277 auto clid = row.colidx(k);
278 if (clid >=
A.numRows()) {
289 template <
class local_matrix_type>
309 KOKKOS_FORCEINLINE_FUNCTION
311 auto row =
A.rowConst(rlid);
312 const size_t offset =
A.graph.row_map(rlid);
314 auto clid = row.colidx(k);
315 if ((
results(offset + k) ==
KEEP) && (rlid != clid))
320 auto clid = row.colidx(k);
333 template <
class local_matrix_type>
356 KOKKOS_FORCEINLINE_FUNCTION
358 auto row =
A.rowConst(rlid);
359 const size_t offset =
A.graph.row_map(rlid);
361 auto clid = row.colidx(k);
362 if ((
results(offset + k) ==
KEEP) && (rlid != clid))
368 auto clid = row.colidx(k);
381 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
402 :
A(A_.getLocalMatrixDevice())
403 ,
point_to_block(point_to_block_.getLocalViewDevice(Xpetra::Access::ReadOnly))
407 if (!importer.is_null()) {
409 ghosted_point_to_blockMV->doImport(point_to_block_, *importer,
Xpetra::INSERT);
415 KOKKOS_FORCEINLINE_FUNCTION
417 auto row =
A.rowConst(rlid);
418 const size_t offset =
A.graph.row_map(rlid);
420 auto clid = row.colidx(k);
434 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
460 :
A(A_.getLocalMatrixDevice())
461 ,
point_to_block(point_to_block_.getLocalViewDevice(Xpetra::Access::ReadOnly))
473 KOKKOS_FORCEINLINE_FUNCTION
475 auto row =
A.rowConst(rlid);
476 const size_t offset =
A.graph.row_map(rlid);
479 auto clid = row.colidx(k);
494 template <
class local_matrix_type>
512 KOKKOS_FORCEINLINE_FUNCTION
514 auto row =
A.rowConst(rlid);
515 const size_t offset =
A.graph.row_map(rlid);
518 Kokkos::printf(
"No dropping decision was taken for entry (%d, %d)\n", rlid, row.colidx(k));
529 template <
class local_matrix_type>
545 KOKKOS_FORCEINLINE_FUNCTION
547 auto row =
A.rowConst(rlid);
548 const size_t offset =
A.graph.row_map(rlid);
551 auto clid = row.colidx(k);
552 if (clid >=
A.numRows())
554 auto row2 =
A.rowConst(clid);
555 const size_t offset2 =
A.graph.row_map(clid);
557 auto clid2 = row2.colidx(k2);
569 template <
class view_type,
class comparator_type>
570 KOKKOS_INLINE_FUNCTION
void serialHeapSort(view_type& v, comparator_type comparator) {
571 auto N = v.extent(0);
572 size_t start = N / 2;
584 while (2 * root + 1 < end) {
585 size_t child = 2 * root + 1;
586 if ((child + 1 < end) and (comparator(v(child), v(child + 1))))
589 if (comparator(v(root), v(child))) {
635 #define MUELU_ETI_SLGN_SoC(CLASSNAME, SC, LO, GO, NO) \
636 template class CLASSNAME<SC, LO, GO, NO, MueLu::Misc::SmoothedAggregationMeasure>; \
637 template class CLASSNAME<SC, LO, GO, NO, MueLu::Misc::SignedRugeStuebenMeasure>; \
638 template class CLASSNAME<SC, LO, GO, NO, MueLu::Misc::SignedSmoothedAggregationMeasure>; \
639 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