3#ifndef DUNE_FUNCTIONS_FUNCTIONSPACEBASES_NODES_HH
4#define DUNE_FUNCTIONS_FUNCTIONSPACEBASES_NODES_HH
8#include <dune/common/indices.hh>
10#include <dune/typetree/leafnode.hh>
11#include <dune/typetree/powernode.hh>
12#include <dune/typetree/compositenode.hh>
13#include <dune/typetree/traversal.hh>
14#include <dune/typetree/visitor.hh>
23 struct ClearSizeVisitor
24 :
public TypeTree::TreeVisitor
25 ,
public TypeTree::DynamicTraversal
28 template<
typename Node,
typename TreePath>
35 template<
typename Node,
typename TreePath>
38 node.setOffset(offset_);
41 ClearSizeVisitor(std::size_t offset)
45 const std::size_t offset_;
50 template<
typename Entity>
52 :
public TypeTree::TreeVisitor
53 ,
public TypeTree::DynamicTraversal
56 template<
typename Node,
typename TreePath>
59 node.setOffset(offset_);
62 template<
typename Node,
typename TreePath>
65 node.setSize(offset_ - node.offset());
68 template<
typename Node,
typename TreePath>
71 node.setOffset(offset_);
73 offset_ += node.size();
76 BindVisitor(
const Entity& entity, std::size_t offset = 0)
81 const Entity& entity_;
87 struct InitializeTreeVisitor :
88 public TypeTree::TreeVisitor,
89 public TypeTree::DynamicTraversal
91 template<
typename Node,
typename TreePath>
94 node.setTreeIndex(treeIndex_);
98 template<
typename Node,
typename TreePath>
101 node.setTreeIndex(treeIndex_);
105 InitializeTreeVisitor(std::size_t treeIndexOffset = 0) :
106 treeIndex_(treeIndexOffset)
109 std::size_t treeIndex_;
118 friend struct Impl::ClearSizeVisitor;
121 friend struct Impl::BindVisitor;
123 friend struct Impl::InitializeTreeVisitor;
127 using size_type = std::size_t;
135 size_type localIndex(size_type i)
const
140 size_type size()
const
145 size_type treeIndex()
const
152 size_type offset()
const
157 void setOffset(
const size_type offset)
162 void setSize(
const size_type size)
167 void setTreeIndex(size_type treeIndex)
169 treeIndex_ = treeIndex;
176 size_type treeIndex_;
181 class LeafBasisNode :
182 public BasisNodeMixin,
183 public TypeTree::LeafNode
187 template<
typename T, std::
size_t n>
188 class PowerBasisNode :
189 public BasisNodeMixin,
190 public TypeTree::PowerNode<T,n>
193 using Node = TypeTree::PowerNode<T,n>;
197 using Element =
typename T::Element;
199 PowerBasisNode() =
default;
205 const Element& element()
const
213 template<
typename... T>
214 class CompositeBasisNode :
215 public BasisNodeMixin,
216 public TypeTree::CompositeNode<T...>
219 using Node = TypeTree::CompositeNode<T...>;
223 using Element =
typename Node::template Child<0>::Type;
225 CompositeBasisNode() =
default;
231 template<
typename... Children>
232 CompositeBasisNode(
const std::shared_ptr<Children>&... children) :
236 const Element& element()
const
244 template<
typename Tree>
245 void clearSize(Tree& tree, std::size_t offset)
250 template<
typename Tree,
typename Entity>
251 void bindTree(Tree& tree,
const Entity& entity, std::size_t offset = 0)
253 Impl::BindVisitor<Entity> visitor(entity,offset);
257 template<
typename Tree>
258 void initializeTree(Tree& tree, std::size_t treeIndexOffset = 0)
260 Impl::InitializeTreeVisitor visitor(treeIndexOffset);
std::tuple< std::shared_ptr< Children >... > NodeStorage
The type used for storing the children.
Definition: compositenode.hh:34
std::array< std::shared_ptr< T >, k > NodeStorage
The type used for storing the children.
Definition: powernode.hh:78
constexpr index_constant< 0 > _0
Compile time index with value 0.
Definition: indices.hh:51
constexpr HybridTreePath< T... > treePath(const T &... t)
Constructs a new HybridTreePath from the given indices.
Definition: treepath.hh:188
void applyToTree(Tree &&tree, Visitor &&visitor)
Apply visitor to TypeTree.
Definition: traversal.hh:237
Dune namespace.
Definition: alignedallocator.hh:11
void pre(T &&t, TreePath treePath) const
Method for prefix tree traversal.
Definition: visitor.hh:58
void post(T &&t, TreePath treePath) const
Method for postfix tree traversal.
Definition: visitor.hh:81
void leaf(T &&t, TreePath treePath) const
Method for leaf traversal.
Definition: visitor.hh:91