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