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

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

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

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

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


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

60
  } // end namespace Impl
61

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

70

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

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

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

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

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

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

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

112
} // end namespace AMDiS