3 #include <dune/common/rangeutilities.hh> 5 #include <dune/typetree/nodetags.hh> 6 #include <dune/typetree/treepath.hh> 8 #include <amdis/common/ForEach.hpp> 9 #include <amdis/common/TypeTraits.hpp> 27 template <
bool dynamic = true,
class Tree>
28 auto traversalDegree(
Tree const& tree)
30 if constexpr (dynamic && Tree::isPower)
31 return std::size_t(tree.degree());
32 else if constexpr (Tree::isPower || Tree::isComposite)
33 return std::integral_constant<std::size_t, Tree::degree()>{};
45 template <
class Tree,
class TreePath,
class Pre,
class Leaf,
class Post>
46 void forEachNode(
Tree&& tree, TreePath treePath, Pre&& preFunc, Leaf&& leafFunc, Post&& postFunc)
48 using TreeType = std::decay_t<Tree>;
49 if constexpr (TreeType::isLeaf) {
51 leafFunc(tree, treePath);
53 preFunc(tree, treePath);
54 const auto degree = Impl_::traversalDegree(tree);
55 if constexpr (std::is_integral_v<TYPEOF(degree)>) {
57 for (std::size_t i = 0; i < std::size_t(degree); ++i) {
58 auto childTreePath = Dune::TypeTree::push_back(treePath, i);
59 forEachNode(tree.child(i), childTreePath, preFunc, leafFunc, postFunc);
63 const auto indices = std::make_index_sequence<VALUE(degree)>{};
64 Ranges::forIndices(indices, [&](
auto i) {
65 auto childTreePath = Dune::TypeTree::push_back(treePath, i);
66 forEachNode(tree.child(i), childTreePath, preFunc, leafFunc, postFunc);
69 postFunc(tree, treePath);
84 template <
class Tree,
class Pre,
class Leaf,
class Post>
85 void forEachNode(
Tree&& tree, Pre&& preFunc, Leaf&& leafFunc, Post&& postFunc)
87 auto root = Dune::TypeTree::hybridTreePath();
88 forEachNode(tree, root, preFunc, leafFunc, postFunc);
100 template <
class Tree,
class Inner,
class Leaf>
101 void forEachNode(
Tree&& tree, Inner&& innerFunc, Leaf&& leafFunc)
103 auto root = Dune::TypeTree::hybridTreePath();
104 forEachNode(tree, root, innerFunc, leafFunc, NoOp{});
115 template <
class Tree,
class NodeFunc>
116 void forEachNode(
Tree&& tree, NodeFunc&& nodeFunc)
118 auto root = Dune::TypeTree::hybridTreePath();
119 forEachNode(tree, root, nodeFunc, nodeFunc, NoOp{});
130 template <
class Tree,
class Leaf>
131 void forEachLeafNode(
Tree&& tree, Leaf&& leafFunc)
133 auto root = Dune::TypeTree::hybridTreePath();
134 forEachNode(tree, root, NoOp{}, leafFunc, NoOp{});
Contains all classes needed for solving linear and non linear equation systems.
Definition: AdaptBase.hpp:6