ProblemStatTraits.hpp 2.96 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
8
#include <dune/functions/functionspacebases/pqknodalbasis.hh>
#include <dune/grid/yaspgrid.hh>
9

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

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

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

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

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


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

58
  } // end namespace Impl
59

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

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

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

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

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

101
} // end namespace AMDiS