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
17#include <dune/common/std/type_traits.hh>
18
20
21namespace Dumux {
22
23#ifndef DOXYGEN
24namespace Detail {
25
26template<class T>
27struct GridDiscretizationType
28{
29 static_assert(AlwaysFalse<T>::value, "Type exports neither GridGeometry nor GridDiscretization");
30};
31
33template<class T>
34 requires requires { typename T::GridDiscretization; }
35struct GridDiscretizationType<T>
36{ using type = typename T::GridDiscretization; };
37
39template<class T>
40 requires (!requires { typename T::GridDiscretization; }
41 && requires { typename T::GridGeometry; })
42struct GridDiscretizationType<T>
43{ using type = typename T::GridGeometry; };
44
47struct NoSubControlVolume {};
48struct NoSubControlVolumeFace {};
49
50template<class ED> using SpecifiedSubControlVolume = typename ED::SubControlVolume;
51template<class ED> using SpecifiedSubControlVolumeFace = typename ED::SubControlVolumeFace;
52
53} // end namespace Detail
54#endif // DOXYGEN
55
63template<class T>
64using GridDiscretization_t = typename Detail::GridDiscretizationType<T>::type;
65
73template<class ElementDiscretization>
74using SubControlVolume_t = Dune::Std::detected_or_t<
75 Detail::NoSubControlVolume, Detail::SpecifiedSubControlVolume, ElementDiscretization
76>;
77
84template<class ElementDiscretization>
85using SubControlVolumeFace_t = Dune::Std::detected_or_t<
86 Detail::NoSubControlVolumeFace, Detail::SpecifiedSubControlVolumeFace, ElementDiscretization
87>;
88
97template<class T, class... Args>
98decltype(auto) gridDiscretization(const T& t, Args&&... args)
99{
100 if constexpr (requires { t.gridDiscretization(std::forward<Args>(args)...); })
101 return t.gridDiscretization(std::forward<Args>(args)...);
102 else
103 return t.gridGeometry(std::forward<Args>(args)...);
104}
105
106} // end namespace Dumux
107
108#endif
Type traits.
decltype(auto) gridDiscretization(const T &t, Args &&... args)
The grid discretization.
Definition griddiscretization.hh:98
Dune::Std::detected_or_t< Detail::NoSubControlVolume, Detail::SpecifiedSubControlVolume, ElementDiscretization > SubControlVolume_t
The sub-control volume type of an element discretization, or a placeholder type for discretizations t...
Definition griddiscretization.hh:74
Dune::Std::detected_or_t< Detail::NoSubControlVolumeFace, Detail::SpecifiedSubControlVolumeFace, ElementDiscretization > SubControlVolumeFace_t
The sub-control volume face type of an element discretization, or a placeholder type for discretizati...
Definition griddiscretization.hh:85
typename Detail::GridDiscretizationType< T >::type GridDiscretization_t
The grid discretization type of a class exporting it.
Definition griddiscretization.hh:64
Definition cvfelocalresidual.hh:25
Definition adapt.hh:17