5 #include <dune/common/rangeutilities.hh> 6 #include <dune/functions/functionspacebases/flatmultiindex.hh> 8 #include <amdis/common/FakeContainer.hpp> 9 #include <amdis/utility/MappedRangeView.hpp> 14 template <
class Derived>
18 Derived
const& asDerived()
const 20 return static_cast<Derived const&
>(*this);
25 return static_cast<Derived&
>(*this);
35 void synchronize() { }
38 template <
class MultiIndex,
class ValueType,
class Assign>
41 assign(value, asDerived().at(idx));
45 template <
class IndexRange,
class OutputIterator>
46 void gather(IndexRange
const& localInd, OutputIterator buffer)
const 48 for (
auto const& idx : localInd)
49 *buffer++ = asDerived().at(idx);
54 template <
class IndexRange,
class LocalVec,
class Assign>
57 auto vec_it = std::begin(vec);
58 for (
auto const& idx : localInd)
59 assign(*vec_it++, asDerived().at(idx));
64 template <
class IndexRange,
class LocalVec,
class MaskRange,
class Assign>
65 void scatter(IndexRange
const& localInd, LocalVec
const& vec, MaskRange
const& mask, Assign assign)
67 auto vec_it = std::begin(vec);
68 auto mask_it = std::begin(mask);
69 auto ind_it = std::begin(localInd);
70 for (; vec_it != std::end(vec); ++vec_it, ++mask_it, ++ind_it) {
72 assign(*vec_it, asDerived().at(*ind_it));
78 template <
class IndexRange,
class Func>
79 void forEach(IndexRange
const& localInd, Func&& f)
const 81 for (
auto const& idx : localInd)
82 f(idx, asDerived().at(idx));
86 template <
class IndexRange,
class Func>
87 void forEach(IndexRange
const& localInd, Func&& f)
89 for (
auto const& idx : localInd)
90 f(idx, asDerived().at(idx));
99 [](
auto i) {
return Dune::Functions::FlatMultiIndex<decltype(i)>{i}; }), FWD(f));
103 template <
class Func>
107 [](
auto i) {
return Dune::Functions::FlatMultiIndex<decltype(i)>{i}; }), FWD(f));
void forEach(IndexRange const &localInd, Func &&f)
Apply the functor f to all entries of the list of multi-indices localInd.
Definition: VectorBase.hpp:87
constexpr bool MultiIndex
A multi-index type.
Definition: Concepts.hpp:150
void forEach(Func &&f)
Apply the functor f to all entries of the container.
Definition: VectorBase.hpp:96
Contains all classes needed for solving linear and non linear equation systems.
Definition: AdaptBase.hpp:6
void scatter(IndexRange const &localInd, LocalVec const &vec, MaskRange const &mask, Assign assign)
Definition: VectorBase.hpp:65
void gather(IndexRange const &localInd, OutputIterator buffer) const
Gather values from the vector into the output range buffer decribed as an output iterator.
Definition: VectorBase.hpp:46
auto mappedRangeView(R &&range, F const &f)
Create a MappedRangeView.
Definition: MappedRangeView.hpp:445
void forEach(IndexRange const &localInd, Func &&f) const
Apply the functor f to all entries of the list of multi-indices localInd.
Definition: VectorBase.hpp:79
void insert(MultiIndex const &idx, ValueType const &value, Assign assign)
Insert or add value at position idx, using the passed assign functor.
Definition: VectorBase.hpp:39
A container-like data-structure not storing anything and with empty implementations in many container...
Definition: FakeContainer.hpp:34
CRTP base class for flat vector backends.
Definition: VectorBase.hpp:15
void scatter(IndexRange const &localInd, LocalVec const &vec, FakeContainer< bool, true >, Assign assign)
Scatter the values from the local vec into the container using the passed assign functor.
Definition: VectorBase.hpp:55
void forEach(Func &&f) const
Apply the functor f to all entries of the container.
Definition: VectorBase.hpp:104