10 #include "DataStructures/DataVector.hpp"
13 #include "Evolution/DgSubcell/Tags/Inactive.hpp"
60 template <
typename... EvolvedVarsTags>
61 bool rdmp_tci(
const Variables<tmpl::list<EvolvedVarsTags...>>&
62 active_grid_candidate_evolved_vars,
64 inactive_grid_candidate_evolved_vars,
67 const double rdmp_delta0,
const double rdmp_epsilon) noexcept {
68 bool cell_is_troubled =
false;
69 size_t component_index = 0;
70 tmpl::for_each<tmpl::list<EvolvedVarsTags...>>(
71 [&active_grid_candidate_evolved_vars, &cell_is_troubled, &component_index,
72 &inactive_grid_candidate_evolved_vars, &max_of_past_variables,
73 &min_of_past_variables, rdmp_delta0, rdmp_epsilon](
auto tag_v) noexcept {
74 if (cell_is_troubled) {
80 using tag = tmpl::type_from<decltype(tag_v)>;
82 const auto& active_var = get<tag>(active_grid_candidate_evolved_vars);
83 const auto& inactive_var =
84 get<inactive_tag>(inactive_grid_candidate_evolved_vars);
85 const size_t number_of_components = active_var.size();
86 ASSERT(number_of_components == inactive_var.size(),
87 "The active and inactive vars must have the same type of tensor "
88 "and therefore the same number of components.");
90 for (
size_t tensor_storage_index = 0;
91 tensor_storage_index < number_of_components;
92 ++tensor_storage_index) {
93 ASSERT(not cell_is_troubled,
94 "If a cell has already been marked as troubled during the "
95 "RDMP TCI, we should not be continuing to check other "
97 const double max_active = max(active_var[tensor_storage_index]);
98 const double min_active = min(active_var[tensor_storage_index]);
99 const double max_inactive = max(inactive_var[tensor_storage_index]);
100 const double min_inactive = min(inactive_var[tensor_storage_index]);
103 rdmp_epsilon * (max_of_past_variables[component_index] -
104 min_of_past_variables[component_index]));
106 max(max_active, max_inactive) >
107 max_of_past_variables[component_index] + delta or
108 min(min_active, min_inactive) <
109 min_of_past_variables[component_index] - delta;
110 if (cell_is_troubled) {
116 return cell_is_troubled;
124 template <
typename... EvolvedVarsTags>
126 const Variables<tmpl::list<EvolvedVarsTags...>>& active_grid_evolved_vars,
128 inactive_grid_evolved_vars,
129 const bool include_inactive_grid) noexcept {
131 active_grid_evolved_vars.number_of_independent_components,
134 active_grid_evolved_vars.number_of_independent_components,
136 size_t component_index = 0;
137 tmpl::for_each<tmpl::list<EvolvedVarsTags...>>(
138 [&active_grid_evolved_vars, &component_index, &inactive_grid_evolved_vars,
139 &include_inactive_grid, &max_of_vars,
140 &min_of_vars](
auto tag_v) noexcept {
144 using tag = tmpl::type_from<decltype(tag_v)>;
145 const auto& active_var = get<tag>(active_grid_evolved_vars);
146 const size_t number_of_components_in_tensor = active_var.size();
147 for (
size_t tensor_storage_index = 0;
148 tensor_storage_index < number_of_components_in_tensor;
149 ++tensor_storage_index) {
150 ASSERT(component_index < max_of_vars.size() and
151 component_index < min_of_vars.size(),
152 "The component index into the variables is out of bounds.");
153 max_of_vars[component_index] = max(active_var[tensor_storage_index]);
154 min_of_vars[component_index] = min(active_var[tensor_storage_index]);
155 if (include_inactive_grid) {
157 const auto& inactive_var =
158 get<inactive_tag>(inactive_grid_evolved_vars);
159 max_of_vars[component_index] =
160 max(max_of_vars[component_index],
161 max(inactive_var[tensor_storage_index]));
162 min_of_vars[component_index] =
163 min(min_of_vars[component_index],
164 min(inactive_var[tensor_storage_index]));
169 return {std::move(max_of_vars), std::move(min_of_vars)};