4 #ifndef DUNE_TYPETREE_PAIRTRAVERSAL_HH
5 #define DUNE_TYPETREE_PAIRTRAVERSAL_HH
20 #ifndef DOXYGEN // these are all internals and not public API. Only access is using applyToTree().
22 template<TreePathType::Type tpType>
23 struct ApplyToTreePair<tpType,StartTag,StartTag,true>
26 template<
typename Node1,
typename Node2,
typename Visitor>
27 static void apply(Node1&& node1, Node2&& node2, Visitor&& visitor)
29 ApplyToTreePair<tpType,
30 typename remove_reference<Node1>::type::NodeTag,
31 typename remove_reference<Node2>::type::NodeTag
32 >::apply(std::forward<Node1>(node1),
33 std::forward<Node2>(node2),
34 std::forward<Visitor>(visitor),
35 TreePathFactory<tpType>::create(node1).mutablePath());
42 template<TreePathType::Type tpType,
typename Tag1,
typename Tag2>
43 struct ApplyToTreePair<tpType,Tag1,Tag2,false>
45 template<
typename Node1,
typename Node2,
typename Visitor,
typename TreePath>
46 static void apply(
const Node1& node1,
const Node2& node2,
const Visitor& visitor, TreePath treePath)
99 template<TreePathType::Type treePathType,
typename FirstTag,
typename SecondTag>
100 struct ApplyToTreePair<
treePathType,FirstTag,SecondTag,true>
101 :
public ApplyToGenericCompositeNodePair<treePathType>
112 struct ApplyToTreePair<TreePathType::
dynamic,PowerNodeTag,PowerNodeTag,true>
115 template<
typename N1,
typename N2,
typename V,
typename TreePath>
116 static void apply(N1&& n1, N2&& n2, V&& v, TreePath tp)
118 v.pre(std::forward<N1>(n1),std::forward<N2>(n2),tp.view());
119 typedef typename remove_reference<N1>::type Node1;
120 typedef typename remove_reference<N2>::type Node2;
123 static_assert(Node1::CHILDREN == Node2::CHILDREN,
124 "non-leaf nodes with different numbers of children " \
125 "are not allowed during simultaneous grid traversal");
126 const bool visit = std::remove_reference<V>::type
127 ::template VisitChild<Node1,C1,Node2,C2,typename TreePath::ViewType>::value;
128 for (std::size_t k = 0; k < Node1::CHILDREN; ++k)
130 v.beforeChild(std::forward<N1>(n1),n1.child(k),std::forward<N2>(n2),n2.child(k),tp.view(),k);
133 typename C1::NodeTag,
134 typename C2::NodeTag,
135 visit>::apply(n1.child(k),
140 v.afterChild(std::forward<N1>(n1),n1.child(k),std::forward<N2>(n2),n2.child(k),tp.view(),k);
141 if (k < Node1::CHILDREN-1)
142 v.in(std::forward<N1>(n1),std::forward<N2>(n2),tp.view());
144 v.post(std::forward<N1>(n1),std::forward<N2>(n2),tp.view());
166 template<
typename Tree1,
typename Tree2,
typename Visitor>
170 std::forward<Tree2>(tree2),
171 std::forward<Visitor>(visitor));
179 #endif // DUNE_TYPETREE_PAIRTRAVERSAL_HH
Definition: accumulate_static.hh:12
Definition: treepath.hh:26
void applyToTreePair(Tree1 &&tree1, Tree2 &&tree2, Visitor &&visitor)
Apply visitor to a pair of TypeTrees.
Definition: pairtraversal.hh:167
Type
Definition: treepath.hh:26
static const TreePathType::Type treePathType
Definition: traversalutilities.hh:30