9#include <kernel/lafem/tuple_vector.hpp>
10#include <kernel/lafem/meta_element.hpp>
35 template<
typename,
typename...>
50 static_assert(std::is_same<DataType, typename RestClass::DataType>::value,
51 "sub-filters have different data-types");
52 static_assert(std::is_same<IndexType, typename RestClass::IndexType>::value,
53 "sub-filters have different index-types");
59 template <
typename DT2_ = DataType,
typename IT2_ = IndexType>
65 template <
typename DataType2_,
typename IndexType2_>
76 _first(std::forward<First_>(the_first)),
88 explicit TupleFilter(First_&& the_first, Rest_&&... the_rest) :
89 _first(std::forward<First_>(the_first)),
90 _rest(std::forward<Rest_>(the_rest)...)
106 _first = std::forward<First_>(other._first);
107 _rest = std::forward<RestClass>(other._rest);
121 _first.clone(other._first, clone_mode);
125 template<
typename... SubFilter2_>
128 _first.convert(other._first);
129 _rest.convert(other._rest);
144 const First_& first()
const
154 const RestClass&
rest()
const
161 typename TupleElement<i_, First_, Rest_...>::Type& at()
163 static_assert((0 <= i_) && (i_ <
num_blocks),
"invalid sub-filter index");
164 return TupleElement<i_, First_, Rest_...>::get(*
this);
171 static_assert((0 <= i_) && (i_ <
num_blocks),
"invalid sub-filter index");
178 first().filter_rhs(vector.first());
179 rest().filter_rhs(vector.rest());
185 first().filter_sol(vector.first());
186 rest().filter_sol(vector.rest());
192 first().filter_def(vector.first());
193 rest().filter_def(vector.rest());
199 first().filter_cor(vector.first());
200 rest().filter_cor(vector.rest());
205 template<
typename First_>
206 class TupleFilter<First_>
208 template<
typename,
typename...>
209 friend class TupleFilter;
215 typedef typename First_::DataType
DataType;
217 typedef typename First_::IndexType
IndexType;
219 typedef TupleVector<typename First_::VectorType>
VectorType;
221 template <
typename DT2_ = DataType,
typename IT2_ = IndexType>
222 using FilterType = TupleFilter<typename First_::template FilterType<DT2_, IT2_> >;
225 template <
typename DataType2_,
typename IndexType2_>
239 explicit TupleFilter(First_&& the_first) :
240 _first(std::forward<First_>(the_first))
245 TupleFilter(TupleFilter&& other) :
251 TupleFilter&
operator=(TupleFilter&& other)
263 return TupleFilter(
_first.clone(clone_mode));
272 template<
typename SubFilter2_>
273 void convert(
const TupleFilter<SubFilter2_>& other)
279 std::size_t
bytes()
const
289 const First_& first()
const
295 typename TupleElement<i_, First_>::Type& at()
297 static_assert(i_ == 0,
"invalid sub-filter index");
302 typename TupleElement<i_, First_>::Type
const& at()
const
304 static_assert(i_ == 0,
"invalid sub-filter index");
311 first().filter_rhs(vector.first());
317 first().filter_sol(vector.first());
323 first().filter_def(vector.first());
329 first().filter_cor(vector.first());
TupleVector meta-filter class template.
First_::DataType DataType
sub-filter data-type
void filter_def(VectorType &vector) const
Applies the filter onto a defect vector.
TupleFilter(First_ &&the_first, RestClass &&the_rest)
data-emplacement ctor; this one is protected for a reason
void filter_rhs(VectorType &vector) const
Applies the filter onto the right-hand-side vector.
TupleFilter clone(CloneMode clone_mode=CloneMode::Deep) const
Creates a clone of itself.
TupleFilter & operator=(TupleFilter &&other)
move-assign operator
void clone(const TupleFilter &other, CloneMode clone_mode=CloneMode::Deep)
Clones data from another TupleFilter.
First_ _first
the first sub-filter
TupleFilter()
default ctor
First_::IndexType IndexType
sub-filter index-type
TupleFilter< typename First_::template FilterType< DT2_, IT2_ >, typename Rest_::template FilterType< DT2_, IT2_ >... > FilterType
Our 'base' class type.
static constexpr int num_blocks
number of vector blocks
TupleElement< i_, First_, Rest_... >::Type const & at() const
TupleFilter(TupleFilter &&other)
move-ctor
TupleVector< typename First_::VectorType, typename Rest_::VectorType... > VectorType
corresponding vector
FilterType< DataType2_, IndexType2_ > FilterTypeByDI
this typedef lets you create a filter with different Data and Index types
TupleFilter(First_ &&the_first, Rest_ &&... the_rest)
sub-filter emplacement ctor
void filter_sol(VectorType &vector) const
Applies the filter onto the solution vector.
void filter_cor(VectorType &vector) const
Applies the filter onto a correction vector.
RestClass _rest
all remaining sub-filters
std::size_t bytes() const
Returns the total amount of bytes allocated.
Variadic TupleVector class template.
@ other
generic/other permutation strategy
@ rest
restriction (multigrid)
Tuple container element helper class template.