ProblemStatTraits.hpp 2.64 KB
Newer Older
1
2
3
4
#pragma once

#include <tuple>

5
6
7
#include <dune/functions/functionspacebases/pqknodalbasis.hh>
#include <dune/functions/functionspacebases/pq1nodalbasis.hh>
#include <dune/grid/yaspgrid.hh>
8
9
10

namespace AMDiS
{
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
  /// \brief A Traits class used in \ref ProblemStat for determining necessary
  /// template parameters.
  /** The intend of the trats class is to collect several typedefs and static
    * constants, needed to describe the parameters of a \ref ProblemStat.
    *
    * The required typedefs are:
    * - Mesh ......... the type of the dune grid
    * - FeSpaces ..... a tuple of dune global functionspace basis types
    *
    * The required static constants are:
    * - dim .......... the dimension of the grid
    * - dow .......... the dimension of the coordinates
    * - nComponents .. number of solution componentd
    *
    * Use the factory class \ref DefaultTraits to give all of these parameters by
    * template parameters.
    *
    * Additionally there are some predefined traits classes:
    * - LagrangeTraits (give a mesh and the polynomial degrees)
    * - TestTraits : LagrangeTraits (fixed mesh=YaspGrid)
    **/
  template <class MeshType, class FeSpaceTypes>
  struct DefaultTraits
  {
    static constexpr int dim = MeshType::dimension;
    static constexpr int dow = MeshType::dimensionworld;
    static constexpr int nComponents = std::tuple_size<FeSpaceTypes>::value;

    using Mesh = MeshType;
    using FeSpaces = FeSpaceTypes;
  };


44
45
46
47
  namespace Impl
  {
    // by default use Lagrange basis
    template <class Mesh, int deg>
48
    struct PQkFeSpaceFactory
49
    {
50
      using GV = typename Mesh::LeafGridView;
51
      using ST = typename GV::IndexSet::IndexType;
52
      using type = Dune::Functions::PQkNodalBasis<GV, deg>;
53
    };
54

55
    template <class Mesh>
56
    struct PQkFeSpaceFactory<Mesh, 1>
57
    {
58
      using GV = typename Mesh::LeafGridView;
59
      using ST = typename GV::IndexSet::IndexType;
60
      using type = Dune::Functions::PQ1NodalBasis<GV>;
61
    };
62

63
  } // end namespace Impl
64

65
66
67
  /// \brief A problem-traits realization for lagrange feSpace with given mesh-type.
  /** The traits class specifies the polynomial degrees of Lagrange basis
    * functions. Together with a Grid type the necessary parameters
68
69
    * for the \ref ProblemStat class are set.
    **/
70
71
72
  template <class Mesh, int... degrees>
  using LagrangeTraits
    = DefaultTraits<Mesh, std::tuple<typename Impl::PQkFeSpaceFactory<Mesh, degrees>::type...>>;
73
74


75
76
77
  /// Specialization of \ref LagrangeTraits for Grid type \ref Dune::YaspGrid for a given dimension.
  template <int dim, int... degrees>
  using TestTraits = LagrangeTraits<Dune::YaspGrid<dim>, degrees...>;
78

79
} // end namespace AMDiS