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