AMDiS 2.11-git
The Adaptive Multi-Dimensional Simulation Toolbox
 
Loading...
Searching...
No Matches
GridFunction.hpp
1#pragma once
2
3#include <type_traits>
4
5#include <dune/common/typeutilities.hh>
6#include <dune/functions/common/functionconcepts.hh>
7
8#include <amdis/common/Concepts.hpp>
9#include <amdis/common/Logical.hpp>
10#include <amdis/common/Order.hpp>
11#include <amdis/gridfunctions/Derivative.hpp>
12
13namespace AMDiS
14{
15 // The localFunction of a GridFunction
16 template <class GridFunction>
17 auto localFunction(GridFunction const& gf)
18 -> decltype(gf.makeLocalFunction())
19 {
20 return gf.makeLocalFunction();
21 }
22
23
24 namespace Traits
25 {
26 template <class T>
28 : std::false_type {};
29
30 } // end namespace Traits
31
32
33 namespace Concepts
34 {
39 namespace Definition
40 {
42 {
43 template <class F>
44 auto require(F&& f) -> decltype(
45 localFunction(f)
46 );
47 };
48
50 {
51 template <class GF>
52 auto require(GF const& /*gf*/) -> std::void_t<
53 typename GF::Range,
54 typename GF::Domain,
55 typename GF::EntitySet
56 >;
57 };
58
60 template<class GF, class Domain = typename GF::EntitySet::GlobalCoordinate>
61 auto require(GF const& gf) -> decltype(
62 Dune::Concept::requireConcept< Dune::Functions::Concept::GridFunction<
63 TYPEOF(gf(std::declval<Domain>()))(Domain), // Signature
64 TYPEOF(gf.entitySet())// EntitySet
65 >>(gf));
66 };
67
69 {
70 template<class GF, class Domain = typename GF::EntitySet::GlobalCoordinate>
71 auto require(GF const& gf) -> decltype(
72 Dune::Concept::requireConcept<GridFunction>(gf),
73 gf.entitySet().gridView());
74 };
75
76 } // end namespace Definition
77
78
80 template <class GF>
81 constexpr bool HasLocalFunction = models<Definition::HasLocalFunction(GF)>;
82
83 template <class GF>
84 using HasLocalFunction_t = models_t<Definition::HasLocalFunction(GF)>;
85
88 template <class GF>
89 constexpr bool GridFunction =
91
92 template <class GF>
93 using GridFunction_t = bool_t<GridFunction<GF>>;
94
98 template <class GF>
99 constexpr bool GridViewFunction =
101
102 template <class GF>
103 using GridViewFunction_t = bool_t<GridViewFunction<GF>>;
104
107 template <class... GFs>
108 constexpr bool AnyGridFunction =
109 (GridFunction<remove_cvref_t<GFs>> ||...) ||
111
112 template <class... GFs>
113 using AnyGridFunction_t = bool_t<AnyGridFunction<GFs...>>;
114
117 } // end namespace Concepts
118
119
120#ifndef DOXYGEN
121 template <class PreGridFct, class = void>
123 : PreGridFct::Creator {};
124
125 // forward declaration
126 template <class Function>
128
129 namespace Impl
130 {
131 // Specialization for type that is already a GridFunction
132 template <class GridFct, class GridView>
133 GridFct const& makeGridFunctionImpl(GridFct const& gridFct, GridView const& /*gridView*/, std::true_type, Dune::PriorityTag<2>)
134 {
135 return gridFct;
136 }
137
138 // If F is a callable with global coordinates, create an AnalyticGridFunction
139 template <class F, class GridView,
140 class Coordinate = typename GridView::template Codim<0>::Entity::Geometry::GlobalCoordinate,
141 std::enable_if_t<std::is_invocable_v<F, Coordinate>, int> = 0>
142 auto makeGridFunctionImpl(F const& f, GridView const& gridView, std::false_type, Dune::PriorityTag<1>)
143 {
144 AnalyticPreGridFunction<F> preGridFct{f};
145 return AnalyticPreGridFunction<F>::Creator::create(preGridFct, gridView);
146 }
147
148 // Use the \ref GridFunctionCreator to create a gridFunction from a preGridFunction
149 template <class PreGridFct, class GridView,
150 class Creator = GridFunctionCreator<PreGridFct>>
151 decltype(auto) makeGridFunctionImpl(PreGridFct const& preGridFct, GridView const& gridView, std::false_type, Dune::PriorityTag<0>)
152 {
153 return Creator::create(preGridFct, gridView);
154 }
155 }
156#endif
157
158
160
193 template <class PreGridFct, class GridView>
194 decltype(auto) makeGridFunction(PreGridFct const& preGridFct, GridView const& gridView)
195 {
196 using isGridFct = Concepts::GridFunction_t<PreGridFct>;
197 return Impl::makeGridFunctionImpl(preGridFct, gridView, isGridFct{}, Dune::PriorityTag<5>{});
198 }
199
200} // end namespace AMDiS
constexpr bool HasLocalFunction
GridFunction GF has free function localFunction(GF)
Definition GridFunction.hpp:81
constexpr bool GridFunction
GridFunction GF is a Type that has LocalFunction, provides some typedefs for Domain,...
Definition GridFunction.hpp:89
constexpr bool AnyGridFunction
Concept is fulfilled, if at least one of the massed Expressions can be converted to a GridFunction,...
Definition GridFunction.hpp:108
constexpr bool GridViewFunction
GridViewFunction GF is a Type that has LocalFunction, provides some typedefs for Domain,...
Definition GridFunction.hpp:99
decltype(auto) makeGridFunction(PreGridFct const &preGridFct, GridView const &gridView)
Generator for Gridfunctions from Expressions (PreGridfunctions)
Definition GridFunction.hpp:194
Definition AnalyticGridFunction.hpp:221
Definition GridFunction.hpp:59
Definition GridFunction.hpp:69
Definition GridFunction.hpp:42
Definition GridFunction.hpp:123
Definition GridFunction.hpp:28