version 3.11-dev
Loading...
Searching...
No Matches
griddiscretization.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// SPDX-FileCopyrightText: Copyright © DuMux Project contributors, see AUTHORS.md in root folder
5// SPDX-License-Identifier: GPL-3.0-or-later
6//
12#ifndef DUMUX_TYPETRAITS_GRID_DISCRETIZATION_HH
13#define DUMUX_TYPETRAITS_GRID_DISCRETIZATION_HH
14
15#include <utility>
16
18
19namespace Dumux {
20
21#ifndef DOXYGEN
22namespace Detail {
23
24template<class T>
25struct GridDiscretizationType
26{
27 static_assert(AlwaysFalse<T>::value, "Type exports neither GridGeometry nor GridDiscretization");
28};
29
31template<class T>
32 requires requires { typename T::GridGeometry; }
33struct GridDiscretizationType<T>
34{ using type = typename T::GridGeometry; };
35
37template<class T>
38 requires (requires { typename T::GridDiscretization; }
39 && !requires { typename T::GridGeometry; })
40struct GridDiscretizationType<T>
41{ using type = typename T::GridDiscretization; };
42
43} // end namespace Detail
44#endif // DOXYGEN
45
53template<class T>
54using GridDiscretization_t = typename Detail::GridDiscretizationType<T>::type;
55
64template<class T, class... Args>
65decltype(auto) gridDiscretization(const T& t, Args&&... args)
66{
67 if constexpr (requires { t.gridDiscretization(std::forward<Args>(args)...); })
68 return t.gridDiscretization(std::forward<Args>(args)...);
69 else
70 return t.gridGeometry(std::forward<Args>(args)...);
71}
72
73} // end namespace Dumux
74
75#endif
Type traits.
decltype(auto) gridDiscretization(const T &t, Args &&... args)
The grid discretization.
Definition griddiscretization.hh:65
typename Detail::GridDiscretizationType< T >::type GridDiscretization_t
The grid discretization type of a class exporting it.
Definition griddiscretization.hh:54
Definition cvfelocalresidual.hh:25
Definition adapt.hh:17