Line data Source code
1 0 : // 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/CreateGetTypeAliasOrDefault.hpp" 10 : #include "Utilities/TypeTraits/CreateHasTypeAlias.hpp" 11 : 12 : namespace evolution::dg::Actions::detail { 13 : CREATE_HAS_TYPE_ALIAS(boundary_conditions_base) 14 : CREATE_HAS_TYPE_ALIAS_V(boundary_conditions_base) 15 : 16 : CREATE_HAS_TYPE_ALIAS(inverse_spatial_metric_tag) 17 : CREATE_HAS_TYPE_ALIAS_V(inverse_spatial_metric_tag) 18 : 19 : template <bool HasInverseSpatialMetricTag = false> 20 : struct inverse_spatial_metric_tag_impl { 21 : template <typename System> 22 : using f = tmpl::list<>; 23 : }; 24 : 25 : template <> 26 : struct inverse_spatial_metric_tag_impl<true> { 27 : template <typename System> 28 : using f = tmpl::list<typename System::inverse_spatial_metric_tag>; 29 : }; 30 : 31 : template <typename System> 32 : using inverse_spatial_metric_tag = typename inverse_spatial_metric_tag_impl< 33 : has_inverse_spatial_metric_tag_v<System>>::template f<System>; 34 : 35 : CREATE_GET_TYPE_ALIAS_OR_DEFAULT(auxiliary_variables) 36 : CREATE_GET_TYPE_ALIAS_OR_DEFAULT(dg_auxiliary_boundary_terms_volume_tags) 37 : CREATE_GET_TYPE_ALIAS_OR_DEFAULT(dg_auxiliary_package_data_temporary_tags) 38 : CREATE_GET_TYPE_ALIAS_OR_DEFAULT(dg_auxiliary_package_data_volume_tags) 39 : CREATE_GET_TYPE_ALIAS_OR_DEFAULT(dg_auxiliary_package_field_tags) 40 : 41 : // `gradient_variables` is prepended since `partial_derivatives` requires the 42 : // differentiated tags to be the *leading* tags of the source `Variables`. 43 : template <typename System> 44 : using evolved_and_auxiliary_vars_tags = tmpl::remove_duplicates< 45 : tmpl::append<typename System::gradient_variables, 46 : typename System::variables_tag::tags_list, 47 : get_auxiliary_variables_or_default_t<System, tmpl::list<>>>>; 48 : 49 : template <bool HasPrimitiveVars = false> 50 : struct get_primitive_vars { 51 : template <typename BoundaryCorrection> 52 : using f = tmpl::list<>; 53 : 54 : template <typename BoundaryCondition> 55 : using boundary_condition_interior_tags = tmpl::list<>; 56 : }; 57 : 58 : template <> 59 : struct get_primitive_vars<true> { 60 : template <typename BoundaryCorrection> 61 : using f = typename BoundaryCorrection::dg_package_data_primitive_tags; 62 : 63 : template <typename BoundaryCondition> 64 : using boundary_condition_interior_tags = 65 : typename BoundaryCondition::dg_interior_primitive_variables_tags; 66 : }; 67 : 68 : template <bool HasPrimitiveAndConservativeVars, typename BoundaryCorrection> 69 : using boundary_correction_primitive_tags = typename get_primitive_vars< 70 : HasPrimitiveAndConservativeVars>::template f<BoundaryCorrection>; 71 : 72 : template <bool HasPrimitiveAndConservativeVars, typename BoundaryCondition> 73 : using boundary_condition_primitive_tags = 74 : typename get_primitive_vars<HasPrimitiveAndConservativeVars>:: 75 : template boundary_condition_interior_tags<BoundaryCondition>; 76 : 77 : template <typename BoundaryCorrection, typename = std::void_t<>> 78 : struct interior_tags_for_boundary_correction { 79 : using type = tmpl::list<>; 80 : }; 81 : 82 : template <typename BoundaryCorrection> 83 : struct interior_tags_for_boundary_correction< 84 : BoundaryCorrection, 85 : std::void_t<typename BoundaryCorrection:: 86 : dg_project_from_interior_for_boundary_condition>> { 87 : using type = typename BoundaryCorrection:: 88 : dg_project_from_interior_for_boundary_condition; 89 : }; 90 : 91 : template <typename BoundaryCondition, typename = std::void_t<>> 92 : struct derivative_tags_for_boundary_condition { 93 : using type = tmpl::list<>; 94 : }; 95 : 96 : template <typename BoundaryCondition> 97 : struct derivative_tags_for_boundary_condition< 98 : BoundaryCondition, 99 : std::void_t<typename BoundaryCondition::dg_interior_derivative_tags>> { 100 : using type = typename BoundaryCondition::dg_interior_derivative_tags; 101 : }; 102 : 103 : template <typename System, bool = System::has_primitive_and_conservative_vars> 104 : struct get_primitive_vars_tags_from_system_impl { 105 : using type = typename System::primitive_variables_tag::tags_list; 106 : }; 107 : 108 : template <typename System> 109 : struct get_primitive_vars_tags_from_system_impl<System, false> { 110 : using type = tmpl::list<>; 111 : }; 112 : 113 : /// Returns a `tmpl::list` of the primitive tags. The list is empty if the 114 : /// system does not have primitive tags. 115 : template <typename System> 116 : using get_primitive_vars_tags_from_system = 117 : typename get_primitive_vars_tags_from_system_impl<System>::type; 118 : 119 : template <typename BoundaryCondition, typename = std::void_t<>> 120 : struct get_dt_vars_from_boundary_condition_impl { 121 : using type = tmpl::list<>; 122 : }; 123 : 124 : template <typename BoundaryCondition> 125 : struct get_dt_vars_from_boundary_condition_impl< 126 : BoundaryCondition, 127 : std::void_t<typename BoundaryCondition::dg_interior_dt_vars_tags>> { 128 : using type = typename BoundaryCondition::dg_interior_dt_vars_tags; 129 : }; 130 : 131 : /// Returns the `dg_interior_dt_vars_tags` if the boundary condition specifies 132 : /// them, otherwise returns an empty list. 133 : template <typename BoundaryCondition> 134 : using get_dt_vars_from_boundary_condition = 135 : typename get_dt_vars_from_boundary_condition_impl<BoundaryCondition>::type; 136 : 137 : template <typename BoundaryCondition, typename = std::void_t<>> 138 : struct get_deriv_vars_from_boundary_condition_impl { 139 : using type = tmpl::list<>; 140 : }; 141 : 142 : template <typename BoundaryCondition> 143 : struct get_deriv_vars_from_boundary_condition_impl< 144 : BoundaryCondition, 145 : std::void_t<typename BoundaryCondition::dg_interior_deriv_vars_tags>> { 146 : using type = typename BoundaryCondition::dg_interior_deriv_vars_tags; 147 : }; 148 : 149 : /// Returns the `dg_interior_deriv_vars_tags` if the boundary condition 150 : /// specifies them, otherwise returns an empty list. 151 : template <typename BoundaryCondition> 152 : using get_deriv_vars_from_boundary_condition = 153 : typename get_deriv_vars_from_boundary_condition_impl< 154 : BoundaryCondition>::type; 155 : } // namespace evolution::dg::Actions::detail