10 #ifndef MUELU_BOUNDARYDETECTION_HPP
11 #define MUELU_BOUNDARYDETECTION_HPP
14 #include <type_traits>
15 #include "Kokkos_Core.hpp"
16 #if KOKKOS_VERSION >= 40799
17 #include "KokkosKernels_ArithTraits.hpp"
19 #include "Kokkos_ArithTraits.hpp"
21 #include "MueLu_LWGraph_kokkos.hpp"
22 #include "MueLu_Utilities.hpp"
28 namespace MueLu::BoundaryDetection {
37 template <
class local_matrix_type>
44 #if KOKKOS_VERSION >= 40799
45 using ATS = KokkosKernels::ArithTraits<scalar_type>;
47 using ATS = Kokkos::ArithTraits<scalar_type>;
64 KOKKOS_FORCEINLINE_FUNCTION
66 auto row =
A.rowConst(rlid);
71 if ((rlid != static_cast<local_ordinal_type>(clid)) && (ATS::magnitude(val) >
dirichletThreshold)) {
91 template <
class local_matrix_type,
bool useGreedyDirichlet>
98 #if KOKKOS_VERSION >= 40799
99 using ATS = KokkosKernels::ArithTraits<scalar_type>;
101 using ATS = Kokkos::ArithTraits<scalar_type>;
120 KOKKOS_FORCEINLINE_FUNCTION
123 auto row =
A.rowConst(rlid);
125 bool rowIsDirichlet =
true;
127 auto clid = row.colidx(k);
128 auto val = row.value(k);
129 if ((rlid != static_cast<local_ordinal_type>(clid)) && (ATS::magnitude(val) >
dirichletThreshold)) {
132 rowIsDirichlet =
false;
137 if constexpr (useGreedyDirichlet) {
138 if (rowIsDirichlet) {
143 if (!rowIsDirichlet) {
148 if constexpr (!useGreedyDirichlet)
160 template <
class local_matrix_type>
167 #if KOKKOS_VERSION >= 40799
168 using ATS = KokkosKernels::ArithTraits<scalar_type>;
170 using ATS = Kokkos::ArithTraits<scalar_type>;
173 #if KOKKOS_VERSION >= 40799
174 using magATS = KokkosKernels::ArithTraits<magnitudeType>;
176 using magATS = Kokkos::ArithTraits<magnitudeType>;
190 KOKKOS_FORCEINLINE_FUNCTION
194 auto row =
A.rowConst(rlid);
196 auto clid = row.colidx(k);
197 auto val = row.value(k);
198 if (rlid == static_cast<local_ordinal_type>(clid))
202 if (ATS::magnitude(rowsum) > ATS::magnitude(diagval) *
rowSumTol) {
212 template <
class local_matrix_type,
class Functor,
class... RemainingFunctors>
221 BoundaryFunctor(local_matrix_type& A_, Functor& functor_, RemainingFunctors&... remainingFunctors_)
231 template <
class local_matrix_type,
class Functor>
Kokkos::ArithTraits< scalar_type > ATS
typename local_matrix_type::value_type scalar_type
magnitudeType dirichletThreshold
typename local_matrix_type::memory_space memory_space
typename local_matrix_type::memory_space memory_space
typename ATS::magnitudeType magnitudeType
Kokkos::View< bool *, memory_space > boundary_nodes_view
boundary_nodes_view boundaryNodes
BoundaryFunctor< local_matrix_type, RemainingFunctors...> remainingFunctors
Kokkos::ArithTraits< magnitudeType > magATS
KOKKOS_FUNCTION void operator()(const local_ordinal_type rlid) const
Kokkos::View< bool *, memory_space > boundary_nodes_view
local_ordinal_type blockSize
BoundaryFunctor(local_matrix_type &A_, Functor &functor_, RemainingFunctors &...remainingFunctors_)
boundary_nodes_view boundaryNodes
KOKKOS_FUNCTION void operator()(const local_ordinal_type rlid) const
typename local_matrix_type::value_type scalar_type
typename local_matrix_type::ordinal_type local_ordinal_type
Kokkos::ArithTraits< scalar_type > ATS
typename local_matrix_type::memory_space memory_space
VectorDirichletFunctor(local_matrix_type &A_, local_ordinal_type blockSize_, boundary_nodes_view boundaryNodes_, magnitudeType dirichletThreshold_, local_ordinal_type dirichletNonzeroThreshold_)
Functor for marking nodes as Dirichlet.
typename local_matrix_type::value_type scalar_type
BoundaryFunctor(local_matrix_type &A_, Functor &functor_)
boundary_nodes_view boundaryNodes
local_ordinal_type dirichletNonzeroThreshold
KOKKOS_FORCEINLINE_FUNCTION void operator()(const local_ordinal_type rblid) const
Kokkos::ArithTraits< scalar_type > ATS
typename ATS::magnitudeType magnitudeType
Functor for marking nodes as Dirichlet based on rowsum.
Functor that serially applies sub-functors to rows.
magnitudeType dirichletThreshold
typename local_matrix_type::ordinal_type local_ordinal_type
Kokkos::View< bool *, memory_space > boundary_nodes_view
Functor for marking nodes as Dirichlet in a block operator.
typename local_matrix_type::ordinal_type local_ordinal_type
typename local_matrix_type::ordinal_type local_ordinal_type
KOKKOS_FORCEINLINE_FUNCTION void operator()(const local_ordinal_type rlid) const
typename local_matrix_type::ordinal_type local_ordinal_type
RowSumFunctor(local_matrix_type &A_, boundary_nodes_view boundaryNodes_, magnitudeType rowSumTol_)
typename ATS::magnitudeType magnitudeType
local_ordinal_type dirichletNonzeroThreshold
PointDirichletFunctor(local_matrix_type &A_, boundary_nodes_view boundaryNodes_, magnitudeType dirichletThreshold_, local_ordinal_type dirichletNonzeroThreshold_)
KOKKOS_FORCEINLINE_FUNCTION void operator()(const local_ordinal_type rlid) const