DUNE-ACFEM (unstable)

localfunctiontraits.hh
1#ifndef __DUNE_ACFEM_FUNCTIONS_LOCALFUNCTIONTRAITS_HH__
2#define __DUNE_ACFEM_FUNCTIONS_LOCALFUNCTIONTRAITS_HH__
3
4#include <dune/fem/function/localfunction/temporary.hh>
5#include <dune/fem/function/localfunction/const.hh>
6
7#include "../common/types.hh"
8#include "../common/quadraturepoint.hh"
9
10namespace Dune {
11
12 namespace ACFem {
13
14 namespace GridFunction {
15
17 template<class T, class SFINAE = void>
19 : FalseType
20 {};
21
23 template<class T>
24 struct IsLocalFunction<T, std::enable_if_t<!IsDecay<T>{}> >
25 : IsLocalFunction<std::decay_t<T> >
26 {};
27
29 template<class T>
31 T,
32 std::enable_if_t<(IsDecay<T>{}
33 && std::is_same<void, decltype(std::declval<T>().bind(std::declval<typename T::EntityType>()))>{}
34 && std::is_same<void, decltype(std::declval<T>().evaluate(
35 std::declval<PlaceholderQuadraturePoint<typename T::DomainType> >(),
36 std::declval<typename T::RangeType&>()))>{}
37 )> >
38 : std::true_type
39 {};
40
42
44 template<class T, class SFINAE = void>
46 : FalseType
47 {};
48
50 template<class T>
51 struct IsConstLocalFunction<T, std::enable_if_t<!IsDecay<T>{}> >
52 : IsConstLocalFunction<std::decay_t<T> >
53 {};
54
56 template<class T>
58 T,
59 std::enable_if_t<(IsDecay<T>{}
60 && std::is_same<T, Fem::ConstLocalFunction<typename T::GridFunctionType> >{}
61 )> >
62 : TrueType
63 {};
64
66
67 template<class T, class SFINAE = void>
68 struct IsDiscreteFunctionSpace
69 : FalseType
70 {};
71
72 template<class T>
73 struct IsDiscreteFunctionSpace<T, std::enable_if_t<!IsDecay<T>{}> >
74 : IsDiscreteFunctionSpace<T, std::decay_t<T> >
75 {};
76
77 template<class T>
78 struct IsDiscreteFunctionSpace<T, std::enable_if_t<(IsDecay<T>{} && std::is_same<T, typename T::DiscreteFunctionSpaceType>{})> >
79 : TrueType
80 {};
81
83
85 template<class T, class SFINAE = void>
87 : FalseType
88 {};
89
91 template<class T>
92 struct IsWrappableByConstLocalFunction<T, std::enable_if_t<!IsDecay<T>{}> >
93 : IsWrappableByConstLocalFunction<std::decay_t<T> >
94 {};
95
97 template<class T>
99 T,
100 std::enable_if_t<(IsDecay<T>{}
101 && std::is_base_of<Fem::HasLocalFunction, T>{}
102 )> >
103 : TrueType
104 {};
105
107
109 template<class T>
111 : BoolConstant<IsConstLocalFunction<T>::value || IsWrappableByConstLocalFunction<T>::value>
112 {};
113
117 template<
118 class F,
119 std::enable_if_t<(!IsConstLocalFunction<F>::value
121 ), int> = 0>
122 constexpr auto ensureConstLocalFunction(F&& f)
123 {
124 return Fem::ConstLocalFunction<std::decay_t<F> >(std::forward<F>(f));
125 }
126
128 template<class F, std::enable_if_t<IsConstLocalFunction<F>::value, int> = 0>
129 constexpr decltype(auto) ensureConstLocalFunction(F&& f)
130 {
131 return std::forward<F>(f);
132 }
133
135 template<class DiscreteSpace, class Dof = typename DiscreteSpace::RangeFieldType>
136 Fem::TemporaryLocalFunction<DiscreteSpace, Dof>
137 temporaryLocalFunction(const DiscreteSpace& space, const Dof& dummy = Dof())
138 {
139 return Fem::TemporaryLocalFunction<DiscreteSpace, Dof>(space);
140 }
141
142 } // NS GridFunction
143
144 using GridFunction::IsConstLocalFunction;
145 using GridFunction::IsDiscreteFunctionSpace;
146 using GridFunction::IsWrappableByConstLocalFunction;
147 using GridFunction::ensureConstLocalFunction;
148 using GridFunction::temporaryLocalFunction;
149
150 } // NS ACFem
151
152} // NS Dune
153
154#endif // __DUNE_ACFEM_FUNCTIONS_LOCALFUNCTIONTRAITS_HH__
Constant< bool, V > BoolConstant
Short-cut for integral constant of type bool.
Definition: types.hh:48
BoolConstant< false > FalseType
Alias for std::false_type.
Definition: types.hh:110
BoolConstant< true > TrueType
Alias for std::true_type.
Definition: types.hh:107
STL namespace.
TrueType if T can be passed through constLocalFunction().
Definition: localfunctiontraits.hh:112
Definition: localfunctiontraits.hh:47
Definition: localfunctiontraits.hh:20
Creative Commons License   |  Legal Statements / Impressum  |  Hosted by TU Dresden  |  generated with Hugo v0.111.3 (Dec 27, 23:30, 2024)