ComputeTimeDerivativeHelpers.hpp
1 // Distributed under the MIT License.
2 // See LICENSE.txt for details.
3 
4 #pragma once
5 
6 #include <type_traits>
7 
8 #include "Utilities/TMPL.hpp"
9 #include "Utilities/TypeTraits/CreateHasTypeAlias.hpp"
10 
11 namespace evolution::dg::Actions::detail {
12 CREATE_HAS_TYPE_ALIAS(boundary_correction)
13 CREATE_HAS_TYPE_ALIAS_V(boundary_correction)
14 
15 CREATE_HAS_TYPE_ALIAS(boundary_conditions_base)
16 CREATE_HAS_TYPE_ALIAS_V(boundary_conditions_base)
17 
18 CREATE_HAS_TYPE_ALIAS(inverse_spatial_metric_tag)
19 CREATE_HAS_TYPE_ALIAS_V(inverse_spatial_metric_tag)
20 
21 template <bool HasInverseSpatialMetricTag = false>
22 struct inverse_spatial_metric_tag_impl {
23  template <typename System>
24  using f = tmpl::list<>;
25 };
26 
27 template <>
28 struct inverse_spatial_metric_tag_impl<true> {
29  template <typename System>
30  using f = tmpl::list<typename System::inverse_spatial_metric_tag>;
31 };
32 
33 template <typename System>
34 using inverse_spatial_metric_tag = typename inverse_spatial_metric_tag_impl<
35  has_inverse_spatial_metric_tag_v<System>>::template f<System>;
36 
37 template <bool HasPrimitiveVars = false>
38 struct get_primitive_vars {
39  template <typename BoundaryCorrection>
40  using f = tmpl::list<>;
41 
42  template <typename BoundaryCondition>
43  using boundary_condition_interior_tags = tmpl::list<>;
44 };
45 
46 template <>
47 struct get_primitive_vars<true> {
48  template <typename BoundaryCorrection>
49  using f = typename BoundaryCorrection::dg_package_data_primitive_tags;
50 
51  template <typename BoundaryCondition>
52  using boundary_condition_interior_tags =
53  typename BoundaryCondition::dg_interior_primitive_variables_tags;
54 };
55 
56 template <typename BoundaryCorrection, typename = std::void_t<>>
57 struct interior_tags_for_boundary_correction {
58  using type = tmpl::list<>;
59 };
60 
61 template <typename BoundaryCorrection>
62 struct interior_tags_for_boundary_correction<
63  BoundaryCorrection,
64  std::void_t<typename BoundaryCorrection::
65  dg_project_from_interior_for_boundary_condition>> {
66  using type = typename BoundaryCorrection::
67  dg_project_from_interior_for_boundary_condition;
68 };
69 
70 template <typename BoundaryCondition, typename = std::void_t<>>
71 struct derivative_tags_for_boundary_condition {
72  using type = tmpl::list<>;
73 };
74 
75 template <typename BoundaryCondition>
76 struct derivative_tags_for_boundary_condition<
77  BoundaryCondition,
78  std::void_t<typename BoundaryCondition::dg_interior_derivative_tags>> {
79  using type = typename BoundaryCondition::dg_interior_derivative_tags;
80 };
81 
82 template <typename System, bool = System::has_primitive_and_conservative_vars>
83 struct get_primitive_vars_tags_from_system_impl {
84  using type = typename System::primitive_variables_tag::tags_list;
85 };
86 
87 template <typename System>
88 struct get_primitive_vars_tags_from_system_impl<System, false> {
89  using type = tmpl::list<>;
90 };
91 
92 /// Returns a `tmpl::list` of the primitive tags. The list is empty if the
93 /// system does not have primitive tags.
94 template <typename System>
95 using get_primitive_vars_tags_from_system =
96  typename get_primitive_vars_tags_from_system_impl<System>::type;
97 
98 template <typename BoundaryCondition, typename = std::void_t<>>
99 struct get_dt_vars_from_boundary_condition_impl {
100  using type = tmpl::list<>;
101 };
102 
103 template <typename BoundaryCondition>
104 struct get_dt_vars_from_boundary_condition_impl<
105  BoundaryCondition,
106  std::void_t<typename BoundaryCondition::dg_interior_dt_vars_tags>> {
107  using type = typename BoundaryCondition::dg_interior_dt_vars_tags;
108 };
109 
110 /// Returns the `dg_interior_dt_vars_tags` if the boundary condition specifies
111 /// them, otherwise returns an empty list.
112 template <typename BoundaryCondition>
113 using get_dt_vars_from_boundary_condition =
114  typename get_dt_vars_from_boundary_condition_impl<BoundaryCondition>::type;
115 
116 template <typename BoundaryCondition, typename = std::void_t<>>
117 struct get_deriv_vars_from_boundary_condition_impl {
118  using type = tmpl::list<>;
119 };
120 
121 template <typename BoundaryCondition>
122 struct get_deriv_vars_from_boundary_condition_impl<
123  BoundaryCondition,
124  std::void_t<typename BoundaryCondition::dg_interior_deriv_vars_tags>> {
125  using type = typename BoundaryCondition::dg_interior_deriv_vars_tags;
126 };
127 
128 /// Returns the `dg_interior_deriv_vars_tags` if the boundary condition
129 /// specifies them, otherwise returns an empty list.
130 template <typename BoundaryCondition>
131 using get_deriv_vars_from_boundary_condition =
132  typename get_deriv_vars_from_boundary_condition_impl<
133  BoundaryCondition>::type;
134 } // namespace evolution::dg::Actions::detail
CREATE_HAS_TYPE_ALIAS
#define CREATE_HAS_TYPE_ALIAS(ALIAS_NAME)
Generate a type trait to check if a class has a type alias with a particular name,...
Definition: CreateHasTypeAlias.hpp:27
type_traits
TMPL.hpp