Finite Volume Solver  prototype
A framework to build finite volume solvers for the AG Klein at the Freie Universität Berlin.
Meta.hpp
Go to the documentation of this file.
1 // Copyright (c) 2019 Maikel Nadolski
2 //
3 // Permission is hereby granted, free of charge, to any person obtaining a copy
4 // of this software and associated documentation files (the "Software"), to deal
5 // in the Software without restriction, including without limitation the rights
6 // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7 // copies of the Software, and to permit persons to whom the Software is
8 // furnished to do so, subject to the following conditions:
9 //
10 // The above copyright notice and this permission notice shall be included in
11 // all copies or substantial portions of the Software.
12 //
13 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16 // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18 // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19 // SOFTWARE.
20 
21 #ifndef FUB_META_HPP
22 #define FUB_META_HPP
23 
24 #include "fub/core/type_traits.hpp"
25 
26 /// \brief The meta namespace
27 namespace fub::meta {
28 
29 /// @{
30 /// \brief A template typedef to detect the member function
31 ///
32 /// This is a template typedef which can be used in conjunction with is_detected
33 /// to detect in a generic context if a given expression is valid or not.
34 template <typename Context, typename... Args>
35 using PreAdvanceHierarchy = decltype(
36  std::declval<Context>().PreAdvanceHierarchy(std::declval<Args>()...));
37 
38 template <typename Context, typename... Args>
39 using PostAdvanceHierarchy = decltype(
40  std::declval<Context>().PostAdvanceHierarchy(std::declval<Args>()...));
41 
42 template <typename Context, typename... Args>
44  decltype(std::declval<Context>().PreAdvanceLevel(std::declval<Args>()...));
45 
46 template <typename Context, typename... Args>
48  decltype(std::declval<Context>().PostAdvanceLevel(std::declval<Args>()...));
49 
50 template <typename T, typename... Args>
51 using ResetHierarchyConfiguration = decltype(
52  std::declval<T>().ResetHierarchyConfiguration(std::declval<Args>()...));
53 
54 template <typename T>
56  std::decay_t<decltype(*std::declval<T>().GetGriddingAlgorithm())>;
57 
58 template <typename T>
59 using Equation = std::decay_t<decltype(std::declval<T>().GetEquation())>;
60 /// @}
61 
62 } // namespace fub::meta
63 
64 namespace fub {
65 
66 template <typename GriddingAlgorithm>
67 struct GridTraits;
68 
69 /// \brief Invokes member function obj.ResetHierarchyConfiguration(grid)
70 ///
71 /// This is a helper function which invokes ResetHierarchyConfiguration if the
72 /// specified object obj has such a member function. If obj does not have such
73 /// a member function the function body will be empty.
74 ///
75 /// This functionality is used by generic algorithms in include/fub/solver/*
76 template <typename T, typename Grid>
77 void ResetHierarchyConfigurationIfDetected(T&& obj, Grid&& grid) {
79  std::forward<T>(obj).ResetHierarchyConfiguration(std::forward<Grid>(grid));
80  }
81 }
82 
83 } // namespace fub
84 
85 #endif
The meta namespace.
Definition: Meta.hpp:27
std::decay_t< decltype(*std::declval< T >().GetGriddingAlgorithm())> GriddingAlgorithm
A template typedef to detect the member function.
Definition: Meta.hpp:56
decltype(std::declval< T >().ResetHierarchyConfiguration(std::declval< Args >()...)) ResetHierarchyConfiguration
A template typedef to detect the member function.
Definition: Meta.hpp:52
decltype(std::declval< Context >().PreAdvanceHierarchy(std::declval< Args >()...)) PreAdvanceHierarchy
A template typedef to detect the member function.
Definition: Meta.hpp:36
std::decay_t< decltype(std::declval< T >().GetEquation())> Equation
A template typedef to detect the member function.
Definition: Meta.hpp:59
decltype(std::declval< Context >().PreAdvanceLevel(std::declval< Args >()...)) PreAdvanceLevel
A template typedef to detect the member function.
Definition: Meta.hpp:44
decltype(std::declval< Context >().PostAdvanceHierarchy(std::declval< Args >()...)) PostAdvanceHierarchy
A template typedef to detect the member function.
Definition: Meta.hpp:40
decltype(std::declval< Context >().PostAdvanceLevel(std::declval< Args >()...)) PostAdvanceLevel
A template typedef to detect the member function.
Definition: Meta.hpp:48
The fub namespace.
Definition: AnyBoundaryCondition.hpp:31
void ResetHierarchyConfigurationIfDetected(T &&obj, Grid &&grid)
Invokes member function obj.ResetHierarchyConfiguration(grid)
Definition: Meta.hpp:77
Definition: Meta.hpp:67
This is std::true_type if Op<Args...> is a valid SFINAE expression.
Definition: type_traits.hpp:92
This file adds basic type traits utilities which are not yet implemented in all standard libraries.