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>
29 void pre(Node& node, TreePath treePath)
35 template<
typename Node,
typename TreePath>
36 void leaf(Node& node, TreePath 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>
57 void pre(Node& node, TreePath treePath)
59 node.setOffset(offset_);
62 template<
typename Node,
typename TreePath>
63 void post(Node& node, TreePath treePath)
65 node.setSize(offset_ - node.offset());
68 template<
typename Node,
typename TreePath>
69 void leaf(Node& node, TreePath 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>
92 void pre(Node& node, TreePath treePath)
94 node.setTreeIndex(treeIndex_);
98 template<
typename Node,
typename TreePath>
99 void leaf(Node& node, TreePath 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;
183 public TypeTree::LeafNode
187 template<
typename T, std::
size_t n>
190 public TypeTree::PowerNode<T,n>
193 using Node = TypeTree::PowerNode<T,n>;
207 return this->child(Dune::Indices::_0).element();
213 template<
typename... T>
216 public TypeTree::CompositeNode<T...>
219 using Node = TypeTree::CompositeNode<T...>;
223 using Element =
typename Node::template Child<0>::Type;
231 template<
typename... Children>
238 return this->child(Dune::Indices::_0).element();
244 template<
typename Tree>
247 TypeTree::applyToTree(tree,Impl::ClearSizeVisitor(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);
254 TypeTree::applyToTree(tree,visitor);
257 template<
typename Tree>
260 Impl::InitializeTreeVisitor visitor(treeIndexOffset);
261 TypeTree::applyToTree(tree,visitor);
Definition: polynomial.hh:10
void clearSize(Tree &tree, std::size_t offset)
Definition: nodes.hh:245
void bindTree(Tree &tree, const Entity &entity, std::size_t offset=0)
Definition: nodes.hh:251
void initializeTree(Tree &tree, std::size_t treeIndexOffset=0)
Definition: nodes.hh:258
size_type treeIndex() const
Definition: nodes.hh:145
size_type localIndex(size_type i) const
Definition: nodes.hh:135
size_type offset() const
Definition: nodes.hh:152
size_type size() const
Definition: nodes.hh:140
void setOffset(const size_type offset)
Definition: nodes.hh:157
std::size_t size_type
Definition: nodes.hh:127
BasisNodeMixin()
Definition: nodes.hh:129
void setSize(const size_type size)
Definition: nodes.hh:162
void setTreeIndex(size_type treeIndex)
Definition: nodes.hh:167
typename T::Element Element
Definition: nodes.hh:197
PowerBasisNode(const typename Node::NodeStorage &children)
Definition: nodes.hh:201
const Element & element() const
Definition: nodes.hh:205
CompositeBasisNode()=default
CompositeBasisNode(const typename Node::NodeStorage &children)
Definition: nodes.hh:227
typename Node::template Child< 0 >::Type Element
Definition: nodes.hh:223
const Element & element() const
Definition: nodes.hh:236
CompositeBasisNode(const std::shared_ptr< Children > &... children)
Definition: nodes.hh:232