8#include <kernel/lafem/dense_vector.hpp> 
    9#include <kernel/lafem/tuple_vector.hpp> 
   10#include <kernel/lafem/meta_element.hpp> 
   32      template<
typename,
typename...>
 
   47      static_assert(std::is_same<DataType, typename RestClass::DataType>::value, 
"sub-mirrors have different data-types");
 
   48      static_assert(std::is_same<IndexType, typename RestClass::IndexType>::value, 
"sub-mirrors have different index-types");
 
   51      template <
typename DT2_ = DataType, 
typename IT2_ = IndexType>
 
   57      template <
typename DataType2_, 
typename IndexType2_>
 
   68        _first(std::forward<First_>(the_first)),
 
   80      explicit TupleMirror(First_&& the_first, Rest_&&... the_rest) :
 
   81        _first(std::forward<First_>(the_first)),
 
   82        _rest(std::forward<Rest_>(the_rest)...)
 
   98          _first = std::forward<First_>(other._first);
 
   99          _rest = std::forward<RestClass>(other._rest);
 
  120      template<
typename... SubMirror2_>
 
  123        this->_first.convert(other._first);
 
  124        this->_rest.
convert(other._rest);
 
  135      template<
typename Tv_, 
typename... Tw_>
 
  163      const First_& first()
 const 
  173      const RestClass& 
rest()
 const 
  185      template<
typename Tv_, 
typename... Tw_>
 
  197      template<
typename Tv_, 
typename... Tw_>
 
  226      template<
typename Tv_, 
typename... Tw_>
 
  232        _first.gather(buffer, vector.first(), buffer_offset);
 
  233        _rest.
gather(buffer, vector.rest(), buffer_offset + 
_first.buffer_size(vector.first()));
 
  237      template<
typename Tv_, 
typename... Tw_>
 
  244        _first.scatter_axpy(vector.first(), buffer, alpha, buffer_offset);
 
  249      template<
Perspective perspective_, 
typename Tv_, 
typename... Tw_>
 
  253        Index nf = 
_first.template mask_scatter<perspective_>(vector.first(), mask, 
value, offset);
 
  254        Index nr = 
_rest.template mask_scatter<perspective_>(vector.rest(), mask, 
value, offset + nf);
 
  260    template<
typename First_>
 
  261    class TupleMirror<First_>
 
  263      template<
typename,
typename...>
 
  264      friend class TupleMirror;
 
  270      typedef typename First_::DataType 
DataType;
 
  271      typedef typename First_::IndexType 
IndexType;
 
  273      template <
typename DT2_ = DataType, 
typename IT2_ = IndexType>
 
  274      using MirrorType = TupleMirror<typename First_::template MirrorType<DT2_, IT2_> >;
 
  277      template <
typename DataType2_, 
typename IndexType2_>
 
  288      explicit TupleMirror(First_&& the_first) :
 
  289        _first(std::forward<First_>(the_first))
 
  293      TupleMirror(TupleMirror&& other) :
 
  298      TupleMirror& 
operator=(TupleMirror&& other)
 
  307      TupleMirror 
clone()
 const 
  309        return TupleMirror(
_first.clone());
 
  314        return TupleMirror(
_first.clone(clone_mode));
 
  317      template<
typename SubMirror2_>
 
  318      void convert(
const TupleMirror<SubMirror2_>& other)
 
  320        this->_first.convert(
other._first);
 
  323      template<
typename Tv_>
 
  324      static TupleMirror 
make_empty(
const TupleVector<Tv_>& tmpl_vec)
 
  326        return TupleMirror(First_::make_empty(tmpl_vec.first()));
 
  330      std::size_t 
bytes()
 const 
  344      const First_& first()
 const 
  349      template<
typename Tv_>
 
  352        return _first.buffer_size(vector.first());
 
  355      template<
typename Tv_>
 
  356      DenseVector<DataType, IndexType> 
create_buffer(
const TupleVector<Tv_>& vector)
 const 
  358        return DenseVector<DataType, IndexType>(
buffer_size(vector));
 
  364        static_assert(i_ == 0, 
"invalid sub-mirror index");
 
  369      const First_& 
at()
 const 
  371        static_assert(i_ == 0, 
"invalid sub-mirror index");
 
  375      template<
typename Tv_>
 
  377        LAFEM::DenseVector<DataType, IndexType>& buffer,
 
  378        const LAFEM::TupleVector<Tv_>& vector,
 
  381        _first.gather(buffer, vector.first(), buffer_offset);
 
  384      template<
typename Tv_>
 
  386        LAFEM::TupleVector<Tv_>& vector,
 
  387        const LAFEM::DenseVector<DataType, IndexType>& buffer,
 
  391        _first.scatter_axpy(vector.first(), buffer, alpha, buffer_offset);
 
  394      template<Perspective perspective_, 
typename Tv_>
 
  395      Index mask_scatter(
const LAFEM::TupleVector<Tv_>& vector, std::vector<int>& mask,
 
  398        return _first.template mask_scatter<perspective_>(vector.first(), mask, 
value, offset);
 
Dense data vector class template.
TupleVector meta-mirror class template.
bool empty() const
Checks whether the mirror is empty.
TupleMirror(TupleMirror &&other)
move-ctor
TupleMirror(First_ &&the_first, Rest_ &&... the_rest)
sub-mirror emplacement ctor
First_::DataType DataType
sub-mirror data-type
static constexpr int num_blocks
number of mirror blocks
TupleMirror< typename First_::template MirrorType< DT2_, IT2_ >, typename Rest_::template MirrorType< DT2_, IT2_ >... > MirrorType
Our 'base' class type.
TupleElement< i_, First_, Rest_... >::Type & at()
Returns a sub-mirror block.
DenseVector< DataType, IndexType > create_buffer(const TupleVector< Tv_, Tw_... > &vector) const
Creates a new buffer vector for a TupleVector.
std::size_t bytes() const
Returns the total amount of bytes allocated.
TupleMirror()
default ctor
void scatter_axpy(LAFEM::TupleVector< Tv_, Tw_... > &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.
TupleMirror & operator=(TupleMirror &&other)
move-assign operator
Index mask_scatter(const LAFEM::TupleVector< Tv_, Tw_... > &vector, std::vector< int > &mask, const int value, const Index offset=Index(0)) const
Updates a scatter mask vector for this mirror.
TupleElement< i_, First_, Rest_... >::Type const & at() const
Returns a sub-mirror block.
void gather(LAFEM::DenseVector< DataType, IndexType > &buffer, const LAFEM::TupleVector< Tv_, Tw_... > &vector, const Index buffer_offset=Index(0)) const
Gathers the buffer entries from a DenseVector.
static TupleMirror make_empty(const TupleVector< Tv_, Tw_... > &tmpl_vec)
Creates and returns an empty mirror.
void convert(const TupleMirror< SubMirror2_... > &other)
Conversion method.
First_::IndexType IndexType
sub-mirror index-type
MirrorType< DataType2_, IndexType2_ > MirrorTypeByDI
this typedef lets you create a mirror with new Data and Index types
TupleMirror(First_ &&the_first, RestClass &&the_rest)
data-move ctor; this one is protected for a reason
First_ _first
the first sub-mirror
RestClass _rest
all remaining sub-mirrors
TupleMirror clone(CloneMode clone_mode=CloneMode::Weak) const
Clone operation.
Index buffer_size(const TupleVector< Tv_, Tw_... > &vector) const
Computes the required buffer size for a TupleVector.
Variadic TupleVector class template.
@ other
generic/other permutation strategy
@ rest
restriction (multigrid)
@ value
specifies whether the space should supply basis function values
std::uint64_t Index
Index data type.
Tuple container element helper class template.