AMDiS  0.3
The Adaptive Multi-Dimensional Simulation Toolbox
ProblemStatTraits.hpp
1 #pragma once
2 
3 #include <dune/functions/functionspacebases/basistags.hh>
4 #include <dune/functions/functionspacebases/compositebasis.hh>
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 #include <amdis/common/TypeTraits.hpp>
12 #include <amdis/functions/GlobalBasis.hpp>
13 
14 namespace AMDiS
15 {
16  namespace Impl
17  {
18  template <bool same, int... degs>
19  struct LagrangePreBasisCreatorImpl;
20 
21  // specialization for single node basis
22  template <int deg>
23  struct LagrangePreBasisCreatorImpl<true, deg>
24  {
25  static auto create()
26  {
27  using namespace Dune::Functions::BasisFactory;
28  return lagrange<deg>();
29  }
30  };
31 
32  // specialization for composite basis
33  template <int... degs>
34  struct LagrangePreBasisCreatorImpl<false, degs...>
35  {
36  static auto create()
37  {
38  using namespace Dune::Functions::BasisFactory;
39  return composite(lagrange<degs>()..., flatLexicographic());
40  }
41  };
42 
43  // specialization for power basis
44  template <int deg, int... degs>
45  struct LagrangePreBasisCreatorImpl<true, deg, degs...>
46  {
47  static auto create()
48  {
49  using namespace Dune::Functions::BasisFactory;
50  return power<1+sizeof...(degs)>(lagrange<deg>(), flatLexicographic());
51  }
52  };
53 
54  // factory to construct a global basis of several lagrange bases, with flat indexing.
55  template <int deg, int... degs>
56  struct LagrangePreBasisCreator
57  : public LagrangePreBasisCreatorImpl<((deg == degs) &&...), deg, degs...>
58  {};
59 
60 
61  template <int dow, int k = 1>
62  struct TaylorHoodPreBasisCreator
63  {
64  static auto create()
65  {
66  using namespace Dune::Functions::BasisFactory;
67  return composite(power<dow>(lagrange<k+1>(), flatInterleaved()), lagrange<k>(), flatLexicographic());
68  }
69  };
70 
71  } // end namespace Impl
72 
73 
75  template <class GB, class T = double,
76  template <class> class TraitsImpl = BackendTraits>
78  {
79  using GlobalBasis = GB;
80  using CoefficientType = T;
81  using LinAlgTraits = TraitsImpl<GB>;
82  };
83 
85  template <class HostGrid, class PreBasisCreator, class T = double,
86  template <class> class TraitsImpl = BackendTraits>
88  {
89  using Grid = AdaptiveGrid_t<HostGrid>;
90  using GridView = typename Grid::LeafGridView;
91 
92  static auto create(std::string const& name, GridView const& gridView)
93  {
94  return AMDiS::GlobalBasis{name, gridView, PreBasisCreator::create()};
95  }
96 
97  static auto create(GridView const& gridView)
98  {
99  return AMDiS::GlobalBasis{gridView, PreBasisCreator::create()};
100  }
101 
102  using GlobalBasis = decltype(create(std::declval<GridView>()));
103  using CoefficientType = T;
104  using LinAlgTraits = TraitsImpl<GlobalBasis>;
105  };
106 
107 
110  template <class Grid, int... degrees>
112  : public DefaultBasisCreator<Grid, Impl::LagrangePreBasisCreator<degrees...>>
113  {};
114 
117  template <int dim, int... degrees>
119  : public LagrangeBasis<Dune::YaspGrid<dim>, degrees...>
120  {};
121 
124  template <class Grid, int k = 1>
126  : public DefaultBasisCreator<Grid, Impl::TaylorHoodPreBasisCreator<Grid::dimensionworld,k>>
127  {};
128 
129 } // end namespace AMDiS
typename Impl::AdaptiveGridImpl< HostGrid >::type AdaptiveGrid_t
Definition: AdaptiveGrid.hpp:367
Global basis defined on a pre-basis.
Definition: GlobalBasis.hpp:53
Generator for a basis and default problem traits.
Definition: ProblemStatTraits.hpp:87
Contains all classes needed for solving linear and non linear equation systems.
Definition: AdaptBase.hpp:6
Wrapper around a global basis providing default traits.
Definition: ProblemStatTraits.hpp:77
ProblemStatTraits of Taylor-Hood basis of lagrange-type with pressure degree k.
Definition: ProblemStatTraits.hpp:125
ProblemStatTraits for a (composite) basis composed of lagrange bases of different degree...
Definition: ProblemStatTraits.hpp:111
Definition: Traits.hpp:14
Specialization of LagrangeBasis for Grid type Dune::YaspGrid for a given dimension.
Definition: ProblemStatTraits.hpp:118