ProblemStatTraits.hpp 3.22 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

70
  template <class Grid, class PreBasisCreator, class T = double>
71
72
  struct DefaultBasisCreator
  {
73
    using GridView = typename Grid::LeafGridView;
74
75
76
77
78
    static auto create(std::string const& name, GridView const& gridView)
    {
      return makeGlobalBasis(name, gridView, PreBasisCreator::create());
    }

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

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

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

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

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

109
} // end namespace AMDiS