Commit 5629246c authored by Praetorius, Simon's avatar Praetorius, Simon
Browse files

Fix LocalView for changes made to dune-functions

parent 5ef376ac
Pipeline #6019 failed with stage
in 75 minutes and 33 seconds
......@@ -44,11 +44,7 @@ namespace AMDiS
using TreeCache = NodeCache_t<Tree>;
/// Type used for global numbering of the basis vectors
using MultiIndex = typename NodeIndexSet::MultiIndex;
private:
template <class NIS, class Iter>
using hasIndices = decltype(std::declval<NIS>().indices(std::declval<Iter>()));
using MultiIndex = typename GlobalBasis::PreBasis::MultiIndex;
public:
/// \brief Construct local view for a given global finite element basis
......@@ -96,14 +92,8 @@ namespace AMDiS
{
element_ = &element;
bindTree(tree_, element);
nodeIndexSet_.bind(tree_);
indices_.resize(tree_.size());
if constexpr (Dune::Std::is_detected_v<hasIndices, NodeIndexSet, TYPEOF(indices_.begin())>)
nodeIndexSet_.indices(indices_.begin());
else
for (size_type i = 0; i < tree_.size(); ++i)
indices_[i] = nodeIndexSet_.index(i);
bindNodeIndexSet(globalBasis_->preBasis(), nodeIndexSet_, tree_, indices_.begin(), Dune::PriorityTag<5>{});
}
// do not bind an rvalue-reference
......@@ -131,7 +121,7 @@ namespace AMDiS
*/
void unbind ()
{
nodeIndexSet_.unbind();
unbindNodeIndexSet(nodeIndexSet_, Dune::PriorityTag<5>{});
element_ = nullptr;
}
......@@ -183,6 +173,52 @@ namespace AMDiS
return *this;
}
private:
template <class PB, class NIS, class Tree, class Iter,
class = decltype(std::declval<PB>().indices(std::declval<Tree>(), std::declval<Iter>()))>
static void bindNodeIndexSet(PB const& preBasis, NIS& /*nodeIndexSet*/, Tree const& tree, Iter it, Dune::PriorityTag<3>)
{
preBasis.indices(tree, it);
}
template <class PB, class NIS, class Tree, class Iter,
class = decltype(std::declval<NIS>().bind(std::declval<Tree>())),
class = decltype(std::declval<NIS>().indices(std::declval<Iter>()))>
static void bindNodeIndexSet(PB const& /*preBasis*/, NIS& nodeIndexSet, Tree const& tree, Iter it, Dune::PriorityTag<2>)
{
nodeIndexSet.bind(tree);
nodeIndexSet.indices(it);
}
template <class PB, class NIS, class Tree, class Iter,
class = decltype(std::declval<NIS>().bind(std::declval<Tree>())),
class = decltype(std::declval<NIS>().index(0u))>
static void bindNodeIndexSet(PB const& /*preBasis*/, NIS& nodeIndexSet, Tree const& tree, Iter it, Dune::PriorityTag<1>)
{
nodeIndexSet.bind(tree);
for (size_type i = 0; i < tree.size(); ++i)
*it++ = nodeIndexSet.index(i);
}
template <class PB, class NIS, class Tree, class Iter>
static void bindNodeIndexSet(PB const& /*preBasis*/, NIS& /*nodeIndexSet*/, Tree const& /*tree*/, Iter /*it*/, Dune::PriorityTag<0>)
{
/* do nothing */
}
template <class NIS,
class = decltype(std::declval<NIS>().unbind())>
static void unbindNodeIndexSet(NIS& nodeIndexSet, Dune::PriorityTag<1>)
{
nodeIndexSet.unbind();
}
template <class NIS>
static void unbindNodeIndexSet(NIS& /*nodeIndexSet*/, Dune::PriorityTag<0>)
{
/* do nothing */
}
protected:
GlobalBasis const* globalBasis_;
Element const* element_ = nullptr;
......
......@@ -4,24 +4,6 @@
namespace AMDiS
{
// dune version independent extraction of node type from preBasis
template <class PB, class TP>
using Node_t =
#if DUNE_VERSION_LT(DUNE_FUNCTIONS,2,7)
typename PB::template Node<TP>;
#else
typename PB::Node;
#endif
// dune version independent extraction of node indexset type from preBasis
template <class PB, class TP>
using NodeIndexSet_t =
#if DUNE_VERSION_LT(DUNE_FUNCTIONS,2,7)
typename PB::template IndexSet<TP>;
#else
typename PB::IndexSet;
#endif
// dune version independent creation of node from preBasis
template <class PB, class TP>
auto makeNode(PB const& preBasis, [[maybe_unused]] TP const& treePath)
......@@ -33,15 +15,35 @@ namespace AMDiS
#endif
}
// dune version independent extraction of node type from preBasis
template <class PB, class TP>
using Node_t = decltype(makeNode(std::declval<PB>(), std::declval<TP>()));
template <class PB,
class Tree = typename PB::Node,
class Iter = typename std::vector<typename PB::MultiIndex>::iterator>
using PreBasisHasIndicesConcept
= decltype(std::declval<PB>().indices(std::declval<Tree>(), std::declval<Iter>()));
struct DummyNodeIndexSet {};
// dune version independent creation of node from preBasis
template <class PB, class TP>
auto makeNodeIndexSet(PB const& preBasis, [[maybe_unused]] TP const& treePath)
{
#if DUNE_VERSION_LT(DUNE_FUNCTIONS,2,7)
return preBasis.template indexSet<TP>();
#if DUNE_VERSION_GTE(DUNE_FUNCTIONS,2,7)
if constexpr(Dune::Std::is_detected_v<PreBasisHasIndicesConcept,PB>)
return DummyNodeIndexSet{};
else
return preBasis.makeIndexSet();
#else
return preBasis.makeIndexSet();
return preBasis.template indexSet<TP>();
#endif
}
// dune version independent extraction of node indexset type from preBasis
template <class PB, class TP>
using NodeIndexSet_t = decltype(makeNodeIndexSet(std::declval<PB>(), std::declval<TP>()));
} // end namespace AMDiS
Markdown is supported
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