diff --git a/src/amdis/functions/HierarchicNodeToRangeMap.hpp b/src/amdis/functions/HierarchicNodeToRangeMap.hpp index 259714400aafa064e6f958f92c249f3cac1c7b75..222b515383bfe4f70306eb4a104f379cb37c5ac4 100644 --- a/src/amdis/functions/HierarchicNodeToRangeMap.hpp +++ b/src/amdis/functions/HierarchicNodeToRangeMap.hpp @@ -15,7 +15,7 @@ namespace AMDiS /** * \brief A simple node to range map using the nested tree indices * - * This map directly usses the tree path entries of the given + * This map directly uses the tree path entries of the given * node to access the nested container. * * If the container does not provide any operator[] access, @@ -23,19 +23,38 @@ namespace AMDiS */ struct HierarchicNodeToRangeMap { + // Specialization for ranges with operator[] access template <class Node, class TreePath, class Range, REQUIRES(Dune::models<Dune::Functions::Concept::HasIndexAccess, Range, Dune::index_constant<0>>())> decltype(auto) operator()(const Node& node, const TreePath& treePath, Range&& y) const { - return Dune::Functions::resolveStaticMultiIndex(y, treePath); + return Dune::Functions::resolveStaticMultiIndex(y, transformTreePath(treePath)); } + // Specialization for non-container ranges template <class Node, class TreePath, class Range, REQUIRES(not Dune::models<Dune::Functions::Concept::HasIndexAccess, Range, Dune::index_constant<0>>())> decltype(auto) operator()(const Node& node, const TreePath& treePath, Range&& y) const { return std::forward<Range>(y); } + + private: +#if DUNE_VERSION_GT(DUNE_FUNCTIONS,2,6) + template <class TreePath> + static TreePath const& transformTreePath(TreePath const& treePath) + { + return treePath; + } +#else + // NOTE: due to a bug in dune-functions <= 2.6, a hybrid-treepath can not be passed to a HierarchicNodeToRangeMap, + // i.e. the HybridTreePath missed a size() function + template <class TreePath> + static auto transformTreePath(TreePath const& treePath) + { + return Tools::apply([](auto... i) { return Dune::makeTupleVector(i...); }, treePath._data); + } +#endif }; } // end namespace AMDiS diff --git a/src/amdis/functions/Interpolate.hpp b/src/amdis/functions/Interpolate.hpp index bdbea99e4c69fd07aa1ac5d0bb27111088b41c7c..7901944eb9385bfee03c5a081440251cc3be9471 100644 --- a/src/amdis/functions/Interpolate.hpp +++ b/src/amdis/functions/Interpolate.hpp @@ -85,7 +85,7 @@ namespace Impl { { const auto& tmp = localF_(x); const auto& tmp_vec = Dune::MatVec::as_vector(tmp); - y = Dune::Functions::flatVectorView(nodeToRangeEntry_(node_, transformTreePath(treePath_), tmp_vec))[comp_]; + y = Dune::Functions::flatVectorView(nodeToRangeEntry_(node_, treePath_, tmp_vec))[comp_]; } void setComponent(std::size_t comp) @@ -93,20 +93,6 @@ namespace Impl { comp_ = comp; } -#if DUNE_VERSION_GT(DUNE_FUNCTIONS,2,6) - static TreePath const& transformTreePath(TreePath const& treePath) - { - return treePath; - } -#else - // NOTE: due to a bug in dune-functions <= 2.6, a hybrid-treepath can not be passed to a HierarchicNodeToRangeMap, - // i.e. the HybridTreePath missed a size() function - static auto transformTreePath(TreePath const& treePath) - { - return Tools::apply([](auto... i) { return Dune::makeTupleVector(i...); }, treePath._data); - } -#endif - private: Node const& node_; TreePath const& treePath_;