FiniteElementTypeTest.cpp 1.37 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
#include <dune/common/filledarray.hh>
#include <dune/grid/yaspgrid.hh>
#include <dune/functions/functionspacebases/compositebasis.hh>
#include <dune/functions/functionspacebases/powerbasis.hh>
#include <dune/functions/functionspacebases/lagrangebasis.hh>

#include <dune/amdis/utility/FiniteElementType.hpp>
#include "Tests.hpp"

int main()
{
  using namespace AMDiS;
  using namespace Dune;
  using namespace Dune::Functions;
  using namespace Dune::Functions::BasisBuilder;
  using namespace Dune::Indices;

  // create grid
  FieldVector<double, 2> L; L = 1.0;
  auto s = Dune::filledArray<2>(1);
  YaspGrid<2> grid(L, s);
  auto gridView = grid.leafGridView();

  // create basis
  static const int k = 1;
  auto taylorHoodBasis = makeBasis(
    gridView,
    composite(
      power<2>(lagrange<k+1>()),
      lagrange<k>()
    ));

  auto localView = taylorHoodBasis.localView();

  for (auto const& e : elements(gridView)) {
    localView.bind(e);

    auto node = localView.tree();
    AMDIS_TEST_EQ( polynomialDegree(node), k+1 ); // maximum over all polynomial degrees
    static_assert( std::is_same<tag::unknown, FiniteElementType_t<decltype(node)>>::value, "" );

    auto v_node = TypeTree::child(node, _0);
    AMDIS_TEST_EQ( polynomialDegree(v_node), k+1 );

    auto p_node = TypeTree::child(node, _1);
    AMDIS_TEST_EQ( polynomialDegree(p_node), k );
  }

  return report_errors();
}