ProblemStatTraits.hpp 3.26 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>
10
11
#include <amdis/common/TypeTraits.hpp>
#include <amdis/functions/ParallelGlobalBasis.hpp>
Praetorius, Simon's avatar
Praetorius, Simon committed
12

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

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

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

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


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

59
  } // end namespace Impl
60

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

69

Praetorius, Simon's avatar
Praetorius, Simon committed
70
  template <class HostGrid, class PreBasisCreator, class T = double>
71
72
  struct DefaultBasisCreator
  {
Praetorius, Simon's avatar
Praetorius, Simon committed
73
    using Grid = AdaptiveGrid<HostGrid>;
74
    using GridView = typename Grid::LeafGridView;
Praetorius, Simon's avatar
Praetorius, Simon committed
75

76
77
78
79
80
    static auto create(std::string const& name, GridView const& gridView)
    {
      return makeGlobalBasis(name, gridView, PreBasisCreator::create());
    }

81
82
    static auto create(GridView const& gridView)
    {
83
      return makeGlobalBasis(gridView, PreBasisCreator::create());
84
85
    }

86
    using GlobalBasis = Underlying_t<decltype(create(std::declval<GridView>()))>;
87
    using CoefficientType = T;
88
89
  };

Praetorius, Simon's avatar
Praetorius, Simon committed
90
91
  /// \brief ProblemStatTraits for a (composite) basis composed of
  /// lagrange bases of different degree.
92
  template <class Grid, int... degrees>
Praetorius, Simon's avatar
Praetorius, Simon committed
93
  struct LagrangeBasis
94
      : public DefaultBasisCreator<Grid, Impl::LagrangePreBasisCreator<degrees...>>
Praetorius, Simon's avatar
Praetorius, Simon committed
95
  {};
96

Praetorius, Simon's avatar
Praetorius, Simon committed
97
98
  /// \brief Specialization of \ref LagrangeBasis for Grid type
  /// \ref Dune::YaspGrid for a given dimension.
99
  template <int dim, int... degrees>
100
  struct YaspGridBasis
101
      : public LagrangeBasis<Dune::YaspGrid<dim>, degrees...>
Praetorius, Simon's avatar
Praetorius, Simon committed
102
  {};
103

Praetorius, Simon's avatar
Praetorius, Simon committed
104
105
  /// \brief ProblemStatTraits of Taylor-Hood basis of lagrange-type
  /// with pressure degree k
106
  template <class Grid, int k = 1>
107
  struct TaylorHoodBasis
108
      : public DefaultBasisCreator<Grid, Impl::TaylorHoodPreBasisCreator<Grid::dimensionworld,k>>
Praetorius, Simon's avatar
Praetorius, Simon committed
109
  {};
110

111
} // end namespace AMDiS