3.1-git
DUNE for Multi-{Phase, Component, Scale, Physics, ...} flow and transport in porous media
propertysystemmacros.hh
Go to the documentation of this file.
1// -*- mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
2// vi: set et ts=4 sw=4 sts=4:
3/*****************************************************************************
4 * See the file COPYING for full copying permissions. *
5 * *
6 * This program is free software: you can redistribute it and/or modify *
7 * it under the terms of the GNU General Public License as published by *
8 * the Free Software Foundation, either version 3 of the License, or *
9 * (at your option) any later version. *
10 * *
11 * This program is distributed in the hope that it will be useful, *
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
13 * MERCHANTBILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
14 * GNU General Public License for more details. *
15 * *
16 * You should have received a copy of the GNU General Public License *
17 * along with this program. If not, see <http://www.gnu.org/licenses/>. *
18 *****************************************************************************/
39#ifndef DUMUX_PROPERTY_SYSTEM_MACROS_HH
40#define DUMUX_PROPERTY_SYSTEM_MACROS_HH
41#warning "Property macros are deprecated and will be removed after release 3.2. \
42If you are not using property macros you can disable this warning by \
43setting DUMUX_ENABLE_OLD_PROPERTY_MACROS to 0 (false) when configuring DuMux. \
44DUMUX_ENABLE_OLD_PROPERTY_MACROS defaults to 1 (true) until release 3.1. \
45After release 3.1 it will default to 0 (false) so you will have to manually \
46enable property macros in order to use them."
47
49
50namespace Dumux {
51namespace Properties {
52
53namespace TTag {}
54
58#define TTAG(TypeTagName) ::Dumux::Properties::TTag::TypeTagName
59
63//#define PTAG(PropTagName) PropTagName
64
68#define PTAG_(PropTagName) ::Dumux::Properties::PropTagName
69
70
71// in the old property system the order in inherit_from was the other way around
72// this flips the order of a tuple to restore old behaviour when using the macro.
73// when you are using non-macro version make sure to flip the order.
74template<class Tuple, class IndexSequence>
76
77template<class Tuple, size_t... I>
78struct ReverseTupleImpl<Tuple, std::index_sequence<I...>>
79{
80 using type = std::tuple<std::tuple_element_t<sizeof...(I) - 1 - I, Tuple>...>;
81};
82
83// revert tuple argument order
84template<class Tuple>
86
87// a temporary hack to make the macro still work, we set using InheritsFrom = void,
88// which gets picked up by the new property as non inheritance, this can be removed
89// once all macros are gone
90namespace Detail {
91template<class TypeTagTuple>
93
94template<class OneTypeTag>
95struct GetTypeTagInheritance<std::tuple<OneTypeTag>>
96{
97 using type = void;
98};
99
100template<class FirstTypeTag, class ...OtherTypeTags>
101struct GetTypeTagInheritance<std::tuple<FirstTypeTag, OtherTypeTags...>>
102{
103 // reverse order to restore old behaviour
104 using type = ReverseTuple<std::tuple<OtherTypeTags...>>;
105};
106} // end namespace Detail
107
128#define DUMUX_GET_HEAD_(Arg1, ...) Arg1
129
130#define NEW_TYPE_TAG(...) \
131 namespace TTag { \
132 struct DUMUX_GET_HEAD_(__VA_ARGS__) \
133 { using InheritsFrom = Detail::GetTypeTagInheritance<std::tuple<__VA_ARGS__>>::type; }; \
134 } extern int semicolonHack_
135
142#define INHERITS_FROM(...) __VA_ARGS__
143
159#define NEW_PROP_TAG(PTagName) \
160 template<class TypeTag, class MyTypeTag> \
161 struct PTagName { using type = UndefinedProperty; }; \
162 extern int semicolonHack_
163
194#define SET_PROP(EffTypeTagName, PropTagName) \
195 template <class TypeTag> \
196 struct PropTagName<TypeTag, TTAG(EffTypeTagName)>
197
204#define SET_INT_PROP(EffTypeTagName, PropTagName, /*Value*/...) \
205 template <class TypeTag> \
206 struct PropTagName<TypeTag, TTAG(EffTypeTagName)> \
207 { \
208 using type = int; \
209 static constexpr int value = __VA_ARGS__; \
210 }
211
218#define SET_BOOL_PROP(EffTypeTagName, PropTagName, /*Value*/...) \
219 template <class TypeTag> \
220 struct PropTagName<TypeTag, TTAG(EffTypeTagName)> \
221 { \
222 using type = bool; \
223 static constexpr bool value = __VA_ARGS__; \
224 }
225
232#define SET_TYPE_PROP(EffTypeTagName, PropTagName, /*Value*/...) \
233 template <class TypeTag> \
234 struct PropTagName<TypeTag, TTAG(EffTypeTagName)> \
235 { \
236 using type = __VA_ARGS__; \
237 }
238
247#define SET_SCALAR_PROP(EffTypeTagName, PropTagName, ...) \
248 template <class TypeTag> \
249 struct PropTagName<TypeTag, TTAG(EffTypeTagName)> \
250 { \
251 using Scalar = Dumux::GetPropType<TypeTag, Scalar>; \
252 public: \
253 using type = Scalar; \
254 static const Scalar value; \
255 }; \
256 template <class TypeTag> \
257 const typename PropTagName<TypeTag, TTAG(EffTypeTagName)>::type \
258 PropTagName<TypeTag, TTAG(EffTypeTagName)>::value(__VA_ARGS__)
259
267#define SET_STRING_PROP(EffTypeTagName, PropTagName, ...) \
268 template <class TypeTag> \
269 struct PropTagName<TypeTag, TTAG(EffTypeTagName)> \
270 { \
271 public: \
272 using type = std::string; \
273 static const std::string value; \
274 }; \
275 template <class TypeTag> \
276 const typename PropTagName<TypeTag, TTAG(EffTypeTagName)>::type \
277 PropTagName<TypeTag, TTAG(EffTypeTagName)>::value(__VA_ARGS__)
278
279
280// getters
281#define GET_PROP(TypeTag, PropTagName) ::Dumux::Properties::Detail::GetPropImpl<TypeTag, PTAG_(PropTagName)>::type
282#define GET_PROP_VALUE(TypeTag, PropTagName) ::Dumux::Properties::Detail::GetPropImpl<TypeTag, PTAG_(PropTagName)>::type::value
283#define GET_PROP_TYPE(TypeTag, PropTagName) ::Dumux::Properties::Detail::GetPropImpl<TypeTag, PTAG_(PropTagName)>::type::type
284
285} // namespace Properties
286} // namespace Dumux
287
288#endif // DUMUX_PROPERTY_SYSTEM_HH
The Dumux property system, traits with inheritance.
make the local view function available whenever we use the grid geometry
Definition: adapt.hh:29
typename ReverseTupleImpl< Tuple, std::make_index_sequence< std::tuple_size< Tuple >::value > >::type ReverseTuple
Definition: propertysystemmacros.hh:85
Definition: propertysystemmacros.hh:75
std::tuple< std::tuple_element_t< sizeof...(I) - 1 - I, Tuple >... > type
Definition: propertysystemmacros.hh:80
Definition: propertysystemmacros.hh:92
ReverseTuple< std::tuple< OtherTypeTags... > > type
Definition: propertysystemmacros.hh:104