Commit 16eaf7a6 authored by Praetorius, Simon's avatar Praetorius, Simon
Browse files

Added extended AllTrueBitSetVector class

parent 7e46647e
......@@ -13,6 +13,7 @@
#include <amdis/common/Logical.hpp>
#include <amdis/functions/HierarchicNodeToRangeMap.hpp>
#include <amdis/typetree/Traversal.hpp>
#include <amdis/utility/AllTrueBitSetVector.hpp>
namespace AMDiS {
namespace Impl {
......@@ -284,7 +285,7 @@ template <class B, class... I, class Vec, class C, class GF, class NTRE, bool av
void interpolateTree(B const& basis, Dune::TypeTree::HybridTreePath<I...> const& treePath,
Vec& vec, C& count, GF const& gf, NTRE const& nodeToRangeEntry, bool_t<average>)
{
auto bitVec = Dune::Functions::Imp::AllTrueBitSetVector();
auto bitVec = AllTrueBitSetVector{};
AMDiS::interpolateTreeSubset(basis, treePath, vec, count, bitVec, gf, nodeToRangeEntry, bool_t<average>{});
}
......@@ -295,7 +296,7 @@ template <class B, class... I, class Vec, class C, class GF, bool average,
void interpolateTree(B const& basis, Dune::TypeTree::HybridTreePath<I...> const& treePath,
Vec& vec, C& count, GF const& gf, bool_t<average>)
{
auto bitVec = Dune::Functions::Imp::AllTrueBitSetVector();
auto bitVec = AllTrueBitSetVector{};
auto ntrm = AMDiS::HierarchicNodeToRangeMap();
AMDiS::interpolateTreeSubset(basis, treePath, vec, count, bitVec, gf, ntrm, bool_t<average>{});
}
......@@ -380,7 +381,7 @@ template <class B, class Vec, class C, class GF, bool average,
void interpolate(B const& basis, Vec& vec, C& count, GF const& gf, bool_t<average>)
{
auto root = Dune::TypeTree::hybridTreePath();
auto bitVec = Dune::Functions::Imp::AllTrueBitSetVector();
auto bitVec = AllTrueBitSetVector{};
AMDiS::interpolateFiltered(basis, root, vec, count, bitVec, gf, bool_t<average>{});
}
......@@ -391,7 +392,7 @@ template <class B, class... I, class Vec, class GF,
void interpolate(B const& basis, Vec& vec, GF const& gf)
{
auto root = Dune::TypeTree::hybridTreePath();
auto bitVec = Dune::Functions::Imp::AllTrueBitSetVector();
auto bitVec = AllTrueBitSetVector{};
auto count = Impl::FakeCounter();
AMDiS::interpolateFiltered(basis, root, vec, count, bitVec, gf, std::false_type{});
}
......@@ -419,7 +420,7 @@ template <class B, class... I, class Vec, class C, class GF, bool average,
void interpolate(B const& basis, Dune::TypeTree::HybridTreePath<I...> const& treePath,
Vec& vec, C& count, GF const& gf, bool_t<average>)
{
auto bitVec = Dune::Functions::Imp::AllTrueBitSetVector();
auto bitVec = AllTrueBitSetVector{};
AMDiS::interpolateFiltered(basis, treePath, vec, count, bitVec, gf, bool_t<average>{});
}
......@@ -428,7 +429,7 @@ template <class B, class... I, class Vec, class GF,
REQUIRES(Concepts::GridFunction<GF>)>
void interpolate(B const& basis, Dune::TypeTree::HybridTreePath<I...> const& treePath, Vec& vec, GF const& gf)
{
auto bitVec = Dune::Functions::Imp::AllTrueBitSetVector();
auto bitVec = AllTrueBitSetVector{};
auto count = Impl::FakeCounter();
AMDiS::interpolateFiltered(basis, treePath, vec, count, bitVec, gf, std::false_type{});
}
......
#pragma once
namespace AMDiS
{
/// \brief Vector-like container of bools returning always true
class AllTrueBitSetVector
{
struct const_iterator
{
constexpr const_iterator(bool sentinel = false) noexcept : sentinel_(sentinel) {}
constexpr bool operator*() const noexcept { return true; }
constexpr const_iterator& operator++() noexcept { return *this; }
constexpr const_iterator operator++(int) noexcept { return *this; }
/// Comparison of the iterator is always true if both are sentinel or both are const_iterator
friend constexpr bool operator==(const_iterator a, const_iterator b) noexcept
{
return a.sentinel_ == b.sentinel_;
}
bool sentinel_ = false;
};
/// Constexpr default constructor
constexpr AllTrueBitSetVector() noexcept = default;
/// Converting to true
constexpr operator bool() const noexcept
{
return true;
}
/// Access any element of the container returning always true.
template <class Index>
constexpr const AllTrueBitSetVector& operator[](Index const& /*index*/) const noexcept
{
return *this;
}
/// Return iterator that always redirects to a bool true.
constexpr const_iterator begin() const noexcept { return const_iterator{false}; }
constexpr const_iterator end() const noexcept { return const_iterator{true}; }
/// Return iterator that always redirects to a bool true.
constexpr const_iterator cbegin() const noexcept { return const_iterator{false}; }
constexpr const_iterator cend() const noexcept { return const_iterator{true}; }
/// Resize does nothing
template <class Size>
constexpr void resize(Size const& /*size*/) const noexcept { /* do nothing */ }
};
} // end namespace AMDiS
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment