10 #ifndef MUELU_CLASSICALDROPPING_HPP
11 #define MUELU_CLASSICALDROPPING_HPP
14 #include "Kokkos_Core.hpp"
15 #include "Kokkos_ArithTraits.hpp"
17 #include "MueLu_Utilities.hpp"
19 namespace MueLu::ClassicalDropping {
30 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
39 using diag_view_type =
typename Kokkos::DualView<const scalar_type*, Kokkos::LayoutStride, typename Node::device_type, Kokkos::MemoryUnmanaged>::t_dev;
43 using ATS = Kokkos::ArithTraits<scalar_type>;
55 :
A(A_.getLocalMatrixDevice())
59 auto lclDiag2d =
diagVec->getDeviceLocalView(Xpetra::Access::ReadOnly);
60 diag = Kokkos::subview(lclDiag2d, Kokkos::ALL(), 0);
63 KOKKOS_FORCEINLINE_FUNCTION
65 auto row =
A.rowConst(rlid);
66 size_t offset =
A.graph.row_map(rlid);
68 auto clid = row.colidx(k);
70 auto val = row.value(k);
71 auto aiiajj = ATS::magnitude(
diag(rlid)) * ATS::magnitude(
diag(clid));
72 auto aij2 = ATS::magnitude(val) * ATS::magnitude(val);
89 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
100 using ATS = Kokkos::ArithTraits<scalar_type>;
105 using diag_view_type =
typename Kokkos::DualView<const scalar_type*, Kokkos::LayoutStride, typename Node::device_type, Kokkos::MemoryUnmanaged>::t_dev;
115 :
A(A_.getLocalMatrixDevice())
119 auto lclDiag2d =
diagVec->getDeviceLocalView(Xpetra::Access::ReadOnly);
120 diag = Kokkos::subview(lclDiag2d, Kokkos::ALL(), 0);
123 KOKKOS_FORCEINLINE_FUNCTION
125 auto row =
A.rowConst(rlid);
126 size_t offset =
A.graph.row_map(rlid);
128 auto val = row.value(k);
129 auto neg_aij = -ATS::real(val);
130 auto max_neg_aik =
eps * ATS::real(
diag(rlid));
131 results(offset + k) = Kokkos::max((neg_aij <= max_neg_aik) ?
DROP :
KEEP,
146 template <
class Scalar,
class LocalOrdinal,
class GlobalOrdinal,
class Node>
155 using diag_view_type =
typename Kokkos::DualView<const scalar_type*, Kokkos::LayoutStride, typename Node::device_type, Kokkos::MemoryUnmanaged>::t_dev;
159 using ATS = Kokkos::ArithTraits<scalar_type>;
161 using mATS = Kokkos::ArithTraits<magnitudeType>;
172 :
A(A_.getLocalMatrixDevice())
177 auto lclDiag2d =
diagVec->getDeviceLocalView(Xpetra::Access::ReadOnly);
178 diag = Kokkos::subview(lclDiag2d, Kokkos::ALL(), 0);
181 KOKKOS_FORCEINLINE_FUNCTION
183 auto row =
A.rowConst(rlid);
184 size_t offset =
A.graph.row_map(rlid);
186 auto clid = row.colidx(k);
188 auto val = row.value(k);
189 auto aiiajj = ATS::magnitude(
diag(rlid)) * ATS::magnitude(
diag(clid));
190 const bool is_nonpositive = ATS::real(val) <= mATS::zero();
191 magnitudeType aij2 = ATS::magnitude(val) * ATS::magnitude(val);
KOKKOS_FORCEINLINE_FUNCTION void operator()(const local_ordinal_type rlid) const
typename ATS::magnitudeType magnitudeType
static Teuchos::RCP< Vector > GetMatrixMaxMinusOffDiagonal(const Xpetra::Matrix< Scalar, LocalOrdinal, GlobalOrdinal, Node > &A)
Return vector containing: max_{i=k}(-a_ik), for each for i in the matrix.
typename local_matrix_type::ordinal_type local_ordinal_type
Kokkos::View< const bool *, memory_space > boundary_nodes_view
SAFunctor(matrix_type &A_, magnitudeType threshold, results_view &results_)
typename matrix_type::local_matrix_type local_matrix_type
typename Kokkos::DualView< const scalar_type *, Kokkos::LayoutStride, typename Node::device_type, Kokkos::MemoryUnmanaged >::t_dev diag_view_type
Kokkos::ArithTraits< scalar_type > ATS
Classical smoothed aggregation dropping criterion.
typename ATS::magnitudeType magnitudeType
Signed classical Ruge-Stueben dropping criterion.
Signed classical smoothed aggregation dropping criterion.
typename local_matrix_type::memory_space memory_space
Kokkos::ArithTraits< scalar_type > ATS
Teuchos::RCP< diag_vec_type > diagVec
KOKKOS_FORCEINLINE_FUNCTION void operator()(const local_ordinal_type rlid) const
Kokkos::ArithTraits< magnitudeType > mATS
typename Kokkos::DualView< const scalar_type *, Kokkos::LayoutStride, typename Node::device_type, Kokkos::MemoryUnmanaged >::t_dev diag_view_type
Kokkos::ArithTraits< scalar_type > ATS
typename matrix_type::local_matrix_type local_matrix_type
KOKKOS_FORCEINLINE_FUNCTION void operator()(const local_ordinal_type rlid) const
Kokkos::View< DecisionType *, memory_space > results_view
typename local_matrix_type::ordinal_type local_ordinal_type
static RCP< Vector > GetMatrixOverlappedDiagonal(const Matrix &A)
Extract Overlapped Matrix Diagonal.
typename local_matrix_type::ordinal_type local_ordinal_type
typename local_matrix_type::value_type scalar_type
typename local_matrix_type::value_type scalar_type
Teuchos::RCP< diag_vec_type > diagVec
Kokkos::View< DecisionType *, memory_space > results_view
typename ATS::magnitudeType magnitudeType
SignedRSFunctor(matrix_type &A_, magnitudeType threshold, results_view &results_)
Teuchos::RCP< diag_vec_type > diagVec
Kokkos::View< const bool *, memory_space > boundary_nodes_view
typename Kokkos::DualView< const scalar_type *, Kokkos::LayoutStride, typename Node::device_type, Kokkos::MemoryUnmanaged >::t_dev diag_view_type
Kokkos::View< DecisionType *, memory_space > results_view
typename matrix_type::local_matrix_type local_matrix_type
typename local_matrix_type::memory_space memory_space
Kokkos::View< const bool *, memory_space > boundary_nodes_view
typename local_matrix_type::memory_space memory_space
typename local_matrix_type::value_type scalar_type
SignedSAFunctor(matrix_type &A_, magnitudeType threshold, results_view &results_)