Skip to content

Commit

Permalink
Add ExpirationTime and WorldtubeRadius tags
Browse files Browse the repository at this point in the history
  • Loading branch information
nikwit committed Nov 13, 2024
1 parent 7aebb48 commit bd78a30
Show file tree
Hide file tree
Showing 6 changed files with 62 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ struct InitializeEvolvedVariables {

using simple_tags =
tmpl::list<variables_tag, dt_variables_tag, Tags::CurrentIteration,
Tags::ExpirationTime, Tags::WorldtubeRadius,
::Tags::HistoryEvolvedVariables<variables_tag>>;
using return_tags = simple_tags;

Expand All @@ -41,7 +42,8 @@ struct InitializeEvolvedVariables {
using mutable_global_cache_tags = tmpl::list<>;
using simple_tags_from_options = tmpl::list<Tags::InitialPositionAndVelocity>;
using argument_tags = tmpl::list<::Tags::TimeStepper<TimeStepper>,
Tags::InitialPositionAndVelocity>;
Tags::InitialPositionAndVelocity,
::Tags::Time, Tags::ExcisionSphere<Dim>>;
static void apply(
const gsl::not_null<Variables<
tmpl::list<Tags::EvolvedPosition<Dim>, Tags::EvolvedVelocity<Dim>>>*>
Expand All @@ -51,11 +53,20 @@ struct InitializeEvolvedVariables {
::Tags::dt<Tags::EvolvedVelocity<Dim>>>>*>
dt_evolved_vars,
const gsl::not_null<size_t*> current_iteration,
const gsl::not_null<double*> expiration_time,
const gsl::not_null<double*> worldtube_radius,
const gsl::not_null<::Tags::HistoryEvolvedVariables<variables_tag>::type*>
time_stepper_history,
const TimeStepper& time_stepper,
const std::array<tnsr::I<double, Dim>, 2>& initial_pos_and_vel) {
const std::array<tnsr::I<double, Dim>, 2>& initial_pos_and_vel,
const double initial_time, const ExcisionSphere<Dim>& 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 =
Expand Down
15 changes: 15 additions & 0 deletions src/Evolution/Systems/CurvedScalarWave/Worldtube/Tags.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,8 @@ struct MockMetavariables {
using const_global_cache_tags = tmpl::list<
domain::Tags::Domain<Dim>,
CurvedScalarWave::Tags::BackgroundSpacetime<gr::Solutions::KerrSchild>,
Tags::ExcisionSphere<Dim>, Tags::ExpansionOrder, Tags::MaxIterations,
Tags::Charge, Tags::Mass>;
Tags::ExcisionSphere<Dim>, Tags::WorldtubeRadius, Tags::ExpansionOrder,
Tags::MaxIterations, Tags::Charge, Tags::Mass>;
};

void test_iterations(const size_t max_iterations) {
Expand Down Expand Up @@ -166,10 +166,15 @@ void test_iterations(const size_t max_iterations) {
tuples::TaggedTuple<
domain::Tags::Domain<Dim>,
CurvedScalarWave::Tags::BackgroundSpacetime<gr::Solutions::KerrSchild>,
Tags::ExcisionSphere<Dim>, 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<Dim>, 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<metavars> runner{std::move(tuple_of_opts)};
const auto element_ids = initial_element_ids(initial_refinements);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,8 +122,8 @@ struct MockMetavariables {
using dg_element_array = MockElementArray<MockMetavariables>;
using const_global_cache_tags =
tmpl::list<domain::Tags::Domain<Dim>, Tags::ExcisionSphere<Dim>,
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
Expand Down Expand Up @@ -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<domain::Tags::Domain<Dim>, Tags::ExcisionSphere<Dim>,
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<size_t>(0),
0.1,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -19,21 +20,30 @@ SPECTRE_TEST_CASE(
tmpl::list<Tags::EvolvedPosition<3>, Tags::EvolvedVelocity<3>>>;
using dt_variables_tag = db::add_tag_prefix<::Tags::dt, variables_tag>;
const tnsr::I<double, 3> initial_pos{{1., 2., 3.}};
const tnsr::I<double, 3, Frame::Grid> initial_excision_pos{{1., 2., 3.}};
const tnsr::I<double, 3> 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<db::AddSimpleTags<
variables_tag, dt_variables_tag,
::Tags::HistoryEvolvedVariables<variables_tag>,
::Tags::ConcreteTimeStepper<TimeStepper>,
Tags::InitialPositionAndVelocity, Tags::CurrentIteration>,
Tags::InitialPositionAndVelocity, Tags::CurrentIteration,
Tags::ExpirationTime, Tags::WorldtubeRadius, ::Tags::Time,
Tags::ExcisionSphere<3>>,
time_stepper_ref_tags<TimeStepper>>(
variables_tag::type{}, dt_variables_tag::type{},
TimeSteppers::History<variables_tag::type>{},
static_cast<std::unique_ptr<TimeStepper>>(
std::make_unique<TimeSteppers::AdamsBashforth>(4)),
std::array<tnsr::I<double, 3>, 2>{{initial_pos, initial_vel}},
current_iteration);
current_iteration, expiration_time, initial_wt_radius, initial_time,
excision_sphere);

db::mutate_apply<Initialization::InitializeEvolvedVariables>(
make_not_null(&box));
Expand All @@ -47,6 +57,8 @@ SPECTRE_TEST_CASE(
CHECK(db::get<::Tags::HistoryEvolvedVariables<variables_tag>>(box) ==
TimeSteppers::History<variables_tag::type>(1));
CHECK(get<Tags::CurrentIteration>(box) == 0);
CHECK(get<Tags::ExpirationTime>(box) == initial_time + 1e-10);
CHECK(get<Tags::WorldtubeRadius>(box) == wt_radius);
}
} // namespace
} // namespace CurvedScalarWave::Worldtube
Original file line number Diff line number Diff line change
Expand Up @@ -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<
Expand Down

0 comments on commit bd78a30

Please sign in to comment.