3#ifndef DUNE_FUNCTIONS_FUNCTIONSPACEBASES_NODES_HH
4#define DUNE_FUNCTIONS_FUNCTIONSPACEBASES_NODES_HH
6#include <dune/common/indices.hh>
8#include <dune/typetree/leafnode.hh>
9#include <dune/typetree/powernode.hh>
10#include <dune/typetree/compositenode.hh>
11#include <dune/typetree/traversal.hh>
12#include <dune/typetree/visitor.hh>
21 struct ClearSizeVisitor
22 :
public TypeTree::TreeVisitor
23 ,
public TypeTree::DynamicTraversal
26 template<
typename Node,
typename TreePath>
33 template<
typename Node,
typename TreePath>
36 node.setOffset(offset_);
39 ClearSizeVisitor(std::size_t offset)
43 const std::size_t offset_;
48 template<
typename Entity>
50 :
public TypeTree::TreeVisitor
51 ,
public TypeTree::DynamicTraversal
54 template<
typename Node,
typename TreePath>
57 node.setOffset(offset_);
60 template<
typename Node,
typename TreePath>
63 node.setSize(offset_ - node.offset());
66 template<
typename Node,
typename TreePath>
69 node.setOffset(offset_);
71 offset_ += node.size();
74 BindVisitor(
const Entity& entity, std::size_t offset = 0)
79 const Entity& entity_;
85 struct InitializeTreeVisitor :
86 public TypeTree::TreeVisitor,
87 public TypeTree::DynamicTraversal
89 template<
typename Node,
typename TreePath>
92 node.setTreeIndex(treeIndex_);
96 template<
typename Node,
typename TreePath>
99 node.setTreeIndex(treeIndex_);
103 InitializeTreeVisitor(std::size_t treeIndexOffset = 0) :
104 treeIndex_(treeIndexOffset)
107 std::size_t treeIndex_;
116 friend struct Impl::ClearSizeVisitor;
119 friend struct Impl::BindVisitor;
121 friend struct Impl::InitializeTreeVisitor;
125 using size_type = std::size_t;
133 size_type localIndex(size_type i)
const
138 size_type size()
const
143 size_type treeIndex()
const
150 size_type offset()
const
155 void setOffset(
const size_type offset)
160 void setSize(
const size_type size)
165 void setTreeIndex(size_type treeIndex)
167 treeIndex_ = treeIndex;
174 size_type treeIndex_;
179 class LeafBasisNode :
180 public BasisNodeMixin,
181 public TypeTree::LeafNode
185 template<
typename T, std::
size_t n>
186 class PowerBasisNode :
187 public BasisNodeMixin,
188 public TypeTree::PowerNode<T,n>
191 using Node = TypeTree::PowerNode<T,n>;
195 using Element =
typename T::Element;
197 PowerBasisNode() =
default;
203 const Element& element()
const
211 template<
typename... T>
212 class CompositeBasisNode :
213 public BasisNodeMixin,
214 public TypeTree::CompositeNode<T...>
217 using Node = TypeTree::CompositeNode<T...>;
221 using Element =
typename Node::template Child<0>::Type;
223 CompositeBasisNode() =
default;
229 template<
typename... Children>
230 CompositeBasisNode(
const shared_ptr<Children>&... children) :
234 const Element& element()
const
242 template<
typename Tree>
243 void clearSize(Tree& tree, std::size_t offset)
248 template<
typename Tree,
typename Entity>
249 void bindTree(Tree& tree,
const Entity& entity, std::size_t offset = 0)
251 Impl::BindVisitor<Entity> visitor(entity,offset);
255 template<
typename Tree>
256 void initializeTree(Tree& tree, std::size_t treeIndexOffset = 0)
258 Impl::InitializeTreeVisitor visitor(treeIndexOffset);
std::tuple< std::shared_ptr< Children >... > NodeStorage
The type used for storing the children.
Definition: compositenode.hh:33
std::array< ChildStorageType, k > NodeStorage
The type used for storing the children.
Definition: powernode.hh:84
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:213
Dune namespace.
Definition: alignedallocator.hh:14
void pre(T &&t, TreePath treePath) const
Method for prefix tree traversal.
Definition: visitor.hh:57
void post(T &&t, TreePath treePath) const
Method for postfix tree traversal.
Definition: visitor.hh:80
void leaf(T &&t, TreePath treePath) const
Method for leaf traversal.
Definition: visitor.hh:90