4 #ifndef DUNE_TYPETREE_APPLYTOCHILDRENTREEPAIR_HH 5 #define DUNE_TYPETREE_APPLYTOCHILDRENTREEPAIR_HH 7 #include <dune/common/typetraits.hh> 24 #ifndef DOXYGEN // these are all internals and not public API. Only access is using applyToTree(). 27 template<TreePathType::Type tpType,
typename tag1 = StartTag,
typename tag2 = StartTag,
bool doApply = true>
28 struct ApplyToTreePair;
35 template<std::
size_t inverse_k, std::
size_t count>
36 struct apply_to_children_pair_fully_static
39 template<
typename N1,
typename N2,
typename V,
typename TreePath>
40 static void apply(N1&& n1, N2&& n2, V&& v, TreePath tp)
42 typedef typename std::remove_reference<N1>::type::template
Child<count-inverse_k>
::Type C1;
43 typedef typename std::remove_reference<N2>::type::template
Child<count-inverse_k>
::Type C2;
44 typedef typename TreePathPushBack<TreePath,count-inverse_k>::type ChildTreePath;
45 const bool visit = std::remove_reference<V>::type
46 ::template VisitChild<typename std::remove_reference<N1>::type,
48 typename std::remove_reference<N2>::type,
50 ChildTreePath>::value;
51 v.beforeChild(std::forward<N1>(n1),n1.template child<count-inverse_k>(),
52 std::forward<N2>(n2),n2.template child<count-inverse_k>(),
53 tp,std::integral_constant<std::size_t,count-inverse_k>());
57 visit>::apply(n1.template child<count-inverse_k>(),
58 n2.template child<count-inverse_k>(),
61 v.afterChild(std::forward<N1>(n1),n1.template child<count-inverse_k>(),
62 std::forward<N2>(n2),n2.template child<count-inverse_k>(),
63 tp,std::integral_constant<std::size_t,count-inverse_k>());
64 v.in(std::forward<N1>(n1),std::forward<N2>(n2),tp);
65 apply_to_children_pair_fully_static<inverse_k-1,count>::apply(std::forward<N1>(n1),
75 template<std::
size_t count>
76 struct apply_to_children_pair_fully_static<1,count>
79 template<
typename N1,
typename N2,
typename V,
typename TreePath>
80 static void apply(N1&& n1, N2&& n2, V&& v, TreePath tp)
82 typedef typename std::remove_reference<N1>::type::template
Child<count-1>
::Type C1;
83 typedef typename std::remove_reference<N2>::type::template
Child<count-1>
::Type C2;
84 typedef typename TreePathPushBack<TreePath,count-1>::type ChildTreePath;
85 const bool visit = std::remove_reference<V>::type
86 ::template VisitChild<typename std::remove_reference<N1>::type,
88 typename std::remove_reference<N2>::type,
90 ChildTreePath>::value;
91 v.beforeChild(std::forward<N1>(n1),n1.template child<count-1>(),
92 std::forward<N2>(n2),n2.template child<count-1>(),
93 tp,std::integral_constant<std::size_t,count-1>());
97 visit>::apply(n1.template child<count-1>(),
98 n2.template child<count-1>(),
101 v.afterChild(std::forward<N1>(n1),n1.template child<count-1>(),
102 std::forward<N2>(n2),n2.template child<count-1>(),
103 tp,std::integral_constant<std::size_t,count-1>());
110 struct apply_to_children_pair_fully_static<0,0>
113 template<
typename N1,
typename N2,
typename V,
typename TreePath>
114 static void apply(N1&& n1, N2&& n2, V&& v, TreePath tp) {}
123 template<std::
size_t inverse_k, std::
size_t count>
124 struct apply_to_children_pair_dynamic
127 template<
typename N1,
typename N2,
typename V,
typename TreePath>
128 static void apply(N1&& n1, N2&& n2, V&& v, TreePath tp)
130 typedef typename std::remove_reference<N1>::type::template
Child<count-inverse_k>
::Type C1;
131 typedef typename std::remove_reference<N2>::type::template
Child<count-inverse_k>
::Type C2;
132 const bool visit = std::remove_reference<V>::type
133 ::template VisitChild<typename std::remove_reference<N1>::type,
135 typename std::remove_reference<N2>::type,
138 v.beforeChild(std::forward<N1>(n1),n1.template child<count-inverse_k>(),
139 std::forward<N2>(n2),n2.template child<count-inverse_k>(),
140 tp.view(),count-inverse_k);
141 tp.push_back(count-inverse_k);
145 visit>::apply(n1.template child<count-inverse_k>(),
146 n2.template child<count-inverse_k>(),
150 v.afterChild(std::forward<N1>(n1),n1.template child<count-inverse_k>(),
151 std::forward<N2>(n2),n2.template child<count-inverse_k>(),
152 tp.view(),count-inverse_k);
153 v.in(std::forward<N1>(n1),std::forward<N2>(n2),tp.view());
154 apply_to_children_pair_dynamic<inverse_k-1,count>::apply(std::forward<N1>(n1),
155 std::forward<N2>(n2),
164 template<std::
size_t count>
165 struct apply_to_children_pair_dynamic<1,count>
168 template<
typename N1,
typename N2,
typename V,
typename TreePath>
169 static void apply(N1&& n1, N2&& n2, V&& v, TreePath tp)
171 typedef typename std::remove_reference<N1>::type::template
Child<count-1>
::Type C1;
172 typedef typename std::remove_reference<N2>::type::template
Child<count-1>
::Type C2;
173 const bool visit = std::remove_reference<V>::type
174 ::template VisitChild<typename std::remove_reference<N1>::type,
176 typename std::remove_reference<N2>::type,
179 v.beforeChild(std::forward<N1>(n1),n1.template child<count-1>(),
180 std::forward<N2>(n2),n2.template child<count-1>(),
182 tp.push_back(count-1);
186 visit>::apply(n1.template child<count-1>(),
187 n2.template child<count-1>(),
191 v.afterChild(std::forward<N1>(n1),n1.template child<count-1>(),
192 std::forward<N2>(n2),n2.template child<count-1>(),
200 struct apply_to_children_pair_dynamic<0,0>
203 template<
typename N1,
typename N2,
typename V,
typename TreePath>
204 static void apply(N1&& n1, N2&& n2, V&& v, TreePath tp) {}
210 template<TreePathType::Type treePathType, std::
size_t CHILDREN>
211 struct apply_to_children_pair;
213 template<std::
size_t CHILDREN>
214 struct apply_to_children_pair<TreePathType::
fullyStatic,CHILDREN>
215 :
public apply_to_children_pair_fully_static<CHILDREN,CHILDREN>
218 template<std::
size_t CHILDREN>
219 struct apply_to_children_pair<TreePathType::
dynamic,CHILDREN>
220 :
public apply_to_children_pair_dynamic<CHILDREN,CHILDREN>
228 template<TreePathType::Type treePathType>
229 struct ApplyToGenericCompositeNodePair
233 template<
typename N1,
typename N2,
typename V,
typename TreePath>
234 static typename std::enable_if<(std::remove_reference<N1>::type::isLeaf || std::remove_reference<N2>::type::isLeaf)>::type
235 apply(N1&& n1, N2&& n2, V&& v, TreePath tp)
237 v.leaf(std::forward<N1>(n1),std::forward<N2>(n2),tp.view());
241 template<
typename N1,
typename N2,
typename V,
typename TreePath>
242 static typename std::enable_if<!(std::remove_reference<N1>::type::isLeaf || std::remove_reference<N2>::type::isLeaf)>::type
243 apply(N1&& n1, N2&& n2, V&& v, TreePath tp)
245 v.pre(std::forward<N1>(n1),std::forward<N2>(n2),tp.view());
248 static_assert(StaticDegree<N1>::value == StaticDegree<N2>::value,
249 "non-leaf nodes with different numbers of children " \
250 "are not allowed during simultaneous grid traversal");
251 apply_to_children_pair<treePathType,StaticDegree<N1>::value>::apply(std::forward<N1>(n1),
252 std::forward<N2>(n2),
255 v.post(std::forward<N1>(n1),std::forward<N2>(n2),tp.view());
268 #endif // DUNE_TYPETREE_APPLYTOCHILDRENTREEPAIR_HH
static const TreePathType::Type treePathType
Definition: traversalutilities.hh:30
typename impl::_Child< Node, indices... >::type Child
Template alias for the type of a child node given by a list of child indices.
Definition: childextraction.hh:307
Definition: accumulate_static.hh:13
TreePath ViewType
Definition: treepath.hh:36
Definition: treepath.hh:26
Definition: treepath.hh:26
Type
Definition: treepath.hh:26