ValidTreePathTest.cpp 1.92 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#include <config.h>

#include <dune/grid/yaspgrid.hh>

#include <dune/functions/functionspacebases/compositebasis.hh>
#include <dune/functions/functionspacebases/lagrangebasis.hh>
#include <dune/functions/functionspacebases/powerbasis.hh>

#include <amdis/Environment.hpp>
#include <amdis/common/TypeTraits.hpp>
#include <amdis/typetree/Traits.hpp>
#include <amdis/typetree/TreePath.hpp>

using namespace AMDiS;

int main (int argc, char** argv)
{
  Environment env(argc, argv);

  Dune::YaspGrid<2> grid({1.0,1.0}, {1,1});

  using namespace Dune::Functions::BasisFactory;
  auto basis = makeBasis(grid.leafGridView(),
    composite(
      power<2>(lagrange<2>()),
      lagrange<1>()
    ));

  using Tree = TYPEOF(basis.localView().tree());

  // index access of composite node
  static_assert(not Concepts::ValidTreePath<Tree,int>);
  static_assert(not Concepts::ValidTreePath<Tree,std::size_t>);
  static_assert(    Concepts::ValidTreePath<Tree,std::integral_constant<int,0>>);
  static_assert(    Concepts::ValidTreePath<Tree,std::integral_constant<std::size_t,0>>);

  static_assert(not Concepts::ValidTreePath<Tree,std::integral_constant<int,2>>);
  static_assert(not Concepts::ValidTreePath<Tree,std::integral_constant<std::size_t,2>>);

  using namespace Dune::Indices;

  auto tp0 = makeTreePath(0);
  auto tp1 = makeTreePath(_0);
  static_assert(not Concepts::ValidTreePath<Tree,TYPEOF(tp0)>);
  static_assert(    Concepts::ValidTreePath<Tree,TYPEOF(tp1)>);

  auto tp2 = makeTreePath(_0,0);
  auto tp3 = makeTreePath(_0,_0);
  auto tp4 = makeTreePath(_1,0);
  static_assert(    Concepts::ValidTreePath<Tree,TYPEOF(tp2)>);
  static_assert(    Concepts::ValidTreePath<Tree,TYPEOF(tp3)>);
  static_assert(not Concepts::ValidTreePath<Tree,TYPEOF(tp4)>);

  auto tp5 = makeTreePath(_0,0,0);
  auto tp6 = makeTreePath(_0,0,_0);
  static_assert(not Concepts::ValidTreePath<Tree,TYPEOF(tp5)>);
  static_assert(not Concepts::ValidTreePath<Tree,TYPEOF(tp6)>);
}