From bd78a304110a09833821340c19afb747c26653fe Mon Sep 17 00:00:00 2001 From: Nikolas Date: Tue, 3 Sep 2024 10:45:28 +0200 Subject: [PATCH] Add ExpirationTime and WorldtubeRadius tags --- .../InitializeEvolvedVariables.hpp | 15 +++++++++++++-- .../Systems/CurvedScalarWave/Worldtube/Tags.hpp | 15 +++++++++++++++ .../ElementActions/Test_Iterations.cpp | 17 +++++++++++------ .../ElementActions/Test_SendToWorldtube.cpp | 9 +++++---- .../Test_InitializeEvolvedVariables.cpp | 16 ++++++++++++++-- .../CurvedScalarWave/Worldtube/Test_Tags.cpp | 4 ++++ 6 files changed, 62 insertions(+), 14 deletions(-) diff --git a/src/Evolution/Systems/CurvedScalarWave/Worldtube/SingletonActions/InitializeEvolvedVariables.hpp b/src/Evolution/Systems/CurvedScalarWave/Worldtube/SingletonActions/InitializeEvolvedVariables.hpp index 03dea963b43e..71c36f79a55b 100644 --- a/src/Evolution/Systems/CurvedScalarWave/Worldtube/SingletonActions/InitializeEvolvedVariables.hpp +++ b/src/Evolution/Systems/CurvedScalarWave/Worldtube/SingletonActions/InitializeEvolvedVariables.hpp @@ -33,6 +33,7 @@ struct InitializeEvolvedVariables { using simple_tags = tmpl::list>; using return_tags = simple_tags; @@ -41,7 +42,8 @@ struct InitializeEvolvedVariables { using mutable_global_cache_tags = tmpl::list<>; using simple_tags_from_options = tmpl::list; using argument_tags = tmpl::list<::Tags::TimeStepper, - Tags::InitialPositionAndVelocity>; + Tags::InitialPositionAndVelocity, + ::Tags::Time, Tags::ExcisionSphere>; static void apply( const gsl::not_null, Tags::EvolvedVelocity>>*> @@ -51,11 +53,20 @@ struct InitializeEvolvedVariables { ::Tags::dt>>>*> dt_evolved_vars, const gsl::not_null current_iteration, + const gsl::not_null expiration_time, + const gsl::not_null worldtube_radius, const gsl::not_null<::Tags::HistoryEvolvedVariables::type*> time_stepper_history, const TimeStepper& time_stepper, - const std::array, 2>& initial_pos_and_vel) { + const std::array, 2>& initial_pos_and_vel, + const double initial_time, const ExcisionSphere& excision_sphere) { *current_iteration = 0; + + // the functions of time should be ready during the first step but not the + // second. We choose the arbitrary value of 1e-10 here to ensure this. + *expiration_time = initial_time + 1e-10; + *worldtube_radius = excision_sphere.radius(); + const size_t starting_order = time_stepper.number_of_past_steps() == 0 ? time_stepper.order() : 1; *time_stepper_history = diff --git a/src/Evolution/Systems/CurvedScalarWave/Worldtube/Tags.hpp b/src/Evolution/Systems/CurvedScalarWave/Worldtube/Tags.hpp index 9eb200f9785d..7db0ee87208b 100644 --- a/src/Evolution/Systems/CurvedScalarWave/Worldtube/Tags.hpp +++ b/src/Evolution/Systems/CurvedScalarWave/Worldtube/Tags.hpp @@ -430,6 +430,21 @@ struct CurrentIteration : db::SimpleTag { using type = size_t; }; +/*! + * \brief The current expiration time of the functions of time which are + * controlled by the worldtube singleton. + */ +struct ExpirationTime : db::SimpleTag { + using type = double; +}; + +/*! + * \brief The current worldtube radius held by the singleton. + */ +struct WorldtubeRadius : db::SimpleTag { + using type = double; +}; + /*! * \brief The initial position and velocity of the scalar charge in inertial * coordinates. diff --git a/tests/Unit/Evolution/Systems/CurvedScalarWave/Worldtube/ElementActions/Test_Iterations.cpp b/tests/Unit/Evolution/Systems/CurvedScalarWave/Worldtube/ElementActions/Test_Iterations.cpp index 0c22153666e3..d462f4e03486 100644 --- a/tests/Unit/Evolution/Systems/CurvedScalarWave/Worldtube/ElementActions/Test_Iterations.cpp +++ b/tests/Unit/Evolution/Systems/CurvedScalarWave/Worldtube/ElementActions/Test_Iterations.cpp @@ -120,8 +120,8 @@ struct MockMetavariables { using const_global_cache_tags = tmpl::list< domain::Tags::Domain, CurvedScalarWave::Tags::BackgroundSpacetime, - Tags::ExcisionSphere, Tags::ExpansionOrder, Tags::MaxIterations, - Tags::Charge, Tags::Mass>; + Tags::ExcisionSphere, Tags::WorldtubeRadius, Tags::ExpansionOrder, + Tags::MaxIterations, Tags::Charge, Tags::Mass>; }; void test_iterations(const size_t max_iterations) { @@ -166,10 +166,15 @@ void test_iterations(const size_t max_iterations) { tuples::TaggedTuple< domain::Tags::Domain, CurvedScalarWave::Tags::BackgroundSpacetime, - Tags::ExcisionSphere, Tags::ExpansionOrder, Tags::MaxIterations, - Tags::Charge, Tags::Mass> - tuple_of_opts{shell.create_domain(), kerr_schild, excision_sphere, - expansion_order, max_iterations, charge, + Tags::ExcisionSphere, Tags::WorldtubeRadius, Tags::ExpansionOrder, + Tags::MaxIterations, Tags::Charge, Tags::Mass> + tuple_of_opts{shell.create_domain(), + kerr_schild, + excision_sphere, + excision_sphere.radius(), + expansion_order, + max_iterations, + charge, std::make_optional(mass)}; ActionTesting::MockRuntimeSystem runner{std::move(tuple_of_opts)}; const auto element_ids = initial_element_ids(initial_refinements); diff --git a/tests/Unit/Evolution/Systems/CurvedScalarWave/Worldtube/ElementActions/Test_SendToWorldtube.cpp b/tests/Unit/Evolution/Systems/CurvedScalarWave/Worldtube/ElementActions/Test_SendToWorldtube.cpp index 4632547b1224..28dc78bb6a6f 100644 --- a/tests/Unit/Evolution/Systems/CurvedScalarWave/Worldtube/ElementActions/Test_SendToWorldtube.cpp +++ b/tests/Unit/Evolution/Systems/CurvedScalarWave/Worldtube/ElementActions/Test_SendToWorldtube.cpp @@ -122,8 +122,8 @@ struct MockMetavariables { using dg_element_array = MockElementArray; using const_global_cache_tags = tmpl::list, Tags::ExcisionSphere, - Tags::ExpansionOrder, Tags::MaxIterations, Tags::Charge, - Tags::Mass>; + Tags::WorldtubeRadius, Tags::ExpansionOrder, + Tags::MaxIterations, Tags::Charge, Tags::Mass>; }; // This test checks that `SendToWorldtube` integrates the regular field on the @@ -165,10 +165,11 @@ SPECTRE_TEST_CASE("Unit.CurvedScalarWave.Worldtube.SendToWorldtube", "[Unit]") { const auto& initial_extents = shell.initial_extents(); // self force and therefore iterative scheme is turned off tuples::TaggedTuple, Tags::ExcisionSphere, - Tags::ExpansionOrder, Tags::MaxIterations, Tags::Charge, - Tags::Mass> + Tags::WorldtubeRadius, Tags::ExpansionOrder, + Tags::MaxIterations, Tags::Charge, Tags::Mass> tuple_of_opts{shell.create_domain(), excision_sphere, + excision_sphere.radius(), expansion_order, static_cast(0), 0.1, diff --git a/tests/Unit/Evolution/Systems/CurvedScalarWave/Worldtube/SingletonActions/Test_InitializeEvolvedVariables.cpp b/tests/Unit/Evolution/Systems/CurvedScalarWave/Worldtube/SingletonActions/Test_InitializeEvolvedVariables.cpp index be04765a7379..0b6b02f53c39 100644 --- a/tests/Unit/Evolution/Systems/CurvedScalarWave/Worldtube/SingletonActions/Test_InitializeEvolvedVariables.cpp +++ b/tests/Unit/Evolution/Systems/CurvedScalarWave/Worldtube/SingletonActions/Test_InitializeEvolvedVariables.cpp @@ -7,6 +7,7 @@ #include "Evolution/Systems/CurvedScalarWave/Worldtube/SingletonActions/InitializeEvolvedVariables.hpp" #include "Framework/TestingFramework.hpp" #include "Time/Tags/HistoryEvolvedVariables.hpp" +#include "Time/Tags/Time.hpp" #include "Time/Tags/TimeStepper.hpp" #include "Time/TimeSteppers/AdamsBashforth.hpp" #include "Time/TimeSteppers/TimeStepper.hpp" @@ -19,21 +20,30 @@ SPECTRE_TEST_CASE( tmpl::list, Tags::EvolvedVelocity<3>>>; using dt_variables_tag = db::add_tag_prefix<::Tags::dt, variables_tag>; const tnsr::I initial_pos{{1., 2., 3.}}; + const tnsr::I initial_excision_pos{{1., 2., 3.}}; const tnsr::I initial_vel{{4., 5., 6.}}; const size_t current_iteration = 77; + const double expiration_time = 1234.; + const double initial_time = 0.; + const double initial_wt_radius = 12345.; + const double wt_radius = 2.; + const ExcisionSphere<3> excision_sphere(wt_radius, initial_excision_pos, {}); auto box = db::create, ::Tags::ConcreteTimeStepper, - Tags::InitialPositionAndVelocity, Tags::CurrentIteration>, + Tags::InitialPositionAndVelocity, Tags::CurrentIteration, + Tags::ExpirationTime, Tags::WorldtubeRadius, ::Tags::Time, + Tags::ExcisionSphere<3>>, time_stepper_ref_tags>( variables_tag::type{}, dt_variables_tag::type{}, TimeSteppers::History{}, static_cast>( std::make_unique(4)), std::array, 2>{{initial_pos, initial_vel}}, - current_iteration); + current_iteration, expiration_time, initial_wt_radius, initial_time, + excision_sphere); db::mutate_apply( make_not_null(&box)); @@ -47,6 +57,8 @@ SPECTRE_TEST_CASE( CHECK(db::get<::Tags::HistoryEvolvedVariables>(box) == TimeSteppers::History(1)); CHECK(get(box) == 0); + CHECK(get(box) == initial_time + 1e-10); + CHECK(get(box) == wt_radius); } } // namespace } // namespace CurvedScalarWave::Worldtube diff --git a/tests/Unit/Evolution/Systems/CurvedScalarWave/Worldtube/Test_Tags.cpp b/tests/Unit/Evolution/Systems/CurvedScalarWave/Worldtube/Test_Tags.cpp index ca56508db6e8..be35e78f033e 100644 --- a/tests/Unit/Evolution/Systems/CurvedScalarWave/Worldtube/Test_Tags.cpp +++ b/tests/Unit/Evolution/Systems/CurvedScalarWave/Worldtube/Test_Tags.cpp @@ -756,6 +756,10 @@ SPECTRE_TEST_CASE("Unit.Evolution.Systems.CurvedScalarWave.Worldtube.Tags", TestHelpers::db::test_simple_tag< CurvedScalarWave::Worldtube::Tags::SelfForceTurnOnInterval>( "SelfForceTurnOnInterval"); + TestHelpers::db::test_simple_tag< + CurvedScalarWave::Worldtube::Tags::ExpirationTime>("ExpirationTime"); + TestHelpers::db::test_simple_tag< + CurvedScalarWave::Worldtube::Tags::WorldtubeRadius>("WorldtubeRadius"); TestHelpers::db::test_simple_tag< CurvedScalarWave::Worldtube::Tags::MaxIterations>("MaxIterations"); TestHelpers::db::test_simple_tag<