3#ifndef DUNE_FUNCTIONS_FUNCTIONSPACEBASES_DEFAULTNODETORANGEMAP_HH
4#define DUNE_FUNCTIONS_FUNCTIONSPACEBASES_DEFAULTNODETORANGEMAP_HH
7#include <dune/common/concept.hh>
9#include <dune/functions/functionspacebases/concepts.hh>
11#include <dune/typetree/traversal.hh>
12#include <dune/typetree/visitor.hh>
47 :
public TypeTree::TreeVisitor
48 ,
public TypeTree::DynamicTraversal
50 Visitor(std::vector<std::size_t>& indices) :
55 template<
typename Node,
typename TreePath>
56 void leaf(Node& node, TreePath treePath)
58 if (indices_.size() < node.treeIndex()+1)
59 indices_.resize(node.treeIndex()+1);
60 indices_[node.treeIndex()] = counter_;
64 std::vector<std::size_t>& indices_;
80 TypeTree::applyToTree(tree, Visitor(indices_));
83 template<
class Node,
class TreePath,
class Range,
84 std::enable_if_t<models<Concept::HasIndexAccess, Range, decltype(std::declval<Node>().treeIndex())>() and not Tree::isLeaf,
int> = 0>
85 decltype(
auto)
operator()(
const Node& node,
const TreePath& treePath, Range&& y)
const
87 return y[indices_[node.treeIndex()]];
90 template<
class Node,
class TreePath,
class Range,
91 std::enable_if_t< not models<Concept::HasIndexAccess, Range, decltype(std::declval<Node>().treeIndex())>() or Tree::isLeaf,
int> = 0>
92 decltype(
auto)
operator()(
const Node& node,
const TreePath& treePath, Range&& y)
const
94 return std::forward<Range>(y);
97 std::vector<std::size_t> indices_;
103DefaultNodeToRangeMap<Tree> makeDefaultNodeToRangeMap(
const Tree& tree)
105 return DefaultNodeToRangeMap<Tree>(tree);
110template<
class Basis,
class TreePath>
111auto makeDefaultNodeToRangeMap(
const Basis& basis, TreePath&& treePath)
112 ->
decltype(makeDefaultNodeToRangeMap(TypeTree::child(basis.localView().tree(),treePath)))
114 auto&& localView = basis.localView();
115 localView.bind(*basis.gridView().template begin<0>());
116 auto&& tree = TypeTree::child(localView.tree(),treePath);
117 return makeDefaultNodeToRangeMap(tree);
Definition: polynomial.hh:10
A simple node to range map using lexicographic ordering.
Definition: defaultnodetorangemap.hh:39
DefaultNodeToRangeMap(const Tree &tree)
Construct DefaultNodeToRangeMap.
Definition: defaultnodetorangemap.hh:78