10#include <kernel/lafem/sparse_matrix_csr.hpp>
11#include <kernel/lafem/sparse_matrix_bcsr.hpp>
12#include <kernel/lafem/dense_vector.hpp>
13#include <kernel/lafem/sparse_vector.hpp>
14#include <kernel/lafem/arch/unit_filter.hpp>
40 template <
typename DT2_ = DT_,
typename IT2_ = IT_>
44 template <
typename DataType2_,
typename IndexType2_>
47 static constexpr bool is_global =
false;
48 static constexpr bool is_local =
true;
80 _sv(size_in, values, indices)
96 _sv = std::forward<
decltype(other._sv)>(other._sv);
110 other.clone(*
this, clone_mode);
117 _sv.clone(other.get_filter_vector(), clone_mode);
121 template<
typename DT2_,
typename IT2_>
124 _sv.convert(other.get_filter_vector());
145 const SparseVector<DT_, IT_>& get_filter_vector()
const
172 return _sv.used_elements();
178 return _sv.indices();
184 return _sv.indices();
190 return _sv.elements();
196 return _sv.elements();
253 Arch::UnitFilter::filter_unit_mat(matrix.
val(), row_ptr, col_idx,
_sv.indices(),
_sv.used_elements());
261 XASSERTM(
_sv.size() == matrix.rows(),
"Matrix size does not match!");
263 const IndexType* row_ptr(matrix.row_ptr());
264 Arch::UnitFilter::filter_offdiag_row_mat(matrix.val(), row_ptr, 1,
_sv.indices(),
_sv.used_elements());
272 template<
int block_w
idth_>
278 XASSERTM(
_sv.size() == matrix.rows(),
"Matrix size does not match!");
280 const IndexType* row_ptr(matrix.row_ptr());
281 Arch::UnitFilter::filter_offdiag_row_mat(matrix.template val<Perspective::pod>(), row_ptr, block_width_,
_sv.indices(),
_sv.used_elements());
284 template<
int block_height_>
311 XASSERTM(
_sv.size() == matrix_a.
rows(),
"Matrix size does not match!");
312 XASSERTM(
_sv.size() == matrix_m.
rows(),
"Matrix size does not match!");
316 XASSERTM(row_ptr == matrix_m.
row_ptr(),
"matrix A and M must share their layout");
317 XASSERTM(col_idx == matrix_m.
col_ind(),
"matrix A and M must share their layout");
319 DT_* val_a(matrix_a.
val());
320 const DT_* val_m(matrix_m.
val());
337 Arch::UnitFilter::filter_rhs(vector.
elements(),
_sv.elements(),
_sv.indices(),
_sv.used_elements());
363 Arch::UnitFilter::filter_def(vector.
elements(),
_sv.indices(),
_sv.used_elements());
#define XASSERTM(expr, msg)
Assertion macro definition with custom message.
Index size() const
Returns the containers size.
Dense data vector class template.
DT_ * elements()
Get a pointer to the data array.
IT_ * col_ind()
Retrieve column indices array.
DT_ * val()
Retrieve non zero element array.
Index rows() const
Retrieve matrix row count.
IT_ * row_ptr()
Retrieve row start index array.
Sparse vector class template.
Unit Filter class template.
const DT_ * get_values() const
UnitFilter clone(CloneMode clone_mode=CloneMode::Deep) const
Creates a clone of itself.
UnitFilter()
default constructor
void clone(const UnitFilter &other, CloneMode clone_mode=CloneMode::Deep)
Clones data from another UnitFilter.
DenseVector< DataType, IndexType > VectorType
our supported vector type
void permute(Adjacency::Permutation &perm)
Permutate internal vector according to the given Permutation.
SparseVector< DT_, IT_ > _sv
SparseVector, containing all entries of the unit filter.
void filter_mat(MatrixType &matrix) const
Applies the filter onto a system matrix.
const IT_ * get_indices() const
void filter_weak_matrix_rows(SparseMatrixCSR< DT_, IT_ > &matrix_a, const SparseMatrixCSR< DT_, IT_ > &matrix_m) const
Replaces the rows of the system matrix by scaled rows of another matrix.
void filter_def(DenseVector< DT_, IT_ > &vector) const
Applies the filter onto a defect vector.
void filter_cor(DenseVector< DT_, IT_ > &vector) const
Applies the filter onto a correction vector.
UnitFilter(Index size_in, DenseVector< DT_, IT_ > &values, DenseVector< IT_, IT_ > &indices)
Constructor.
void filter_offdiag_col_mat(MatrixType &matrix) const
Filter the non-diagonal entries, column wise.
void filter_offdiag_row_mat(MatrixType &matrix) const
Filter the non-diagonal entries, row wise.
UnitFilter & operator=(UnitFilter &&other)
move-assignment operator
void filter_rhs(DenseVector< DT_, IT_ > &vector) const
Applies the filter onto the right-hand-side vector.
void convert(const UnitFilter< DT2_, IT2_ > &other)
Converts data from another UnitFilter.
Index used_elements() const
virtual ~UnitFilter()
virtual destructor
std::size_t bytes() const
Returns the total amount of bytes allocated.
void filter_sol(DenseVector< DT_, IT_ > &vector) const
Applies the filter onto the solution vector.
UnitFilter(UnitFilter &&other)
move-ctor
UnitFilter(Index size_in)
Constructor.
void add(IndexType idx, DataType val)
Adds one element to the filter.
DT_ DataType
data-type typedef
IT_ IndexType
index-type typedef
void clear()
Clears the underlying data (namely the SparseVector)
std::uint64_t Index
Index data type.