ProblemStatTraits.hpp 2.91 KB
Newer Older
1
2
#pragma once

3
4
#include <dune/functions/functionspacebases/basistags.hh>
#include <dune/functions/functionspacebases/compositebasis.hh>
Praetorius, Simon's avatar
Praetorius, Simon committed
5
#include <dune/functions/functionspacebases/lagrangebasis.hh>
6
#include <dune/functions/functionspacebases/powerbasis.hh>
7
#include <dune/grid/yaspgrid.hh>
8

9
#include <amdis/common/Logical.hpp>
Praetorius, Simon's avatar
Praetorius, Simon committed
10

11
12
namespace AMDiS
{
13
  namespace Impl
14
  {
15
16
    template <bool same, int... degs>
    struct LagrangePreBasisCreatorImpl;
17
18

    // specialization for composite basis
19
20
    template <int... degs>
    struct LagrangePreBasisCreatorImpl<false, degs...>
21
    {
22
23
24
25
26
      static auto create()
      {
        using namespace Dune::Functions::BasisFactory;
        return composite(lagrange<degs>()..., flatLexicographic());
      }
27
28
29
    };

    // specialization for power basis
30
31
    template <int deg, int... degs>
    struct LagrangePreBasisCreatorImpl<true, deg, degs...>
32
    {
33
34
35
36
37
      static auto create()
      {
        using namespace Dune::Functions::BasisFactory;
        return power<1+sizeof...(degs)>(lagrange<deg>(), flatLexicographic());
      }
38
39
40
    };

    // factory to construct a global basis of several lagrange bases, with flat indexing.
41
42
43
44
    template <int deg, int... degs>
    struct LagrangePreBasisCreator
        : public LagrangePreBasisCreatorImpl<all_of_v<(deg == degs)...>, deg, degs...>
    {};
45
46


47
48
    template <int dow, int k = 1>
    struct TaylorHoodPreBasisCreator
49
    {
50
51
52
53
54
      static auto create()
      {
        using namespace Dune::Functions::BasisFactory;
        return composite(power<dow>(lagrange<k+1>(), flatInterleaved()), lagrange<k>(), flatLexicographic());
      }
55
    };
56

57
  } // end namespace Impl
58

Praetorius, Simon's avatar
Praetorius, Simon committed
59
60
  /// An Exemplar for ProblemStatTraits
  template <class GlobalBasisType>
61
  struct DefaultProblemTraits
62
  {
Praetorius, Simon's avatar
Praetorius, Simon committed
63
    using GlobalBasis = GlobalBasisType;
64
  };
65

66
67
68
69
70
71
72
73
74
75
76
77
78

  template <class GridView, class PreBasisCreator>
  struct DefaultBasisCreator
  {
    static auto create(GridView const& gridView)
    {
      using namespace Dune::Functions::BasisFactory;
      return makeBasis(gridView, PreBasisCreator::create());
    }

    using GlobalBasis = decltype(create(std::declval<GridView>()));
  };

Praetorius, Simon's avatar
Praetorius, Simon committed
79
80
81
82
  /// \brief ProblemStatTraits for a (composite) basis composed of
  /// lagrange bases of different degree.
  template <class GridView, int... degrees>
  struct LagrangeBasis
83
      : public DefaultBasisCreator<GridView, Impl::LagrangePreBasisCreator<degrees...>>
Praetorius, Simon's avatar
Praetorius, Simon committed
84
  {};
85

Praetorius, Simon's avatar
Praetorius, Simon committed
86
87
  /// \brief Specialization of \ref LagrangeBasis for Grid type
  /// \ref Dune::YaspGrid for a given dimension.
88
  template <int dim, int... degrees>
89
  struct YaspGridBasis
Praetorius, Simon's avatar
Praetorius, Simon committed
90
91
      : public LagrangeBasis<typename Dune::YaspGrid<dim>::LeafGridView, degrees...>
  {};
92

Praetorius, Simon's avatar
Praetorius, Simon committed
93
94
95
  /// \brief ProblemStatTraits of Taylor-Hood basis of lagrange-type
  /// with pressure degree k
  template <class GridView, int k = 1>
96
  struct TaylorHoodBasis
97
      : public DefaultBasisCreator<GridView, Impl::TaylorHoodPreBasisCreator<GridView::dimensionworld,k>>
Praetorius, Simon's avatar
Praetorius, Simon committed
98
  {};
99

100
} // end namespace AMDiS