AMDiS 2.10
The Adaptive Multi-Dimensional Simulation Toolbox
Concepts.hpp
1#pragma once
2
3#include <type_traits>
4
5#include <dune/typetree/treepath.hh>
6#include <amdis/typetree/TreePath.hpp>
7
8namespace AMDiS {
9namespace Traits {
10
11template <class Tree, class TreePath, class NodeTag = typename Tree::NodeTag>
13
14// empty treepath
15template <class Tree, class NodeTag>
16struct IsValidTreePath<Tree, Dune::TypeTree::HybridTreePath<>, NodeTag>
17 : std::true_type {};
18
19// leaf nodes
20template <class Tree, class I0, class... II>
21struct IsValidTreePath<Tree, Dune::TypeTree::HybridTreePath<I0,II...>, Dune::TypeTree::LeafNodeTag>
22 : std::false_type {};
23
24// power nodes
25template <class Tree, class I0, class... II>
26struct IsValidTreePath<Tree, Dune::TypeTree::HybridTreePath<I0,II...>, Dune::TypeTree::PowerNodeTag>
27 : IsValidTreePath<typename Tree::ChildType, Dune::TypeTree::HybridTreePath<II...>> {};
28
29// composite node with integer index
30template <class Tree, class I0, class... II>
31struct IsValidTreePath<Tree, Dune::TypeTree::HybridTreePath<I0,II...>, Dune::TypeTree::CompositeNodeTag>
32 : std::false_type {};
33
34// composite node with integral-constant index
35template <class Tree, class Int, Int i, class... II>
36struct IsValidTreePath<Tree, Dune::TypeTree::HybridTreePath<std::integral_constant<Int,i>,II...>, Dune::TypeTree::CompositeNodeTag>
37 : std::conditional_t<(i >= 0 && i < Int(Tree::degree())),
38 IsValidTreePath<typename Tree::template Child<(i >= 0 && i < Int(Tree::degree())) ? i : 0>::Type, Dune::TypeTree::HybridTreePath<II...>>,
39 std::false_type> {};
40
41} // end namespace Traits
42
43
44namespace Concepts {
45
47template <class Tree, class Path>
48static constexpr bool ValidTreePath = Traits::IsValidTreePath<Tree,TYPEOF(makeTreePath(std::declval<Path>()))>::value;
49
50} // end namespace Concepts
51} // end namespace AMDiS
Definition: Concepts.hpp:12