3#ifndef DUNE_FUNCTIONS_FUNCTIONSPACEBASES_NODES_HH
4#define DUNE_FUNCTIONS_FUNCTIONSPACEBASES_NODES_HH
9#include <dune/common/indices.hh>
11#include <dune/typetree/leafnode.hh>
12#include <dune/typetree/powernode.hh>
13#include <dune/typetree/compositenode.hh>
14#include <dune/typetree/traversal.hh>
15#include <dune/typetree/visitor.hh>
24 struct ClearSizeVisitor
25 :
public TypeTree::TreeVisitor
26 ,
public TypeTree::DynamicTraversal
29 template<
typename Node,
typename TreePath>
30 void pre(Node& node, TreePath treePath)
36 template<
typename Node,
typename TreePath>
37 void leaf(Node& node, TreePath treePath)
39 node.setOffset(offset_);
42 ClearSizeVisitor(std::size_t offset)
46 const std::size_t offset_;
51 template<
typename Entity>
53 :
public TypeTree::TreeVisitor
54 ,
public TypeTree::DynamicTraversal
57 template<
typename Node,
typename TreePath>
58 void pre(Node& node, TreePath)
60 node.setOffset(offset_);
63 template<
typename Node,
typename TreePath>
64 void post(Node& node, TreePath)
66 node.setSize(offset_ - node.offset());
69 template<
typename Node,
typename TreePath>
70 void leaf(Node& node, TreePath)
72 node.setOffset(offset_);
74 offset_ += node.size();
77 BindVisitor(
const Entity& entity, std::size_t offset = 0)
82 const Entity& entity_;
88 struct InitializeTreeVisitor :
89 public TypeTree::TreeVisitor,
90 public TypeTree::DynamicTraversal
92 template<
typename Node,
typename TreePath>
93 void pre(Node& node, TreePath)
95 node.setTreeIndex(treeIndex_);
99 template<
typename Node,
typename TreePath>
100 void leaf(Node& node, TreePath)
102 node.setTreeIndex(treeIndex_);
106 InitializeTreeVisitor(std::size_t treeIndexOffset = 0) :
107 treeIndex_(treeIndexOffset)
110 std::size_t treeIndex_;
119 friend struct Impl::ClearSizeVisitor;
122 friend struct Impl::BindVisitor;
124 friend struct Impl::InitializeTreeVisitor;
185 public TypeTree::LeafNode
189 template<
typename T, std::
size_t n>
192 public TypeTree::PowerNode<T,n>
195 using Node = TypeTree::PowerNode<T,n>;
209 return this->child(Dune::Indices::_0).element();
215 template<
typename... T>
218 public TypeTree::CompositeNode<T...>
221 using Node = TypeTree::CompositeNode<T...>;
225 using Element =
typename Node::template Child<0>::Type::Element;
233 template<
typename... Children>
240 return this->child(Dune::Indices::_0).element();
246 template<
typename Tree>
249 TypeTree::applyToTree(tree,Impl::ClearSizeVisitor(offset));
252 template<
typename Tree,
typename Entity>
253 void bindTree(Tree& tree,
const Entity& entity, std::size_t offset = 0)
255 Impl::BindVisitor<Entity> visitor(entity,offset);
256 TypeTree::applyToTree(tree,visitor);
259 template<
typename Tree>
262 Impl::InitializeTreeVisitor visitor(treeIndexOffset);
263 TypeTree::applyToTree(tree,visitor);
Definition: polynomial.hh:10
void clearSize(Tree &tree, std::size_t offset)
Definition: nodes.hh:247
void bindTree(Tree &tree, const Entity &entity, std::size_t offset=0)
Definition: nodes.hh:253
void initializeTree(Tree &tree, std::size_t treeIndexOffset=0)
Definition: nodes.hh:260
size_type treeIndex() const
Definition: nodes.hh:147
size_type localIndex(size_type i) const
Definition: nodes.hh:136
size_type offset() const
Definition: nodes.hh:154
size_type size() const
Definition: nodes.hh:142
void setOffset(const size_type offset)
Definition: nodes.hh:159
std::size_t size_type
Definition: nodes.hh:128
BasisNodeMixin()
Definition: nodes.hh:130
void setSize(const size_type size)
Definition: nodes.hh:164
void setTreeIndex(size_type treeIndex)
Definition: nodes.hh:169
const Element & element() const
Definition: nodes.hh:207
typename T::Element Element
Definition: nodes.hh:199
PowerBasisNode(const typename Node::NodeStorage &children)
Definition: nodes.hh:203
CompositeBasisNode()=default
CompositeBasisNode(const typename Node::NodeStorage &children)
Definition: nodes.hh:229
const Element & element() const
Definition: nodes.hh:238
typename Node::template Child< 0 >::Type::Element Element
Definition: nodes.hh:225
CompositeBasisNode(const std::shared_ptr< Children > &... children)
Definition: nodes.hh:234