AMDiS  0.3
The Adaptive Multi-Dimensional Simulation Toolbox
HierarchicNodeToRangeMap.hpp
1 #pragma once
2 
3 #include <utility>
4 #include <type_traits>
5 
6 #include <dune/common/concept.hh>
7 
8 #include <dune/functions/common/indexaccess.hh>
9 
10 #include <amdis/common/Concepts.hpp>
11 
12 namespace AMDiS
13 {
24  {
25  // Specialization for ranges with operator[] access
26  template <class Node, class TreePath, class Range,
27  REQUIRES(Concepts::HasIndexAccess<Range, Dune::index_constant<0>>)>
28  decltype(auto) operator()(const Node& node, const TreePath& treePath, Range&& y) const
29  {
30  return Dune::Functions::resolveStaticMultiIndex(y, transformTreePath(treePath));
31  }
32 
33  // Specialization for non-container ranges
34  template <class Node, class TreePath, class Range,
35  REQUIRES(not Concepts::HasIndexAccess<Range, Dune::index_constant<0>>)>
36  decltype(auto) operator()(const Node& node, const TreePath& treePath, Range&& y) const
37  {
38  return std::forward<Range>(y);
39  }
40 
41  private:
42 #if DUNE_VERSION_GT(DUNE_FUNCTIONS,2,6)
43  template <class TreePath>
44  static TreePath const& transformTreePath(TreePath const& treePath)
45  {
46  return treePath;
47  }
48 #else
49  // NOTE: due to a bug in dune-functions <= 2.6, a hybrid-treepath can not be passed to a HierarchicNodeToRangeMap,
50  // i.e. the HybridTreePath missed a size() function
51  template <class TreePath>
52  static auto transformTreePath(TreePath const& treePath)
53  {
54  return Ranges::apply([](auto... i) { return Dune::makeTupleVector(i...); }, treePath._data);
55  }
56 #endif
57  };
58 
59 } // end namespace AMDiS
Contains all classes needed for solving linear and non linear equation systems.
Definition: AdaptBase.hpp:6
constexpr bool HasIndexAccess
A Dune::Functions::HasIndexAccess type.
Definition: Concepts.hpp:158
A simple node to range map using the nested tree indices.
Definition: HierarchicNodeToRangeMap.hpp:23