ProblemStatTraits.hpp 3.01 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
  /// An Exemplar for ProblemStatTraits
60
  template <class GlobalBasisType, class T = double>
61
  struct DefaultProblemTraits
62
  {
Praetorius, Simon's avatar
Praetorius, Simon committed
63
    using GlobalBasis = GlobalBasisType;
64
    using CoefficientType = T;
65
  };
66

67

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

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

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

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

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

103
} // end namespace AMDiS