diff --git a/src/Domain/Creators/SphereTimeDependentMaps.cpp b/src/Domain/Creators/SphereTimeDependentMaps.cpp index 9ee2a4f0b8c6..65ed01267916 100644 --- a/src/Domain/Creators/SphereTimeDependentMaps.cpp +++ b/src/Domain/Creators/SphereTimeDependentMaps.cpp @@ -27,15 +27,10 @@ namespace domain::creators::sphere { TimeDependentMapOptions::TimeDependentMapOptions( - const double initial_time, - const std::optional>& initial_size_values, - const size_t initial_l_max, - const typename ShapeMapInitialValues::type::value_type& - initial_shape_values) + const double initial_time, const ShapeMapOptions& shape_map_options) : initial_time_(initial_time), - initial_size_values_(initial_size_values), - initial_l_max_(initial_l_max), - initial_shape_values_(initial_shape_values) {} + initial_l_max_(shape_map_options.l_max), + initial_shape_values_(shape_map_options.initial_values) {} std::unordered_map> @@ -62,7 +57,7 @@ TimeDependentMapOptions::create_functions_of_time( DataVector shape_zeros{ ylm::Spherepack::spectral_size(initial_l_max_, initial_l_max_), 0.0}; DataVector shape_func{}; - double size_func_from_shape = std::numeric_limits::signaling_NaN(); + DataVector size_func{1, 0.0}; if (initial_shape_values_.has_value()) { if (std::holds_alternative( @@ -77,18 +72,15 @@ TimeDependentMapOptions::create_functions_of_time( inner_radius; shape_func = ylm.phys_to_spec(radial_distortion); // Transform from SPHEREPACK to actual Ylm for size func - size_func_from_shape = shape_func[0] * sqrt(0.5 * M_PI); + size_func[0] = shape_func[0] * sqrt(0.5 * M_PI); // Set l=0 for shape map to 0 because size is going to be used shape_func[0] = 0.0; } } else { shape_func = shape_zeros; - size_func_from_shape = 0.0; + size_func[0] = 0.0; } - ASSERT(not std::isnan(size_func_from_shape), - "Size func value from shape coefficients is NaN."); - // ShapeMap FunctionOfTime result[shape_name] = std::make_unique>( @@ -97,16 +89,9 @@ TimeDependentMapOptions::create_functions_of_time( {std::move(shape_func), shape_zeros, shape_zeros}}, expiration_times.at(shape_name)); - DataVector size_func{1, size_func_from_shape}; DataVector size_deriv{1, 0.0}; DataVector size_2nd_deriv{1, 0.0}; - if (initial_size_values_.has_value()) { - size_func[0] = gsl::at(initial_size_values_.value(), 0); - size_deriv[0] = gsl::at(initial_size_values_.value(), 1); - size_2nd_deriv[0] = gsl::at(initial_size_values_.value(), 2); - } - // Size FunctionOfTime (used in ShapeMap) result[size_name] = std::make_unique>( initial_time_, diff --git a/src/Domain/Creators/SphereTimeDependentMaps.hpp b/src/Domain/Creators/SphereTimeDependentMaps.hpp index 0d1e90c150d2..e333d9acfad9 100644 --- a/src/Domain/Creators/SphereTimeDependentMaps.hpp +++ b/src/Domain/Creators/SphereTimeDependentMaps.hpp @@ -67,8 +67,8 @@ struct Spherical {}; * \brief This holds all options related to the time dependent maps of the * domain::creators::Sphere domain creator. * - * \details Currently this class will only add a Size and a Shape map (and - * FunctionsOfTime) to the domain. Other maps can be added as needed. + * \details Currently this class will only add a Shape map (and size + * FunctionOfTime) to the domain. Other maps can be added as needed. * * \note This struct contains no information about what blocks the time * dependent maps will go in. @@ -104,60 +104,42 @@ struct TimeDependentMapOptions { "The initial time of the functions of time"}; }; - struct SizeMap { - static constexpr Options::String help = { - "Options for a time-dependent size map in the inner-most shell of the " - "domain."}; - }; - - struct SizeMapInitialValues { - static std::string name() { return "InitialValues"; } - using type = Options::Auto>; - static constexpr Options::String help = { - "Initial value and two derivatives of the size map. Specify 'Auto' to " - "use the l=0 coefficient calculated from the shape map Ylm " - "coefficients (derivs will be zero)."}; - using group = SizeMap; - }; - struct ShapeMapOptions { + using type = ShapeMapOptions; static std::string name() { return "ShapeMap"; } static constexpr Options::String help = { - "Options for a time-dependent size map in the inner-most shell of the " + "Options for a time-dependent shape map in the inner-most shell of the " "domain."}; - }; - struct ShapeMapLMax { - static std::string name() { return "LMax"; } - using type = size_t; - static constexpr Options::String help = {"Initial LMax for the shape map."}; - using group = ShapeMapOptions; - }; + struct LMax { + using type = size_t; + static constexpr Options::String help = { + "Initial LMax for the shape map."}; + }; - struct ShapeMapInitialValues { - static std::string name() { return "InitialValues"; } - using type = - Options::Auto, Spherical>; - static constexpr Options::String help = { - "Initial Ylm coefficients for the shape map. Specify 'Spherical' for " - "all coefficients to be initialized to zero."}; - using group = ShapeMapOptions; + struct InitialValues { + using type = + Options::Auto, Spherical>; + static constexpr Options::String help = { + "Initial Ylm coefficients for the shape map. Specify 'Spherical' for " + "all coefficients to be initialized to zero."}; + }; + + using options = tmpl::list; + + size_t l_max{}; + std::optional> initial_values{}; }; - using options = tmpl::list; + using options = tmpl::list; static constexpr Options::String help{ "The options for all the hard-coded time dependent maps in the Sphere " "domain."}; TimeDependentMapOptions() = default; - TimeDependentMapOptions( - double initial_time, - const std::optional>& initial_size_values, - size_t initial_l_max, - const typename ShapeMapInitialValues::type::value_type& - initial_shape_values); + TimeDependentMapOptions(double initial_time, + const ShapeMapOptions& shape_map_options); /*! * \brief Create the function of time map using the options that were @@ -220,9 +202,9 @@ struct TimeDependentMapOptions { private: double initial_time_{std::numeric_limits::signaling_NaN()}; - std::optional> initial_size_values_{}; size_t initial_l_max_{}; ShapeMap shape_map_{}; - typename ShapeMapInitialValues::type::value_type initial_shape_values_{}; + std::optional> + initial_shape_values_{}; }; } // namespace domain::creators::sphere diff --git a/tests/Unit/Domain/Creators/Test_Sphere.cpp b/tests/Unit/Domain/Creators/Test_Sphere.cpp index 2db322e1744c..59ac389d7cd1 100644 --- a/tests/Unit/Domain/Creators/Test_Sphere.cpp +++ b/tests/Unit/Domain/Creators/Test_Sphere.cpp @@ -136,8 +136,6 @@ std::string option_string( time_dependent ? (hard_coded_time_dependent_maps ? " TimeDependentMaps:\n" " InitialTime: 1.0\n" - " SizeMap:\n" - " InitialValues: [0.5, -0.04, 0.003]\n" " ShapeMap:\n" " LMax: 10\n" " InitialValues: Spherical\n" @@ -535,14 +533,13 @@ void test_parse_errors() { Catch::Matchers::ContainsSubstring( "None boundary condition is not supported. If you would like " "an outflow-type boundary condition, you must use that.")); + using TDMO = domain::creators::sphere::TimeDependentMapOptions; CHECK_THROWS_WITH( - creators::Sphere(inner_radius, outer_radius, inner_cube, refinement, - initial_extents, use_equiangular_map, - equatorial_compression, radial_partitioning, - radial_distribution, which_wedges, - domain::creators::sphere::TimeDependentMapOptions{ - 1.0, std::nullopt, 5, std::nullopt}, - nullptr), + creators::Sphere( + inner_radius, outer_radius, inner_cube, refinement, initial_extents, + use_equiangular_map, equatorial_compression, radial_partitioning, + radial_distribution, which_wedges, + TDMO{1.0, TDMO::ShapeMapOptions{5, std::nullopt}}, nullptr), Catch::Matchers::ContainsSubstring( "Currently cannot use hard-coded time dependent maps with an inner " "cube. Use a TimeDependence instead.")); @@ -579,7 +576,7 @@ void test_sphere() { {domain::CoordinateMaps::Distribution::Linear}}}; const std::array velocity{{2.3, -0.3, 0.5}}; - const std::array size_values{0.5, -0.04, 0.003}; + const std::array size_values{0.0, 0.0, 0.0}; const size_t l_max = 10; const std::vector times{1., 10.}; @@ -633,7 +630,8 @@ void test_sphere() { if (time_dependent) { if (use_hard_coded_time_dep_options) { time_dependent_options = creators::sphere::TimeDependentMapOptions( - 1.0, size_values, l_max, std::nullopt); + 1.0, creators::sphere::TimeDependentMapOptions::ShapeMapOptions{ + l_max, std::nullopt}); } else { time_dependent_options = std::make_unique< domain::creators::time_dependence::UniformTranslation<3, 0>>( @@ -660,7 +658,7 @@ void test_sphere() { with_boundary_conditions, time_dependent ? times : std::vector{0.}, time_dependent ? velocity : std::array{{0., 0., 0.}}, - time_dependent ? size_values : std::array{{0., 0., 0.}}); + size_values); TestHelpers::domain::creators::test_creation( option_string(inner_radius, outer_radius, interior, initial_refinement, initial_extents, equiangular, equatorial_compression, diff --git a/tests/Unit/Domain/Creators/Test_SphereTimeDependentMaps.cpp b/tests/Unit/Domain/Creators/Test_SphereTimeDependentMaps.cpp index 449355c6ca3a..239e292772f3 100644 --- a/tests/Unit/Domain/Creators/Test_SphereTimeDependentMaps.cpp +++ b/tests/Unit/Domain/Creators/Test_SphereTimeDependentMaps.cpp @@ -27,12 +27,8 @@ struct Inertial; namespace domain::creators::sphere { namespace { -std::string create_option_string(const bool use_non_zero_shape, - const bool use_size_from_shape) { +std::string create_option_string(const bool use_non_zero_shape) { return "InitialTime: 1.5\n" - "SizeMap:\n" + - (use_size_from_shape ? " InitialValues: Auto\n"s - : " InitialValues: [0.9, 0.08, 0.007]\n"s) + "ShapeMap:\n" " LMax: 8\n" + (use_non_zero_shape ? " InitialValues:\n" @@ -40,20 +36,14 @@ std::string create_option_string(const bool use_non_zero_shape, " Spin: [0.0, 0.0, 0.0]\n"s : " InitialValues: Spherical\n"s); } -void test(const bool use_non_zero_shape, const bool use_size_from_shape) { +void test(const bool use_non_zero_shape) { CAPTURE(use_non_zero_shape); - CAPTURE(use_size_from_shape); const double initial_time = 1.5; const size_t l_max = 8; - std::optional> size_values{}; - - if (not use_size_from_shape) { - size_values = std::array{0.9, 0.08, 0.007}; - } TimeDependentMapOptions time_dep_options = TestHelpers::test_creation( - create_option_string(use_non_zero_shape, use_size_from_shape)); + create_option_string(use_non_zero_shape)); std::unordered_map expiration_times{ {TimeDependentMapOptions::shape_name, 15.5}, @@ -69,11 +59,6 @@ void test(const bool use_non_zero_shape, const bool use_size_from_shape) { DataVector size_func{1, 0.0}; DataVector size_deriv{1, 0.0}; DataVector size_2nd_deriv{1, 0.0}; - if (not use_size_from_shape) { - size_func[0] = gsl::at(size_values.value(), 0); - size_deriv[0] = gsl::at(size_values.value(), 1); - size_2nd_deriv[0] = gsl::at(size_values.value(), 2); - } PP3 size{ initial_time, std::array{{size_func, size_deriv, size_2nd_deriv, {0.0}}}, @@ -150,9 +135,7 @@ SPECTRE_TEST_CASE("Unit.Domain.Creators.SphereTimeDependentMaps", "[Domain][Unit]") { test_shape_initial_values(); - for (auto& [use_non_zero_shape, use_size_from_shape] : - cartesian_product(make_array(true, false), make_array(true, false))) { - test(use_non_zero_shape, use_size_from_shape); - } + test(true); + test(false); } } // namespace domain::creators::sphere diff --git a/tests/Unit/ParallelAlgorithms/Interpolation/Test_ComputeDestVars.cpp b/tests/Unit/ParallelAlgorithms/Interpolation/Test_ComputeDestVars.cpp index d93381a6a0d3..1382722833c4 100644 --- a/tests/Unit/ParallelAlgorithms/Interpolation/Test_ComputeDestVars.cpp +++ b/tests/Unit/ParallelAlgorithms/Interpolation/Test_ComputeDestVars.cpp @@ -107,8 +107,8 @@ template void test() { domain::FunctionsOfTime::register_derived_with_charm(); - domain::creators::sphere::TimeDependentMapOptions time_dep_opts{ - 0.0, std::nullopt, 2, std::nullopt}; + using TDMO = domain::creators::sphere::TimeDependentMapOptions; + TDMO time_dep_opts{0.0, TDMO::ShapeMapOptions{2, std::nullopt}}; const auto domain_creator = domain::creators::Sphere( 0.9, 4.9, domain::creators::Sphere::Excision{}, 1_st, 7_st, false, {}, {},