diff --git a/src/Domain/Creators/Sphere.cpp b/src/Domain/Creators/Sphere.cpp index 7d01fcc2db9ce..157142e43dff4 100644 --- a/src/Domain/Creators/Sphere.cpp +++ b/src/Domain/Creators/Sphere.cpp @@ -383,9 +383,13 @@ Domain<3> Sphere::create_domain() const { time_dependent_options_.value()); // First shell gets the distorted maps. + // Last shell gets translation with transition region for (size_t block_id = 0; block_id < num_blocks_; block_id++) { const bool include_distorted_map_in_first_shell = block_id < num_blocks_per_shell_; + // False if block_id is in the last shell + const bool use_rigid_translation = + block_id + num_blocks_per_shell_ < num_blocks_; block_maps_grid_to_distorted[block_id] = hard_coded_options.grid_to_distorted_map( include_distorted_map_in_first_shell); @@ -394,7 +398,7 @@ Domain<3> Sphere::create_domain() const { include_distorted_map_in_first_shell); block_maps_grid_to_inertial[block_id] = hard_coded_options.grid_to_inertial_map( - include_distorted_map_in_first_shell); + include_distorted_map_in_first_shell, use_rigid_translation); } } else { const auto& time_dependence = std::get TimeDependentMapOptions::distorted_to_inertial_map( const bool include_distorted_map) const { if (include_distorted_map) { - return std::make_unique(translation_map_); + return std::make_unique( + rigid_translation_map_); } else { return nullptr; } @@ -172,10 +175,12 @@ TimeDependentMapOptions::grid_to_distorted_map( TimeDependentMapOptions::MapType TimeDependentMapOptions::grid_to_inertial_map( - const bool include_distorted_map) const { + const bool include_distorted_map, const bool use_rigid_translation) const { if (include_distorted_map) { return std::make_unique(shape_map_, - translation_map_); + rigid_translation_map_); + } else if (use_rigid_translation) { + return std::make_unique(rigid_translation_map_); } else { return std::make_unique(translation_map_); } diff --git a/src/Domain/Creators/SphereTimeDependentMaps.hpp b/src/Domain/Creators/SphereTimeDependentMaps.hpp index 599acef0cbd52..49a77a9801077 100644 --- a/src/Domain/Creators/SphereTimeDependentMaps.hpp +++ b/src/Domain/Creators/SphereTimeDependentMaps.hpp @@ -223,7 +223,7 @@ struct TimeDependentMapOptions { * only be an identity map. */ MapType grid_to_inertial_map( - bool include_distorted_map) const; + bool include_distorted_map, const bool use_rigid_translation) const; inline static const std::string size_name{"Size"}; inline static const std::string shape_name{"Shape"}; @@ -233,6 +233,7 @@ struct TimeDependentMapOptions { double initial_time_{std::numeric_limits::signaling_NaN()}; size_t initial_l_max_{}; ShapeMap shape_map_{}; + TranslationMap rigid_translation_map_{}; TranslationMap translation_map_{}; std::optional> initial_shape_values_{}; diff --git a/tests/Unit/Domain/Creators/Test_SphereTimeDependentMaps.cpp b/tests/Unit/Domain/Creators/Test_SphereTimeDependentMaps.cpp index 9908a07bb9015..e0da900597501 100644 --- a/tests/Unit/Domain/Creators/Test_SphereTimeDependentMaps.cpp +++ b/tests/Unit/Domain/Creators/Test_SphereTimeDependentMaps.cpp @@ -104,41 +104,43 @@ void test(const bool use_non_zero_shape) { .get()) == translation_non_zero); for (const bool include_distorted : make_array(true, false)) { - time_dep_options.build_maps( - center, inner_radius, outer_radius, - std::pair{translation_inner_radius, - translation_outer_radius}); - - const auto grid_to_distorted_map = - time_dep_options.grid_to_distorted_map(include_distorted); - const auto grid_to_inertial_map = - time_dep_options.grid_to_inertial_map(include_distorted); - const auto distorted_to_inertial_map = - time_dep_options.distorted_to_inertial_map(include_distorted); - - // All of these maps are tested individually. Rather than going through the - // effort of coming up with a source coordinate and calculating analytically - // what we would get after it's mapped, we just check that whether it's - // supposed to be a nullptr and if it's not, if it's the identity and that - // the jacobians are time dependent. - const auto check_map = [](const auto& map, const bool is_null, - const bool is_identity) { - if (is_null) { - CHECK(map == nullptr); - } else { - CHECK(map->is_identity() == is_identity); - CHECK(map->inv_jacobian_is_time_dependent() == not is_identity); - CHECK(map->jacobian_is_time_dependent() == not is_identity); - } - }; - - // There is no null pointer in the grid to inertial map - check_map(grid_to_inertial_map, false, false); - - check_map(grid_to_distorted_map, not include_distorted, false); - - // If no shape distortion, there is only the translation - check_map(distorted_to_inertial_map, not include_distorted, false); + for (const bool use_rigid_translation : make_array(true, false)) { + time_dep_options.build_maps( + center, inner_radius, outer_radius, + std::pair{translation_inner_radius, + translation_outer_radius}); + + const auto grid_to_distorted_map = + time_dep_options.grid_to_distorted_map(include_distorted); + const auto grid_to_inertial_map = time_dep_options.grid_to_inertial_map( + include_distorted, use_rigid_translation); + const auto distorted_to_inertial_map = + time_dep_options.distorted_to_inertial_map(include_distorted); + + // All of these maps are tested individually. Rather than going through + // the effort of coming up with a source coordinate and calculating + // analytically what we would get after it's mapped, we just check that + // whether it's supposed to be a nullptr and if it's not, if it's the + // identity and that the jacobians are time dependent. + const auto check_map = [](const auto& map, const bool is_null, + const bool is_identity) { + if (is_null) { + CHECK(map == nullptr); + } else { + CHECK(map->is_identity() == is_identity); + CHECK(map->inv_jacobian_is_time_dependent() == not is_identity); + CHECK(map->jacobian_is_time_dependent() == not is_identity); + } + }; + + // There is no null pointer in the grid to inertial map + check_map(grid_to_inertial_map, false, false); + + check_map(grid_to_distorted_map, not include_distorted, false); + + // If no shape distortion, there is only the translation + check_map(distorted_to_inertial_map, not include_distorted, false); + } } }