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 Sep 3, 2024
1 parent 3b84a37 commit 8d2caeb
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,17 @@ struct InitializeEvolvedVariables {

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

using compute_tags = tmpl::list<>;
using const_global_cache_tags = tmpl::list<>;
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>;
using argument_tags =
tmpl::list<::Tags::TimeStepper<TimeStepper>,
Tags::InitialPositionAndVelocity, ::Tags::Time>;
static void apply(
const gsl::not_null<Variables<
tmpl::list<Tags::EvolvedPosition<Dim>, Tags::EvolvedVelocity<Dim>>>*>
Expand All @@ -51,11 +53,15 @@ 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<::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) {
*current_iteration = 0;
*expiration_time = initial_time + 1e-10;

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 @@ -355,6 +355,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 @@ -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 @@ -21,19 +22,22 @@ SPECTRE_TEST_CASE(
const tnsr::I<double, 3> initial_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.;
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::Time>,
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_time);

db::mutate_apply<Initialization::InitializeEvolvedVariables>(
make_not_null(&box));
Expand All @@ -47,6 +51,7 @@ 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);
}
} // namespace
} // namespace CurvedScalarWave::Worldtube
Original file line number Diff line number Diff line change
Expand Up @@ -731,6 +731,10 @@ SPECTRE_TEST_CASE("Unit.Evolution.Systems.CurvedScalarWave.Worldtube.Tags",
"Charge");
TestHelpers::db::test_simple_tag<CurvedScalarWave::Worldtube::Tags::Mass>(
"Mass");
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 8d2caeb

Please sign in to comment.