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
#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
  template <class Grid, class PreBasisCreator, class T = double>
68
69
  struct DefaultBasisCreator
  {
70
    using GridView = typename Grid::LeafGridView;
71
72
73
74
75
76
77
    static auto create(GridView const& gridView)
    {
      using namespace Dune::Functions::BasisFactory;
      return makeBasis(gridView, PreBasisCreator::create());
    }

    using GlobalBasis = decltype(create(std::declval<GridView>()));
78
    using CoefficientType = T;
79
80
  };

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

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

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

102
} // end namespace AMDiS