10#include <kernel/util/math.hpp>
11#include <kernel/lafem/sparse_matrix_bcsr.hpp>
12#include <kernel/lafem/dense_vector_blocked.hpp>
13#include <kernel/lafem/sparse_vector_blocked.hpp>
14#include <kernel/lafem/arch/unit_filter_blocked.hpp>
62 template <
typename DT2_ = DT_,
typename IT2_ = IT_>
66 template <
typename DataType2_,
typename IndexType2_>
69 static constexpr bool is_global =
false;
70 static constexpr bool is_local =
true;
72 static_assert(
BlockSize > 1,
"BlockSize has to be >= 2 in UnitFilterBlocked!");
114 _sv(size_in, values, indices),
122 _sv(std::move(other.
_sv)),
132 _sv = std::forward<
decltype(other._sv)>(other._sv);
147 other.clone(*
this, clone_mode);
154 _sv.
clone(other.get_filter_vector(), clone_mode);
159 template<
typename DT2_,
typename IT2_,
int BS_>
183 const SparseVectorBlocked<DT_, IT_, BlockSize>& get_filter_vector()
const
317 template<
int BlockW
idth_>
325 Arch::UnitFilterBlocked::filter_unit_mat
326 (matrix.template val<LAFEM::Perspective::pod>(), matrix.
row_ptr(), matrix.
col_ind(), BlockSize_, BlockWidth_,
330 template<
int BlockW
idth_>
338 Arch::UnitFilterBlocked::filter_offdiag_row_mat
339 (matrix.template val<LAFEM::Perspective::pod>(), matrix.row_ptr(), BlockSize_, BlockWidth_,
343 template<
int BlockW
idth_>
366 template<
int BlockW
idth_>
373 if(matrix_a.
val() == matrix_m.
val())
375 XABORTM(
"Matrices are not allowed to hold the same data");
383 XASSERTM(row_ptr == matrix_m.
row_ptr(),
"matrix A and M must share their layout");
384 XASSERTM(col_idx == matrix_m.
col_ind(),
"matrix A and M must share their layout");
386 Arch::UnitFilterBlocked::filter_weak_matrix_rows
387 (matrix_a.template val<LAFEM::Perspective::pod>(), matrix_m.template val<LAFEM::Perspective::pod>(), row_ptr, BlockSize_, BlockWidth_,
404 Arch::UnitFilterBlocked::filter_rhs
405 (vector.template elements<Perspective::pod>(), BlockSize_,
_sv.template elements<Perspective::pod>(),
433 Arch::UnitFilterBlocked::filter_def
434 (vector.template elements<Perspective::pod>(), BlockSize_,
_sv.template elements<Perspective::pod>(),
#define XABORTM(msg)
Abortion macro definition with custom message.
#define XASSERTM(expr, msg)
Assertion macro definition with custom message.
std::size_t bytes() const
Returns the total amount of bytes allocated.
Index size() const
Returns the containers size.
virtual void clear()
Free all allocated arrays.
Blocked Dense data vector class template.
Index size() const
The number of elements.
Dense data vector class template.
CSR based blocked sparse matrix.
Index rows() const
Retrieve matrix row count.
IT_ * col_ind()
Retrieve column indices array.
IT_ * row_ptr()
Retrieve row start index array.
auto val() const -> const typename Intern::BCSRPerspectiveHelper< DT_, BlockHeight_, BlockWidth_, perspective_ >::Type *
Retrieve non zero element array.
Sparse vector class template.
Index size() const
The number of elements.
Index used_elements() const
Retrieve non zero element count.
void permute(Adjacency::Permutation &perm)
Permutate vector according to the given Permutation.
SparseVectorBlocked clone(CloneMode clone_mode=CloneMode::Deep) const
Clone operation.
void convert(const SparseVectorBlocked< DT2_, IT2_, BlockSize_ > &other)
Conversion method.
IT_ * indices()
Get a pointer to the non zero indices array.
auto elements() const -> const typename Intern::SparseVectorBlockedPerspectiveHelper< DT_, BlockSize_, perspective_ >::Type *
Retrieve a pointer to the data array.
Unit Filter Blocked class template.
std::size_t bytes() const
Returns the total amount of bytes allocated.
void filter_offdiag_col_mat(MatrixType &matrix) const
Filter the non-diagonal column entries.
DT_ DataType
data-type typedef
void set_ignore_nans(bool ignore_nans)
Specifies whether the filter should ignore NaN filter values.
void filter_weak_matrix_rows(SparseMatrixBCSR< DT_, IT_, BlockSize_, BlockWidth_ > &matrix_a, const SparseMatrixBCSR< DT_, IT_, BlockSize_, BlockWidth_ > &matrix_m) const
Replaces the rows of the system matrix by scaled rows of another matrix.
IT_ IndexType
index-type typedef
UnitFilterBlocked(Index size_in, DenseVectorBlocked< DT_, IT_, BlockSize_ > &values, DenseVector< IT_, IT_ > &indices, bool ignore_nans=false)
Constructor.
static constexpr int BlockSize
The block size.
bool get_ignore_nans() const
Specifies whether the filter should ignore NaNs filter values.
Tiny::Vector< DataType, BlockSize > ValueType
Value type.
void clone(const UnitFilterBlocked &other, CloneMode clone_mode=CloneMode::Deep)
Clones data from another UnitFilterBlocked.
void permute(Adjacency::Permutation &perm)
Permutate internal vector according to the given Permutation.
UnitFilterBlocked(Index num_entries, bool ignore_nans=false)
Constructor.
void filter_offdiag_row_mat(MatrixType &matrix) const
Filter the non-diagonal row entries.
void clear()
Clears the underlying data (namely the SparseVector)
UnitFilterBlocked clone(CloneMode clone_mode=CloneMode::Deep) const
Creates a clone of itself.
void filter_sol(VectorType &vector) const
Applies the filter onto the solution vector.
void add(IndexType idx, ValueType val)
Adds one element to the filter.
DenseVectorBlocked< DataType, IndexType, BlockSize > VectorType
Our supported vector type.
UnitFilterBlocked & operator=(UnitFilterBlocked &&other)
move-assignment operator
SparseVectorBlocked< DataType, IndexType, BlockSize > _sv
SparseVector, containing all entries of the unit filter.
void filter_rhs(VectorType &vector) const
Applies the filter onto the right-hand-side vector.
void convert(const UnitFilterBlocked< DT2_, IT2_, BS_ > &other)
Converts data from another UnitFilter.
const IT_ * get_indices() const
virtual ~UnitFilterBlocked()
virtual destructor
void filter_mat(MatrixType &matrix) const
Applies the filter onto a system matrix.
bool _ignore_nans
ignore NaNs in filter values
Index used_elements() const
void filter_cor(VectorType &vector) const
Applies the filter onto a correction vector.
void filter_def(VectorType &vector) const
Applies the filter onto a defect vector.
UnitFilterBlocked(UnitFilterBlocked &&other)
move-ctor
UnitFilterBlocked()
default constructor
const ValueType * get_values() const
Tiny Vector class template.
std::uint64_t Index
Index data type.