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_block_bcsr.hpp>
15#include <kernel/lafem/arch/unit_filter_block_vec.hpp>
16#include <kernel/lafem/arch/unit_filter_block_weak_bcsr.hpp>
64 template <
typename DT2_ = DT_,
typename IT2_ = IT_>
68 template <
typename DataType2_,
typename IndexType2_>
71 static constexpr bool is_global =
false;
72 static constexpr bool is_local =
true;
74 static_assert(
block_size > 1,
"block_size has to be >= 2 in UnitFilterBlocked!");
101 _sv(num_entries, num_nonzeros),
116 _sv(size_in, values, indices),
124 _sv(std::move(other.
_sv)),
134 _sv = std::forward<
decltype(other._sv)>(other._sv);
149 other.clone(*
this, clone_mode);
156 _sv.
clone(other.get_filter_vector(), clone_mode);
161 template<
typename DT2_,
typename IT2_,
int BS_>
185 const SparseVectorBlocked<DT_, IT_, block_size>& get_filter_vector()
const
247 return _sv.elements_arbiter();
253 return _sv.elements_arbiter();
259 return _sv.elements_view_r(loc);
265 return _sv.elements_view_w(loc);
271 return _sv.elements_view_rw(loc);
285 return _sv.elements_view(loc, acc);
291 return _sv.indices_arbiter();
297 return _sv.indices_arbiter();
303 return _sv.indices_view_r(loc);
309 return _sv.indices_view_w(loc);
315 return _sv.indices_view_rw(loc);
329 return _sv.indices_view(loc, acc);
389 template<
int block_w
idth_>
401 template<
int block_w
idth_>
407 XASSERTM(
_sv.
size() == matrix.num_rows(),
"Matrix size does not match!");
409 Arch::UnitFilterBlockBCSR::template exec<DT_, IT_, block_size_, block_width_>(
410 matrix.val_arbiter(), matrix.row_ptr_arbiter(), matrix.col_idx_arbiter(),
414 template<
int block_w
idth_>
437 template<
int block_w
idth_>
451 Arch::UnitFilterBlockWeakBCSR::template exec<DT_, IT_, block_size_, block_width_>(
470 Arch::UnitFilterBlockVec::template exec<DT_, IT_, block_size_>(vector.
elements_arbiter(),
499 Arch::UnitFilterBlockVec::template exec<DT_, IT_, block_size_>(vector.
elements_arbiter(),
#define XASSERTM(expr, msg)
Assertion macro definition with custom message.
std::size_t bytes() const
Returns the total amount of bytes allocated.
virtual void clear()
Free all allocated arrays.
Blocked Dense data vector class template.
Index size() const
Returns the size of this vector, i.e. its number of entries.
Memory::Arbiter & elements_arbiter()
Returns a reference to the element array arbiter.
Dense data vector class template.
Index size() const
Returns the size of this vector, i.e. its number of entries.
CSR based blocked sparse matrix.
Memory::Arbiter & val_arbiter()
Returns a reference to the values array arbiter.
Index num_rows() const
Retrieve matrix row count.
Index num_nzes() const
Retrieve non zero element count.
Memory::Arbiter & row_ptr_arbiter()
Returns a reference to the row-pointer array arbiter.
Index num_cols() const
Retrieve matrix column count.
Memory::Arbiter & col_idx_arbiter()
Returns a reference to the column-index array arbiter.
Sparse vector class template.
bool hollow() const
Checks whether the sparse vector does not contain any non-zero elements.
Index size() const
Returns the native size of the sparse vector.
bool empty() const
Checks whether the size of the sparse vector is zero.
Index num_nzes_raw() const
Returns the raw number of non-zero elements in the sparse vector.
void convert(const SparseVectorBlocked< DT2_, IT2_, block_size_ > &other)
Conversion method.
Index num_nzes() const
Returns the number of non-zero elements in the sparse vector.
SparseVectorBlocked clone(CloneMode clone_mode=CloneMode::Deep) const
Clone operation.
Index size_raw() const
Returns the raw size of the sparse vector.
Unit Filter Blocked class template.
UnitFilterBlocked(Index num_entries, Index num_nonzeros, bool ignore_nans=false)
Constructor.
std::size_t bytes() const
Returns the total amount of bytes allocated.
Memory::TypedView< IT_ > indices_view_w(Memory::Location loc=Memory::Location::main)
Creates a write-only memory view for the indices array for a given memory location.
void filter_offdiag_col_mat(MatrixType &matrix) const
Filter the non-diagonal column entries.
void convert(const UnitFilterBlocked< DT2_, IT2_, BS_ > &other)
Converts data from another UnitFilter.
Memory::TypedView< ValueType > elements_view_w(Memory::Location loc=Memory::Location::main)
Creates a write-only memory view for the elements array for a given memory location.
Memory::TypedView< IT_ > indices_view_r(Memory::Location loc=Memory::Location::main) const
Creates a read-only memory view for the indices array for a given memory location.
void filter_cor(VectorType &vector) const
Applies the filter onto a correction vector.
UnitFilterBlocked()
default constructor
Index num_nzes_raw() const
Returns the raw number of non-zero entries in the filter.
Memory::Arbiter & indices_arbiter()
Returns a reference to the indices memory arbiter.
Index size_raw() const
Returns the total raw size of the filter.
IT_ IndexType
index-type typedef
UnitFilterBlocked & operator=(UnitFilterBlocked &&other)
move-assignment operator
DenseVectorBlocked< DataType, IndexType, block_size > VectorType
Our supported vector type.
void filter_mat(MatrixType &matrix) const
Applies the filter onto a system matrix.
void clone(const UnitFilterBlocked &other, CloneMode clone_mode=CloneMode::Deep)
Clones data from another UnitFilterBlocked.
Tiny::Vector< DataType, block_size > ValueType
Value type.
const Memory::Arbiter & elements_arbiter() const
Returns a const reference to the elements memory arbiter.
Memory::TypedView< IT_ > indices_view(Memory::Location loc, Memory::Access acc)
Creates a memory view for the indices array.
void filter_sol(VectorType &vector) const
Applies the filter onto the solution vector.
bool empty() const
Checks whether the size of the filter is zero.
UnitFilterBlocked(UnitFilterBlocked &&other)
move-ctor
Index num_nzes() const
Returns the number of non-zero entries in the filter.
const Memory::Arbiter & indices_arbiter() const
Returns a const reference to the indices memory arbiter.
void filter_weak_matrix_rows(SparseMatrixBCSR< DT_, IT_, block_size_, block_width_ > &matrix_a, const SparseMatrixBCSR< DT_, IT_, block_size_, block_width_ > &matrix_m) const
Replaces the rows of the system matrix by scaled rows of another matrix.
void clear()
Clears the underlying data (namely the SparseVector)
Memory::TypedView< IT_ > indices_view_rw(Memory::Location loc=Memory::Location::main)
Creates a read-write memory view for the indices array for a given memory location.
bool hollow() const
Checks whether the filter does not contain any non-zero elements.
Memory::TypedView< ValueType > elements_view_r(Memory::Location loc=Memory::Location::main) const
Creates a read-only memory view for the elements array for a given memory location.
void filter_rhs(VectorType &vector) const
Applies the filter onto the right-hand-side vector.
Memory::Arbiter & elements_arbiter()
Returns a reference to the elements memory arbiter.
void filter_offdiag_row_mat(MatrixType &matrix) const
Filter the non-diagonal row entries.
Memory::TypedView< ValueType > elements_view(Memory::Location loc, Memory::Access acc)
Creates a memory view for the elements array.
bool get_ignore_nans() const
Specifies whether the filter should ignore NaNs filter values.
Index size() const
Returns the total native size of the filter.
void set_ignore_nans(bool ignore_nans)
Specifies whether the filter should ignore NaN filter values.
SparseVectorBlocked< DataType, IndexType, block_size > _sv
SparseVector, containing all entries of the unit filter.
void filter_def(VectorType &vector) const
Applies the filter onto a defect vector.
bool _ignore_nans
ignore NaNs in filter values
DT_ DataType
data-type typedef
UnitFilterBlocked(Index size_in, DenseVectorBlocked< DT_, IT_, block_size_ > &values, DenseVector< IT_, IT_ > &indices, bool ignore_nans=false)
Constructor.
UnitFilterBlocked clone(CloneMode clone_mode=CloneMode::Deep) const
Creates a clone of itself.
virtual ~UnitFilterBlocked()
virtual destructor
static constexpr int block_size
The block size.
Memory::TypedView< ValueType > elements_view_rw(Memory::Location loc=Memory::Location::main)
Creates a read-write memory view for the elements array for a given memory location.
Tiny Vector class template.
Access
Memory access enumeration.
Location
Memory location enumeration.
std::uint64_t Index
Index data type.