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_base)
13 CREATE_HAS_TYPE_ALIAS_V(boundary_correction_base)
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 <bool HasPrimitiveAndConservativeVars, typename BoundaryCorrection>
57 using boundary_correction_primitive_tags = typename get_primitive_vars<
58  HasPrimitiveAndConservativeVars>::template f<BoundaryCorrection>;
59 
60 template <bool HasPrimitiveAndConservativeVars, typename BoundaryCondition>
61 using boundary_condition_primitive_tags =
62  typename get_primitive_vars<HasPrimitiveAndConservativeVars>::
63  template boundary_condition_interior_tags<BoundaryCondition>;
64 
65 template <typename BoundaryCorrection, typename = std::void_t<>>
66 struct interior_tags_for_boundary_correction {
67  using type = tmpl::list<>;
68 };
69 
70 template <typename BoundaryCorrection>
71 struct interior_tags_for_boundary_correction<
72  BoundaryCorrection,
73  std::void_t<typename BoundaryCorrection::
74  dg_project_from_interior_for_boundary_condition>> {
75  using type = typename BoundaryCorrection::
76  dg_project_from_interior_for_boundary_condition;
77 };
78 
79 template <typename BoundaryCondition, typename = std::void_t<>>
80 struct derivative_tags_for_boundary_condition {
81  using type = tmpl::list<>;
82 };
83 
84 template <typename BoundaryCondition>
85 struct derivative_tags_for_boundary_condition<
86  BoundaryCondition,
87  std::void_t<typename BoundaryCondition::dg_interior_derivative_tags>> {
88  using type = typename BoundaryCondition::dg_interior_derivative_tags;
89 };
90 
91 template <typename System, bool = System::has_primitive_and_conservative_vars>
92 struct get_primitive_vars_tags_from_system_impl {
93  using type = typename System::primitive_variables_tag::tags_list;
94 };
95 
96 template <typename System>
97 struct get_primitive_vars_tags_from_system_impl<System, false> {
98  using type = tmpl::list<>;
99 };
100 
101 /// Returns a `tmpl::list` of the primitive tags. The list is empty if the
102 /// system does not have primitive tags.
103 template <typename System>
104 using get_primitive_vars_tags_from_system =
105  typename get_primitive_vars_tags_from_system_impl<System>::type;
106 
107 template <typename BoundaryCondition, typename = std::void_t<>>
108 struct get_dt_vars_from_boundary_condition_impl {
109  using type = tmpl::list<>;
110 };
111 
112 template <typename BoundaryCondition>
113 struct get_dt_vars_from_boundary_condition_impl<
114  BoundaryCondition,
115  std::void_t<typename BoundaryCondition::dg_interior_dt_vars_tags>> {
116  using type = typename BoundaryCondition::dg_interior_dt_vars_tags;
117 };
118 
119 /// Returns the `dg_interior_dt_vars_tags` if the boundary condition specifies
120 /// them, otherwise returns an empty list.
121 template <typename BoundaryCondition>
122 using get_dt_vars_from_boundary_condition =
123  typename get_dt_vars_from_boundary_condition_impl<BoundaryCondition>::type;
124 
125 template <typename BoundaryCondition, typename = std::void_t<>>
126 struct get_deriv_vars_from_boundary_condition_impl {
127  using type = tmpl::list<>;
128 };
129 
130 template <typename BoundaryCondition>
131 struct get_deriv_vars_from_boundary_condition_impl<
132  BoundaryCondition,
133  std::void_t<typename BoundaryCondition::dg_interior_deriv_vars_tags>> {
134  using type = typename BoundaryCondition::dg_interior_deriv_vars_tags;
135 };
136 
137 /// Returns the `dg_interior_deriv_vars_tags` if the boundary condition
138 /// specifies them, otherwise returns an empty list.
139 template <typename BoundaryCondition>
140 using get_deriv_vars_from_boundary_condition =
141  typename get_deriv_vars_from_boundary_condition_impl<
142  BoundaryCondition>::type;
143 } // 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
CREATE_HAS_TYPE_ALIAS_V
#define CREATE_HAS_TYPE_ALIAS_V(ALIAS_NAME)
Generate a type trait to check if a class has a type alias with a particular name,...
Definition: CreateHasTypeAlias.hpp:39
type_traits
TMPL.hpp