AMDiS  0.1
The Adaptive Multi-Dimensional Simulation Toolbox
GridFunction.hpp
1 #pragma once
2 
3 #include <type_traits>
4 
5 #include <dune/common/typeutilities.hh>
6 
7 #include <amdis/common/Concepts.hpp>
8 #include <amdis/common/Logical.hpp>
9 #include <amdis/common/Order.hpp>
10 #include <amdis/gridfunctions/Derivative.hpp>
11 
12 namespace AMDiS
13 {
14  // The localFunction of a GridFunction
15  template <class GridFunction>
16  auto localFunction(GridFunction const& gf)
17  -> decltype(gf.makeLocalFunction())
18  {
19  return gf.makeLocalFunction();
20  }
21 
22 
23  namespace Traits
24  {
25  template <class T>
27  : std::false_type {};
28 
29  } // end namespace Traits
30 
31 
32  namespace Concepts
33  {
38  namespace Definition
39  {
41  {
42  template <class F>
43  auto require(F&& f) -> decltype(
44  localFunction(f)
45  );
46  };
47 
49  {
50  template <class GF>
51  auto require(GF const& /*gf*/) -> std::void_t<
52  typename GF::Range,
53  typename GF::Domain,
54  typename GF::EntitySet
55  >;
56  };
57 
58  } // end namespace Definition
59 
60 
62  template <class GF>
63  constexpr bool HasLocalFunction = models<Definition::HasLocalFunction(GF)>;
64 
65  template <class GF>
66  using HasLocalFunction_t = models_t<Definition::HasLocalFunction(GF)>;
67 
68 
71  template <class GF>
72  constexpr bool GridFunction =
73  HasLocalFunction<GF> && models<Definition::HasGridFunctionTypes(GF)>;
74 
75  template <class GF>
76  using GridFunction_t = bool_t<GridFunction<GF>>;
77 
78 
81  template <class... GFs>
82  constexpr bool AnyGridFunction =
83  (GridFunction<remove_cvref_t<GFs>> ||...) ||
85 
86  template <class... GFs>
87  using AnyGridFunction_t = bool_t<AnyGridFunction<GFs...>>;
88 
91  } // end namespace Concepts
92 
93 
94 #ifndef DOXYGEN
95  template <class PreGridFct, class = void>
97  : PreGridFct::Creator {};
98 
99  namespace Impl
100  {
101  // Specialization for type that is already a GridFunction
102  template <class GridFct, class GridView>
103  GridFct const& makeGridFunctionImpl(GridFct const& gridFct, GridView const& /*gridView*/, std::true_type)
104  {
105  return gridFct;
106  }
107 
108  // Use the \ref GridFunctionCreator to create a gridFunction from a preGridFunction
109  template <class PreGridFct, class GridView,
110  class Creator = GridFunctionCreator<PreGridFct>>
111  decltype(auto) makeGridFunctionImpl(PreGridFct const& preGridFct, GridView const& gridView, std::false_type)
112  {
113  return Creator::create(preGridFct, gridView);
114  }
115  }
116 #endif
117 
118 
120 
153  template <class PreGridFct, class GridView>
154  decltype(auto) makeGridFunction(PreGridFct const& preGridFct, GridView const& gridView)
155  {
156  using isGridFct = Concepts::GridFunction_t<PreGridFct>;
157  return Impl::makeGridFunctionImpl(preGridFct, gridView, isGridFct{});
158  }
159 
160 } // end namespace AMDiS
constexpr bool GridFunction
GridFunction GF is a Type that has LocalFunction and provides some typedefs for Domain, Range, and EntitySet.
Definition: GridFunction.hpp:72
Definition: GridFunction.hpp:26
constexpr bool AnyGridFunction
Concept is fulfilled, if at least one of the massed Expressions can be converted to a GridFunction...
Definition: GridFunction.hpp:82
Definition: GridFunction.hpp:96
decltype(auto) makeGridFunction(PreGridFct const &preGridFct, GridView const &gridView)
Generator for Gridfunctions from Expressions (PreGridfunctions)
Definition: GridFunction.hpp:154
Contains all classes needed for solving linear and non linear equation systems.
Definition: AdaptBase.hpp:6
Definition: GridFunction.hpp:40
constexpr bool HasLocalFunction
GridFunction GF has free function localFunction(GF)
Definition: GridFunction.hpp:63
std::integral_constant< bool, B > bool_t
A wrapper for bool types.
Definition: Logical.hpp:12