9#include <kernel/lafem/container.hpp>
10#include <kernel/lafem/dense_vector.hpp>
11#include <kernel/lafem/dense_vector_blocked.hpp>
12#include <kernel/lafem/sparse_vector.hpp>
13#include <kernel/lafem/sparse_vector_blocked.hpp>
14#include <kernel/lafem/sparse_matrix_csr.hpp>
15#include <kernel/lafem/arch/mirror_block_gather.hpp>
16#include <kernel/lafem/arch/mirror_block_scatter.hpp>
17#include <kernel/lafem/arch/mirror_dense_gather.hpp>
18#include <kernel/lafem/arch/mirror_dense_scatter.hpp>
19#include <kernel/lafem/arch/mirror_sparse_block_gather.hpp>
20#include <kernel/lafem/arch/mirror_sparse_block_scatter.hpp>
21#include <kernel/lafem/arch/mirror_sparse_gather.hpp>
22#include <kernel/lafem/arch/mirror_sparse_scatter.hpp>
30 template<
typename,
typename =
void>
31 static constexpr int dim_vec = 1;
34 static constexpr int dim_vec<T,
35 std::void_t<
decltype(T::BlockSize)>> = T::BlockSize;
65 template<
typename DT_,
typename IT_>
78 template <
typename DT2_ = DT_,
typename IT2_ = IT_>
82 template <
typename DataType2_,
typename IndexType2_>
97 _idx_view(mirror.indices_view_r())
113 return _mirror.
size();
120 return &_idx_view.
get_r()[domain_node];
127 return &_idx_view.
get_r()[domain_node+1];
157 if(num_idx >
Index(0))
176 this->
move(std::forward<BaseClass>(other));
193 for(
Index i(0); i < size_in; ++i)
219 template<
int block_size_>
225 Adjactor adjactor()
const
227 return Adjactor(*
this);
240 t.
clone(*
this, clone_mode);
252 template<
typename DT2_,
typename IT2_>
264 template<
typename DT2_,
typename IT2_>
298 Index nonzeros()
const
332 return Memory::TypedView<IT_>();
339 return Memory::TypedView<IT_>();
340 return Memory::TypedView<IT_>(this->
_indices.at(0).view(loc, acc));
349 template<
typename Vector_>
361 template<
typename DT2_,
typename IT2_,
int block_size_>
373 template<
typename DT2_,
typename IT2_>
385 template<
typename DT2_,
typename IT2_,
int block_size_>
397 template<
typename Vector_>
421 XASSERTM(this->
size() == vector.
size(),
"size mismatch between mirror and vector");
426 LAFEM::Arch::MirrorDenseGather::template exec<DT_, IT_>(buffer_offset, this->
num_indices(),
452 XASSERTM(this->
size() == vector.
size(),
"size mismatch between mirror and vector");
457 LAFEM::Arch::MirrorDenseScatter::template exec<DT_, IT_>(buffer_offset, this->
num_indices(),
473 template<
int block_size_>
480 XASSERTM(this->
size() == vector.
size(),
"size mismatch between mirror and vector");
485 LAFEM::Arch::MirrorBlockGather::template exec<DT_, IT_, block_size_>(buffer_offset, this->
num_indices(),
504 template<
int block_size_>
512 XASSERTM(this->
size() == vector.
size(),
"size mismatch between mirror and vector");
517 LAFEM::Arch::MirrorBlockScatter::template exec<DT_, IT_, block_size_>(buffer_offset, this->
num_indices(),
539 XASSERTM(this->
size() == vector.
size(),
"size mismatch between mirror and vector");
544 LAFEM::Arch::MirrorSparseGather::template exec<DT_, IT_>(buffer_offset, this->
num_indices(),
571 XASSERTM(this->
size() == vector.
size(),
"size mismatch between mirror and vector");
576 LAFEM::Arch::MirrorSparseScatter::template exec<DT_, IT_>(buffer_offset, this->
num_indices(),
593 template<
int block_size_>
600 XASSERTM(this->
size() == vector.
size(),
"size mismatch between mirror and vector");
605 LAFEM::Arch::MirrorSparseBlockGather::template exec<DT_, IT_, block_size_>(buffer_offset,
607 vector.
num_nzes(), vector.elements_arbiter(), vector.indices_arbiter());
625 template<
int block_size_>
633 XASSERTM(this->
size() == vector.
size(),
"size mismatch between mirror and vector");
638 LAFEM::Arch::MirrorSparseBlockScatter::template exec<DT_, IT_, block_size_>(buffer_offset,
640 vector.
num_nzes(), vector.elements_arbiter(), vector.indices_arbiter(), alpha);
665 template<
typename DT2_,
typename IT2_>
674 for(
Index i(0); i < n; ++i)
675 mask[offset + idx[i]] =
value;
677 return vector.
size();
680 template<
typename DT2_,
typename IT2_>
709 template<
typename DT2_,
typename IT2_,
int block_size_>
718 for(
Index i(0); i < n; ++i)
719 mask[offset + idx[i]] =
value;
721 return vector.
size();
724 template<
typename DT2_,
typename IT2_,
int block_size_>
733 for(
Index i(0); i < n; ++i)
735 const Index ibs = idx[i] *
Index(block_size_);
736 for(
int k(0); k < block_size_; ++k)
739 return vector.
size();
742 friend std::ostream & operator<< (std::ostream & lhs,
const VectorMirror & b)
744 Index n = b.num_indices();
745 const Memory::TypedView<IT_> idx = b.indices_view_r();
748 for (
Index i(0) ; i < n ; ++i)
750 lhs <<
" " << idx[i];
#define XASSERT(expr)
Assertion macro definition.
#define XASSERTM(expr, msg)
Assertion macro definition with custom message.
void move(Container &&source)
Assignment move operation.
void clone(const Container &source, CloneMode clone_mode=CloneMode::Weak)
Clone operation.
void assign(const Container< DT2_, IT2_ > &other)
Assignment operation.
std::vector< Memory::Arbiter > _indices
List of pointers to all IT_ dependent arrays.
std::vector< Index > _indices_size
List of corresponding IT_ array sizes.
std::vector< Index > _scalar_index
List of scalars with datatype index.
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.
Memory::Arbiter & elements_arbiter()
Returns a reference to the element array arbiter.
Index size() const
Returns the size of this vector, i.e. its number of entries.
Sparse vector class template.
Index size() const
Returns the native size of the sparse vector.
Index num_nzes() const
Returns the number of non-zero elements in the sparse vector.
Sparse vector class template.
Index num_nzes() const
Returns the number of non-zero elements in the sparse vector.
Memory::Arbiter & elements_arbiter()
Returns a reference to the elements memory arbiter.
Index size() const
Returns the native size of the sparse vector.
Memory::Arbiter & indices_arbiter()
Returns a reference to the indices memory arbiter.
ImageIterator image_begin(Index domain_node) const
ImageIterator image_end(Index domain_node) const
Index get_num_nodes_image() const
const IT_ * ImageIterator
ImageIterator for Adjactor interface implementation.
Index get_num_nodes_domain() const
Handles vector prolongation, restriction and serialization.
static VectorMirror make_hollow(const DenseVector< DT_, IT_ > &tmpl_vec)
Creates and returns a hollow mirror.
static VectorMirror make_identity(Index size_in)
Creates and returns an identity mirror.
Index buffer_size(const Vector_ &vector) const
Computes the required buffer size for a DenseVector.
void gather(LAFEM::DenseVector< DataType, IndexType > &buffer, const LAFEM::SparseVectorBlocked< DataType, IndexType, block_size_ > &vector, const Index buffer_offset=Index(0)) const
Gathers the buffer entries from a SparseVectorBlocked.
const Memory::Arbiter & indices_arbiter() const
Returns a reference to the element array arbiter.
Index size() const
Returns the size of this vector, i.e. its number of entries.
void gather(LAFEM::DenseVector< DataType, IndexType > &buffer, const LAFEM::DenseVector< DataType, IndexType > &vector, const Index buffer_offset=Index(0)) const
Gathers the buffer entries from a DenseVector.
Index buffer_size(const DenseVectorBlocked< DT2_, IT2_, block_size_ > &vector) const
Computes the required buffer size for a DenseVectorBlocked.
Index mask_scatter(const DenseVectorBlocked< DT2_, IT2_, block_size_ > &vector, std::vector< int > &mask, const int value, const Index offset=Index(0)) const
Updates a scatter mask vector for this mirror.
void scatter_axpy(LAFEM::SparseVectorBlocked< DataType, IndexType, block_size_ > &vector, const LAFEM::DenseVector< DataType, IndexType > &buffer, const DataType alpha=DataType(1), const Index buffer_offset=Index(0)) const
Scatters the buffer entries onto a SparseVectorBlocked.
void scatter_axpy(LAFEM::SparseVector< DataType, IndexType > &vector, const LAFEM::DenseVector< DataType, IndexType > &buffer, const DataType alpha=DataType(1), const Index buffer_offset=Index(0)) const
Scatters the buffer entries onto a SparseVector.
void gather(LAFEM::DenseVector< DataType, IndexType > &buffer, const LAFEM::SparseVector< DataType, IndexType > &vector, const Index buffer_offset=Index(0)) const
Gathers the buffer entries from a SparseVector.
IT_ IndexType
index-type typedef
DenseVector< DataType, IndexType > create_buffer(const Vector_ &vector) const
Creates a new buffer vector for a vector.
VectorMirror(Index size_in, Index num_idx)
Constructor.
VectorMirror()
default constructor
VectorMirror & operator=(VectorMirror &&other)
move-assign operator
void gather(LAFEM::DenseVector< DataType, IndexType > &buffer, const LAFEM::DenseVectorBlocked< DataType, IndexType, block_size_ > &vector, const Index buffer_offset=Index(0)) const
Gathers the buffer entries from a DenseVectorBlocked.
Memory::Arbiter & indices_arbiter()
Returns a reference to the element array arbiter.
VectorMirror clone(CloneMode clone_mode=CloneMode::Weak) const
Clone operation.
static VectorMirror make_hollow(const DenseVectorBlocked< DT_, IT_, block_size_ > &tmpl_vec)
Creates and returns a hollow mirror.
Index buffer_size(const SparseVector< DT2_, IT2_ > &vector) const
Computes the required buffer size for a SparseVector.
void scatter_axpy(LAFEM::DenseVector< DataType, IndexType > &vector, const LAFEM::DenseVector< DataType, IndexType > &buffer, const DataType alpha=DataType(1), const Index buffer_offset=Index(0)) const
Scatters the buffer entries onto a DenseVector.
void scatter_axpy(LAFEM::DenseVectorBlocked< DataType, IndexType, block_size_ > &vector, const LAFEM::DenseVector< DataType, IndexType > &buffer, const DataType alpha=DataType(1), const Index buffer_offset=Index(0)) const
Scatters the buffer entries onto a DenseVectorBlocked.
Index mask_scatter(const DenseVector< DT2_, IT2_ > &vector, std::vector< int > &mask, const int value, const Index offset=Index(0)) const
Updates a scatter mask vector for this mirror.
Index num_indices() const
Returns the number of indices in the mirror.
Index buffer_size(const SparseVectorBlocked< DT2_, IT2_, block_size_ > &vector) const
Computes the required buffer size for a SparseVectorBlocked.
void clone(const VectorMirror< DT2_, IT2_ > &other, CloneMode clone_mode=CloneMode::Weak)
Clone operation.
DT_ DataType
data-type typedef
VectorMirror(VectorMirror &&other)
move-ctor
void convert(const VectorMirror< DT2_, IT2_ > &other)
Conversion method.
bool empty() const
Checks whether the vector is empty, i.e. if it has size 0.
bool hollow() const
Checks whether the vector is empty, i.e. if it has no nonzero entries.
Container< DT_, IT_ > BaseClass
our base class
const T_ * get_r() const
Returns a const typed pointer to the array that grants read access.
Access
Memory access enumeration.
@ read_write
read-write access
@ write
write-only access (see attention note above)
Location
Memory location enumeration.
@ value
specifies whether the space should supply basis function values
std::uint64_t Index
Index data type.