diff --git a/src/Elliptic/Actions/RunEventsAndTriggers.hpp b/src/Elliptic/Actions/RunEventsAndTriggers.hpp index 5378db841089..74e68ff202ce 100644 --- a/src/Elliptic/Actions/RunEventsAndTriggers.hpp +++ b/src/Elliptic/Actions/RunEventsAndTriggers.hpp @@ -8,6 +8,7 @@ #include "Parallel/AlgorithmExecution.hpp" #include "Parallel/GlobalCache.hpp" #include "ParallelAlgorithms/EventsAndTriggers/Tags.hpp" +#include "ParallelAlgorithms/EventsAndTriggers/WhenToCheck.hpp" #include "Utilities/Gsl.hpp" #include "Utilities/TMPL.hpp" #include "Utilities/TaggedTuple.hpp" @@ -28,7 +29,8 @@ namespace elliptic::Actions { /// - Modifies: nothing template struct RunEventsAndTriggers { - using const_global_cache_tags = tmpl::list; + using const_global_cache_tags = + tmpl::list>; template & cache, const ArrayIndex& array_index, const ActionList /*meta*/, const ParallelComponent* const component) { - Parallel::get(cache).run_events( - make_not_null(&box), cache, array_index, component, - {db::tag_name(), - static_cast(db::get(box))}); + Parallel::get>( + cache) + .run_events(make_not_null(&box), cache, array_index, component, + {db::tag_name(), + static_cast(db::get(box))}); return {Parallel::AlgorithmExecution::Continue, std::nullopt}; } diff --git a/src/Evolution/Actions/RunEventsAndTriggers.hpp b/src/Evolution/Actions/RunEventsAndTriggers.hpp index eef2df464483..2cff3b91efa8 100644 --- a/src/Evolution/Actions/RunEventsAndTriggers.hpp +++ b/src/Evolution/Actions/RunEventsAndTriggers.hpp @@ -10,6 +10,7 @@ #include "Parallel/AlgorithmExecution.hpp" #include "Parallel/GlobalCache.hpp" #include "ParallelAlgorithms/EventsAndTriggers/Tags.hpp" +#include "ParallelAlgorithms/EventsAndTriggers/WhenToCheck.hpp" #include "Time/SelfStart.hpp" #include "Time/Tags/Time.hpp" #include "Time/Triggers/OnSubsteps.hpp" @@ -24,6 +25,37 @@ struct TimeStepId; /// \endcond namespace evolution::Actions { +namespace detail { +template +void run_events_and_triggers(db::DataBox& box, + Parallel::GlobalCache& cache, + const ArrayIndex& array_index, + const ParallelComponent* const component, + const EventsAndTriggers_t& events_and_triggers, + const TimeStepId& time_step_id) { + if (time_step_id.substep() == 0) { + events_and_triggers.run_events( + make_not_null(&box), cache, array_index, component, + {db::tag_name<::Tags::Time>(), db::get<::Tags::Time>(box)}); + } else { + const double substep_offset = 1.0e6; + const double observation_value = + time_step_id.step_time().value() + + substep_offset * static_cast(time_step_id.substep()); + events_and_triggers.run_events( + make_not_null(&box), cache, array_index, component, + {db::tag_name<::Tags::Time>(), observation_value}, + [&box](const Trigger& trigger) { + const auto* substep_trigger = + dynamic_cast(&trigger); + return substep_trigger != nullptr and + substep_trigger->is_triggered(box); + }); + } +} +} // namespace detail + /// \ingroup ActionsGroup /// \ingroup EventsAndTriggersGroup /// \brief Run the events and triggers @@ -40,8 +72,14 @@ namespace evolution::Actions { /// - Adds: nothing /// - Removes: nothing /// - Modifies: nothing +template struct RunEventsAndTriggers { - using const_global_cache_tags = tmpl::list<::Tags::EventsAndTriggers>; + static constexpr bool local_time_stepping = LocalTimeStepping; + using const_global_cache_tags = tmpl::conditional_t< + local_time_stepping, + tmpl::list<::Tags::EventsAndTriggers, + ::Tags::EventsAndTriggers>, + tmpl::list<::Tags::EventsAndTriggers>>; template (box); - if (SelfStart::is_self_starting(time_step_id) or - not time_step_id.step_time().is_at_slab_boundary()) { + if (SelfStart::is_self_starting(time_step_id)) { return {Parallel::AlgorithmExecution::Continue, std::nullopt}; } - if (time_step_id.substep() == 0) { - Parallel::get<::Tags::EventsAndTriggers>(cache).run_events( - make_not_null(&box), cache, array_index, component, - {db::tag_name<::Tags::Time>(), db::get<::Tags::Time>(box)}); - } else { - const double substep_offset = 1.0e6; - const double observation_value = time_step_id.step_time().value() + - substep_offset * time_step_id.substep(); + if constexpr (local_time_stepping) { + const auto& events_and_triggers_at_steps = Parallel::get< + ::Tags::EventsAndTriggers>(cache); + detail::run_events_and_triggers(box, cache, array_index, component, + events_and_triggers_at_steps, + time_step_id); + } - Parallel::get<::Tags::EventsAndTriggers>(cache).run_events( - make_not_null(&box), cache, array_index, component, - {db::tag_name<::Tags::Time>(), observation_value}, - [&box](const Trigger& trigger) { - const auto* substep_trigger = - dynamic_cast(&trigger); - return substep_trigger != nullptr and - substep_trigger->is_triggered(box); - }); + if (not time_step_id.step_time().is_at_slab_boundary()) { + return {Parallel::AlgorithmExecution::Continue, std::nullopt}; } + const auto& events_and_triggers_at_slabs = Parallel::get< + ::Tags::EventsAndTriggers>(cache); + detail::run_events_and_triggers(box, cache, array_index, component, + events_and_triggers_at_slabs, time_step_id); return {Parallel::AlgorithmExecution::Continue, std::nullopt}; } }; diff --git a/src/Evolution/Executables/Burgers/EvolveBurgers.hpp b/src/Evolution/Executables/Burgers/EvolveBurgers.hpp index 141f19f4e6d3..01ce0dfa63a2 100644 --- a/src/Evolution/Executables/Burgers/EvolveBurgers.hpp +++ b/src/Evolution/Executables/Burgers/EvolveBurgers.hpp @@ -333,10 +333,10 @@ struct EvolutionMetavars { Parallel::PhaseActions< Parallel::Phase::Evolve, - tmpl::list>>>; + tmpl::list< + evolution::Actions::RunEventsAndTriggers, + Actions::ChangeSlabSize, step_actions, Actions::AdvanceTime, + PhaseControl::Actions::ExecutePhaseChange>>>>; struct registration : tt::ConformsTo { diff --git a/src/Evolution/Executables/CurvedScalarWave/EvolveCurvedScalarWave.hpp b/src/Evolution/Executables/CurvedScalarWave/EvolveCurvedScalarWave.hpp index 4bc6d416abd7..3a2bf3d7ef93 100644 --- a/src/Evolution/Executables/CurvedScalarWave/EvolveCurvedScalarWave.hpp +++ b/src/Evolution/Executables/CurvedScalarWave/EvolveCurvedScalarWave.hpp @@ -304,10 +304,10 @@ struct EvolutionMetavars { Parallel::Actions::TerminatePhase>>, Parallel::PhaseActions< Parallel::Phase::Evolve, - tmpl::list>>>; + tmpl::list< + evolution::Actions::RunEventsAndTriggers, + Actions::ChangeSlabSize, step_actions, Actions::AdvanceTime, + PhaseControl::Actions::ExecutePhaseChange>>>>; struct registration : tt::ConformsTo { diff --git a/src/Evolution/Executables/CurvedScalarWave/EvolveWorldtubeCurvedScalarWave.hpp b/src/Evolution/Executables/CurvedScalarWave/EvolveWorldtubeCurvedScalarWave.hpp index a57c8876baf4..c185b51ccae9 100644 --- a/src/Evolution/Executables/CurvedScalarWave/EvolveWorldtubeCurvedScalarWave.hpp +++ b/src/Evolution/Executables/CurvedScalarWave/EvolveWorldtubeCurvedScalarWave.hpp @@ -329,10 +329,10 @@ struct EvolutionMetavars { Parallel::Actions::TerminatePhase>>, Parallel::PhaseActions< Parallel::Phase::Evolve, - tmpl::list>>>; + tmpl::list< + evolution::Actions::RunEventsAndTriggers, + Actions::ChangeSlabSize, step_actions, Actions::AdvanceTime, + PhaseControl::Actions::ExecutePhaseChange>>>>; struct registration : tt::ConformsTo { diff --git a/src/Evolution/Executables/ForceFree/EvolveForceFree.hpp b/src/Evolution/Executables/ForceFree/EvolveForceFree.hpp index ff2c9e06f402..fc653cc71990 100644 --- a/src/Evolution/Executables/ForceFree/EvolveForceFree.hpp +++ b/src/Evolution/Executables/ForceFree/EvolveForceFree.hpp @@ -259,10 +259,11 @@ struct EvolutionMetavars { Parallel::PhaseActions< Parallel::Phase::Evolve, - tmpl::list>>>; + tmpl::list< + evolution::Actions::RunEventsAndTriggers, + Actions::ChangeSlabSize, dg_step_actions, + Actions::AdvanceTime, + PhaseControl::Actions::ExecutePhaseChange>>>>; struct registration : tt::ConformsTo { diff --git a/src/Evolution/Executables/GeneralizedHarmonic/EvolveGhBinaryBlackHole.hpp b/src/Evolution/Executables/GeneralizedHarmonic/EvolveGhBinaryBlackHole.hpp index ac693670120b..07de46a4df8f 100644 --- a/src/Evolution/Executables/GeneralizedHarmonic/EvolveGhBinaryBlackHole.hpp +++ b/src/Evolution/Executables/GeneralizedHarmonic/EvolveGhBinaryBlackHole.hpp @@ -616,7 +616,7 @@ struct EvolutionMetavars { Parallel::Phase::Evolve, tmpl::list< ::domain::Actions::CheckFunctionsOfTimeAreReady, - evolution::Actions::RunEventsAndTriggers, + evolution::Actions::RunEventsAndTriggers, Actions::ChangeSlabSize, step_actions, Actions::AdvanceTime, PhaseControl::Actions::ExecutePhaseChange>>>>>; diff --git a/src/Evolution/Executables/GeneralizedHarmonic/EvolveGhNoBlackHole.hpp b/src/Evolution/Executables/GeneralizedHarmonic/EvolveGhNoBlackHole.hpp index 4f645274c875..d5d56ba779fb 100644 --- a/src/Evolution/Executables/GeneralizedHarmonic/EvolveGhNoBlackHole.hpp +++ b/src/Evolution/Executables/GeneralizedHarmonic/EvolveGhNoBlackHole.hpp @@ -74,7 +74,8 @@ struct EvolutionMetavars Parallel::Actions::TerminatePhase>>, Parallel::PhaseActions< Parallel::Phase::Evolve, - tmpl::list<::evolution::Actions::RunEventsAndTriggers, + tmpl::list<::evolution::Actions::RunEventsAndTriggers< + local_time_stepping>, Actions::ChangeSlabSize, step_actions, Actions::AdvanceTime, PhaseControl::Actions::ExecutePhaseChange>>>>>; diff --git a/src/Evolution/Executables/GeneralizedHarmonic/EvolveGhSingleBlackHole.hpp b/src/Evolution/Executables/GeneralizedHarmonic/EvolveGhSingleBlackHole.hpp index ff3ce7380df8..bf9d62f295c4 100644 --- a/src/Evolution/Executables/GeneralizedHarmonic/EvolveGhSingleBlackHole.hpp +++ b/src/Evolution/Executables/GeneralizedHarmonic/EvolveGhSingleBlackHole.hpp @@ -80,6 +80,7 @@ template struct EvolutionMetavars : public GeneralizedHarmonicTemplateBase<3, UseLts> { + static constexpr bool local_time_stepping = UseLts; static constexpr size_t volume_dim = 3; using gh_base = GeneralizedHarmonicTemplateBase; using typename gh_base::initialize_initial_data_dependent_quantities_actions; @@ -260,7 +261,7 @@ struct EvolutionMetavars : public GeneralizedHarmonicTemplateBase<3, UseLts> { Parallel::Phase::Evolve, tmpl::list< ::domain::Actions::CheckFunctionsOfTimeAreReady, - evolution::Actions::RunEventsAndTriggers, + evolution::Actions::RunEventsAndTriggers, Actions::ChangeSlabSize, step_actions, Actions::AdvanceTime, PhaseControl::Actions::ExecutePhaseChange>>>>>; diff --git a/src/Evolution/Executables/GrMhd/GhValenciaDivClean/GhValenciaDivCleanBase.hpp b/src/Evolution/Executables/GrMhd/GhValenciaDivClean/GhValenciaDivCleanBase.hpp index 95dc00875db9..46d4d3eefcd9 100644 --- a/src/Evolution/Executables/GrMhd/GhValenciaDivClean/GhValenciaDivCleanBase.hpp +++ b/src/Evolution/Executables/GrMhd/GhValenciaDivClean/GhValenciaDivCleanBase.hpp @@ -866,7 +866,7 @@ struct GhValenciaDivCleanTemplateBase< VariableFixing::Actions::FixVariables< VariableFixing::LimitLorentzFactor>, Actions::UpdateConservatives, - evolution::Actions::RunEventsAndTriggers, + evolution::Actions::RunEventsAndTriggers, Actions::ChangeSlabSize, step_actions, Actions::AdvanceTime, PhaseControl::Actions::ExecutePhaseChange>>, Parallel::PhaseActions< diff --git a/src/Evolution/Executables/GrMhd/ValenciaDivClean/EvolveValenciaDivClean.hpp b/src/Evolution/Executables/GrMhd/ValenciaDivClean/EvolveValenciaDivClean.hpp index 0a7736b808c4..f303aa6b1c02 100644 --- a/src/Evolution/Executables/GrMhd/ValenciaDivClean/EvolveValenciaDivClean.hpp +++ b/src/Evolution/Executables/GrMhd/ValenciaDivClean/EvolveValenciaDivClean.hpp @@ -580,28 +580,29 @@ struct EvolutionMetavars, using dg_element_array_component = DgElementArray< EvolutionMetavars, - tmpl::list, - - Parallel::PhaseActions< - Parallel::Phase::InitializeTimeStepperHistory, - SelfStart::self_start_procedure>, - - Parallel::PhaseActions< - Parallel::Phase::Register, - tmpl::push_back>, - - Parallel::PhaseActions< - Parallel::Phase::Evolve, - tmpl::list>, - Parallel::PhaseActions< - Parallel::Phase::PostFailureCleanup, - tmpl::list, - Parallel::Actions::TerminatePhase>>>>; + tmpl::list< + Parallel::PhaseActions, + + Parallel::PhaseActions< + Parallel::Phase::InitializeTimeStepperHistory, + SelfStart::self_start_procedure>, + + Parallel::PhaseActions< + Parallel::Phase::Register, + tmpl::push_back>, + + Parallel::PhaseActions< + Parallel::Phase::Evolve, + tmpl::list< + evolution::Actions::RunEventsAndTriggers, + Actions::ChangeSlabSize, step_actions, Actions::AdvanceTime, + PhaseControl::Actions::ExecutePhaseChange>>, + Parallel::PhaseActions< + Parallel::Phase::PostFailureCleanup, + tmpl::list, + Parallel::Actions::TerminatePhase>>>>; struct registration : tt::ConformsTo { diff --git a/src/Evolution/Executables/NewtonianEuler/EvolveNewtonianEuler.hpp b/src/Evolution/Executables/NewtonianEuler/EvolveNewtonianEuler.hpp index 22041b30ae8c..720089cf04aa 100644 --- a/src/Evolution/Executables/NewtonianEuler/EvolveNewtonianEuler.hpp +++ b/src/Evolution/Executables/NewtonianEuler/EvolveNewtonianEuler.hpp @@ -389,10 +389,10 @@ struct EvolutionMetavars { Parallel::PhaseActions< Parallel::Phase::Evolve, - tmpl::list>>>; + tmpl::list< + evolution::Actions::RunEventsAndTriggers, + Actions::ChangeSlabSize, step_actions, Actions::AdvanceTime, + PhaseControl::Actions::ExecutePhaseChange>>>>; struct registration : tt::ConformsTo { diff --git a/src/Evolution/Executables/RadiationTransport/M1Grey/EvolveM1Grey.hpp b/src/Evolution/Executables/RadiationTransport/M1Grey/EvolveM1Grey.hpp index 6819a7e235d2..514f9a8246a4 100644 --- a/src/Evolution/Executables/RadiationTransport/M1Grey/EvolveM1Grey.hpp +++ b/src/Evolution/Executables/RadiationTransport/M1Grey/EvolveM1Grey.hpp @@ -259,10 +259,10 @@ struct EvolutionMetavars { Parallel::PhaseActions< Parallel::Phase::Evolve, - tmpl::list>>>; + tmpl::list< + evolution::Actions::RunEventsAndTriggers, + Actions::ChangeSlabSize, step_actions, Actions::AdvanceTime, + PhaseControl::Actions::ExecutePhaseChange>>>>; struct registration : tt::ConformsTo { diff --git a/src/Evolution/Executables/RelativisticEuler/Valencia/EvolveValencia.hpp b/src/Evolution/Executables/RelativisticEuler/Valencia/EvolveValencia.hpp index 89074eb07c55..be8c4d6bd88d 100644 --- a/src/Evolution/Executables/RelativisticEuler/Valencia/EvolveValencia.hpp +++ b/src/Evolution/Executables/RelativisticEuler/Valencia/EvolveValencia.hpp @@ -135,8 +135,7 @@ struct EvolutionMetavars { using analytic_variables_tags = typename system::primitive_variables_tag::tags_list; - using equation_of_state_tag = - hydro::Tags::EquationOfState; + using equation_of_state_tag = hydro::Tags::EquationOfState; using limiter = Tags::Limiter>, - Actions::UpdateConservatives, - evolution::Actions::RunEventsAndTriggers, - Actions::ChangeSlabSize, step_actions, - Actions::AdvanceTime, - PhaseControl::Actions::ExecutePhaseChange>>>>; + tmpl::list< + VariableFixing::Actions::FixVariables< + VariableFixing::FixToAtmosphere>, + Actions::UpdateConservatives, + evolution::Actions::RunEventsAndTriggers, + Actions::ChangeSlabSize, step_actions, Actions::AdvanceTime, + PhaseControl::Actions::ExecutePhaseChange>>>>; struct registration : tt::ConformsTo { diff --git a/src/Evolution/Executables/ScalarAdvection/EvolveScalarAdvection.hpp b/src/Evolution/Executables/ScalarAdvection/EvolveScalarAdvection.hpp index de57f614e71a..af3aed0fdd28 100644 --- a/src/Evolution/Executables/ScalarAdvection/EvolveScalarAdvection.hpp +++ b/src/Evolution/Executables/ScalarAdvection/EvolveScalarAdvection.hpp @@ -359,10 +359,10 @@ struct EvolutionMetavars { Parallel::PhaseActions< Parallel::Phase::Evolve, - tmpl::list>>>; + tmpl::list< + evolution::Actions::RunEventsAndTriggers, + Actions::ChangeSlabSize, step_actions, Actions::AdvanceTime, + PhaseControl::Actions::ExecutePhaseChange>>>>; struct registration : tt::ConformsTo { diff --git a/src/Evolution/Executables/ScalarTensor/EvolveScalarTensorSingleBlackHole.hpp b/src/Evolution/Executables/ScalarTensor/EvolveScalarTensorSingleBlackHole.hpp index 773de8cf12f9..c66921be7f4d 100644 --- a/src/Evolution/Executables/ScalarTensor/EvolveScalarTensorSingleBlackHole.hpp +++ b/src/Evolution/Executables/ScalarTensor/EvolveScalarTensorSingleBlackHole.hpp @@ -215,7 +215,7 @@ struct EvolutionMetavars : public ScalarTensorTemplateBase { Parallel::Phase::Evolve, tmpl::list< ::domain::Actions::CheckFunctionsOfTimeAreReady, - evolution::Actions::RunEventsAndTriggers, + evolution::Actions::RunEventsAndTriggers, Actions::ChangeSlabSize, step_actions, Actions::AdvanceTime, PhaseControl::Actions::ExecutePhaseChange>>>>>; diff --git a/src/Evolution/Executables/ScalarWave/EvolveScalarWave.hpp b/src/Evolution/Executables/ScalarWave/EvolveScalarWave.hpp index 939e25de5d39..3bbdcbc3c745 100644 --- a/src/Evolution/Executables/ScalarWave/EvolveScalarWave.hpp +++ b/src/Evolution/Executables/ScalarWave/EvolveScalarWave.hpp @@ -295,10 +295,10 @@ struct EvolutionMetavars { Parallel::PhaseActions< Parallel::Phase::Evolve, - tmpl::list>>>; + tmpl::list< + evolution::Actions::RunEventsAndTriggers, + Actions::ChangeSlabSize, step_actions, Actions::AdvanceTime, + PhaseControl::Actions::ExecutePhaseChange>>>>; struct amr : tt::ConformsTo<::amr::protocols::AmrMetavariables> { using element_array = dg_element_array; diff --git a/src/Evolution/Systems/Cce/Components/CharacteristicEvolution.hpp b/src/Evolution/Systems/Cce/Components/CharacteristicEvolution.hpp index 41155b0a9c3c..cad62692694c 100644 --- a/src/Evolution/Systems/Cce/Components/CharacteristicEvolution.hpp +++ b/src/Evolution/Systems/Cce/Components/CharacteristicEvolution.hpp @@ -204,7 +204,8 @@ struct CharacteristicEvolution { CharacteristicEvolution>, ::Actions::Label, tmpl::conditional_t, - evolution::Actions::RunEventsAndTriggers>, + evolution::Actions::RunEventsAndTriggers< + Metavariables::local_time_stepping>>, Actions::ReceiveWorldtubeData< Metavariables, typename Metavariables::cce_boundary_communication_tags>, @@ -231,8 +232,8 @@ struct CharacteristicEvolution { Actions::RequestNextBoundaryData< typename Metavariables::cce_boundary_component, CharacteristicEvolution>, - ::Actions::AdvanceTime, - Actions::ExitIfEndTimeReached, ::Actions::Goto>; + ::Actions::AdvanceTime, Actions::ExitIfEndTimeReached, + ::Actions::Goto>; using phase_dependent_action_list = tmpl::list< Parallel::PhaseActions>, ::Actions::Label, tmpl::conditional_t, - evolution::Actions::RunEventsAndTriggers>, + evolution::Actions::RunEventsAndTriggers< + Metavariables::local_time_stepping>>, Actions::ReceiveWorldtubeData< Metavariables, typename Metavariables::cce_boundary_communication_tags>, @@ -161,8 +162,8 @@ struct KleinGordonCharacteristicEvolution Actions::RequestNextBoundaryData< typename Metavariables::cce_boundary_component, KleinGordonCharacteristicEvolution>, - ::Actions::AdvanceTime, - Actions::ExitIfEndTimeReached, ::Actions::Goto>; + ::Actions::AdvanceTime, Actions::ExitIfEndTimeReached, + ::Actions::Goto>; using phase_dependent_action_list = tmpl::list< Parallel::PhaseActions>, Parallel::PhaseActions< Parallel::Phase::Execute, - tmpl::list, - Actions::FindGlobalMinimumGridSpacing, - evolution::Actions::RunEventsAndTriggers, - PhaseControl::Actions::ExecutePhaseChange>>>>; + tmpl::list< + Actions::AdvanceTime, Actions::ExportCoordinates, + Actions::FindGlobalMinimumGridSpacing, + evolution::Actions::RunEventsAndTriggers, + PhaseControl::Actions::ExecutePhaseChange>>>>; struct amr : tt::ConformsTo<::amr::protocols::AmrMetavariables> { using element_array = dg_element_array; diff --git a/src/IO/Observer/Actions/RegisterEvents.hpp b/src/IO/Observer/Actions/RegisterEvents.hpp index 8f7b8b362714..7313035f69ce 100644 --- a/src/IO/Observer/Actions/RegisterEvents.hpp +++ b/src/IO/Observer/Actions/RegisterEvents.hpp @@ -20,6 +20,7 @@ #include "Parallel/TypeTraits.hpp" #include "ParallelAlgorithms/EventsAndDenseTriggers/Tags.hpp" #include "ParallelAlgorithms/EventsAndTriggers/Tags.hpp" +#include "ParallelAlgorithms/EventsAndTriggers/WhenToCheck.hpp" #include "Utilities/ProtocolHelpers.hpp" #include "Utilities/TMPL.hpp" #include "Utilities/TaggedTuple.hpp" @@ -135,9 +136,30 @@ struct RegisterEventsWithObservers (void)collect_observations; #endif // defined(__GNUC__) && !defined(__clang__) && __GNUC__ < 10 - if constexpr (db::tag_is_retrievable_v<::Tags::EventsAndTriggers, - db::DataBox>) { - const auto& triggers_and_events = db::get<::Tags::EventsAndTriggers>(box); + if constexpr (db::tag_is_retrievable_v< + ::Tags::EventsAndTriggers< + Triggers::WhenToCheck::AtIterations>, + db::DataBox>) { + const auto& triggers_and_events = db::get< + ::Tags::EventsAndTriggers>(box); + triggers_and_events.for_each_event(collect_observations); + } + + if constexpr (db::tag_is_retrievable_v< + ::Tags::EventsAndTriggers, + db::DataBox>) { + const auto& triggers_and_events = + db::get<::Tags::EventsAndTriggers>( + box); + triggers_and_events.for_each_event(collect_observations); + } + + if constexpr (db::tag_is_retrievable_v< + ::Tags::EventsAndTriggers, + db::DataBox>) { + const auto& triggers_and_events = + db::get<::Tags::EventsAndTriggers>( + box); triggers_and_events.for_each_event(collect_observations); } diff --git a/src/ParallelAlgorithms/EventsAndTriggers/CMakeLists.txt b/src/ParallelAlgorithms/EventsAndTriggers/CMakeLists.txt index f7b8ed326ead..68d57ff12e56 100644 --- a/src/ParallelAlgorithms/EventsAndTriggers/CMakeLists.txt +++ b/src/ParallelAlgorithms/EventsAndTriggers/CMakeLists.txt @@ -11,6 +11,7 @@ spectre_target_sources( Completion.cpp EventsAndTriggers.cpp LogicalTriggers.cpp + WhenToCheck.cpp ) spectre_target_headers( @@ -23,6 +24,7 @@ spectre_target_headers( LogicalTriggers.hpp Tags.hpp Trigger.hpp + WhenToCheck.hpp ) target_link_libraries( diff --git a/src/ParallelAlgorithms/EventsAndTriggers/Tags.hpp b/src/ParallelAlgorithms/EventsAndTriggers/Tags.hpp index 6141562c021c..862c05593700 100644 --- a/src/ParallelAlgorithms/EventsAndTriggers/Tags.hpp +++ b/src/ParallelAlgorithms/EventsAndTriggers/Tags.hpp @@ -12,6 +12,7 @@ #include "DataStructures/DataBox/Tag.hpp" #include "Options/String.hpp" #include "ParallelAlgorithms/EventsAndTriggers/EventsAndTriggers.hpp" +#include "ParallelAlgorithms/EventsAndTriggers/WhenToCheck.hpp" #include "Utilities/Serialization/Serialize.hpp" #include "Utilities/TMPL.hpp" @@ -22,7 +23,7 @@ namespace OptionTags { /// /// In yaml this is specified as a map of triggers to lists of events: /// \code{.yaml} -/// EventsAndTriggers: +/// EventsAndTriggersAtSlabs: /// ? TriggerA: /// OptionsForTriggerA /// : - Event1: @@ -36,6 +37,7 @@ namespace OptionTags { /// - Event4: /// OptionsForEvent4 /// \endcode +template struct EventsAndTriggers { using type = ::EventsAndTriggers; static constexpr Options::String help = "Events to run at triggers"; @@ -45,7 +47,9 @@ struct EventsAndTriggers { // OptionParser run-time error saying that an option name is greater // than 21 characters. Adding the name() function below bypasses // pretty_type::short_name(). - static std::string name() { return "EventsAndTriggers"; } + static std::string name() { + return "EventsAndTriggers" + get_output(WhenToCheck); + } }; namespace EventsRunAtCleanup { @@ -80,14 +84,18 @@ struct ObservationValue { namespace Tags { /// \ingroup EventsAndTriggersGroup /// Contains the events and triggers +template struct EventsAndTriggers : db::SimpleTag { using type = ::EventsAndTriggers; - using option_tags = tmpl::list<::OptionTags::EventsAndTriggers>; + using option_tags = tmpl::list<::OptionTags::EventsAndTriggers>; static constexpr bool pass_metavariables = false; static type create_from_options(const type& events_and_triggers) { return deserialize(serialize(events_and_triggers).data()); } + static std::string name() { + return "EventsAndTriggers" + get_output(WhenToCheck); + } }; /// \brief Events to be run on elements during the diff --git a/src/ParallelAlgorithms/EventsAndTriggers/WhenToCheck.cpp b/src/ParallelAlgorithms/EventsAndTriggers/WhenToCheck.cpp new file mode 100644 index 000000000000..71bb5771e267 --- /dev/null +++ b/src/ParallelAlgorithms/EventsAndTriggers/WhenToCheck.cpp @@ -0,0 +1,29 @@ +// Distributed under the MIT License. +// See LICENSE.txt for details. + +#include "ParallelAlgorithms/EventsAndTriggers/WhenToCheck.hpp" + +#include + +#include "Utilities/ErrorHandling/Error.hpp" + +namespace Triggers { + +std::ostream& operator<<(std::ostream& os, const WhenToCheck& when_to_check) { + switch (when_to_check) { + case WhenToCheck::AtIterations: + os << "AtIterations"; + break; + case WhenToCheck::AtSlabs: + os << "AtSlabs"; + break; + case WhenToCheck::AtSteps: + os << "AtSteps"; + break; + default: + ERROR("An unknown check was passed to the stream operator. " + << static_cast(when_to_check)); + } + return os; +} +} // namespace Triggers diff --git a/src/ParallelAlgorithms/EventsAndTriggers/WhenToCheck.hpp b/src/ParallelAlgorithms/EventsAndTriggers/WhenToCheck.hpp new file mode 100644 index 000000000000..0f63b10bc586 --- /dev/null +++ b/src/ParallelAlgorithms/EventsAndTriggers/WhenToCheck.hpp @@ -0,0 +1,24 @@ +// Distributed under the MIT License. +// See LICENSE.txt for details. + +/// \file +/// Defines enum class Triggers::WhenToCheck. + +#pragma once + +#include +#include + +namespace Triggers { + +/// \ingroup EventsAndTriggersGroup +/// \brief Frequency at which Events and Triggers are checked +enum class WhenToCheck : uint8_t { + AtIterations, /**< checked at iterations e.g. of an elliptic solve */ + AtSlabs, /**< checked at time Slab boundaries */ + AtSteps, /**< checked at time step boundaries */ +}; + +/// Output operator for a WhenToCheck. +std::ostream& operator<<(std::ostream& os, const WhenToCheck& when_to_check); +} // namespace Triggers diff --git a/src/Time/StepChoosers/ErrorControl.hpp b/src/Time/StepChoosers/ErrorControl.hpp index 1dd586d3a6d9..23a670ac3336 100644 --- a/src/Time/StepChoosers/ErrorControl.hpp +++ b/src/Time/StepChoosers/ErrorControl.hpp @@ -5,6 +5,7 @@ #include #include +#include #include #include #include @@ -17,6 +18,7 @@ #include "DataStructures/DataBox/DataBoxTag.hpp" #include "Options/String.hpp" #include "ParallelAlgorithms/EventsAndTriggers/EventsAndTriggers.hpp" +#include "ParallelAlgorithms/EventsAndTriggers/WhenToCheck.hpp" #include "Time/ChangeSlabSize/Event.hpp" #include "Time/StepChoosers/StepChooser.hpp" #include "Time/StepperErrorTolerances.hpp" @@ -31,6 +33,7 @@ /// \cond namespace Tags { +template struct EventsAndTriggers; template struct IsUsingTimeSteppingErrorControlCompute; @@ -280,9 +283,9 @@ struct IsUsingTimeSteppingErrorControlCompute IsUsingTimeSteppingErrorControl { using base = IsUsingTimeSteppingErrorControl; using return_type = type; - using argument_tags = - tmpl::conditional_t, - tmpl::list<::Tags::EventsAndTriggers>>; + using argument_tags = tmpl::conditional_t< + LocalTimeStepping, tmpl::list<::Tags::StepChoosers>, + tmpl::list<::Tags::EventsAndTriggers>>; // local time stepping static void function( @@ -340,9 +343,9 @@ struct StepperErrorTolerancesCompute StepperErrorTolerances { using base = StepperErrorTolerances; using return_type = typename base::type; - using argument_tags = - tmpl::conditional_t, - tmpl::list<::Tags::EventsAndTriggers>>; + using argument_tags = tmpl::conditional_t< + LocalTimeStepping, tmpl::list<::Tags::StepChoosers>, + tmpl::list<::Tags::EventsAndTriggers>>; // local time stepping static void function( diff --git a/src/Visualization/Python/ReadInputFile.py b/src/Visualization/Python/ReadInputFile.py index 8c2baca84b06..5bebbdd791ed 100644 --- a/src/Visualization/Python/ReadInputFile.py +++ b/src/Visualization/Python/ReadInputFile.py @@ -20,16 +20,19 @@ """ -def find_event(event_name: str, input_file: dict) -> dict: - """Find a particular event in the "EventsAndTriggers" of the input file. +def find_event( + event_name: str, events_and_triggers_name: str, input_file: dict +) -> dict: + """Find a particular event in the given list of events of the input file. Arguments: event_name: The name of an event like "ObserveTimeSteps". + events_and_triggers_name: The name of a list of events. input_file: The input file read in as a dictionary. Returns: The event as a dictionary, or None if the event wasn't found. """ - for trigger_and_events in input_file["EventsAndTriggers"]: + for trigger_and_events in input_file[events_and_triggers_name]: try: for event in trigger_and_events["Events"]: if isinstance(event, str): diff --git a/support/Pipelines/Bbh/InitialData.yaml b/support/Pipelines/Bbh/InitialData.yaml index 68b695d6eca3..2adfdf724d27 100644 --- a/support/Pipelines/Bbh/InitialData.yaml +++ b/support/Pipelines/Bbh/InitialData.yaml @@ -231,7 +231,7 @@ RadiallyCompressedCoordinates: OuterRadius: *outer_radius Compression: *outer_shell_distribution -EventsAndTriggers: +EventsAndTriggersAtIterations: - Trigger: HasConverged Events: - ObserveFields: diff --git a/support/Pipelines/Bbh/Inspiral.yaml b/support/Pipelines/Bbh/Inspiral.yaml index c6bfdbb9e037..10f9dce7c2c1 100644 --- a/support/Pipelines/Bbh/Inspiral.yaml +++ b/support/Pipelines/Bbh/Inspiral.yaml @@ -155,7 +155,7 @@ Evolution: MinimumTimeStep: 1e-7 # This is the smallest interval we'd need to observe time step/constraints. If # you need it smaller you can edit it, but make sure to change the slab - # intervals in the EventsAndTriggers + # intervals in the EventsAndTriggersAtSlabs InitialSlabSize: 0.1 StepChoosers: - LimitIncrease: @@ -261,7 +261,7 @@ PhaseChangeAndTriggers: - CheckpointAndExitAfterWallclock: WallclockHours: 23.5 -EventsAndTriggers: +EventsAndTriggersAtSlabs: # Observe time step and cheap constraints every slab - Trigger: Slabs: @@ -372,6 +372,8 @@ EventsAndTriggers: Events: - Completion +EventsAndTriggersAtSteps: + EventsAndDenseTriggers: # BondiSachs output needs to be often enough for CCE to run properly. An # interval of 0.1 was found to work well in SpEC. diff --git a/support/Pipelines/Bbh/PostprocessId.py b/support/Pipelines/Bbh/PostprocessId.py index 1e27e15b9541..33b3077cf1d6 100644 --- a/support/Pipelines/Bbh/PostprocessId.py +++ b/support/Pipelines/Bbh/PostprocessId.py @@ -92,7 +92,9 @@ def postprocess_id( excision_radius_A = id_domain[f"ObjectA"]["InnerRadius"] excision_radius_B = id_domain[f"ObjectB"]["InnerRadius"] volfile_name = id_input_file["Observers"]["VolumeFileName"] - id_subfile_name = find_event("ObserveFields", id_input_file)["SubfileName"] + id_subfile_name = find_event( + "ObserveFields", "EventsAndTriggersAtIterations", id_input_file + )["SubfileName"] # Find latest observation in output data if id_run_dir is None: diff --git a/support/Pipelines/Bbh/Ringdown.yaml b/support/Pipelines/Bbh/Ringdown.yaml index 84d63aacedea..5ecce8812885 100644 --- a/support/Pipelines/Bbh/Ringdown.yaml +++ b/support/Pipelines/Bbh/Ringdown.yaml @@ -196,7 +196,7 @@ PhaseChangeAndTriggers: - CheckpointAndExitAfterWallclock: WallclockHours: 23.5 -EventsAndTriggers: +EventsAndTriggersAtSlabs: - Trigger: Slabs: EvenlySpaced: @@ -266,6 +266,8 @@ EventsAndTriggers: Events: - Completion +EventsAndTriggersAtSteps: + EventsAndDenseTriggers: # BondiSachs output needs to be often enough for CCE to run properly. An # interval of 0.1 was found to work well in SpEC. diff --git a/tests/InputFiles/Burgers/Step.yaml b/tests/InputFiles/Burgers/Step.yaml index 8a029273f2b2..e265c325aea5 100644 --- a/tests/InputFiles/Burgers/Step.yaml +++ b/tests/InputFiles/Burgers/Step.yaml @@ -69,7 +69,7 @@ SpatialDiscretization: SubcellSolver: Reconstructor: MonotonisedCentral -EventsAndTriggers: +EventsAndTriggersAtSlabs: - Trigger: Always Events: - ChangeSlabSize: diff --git a/tests/InputFiles/Cce/AnalyticTestBouncingBlackHole.yaml b/tests/InputFiles/Cce/AnalyticTestBouncingBlackHole.yaml index d2ce1c78fa9d..904821d3e2db 100644 --- a/tests/InputFiles/Cce/AnalyticTestBouncingBlackHole.yaml +++ b/tests/InputFiles/Cce/AnalyticTestBouncingBlackHole.yaml @@ -36,7 +36,7 @@ Observers: VolumeFileName: "CharacteristicExtractUnusedVolume" ReductionFileName: "CharacteristicExtractReduction" -EventsAndTriggers: +EventsAndTriggersAtSlabs: - Trigger: Slabs: EvenlySpaced: @@ -47,6 +47,8 @@ EventsAndTriggers: SubfileName: CceTimeStep PrintTimeToTerminal: false +EventsAndTriggersAtSteps: + Cce: Evolution: TimeStepper: diff --git a/tests/InputFiles/Cce/AnalyticTestGaugeWave.yaml b/tests/InputFiles/Cce/AnalyticTestGaugeWave.yaml index 32a430ef31fa..7e1d673a6cd0 100644 --- a/tests/InputFiles/Cce/AnalyticTestGaugeWave.yaml +++ b/tests/InputFiles/Cce/AnalyticTestGaugeWave.yaml @@ -36,7 +36,7 @@ Observers: VolumeFileName: "CharacteristicExtractUnusedVolume" ReductionFileName: "CharacteristicExtractReduction" -EventsAndTriggers: +EventsAndTriggersAtSlabs: - Trigger: Slabs: EvenlySpaced: @@ -47,6 +47,8 @@ EventsAndTriggers: SubfileName: CceTimeStep PrintTimeToTerminal: false +EventsAndTriggersAtSteps: + Cce: Evolution: TimeStepper: diff --git a/tests/InputFiles/Cce/AnalyticTestLinearizedBondiSachs.yaml b/tests/InputFiles/Cce/AnalyticTestLinearizedBondiSachs.yaml index 4d316ad81c7a..c78f3599c4b8 100644 --- a/tests/InputFiles/Cce/AnalyticTestLinearizedBondiSachs.yaml +++ b/tests/InputFiles/Cce/AnalyticTestLinearizedBondiSachs.yaml @@ -36,7 +36,7 @@ Observers: VolumeFileName: "CharacteristicExtractUnusedVolume" ReductionFileName: "CharacteristicExtractReduction" -EventsAndTriggers: +EventsAndTriggersAtSlabs: - Trigger: Slabs: EvenlySpaced: @@ -47,6 +47,8 @@ EventsAndTriggers: SubfileName: CceTimeStep PrintTimeToTerminal: false +EventsAndTriggersAtSteps: + Cce: Evolution: TimeStepper: diff --git a/tests/InputFiles/Cce/AnalyticTestRobinsonTrautman.yaml b/tests/InputFiles/Cce/AnalyticTestRobinsonTrautman.yaml index f413476aa313..6d840d6034c8 100644 --- a/tests/InputFiles/Cce/AnalyticTestRobinsonTrautman.yaml +++ b/tests/InputFiles/Cce/AnalyticTestRobinsonTrautman.yaml @@ -36,7 +36,7 @@ Observers: VolumeFileName: "CharacteristicExtractUnusedVolume" ReductionFileName: "CharacteristicExtractReduction" -EventsAndTriggers: +EventsAndTriggersAtSlabs: - Trigger: Slabs: EvenlySpaced: @@ -47,6 +47,8 @@ EventsAndTriggers: SubfileName: CceTimeStep PrintTimeToTerminal: false +EventsAndTriggersAtSteps: + Cce: Evolution: TimeStepper: diff --git a/tests/InputFiles/Cce/AnalyticTestRotatingSchwarzschild.yaml b/tests/InputFiles/Cce/AnalyticTestRotatingSchwarzschild.yaml index 0ac4a698bd61..e4b50cc49feb 100644 --- a/tests/InputFiles/Cce/AnalyticTestRotatingSchwarzschild.yaml +++ b/tests/InputFiles/Cce/AnalyticTestRotatingSchwarzschild.yaml @@ -36,7 +36,7 @@ Observers: VolumeFileName: "CharacteristicExtractUnusedVolume" ReductionFileName: "CharacteristicExtractReduction" -EventsAndTriggers: +EventsAndTriggersAtSlabs: - Trigger: Slabs: EvenlySpaced: @@ -47,6 +47,8 @@ EventsAndTriggers: SubfileName: CceTimeStep PrintTimeToTerminal: false +EventsAndTriggersAtSteps: + Cce: Evolution: TimeStepper: diff --git a/tests/InputFiles/Cce/AnalyticTestTeukolskyWave.yaml b/tests/InputFiles/Cce/AnalyticTestTeukolskyWave.yaml index 4a77d11118ba..d0dec7ebad65 100644 --- a/tests/InputFiles/Cce/AnalyticTestTeukolskyWave.yaml +++ b/tests/InputFiles/Cce/AnalyticTestTeukolskyWave.yaml @@ -36,7 +36,7 @@ Observers: VolumeFileName: "CharacteristicExtractUnusedVolume" ReductionFileName: "CharacteristicExtractReduction" -EventsAndTriggers: +EventsAndTriggersAtSlabs: - Trigger: Slabs: EvenlySpaced: @@ -47,6 +47,8 @@ EventsAndTriggers: SubfileName: CceTimeStep PrintTimeToTerminal: false +EventsAndTriggersAtSteps: + Cce: Evolution: TimeStepper: diff --git a/tests/InputFiles/Cce/CharacteristicExtract.yaml b/tests/InputFiles/Cce/CharacteristicExtract.yaml index ae48fd6547d3..27bb4d5f14ad 100644 --- a/tests/InputFiles/Cce/CharacteristicExtract.yaml +++ b/tests/InputFiles/Cce/CharacteristicExtract.yaml @@ -31,7 +31,7 @@ Observers: # ExtractionRadius specified below. ReductionFileName: "CharacteristicExtractReduction" -EventsAndTriggers: +EventsAndTriggersAtSlabs: # Write the CCE time step every Slab. A Slab is a fixed length of simulation # time and is not influenced by the dynamically adjusted step size. - Trigger: @@ -46,6 +46,8 @@ EventsAndTriggers: SubfileName: CceTimeStep PrintTimeToTerminal: true +EventsAndTriggersAtSteps: + Cce: Evolution: TimeStepper: diff --git a/tests/InputFiles/CurvedScalarWave/PlaneWaveMinkowski1D.yaml b/tests/InputFiles/CurvedScalarWave/PlaneWaveMinkowski1D.yaml index 24855316b949..80222a8a0682 100644 --- a/tests/InputFiles/CurvedScalarWave/PlaneWaveMinkowski1D.yaml +++ b/tests/InputFiles/CurvedScalarWave/PlaneWaveMinkowski1D.yaml @@ -67,7 +67,7 @@ Filtering: Enable: false BlocksToFilter: All -EventsAndTriggers: +EventsAndTriggersAtSlabs: - Trigger: Slabs: Specified: @@ -75,6 +75,8 @@ EventsAndTriggers: Events: - Completion +EventsAndTriggersAtSteps: + EventsAndDenseTriggers: Observers: diff --git a/tests/InputFiles/CurvedScalarWave/PlaneWaveMinkowski2D.yaml b/tests/InputFiles/CurvedScalarWave/PlaneWaveMinkowski2D.yaml index cdf625b9e6c6..1276eb9e5982 100644 --- a/tests/InputFiles/CurvedScalarWave/PlaneWaveMinkowski2D.yaml +++ b/tests/InputFiles/CurvedScalarWave/PlaneWaveMinkowski2D.yaml @@ -67,7 +67,7 @@ Filtering: Enable: false BlocksToFilter: All -EventsAndTriggers: +EventsAndTriggersAtSlabs: - Trigger: Slabs: Specified: @@ -75,6 +75,8 @@ EventsAndTriggers: Events: - Completion +EventsAndTriggersAtSteps: + EventsAndDenseTriggers: Observers: diff --git a/tests/InputFiles/CurvedScalarWave/PlaneWaveMinkowski3D.yaml b/tests/InputFiles/CurvedScalarWave/PlaneWaveMinkowski3D.yaml index 35b674c1b56e..6058812dd718 100644 --- a/tests/InputFiles/CurvedScalarWave/PlaneWaveMinkowski3D.yaml +++ b/tests/InputFiles/CurvedScalarWave/PlaneWaveMinkowski3D.yaml @@ -82,7 +82,7 @@ Filtering: Enable: false BlocksToFilter: All -EventsAndTriggers: +EventsAndTriggersAtSlabs: - Trigger: Slabs: Specified: @@ -134,6 +134,8 @@ EventsAndTriggers: NormType: L2Norm Components: Individual +EventsAndTriggersAtSteps: + EventsAndDenseTriggers: InterpolationTargets: diff --git a/tests/InputFiles/CurvedScalarWave/WorldtubeKerrSchild.yaml b/tests/InputFiles/CurvedScalarWave/WorldtubeKerrSchild.yaml index 45a08de81396..3023e73d366c 100644 --- a/tests/InputFiles/CurvedScalarWave/WorldtubeKerrSchild.yaml +++ b/tests/InputFiles/CurvedScalarWave/WorldtubeKerrSchild.yaml @@ -97,7 +97,7 @@ SpatialDiscretization: Formulation: StrongInertial Quadrature: GaussLobatto -EventsAndTriggers: +EventsAndTriggersAtSlabs: - Trigger: Slabs: EvenlySpaced: diff --git a/tests/InputFiles/Elasticity/BentBeam.yaml b/tests/InputFiles/Elasticity/BentBeam.yaml index fcbf85296a83..f3739997c2b3 100644 --- a/tests/InputFiles/Elasticity/BentBeam.yaml +++ b/tests/InputFiles/Elasticity/BentBeam.yaml @@ -91,7 +91,7 @@ LinearSolver: WriteMatrixToFile: None ObservePerCoreReductions: False -EventsAndTriggers: +EventsAndTriggersAtIterations: - Trigger: HasConverged Events: - ObserveNorms: diff --git a/tests/InputFiles/Elasticity/HalfSpaceMirror.yaml b/tests/InputFiles/Elasticity/HalfSpaceMirror.yaml index 5665d2202563..1642d6e9e876 100644 --- a/tests/InputFiles/Elasticity/HalfSpaceMirror.yaml +++ b/tests/InputFiles/Elasticity/HalfSpaceMirror.yaml @@ -117,7 +117,7 @@ LinearSolver: BoundaryConditions: Auto ObservePerCoreReductions: False -EventsAndTriggers: +EventsAndTriggersAtIterations: - Trigger: HasConverged Events: - ObserveNorms: diff --git a/tests/InputFiles/Elasticity/SingleCoatingMirror.yaml b/tests/InputFiles/Elasticity/SingleCoatingMirror.yaml index 7fe62e45685d..cdaa115754bc 100644 --- a/tests/InputFiles/Elasticity/SingleCoatingMirror.yaml +++ b/tests/InputFiles/Elasticity/SingleCoatingMirror.yaml @@ -132,7 +132,7 @@ LinearSolver: BoundaryConditions: Auto ObservePerCoreReductions: False -EventsAndTriggers: +EventsAndTriggersAtIterations: - Trigger: HasConverged Events: - ObserveNorms: &error_norms diff --git a/tests/InputFiles/ExportCoordinates/Input1D.yaml b/tests/InputFiles/ExportCoordinates/Input1D.yaml index a41735e2561a..36f86f4e2330 100644 --- a/tests/InputFiles/ExportCoordinates/Input1D.yaml +++ b/tests/InputFiles/ExportCoordinates/Input1D.yaml @@ -52,7 +52,7 @@ SpatialDiscretization: DiscontinuousGalerkin: Quadrature: GaussLobatto -EventsAndTriggers: +EventsAndTriggersAtSlabs: - Trigger: TimeCompares: Comparison: GreaterThanOrEqualTo diff --git a/tests/InputFiles/ExportCoordinates/Input2D.yaml b/tests/InputFiles/ExportCoordinates/Input2D.yaml index 43df3d0d0bfa..d8ad36e5aae5 100644 --- a/tests/InputFiles/ExportCoordinates/Input2D.yaml +++ b/tests/InputFiles/ExportCoordinates/Input2D.yaml @@ -47,7 +47,7 @@ SpatialDiscretization: DiscontinuousGalerkin: Quadrature: GaussLobatto -EventsAndTriggers: +EventsAndTriggersAtSlabs: - Trigger: TimeCompares: Comparison: GreaterThanOrEqualTo diff --git a/tests/InputFiles/ExportCoordinates/Input3D.yaml b/tests/InputFiles/ExportCoordinates/Input3D.yaml index 48f01d6e219f..919a4a658c49 100644 --- a/tests/InputFiles/ExportCoordinates/Input3D.yaml +++ b/tests/InputFiles/ExportCoordinates/Input3D.yaml @@ -54,7 +54,7 @@ Evolution: AdamsBashforth: Order: 1 -EventsAndTriggers: +EventsAndTriggersAtSlabs: - Trigger: TimeCompares: Comparison: GreaterThanOrEqualTo diff --git a/tests/InputFiles/ExportCoordinates/InputTimeDependent3D.yaml b/tests/InputFiles/ExportCoordinates/InputTimeDependent3D.yaml index 8fdc1e49ab4e..6fef2193cac1 100644 --- a/tests/InputFiles/ExportCoordinates/InputTimeDependent3D.yaml +++ b/tests/InputFiles/ExportCoordinates/InputTimeDependent3D.yaml @@ -99,7 +99,7 @@ Evolution: AdamsBashforth: Order: 1 -EventsAndTriggers: +EventsAndTriggersAtSlabs: - Trigger: TimeCompares: Comparison: GreaterThanOrEqualTo diff --git a/tests/InputFiles/ForceFree/FastWave.yaml b/tests/InputFiles/ForceFree/FastWave.yaml index bb5adae506ba..2401d104e6d9 100644 --- a/tests/InputFiles/ForceFree/FastWave.yaml +++ b/tests/InputFiles/ForceFree/FastWave.yaml @@ -72,7 +72,7 @@ Observers: VolumeFileName: "ForceFreeFastWaveVolume" ReductionFileName: "ForceFreeFastWaveReductions" -EventsAndTriggers: +EventsAndTriggersAtSlabs: - Trigger: Slabs: Specified: diff --git a/tests/InputFiles/GeneralizedHarmonic/CylindricalBinaryBlackHole.yaml b/tests/InputFiles/GeneralizedHarmonic/CylindricalBinaryBlackHole.yaml index 37c10b4457f9..ea8f4f8ff7be 100644 --- a/tests/InputFiles/GeneralizedHarmonic/CylindricalBinaryBlackHole.yaml +++ b/tests/InputFiles/GeneralizedHarmonic/CylindricalBinaryBlackHole.yaml @@ -167,7 +167,7 @@ Filtering: BlocksToFilter: All -EventsAndTriggers: +EventsAndTriggersAtSlabs: - Trigger: Slabs: EvenlySpaced: @@ -235,6 +235,8 @@ EventsAndTriggers: Events: - Completion +EventsAndTriggersAtSteps: + Observers: VolumeFileName: "GhBinaryBlackHoleVolumeData" ReductionFileName: "GhBinaryBlackHoleReductionData" diff --git a/tests/InputFiles/GeneralizedHarmonic/GaugeWave1D.yaml b/tests/InputFiles/GeneralizedHarmonic/GaugeWave1D.yaml index 29eef0e84ba2..162d623341d8 100644 --- a/tests/InputFiles/GeneralizedHarmonic/GaugeWave1D.yaml +++ b/tests/InputFiles/GeneralizedHarmonic/GaugeWave1D.yaml @@ -110,7 +110,7 @@ SpatialDiscretization: BoundaryCorrection: UpwindPenalty: -EventsAndTriggers: +EventsAndTriggersAtSlabs: - Trigger: Slabs: EvenlySpaced: diff --git a/tests/InputFiles/GeneralizedHarmonic/GaugeWave3D.yaml b/tests/InputFiles/GeneralizedHarmonic/GaugeWave3D.yaml index 1d7529d5ca1f..ef6c6ec1bb67 100644 --- a/tests/InputFiles/GeneralizedHarmonic/GaugeWave3D.yaml +++ b/tests/InputFiles/GeneralizedHarmonic/GaugeWave3D.yaml @@ -102,7 +102,7 @@ SpatialDiscretization: BoundaryCorrection: UpwindPenalty: -EventsAndTriggers: +EventsAndTriggersAtSlabs: - Trigger: Slabs: EvenlySpaced: diff --git a/tests/InputFiles/GeneralizedHarmonic/KerrSchild.yaml b/tests/InputFiles/GeneralizedHarmonic/KerrSchild.yaml index 8f7c2605d6f9..449325ebf292 100644 --- a/tests/InputFiles/GeneralizedHarmonic/KerrSchild.yaml +++ b/tests/InputFiles/GeneralizedHarmonic/KerrSchild.yaml @@ -139,7 +139,7 @@ SpatialDiscretization: Formulation: StrongInertial Quadrature: GaussLobatto -EventsAndTriggers: +EventsAndTriggersAtSlabs: - Trigger: Slabs: EvenlySpaced: @@ -212,6 +212,8 @@ EventsAndTriggers: Events: - Completion +EventsAndTriggersAtSteps: + EventsAndDenseTriggers: Observers: diff --git a/tests/InputFiles/GrMhd/GhValenciaDivClean/BinaryNeutronStar.yaml b/tests/InputFiles/GrMhd/GhValenciaDivClean/BinaryNeutronStar.yaml index 2691a56a64a6..673d8dfa174c 100644 --- a/tests/InputFiles/GrMhd/GhValenciaDivClean/BinaryNeutronStar.yaml +++ b/tests/InputFiles/GrMhd/GhValenciaDivClean/BinaryNeutronStar.yaml @@ -197,7 +197,7 @@ Filtering: Enable: true BlocksToFilter: All -EventsAndTriggers: +EventsAndTriggersAtSlabs: # Set time step at t=0 - Trigger: Slabs: diff --git a/tests/InputFiles/GrMhd/GhValenciaDivClean/GhMhdBondiMichel.yaml b/tests/InputFiles/GrMhd/GhValenciaDivClean/GhMhdBondiMichel.yaml index 0f0e787aadb5..f7ff71a390de 100644 --- a/tests/InputFiles/GrMhd/GhValenciaDivClean/GhMhdBondiMichel.yaml +++ b/tests/InputFiles/GrMhd/GhValenciaDivClean/GhMhdBondiMichel.yaml @@ -136,7 +136,7 @@ SpatialDiscretization: UpwindPenalty: Rusanov: -EventsAndTriggers: +EventsAndTriggersAtSlabs: - Trigger: Slabs: EvenlySpaced: diff --git a/tests/InputFiles/GrMhd/GhValenciaDivClean/GhMhdTovStar.yaml b/tests/InputFiles/GrMhd/GhValenciaDivClean/GhMhdTovStar.yaml index 1c74ae44596e..4d726575b5ee 100644 --- a/tests/InputFiles/GrMhd/GhValenciaDivClean/GhMhdTovStar.yaml +++ b/tests/InputFiles/GrMhd/GhValenciaDivClean/GhMhdTovStar.yaml @@ -169,7 +169,7 @@ Filtering: BlocksToFilter: All -EventsAndTriggers: +EventsAndTriggersAtSlabs: - Trigger: Slabs: EvenlySpaced: diff --git a/tests/InputFiles/GrMhd/ValenciaDivClean/BlastWave.yaml b/tests/InputFiles/GrMhd/ValenciaDivClean/BlastWave.yaml index fb397bc6a60d..23644081df90 100644 --- a/tests/InputFiles/GrMhd/ValenciaDivClean/BlastWave.yaml +++ b/tests/InputFiles/GrMhd/ValenciaDivClean/BlastWave.yaml @@ -128,7 +128,7 @@ Observers: Interpolator: DumpVolumeDataOnFailure: false -EventsAndTriggers: +EventsAndTriggersAtSlabs: - Trigger: Slabs: Specified: diff --git a/tests/InputFiles/GrMhd/ValenciaDivClean/FishboneMoncriefDisk.yaml b/tests/InputFiles/GrMhd/ValenciaDivClean/FishboneMoncriefDisk.yaml index eaf5be42a887..5fb19113fcbe 100644 --- a/tests/InputFiles/GrMhd/ValenciaDivClean/FishboneMoncriefDisk.yaml +++ b/tests/InputFiles/GrMhd/ValenciaDivClean/FishboneMoncriefDisk.yaml @@ -138,7 +138,7 @@ PrimitiveFromConservative: DensityWhenSkippingInversion: *MinimumD KastaunMaxLorentzFactor: 10.0 -EventsAndTriggers: +EventsAndTriggersAtSlabs: - Trigger: Slabs: Specified: diff --git a/tests/InputFiles/NewtonianEuler/RiemannProblem1D.yaml b/tests/InputFiles/NewtonianEuler/RiemannProblem1D.yaml index 7c7445cb4ebb..fa66b9c64f1e 100644 --- a/tests/InputFiles/NewtonianEuler/RiemannProblem1D.yaml +++ b/tests/InputFiles/NewtonianEuler/RiemannProblem1D.yaml @@ -82,7 +82,7 @@ EvolutionSystem: SourceTerm: NoSource: -EventsAndTriggers: +EventsAndTriggersAtSlabs: - Trigger: TimeCompares: Comparison: GreaterThanOrEqualTo diff --git a/tests/InputFiles/NewtonianEuler/RiemannProblem2D.yaml b/tests/InputFiles/NewtonianEuler/RiemannProblem2D.yaml index dc98496d297e..81f2f3c6657e 100644 --- a/tests/InputFiles/NewtonianEuler/RiemannProblem2D.yaml +++ b/tests/InputFiles/NewtonianEuler/RiemannProblem2D.yaml @@ -85,7 +85,7 @@ EvolutionSystem: SourceTerm: NoSource: -EventsAndTriggers: +EventsAndTriggersAtSlabs: - Trigger: Slabs: Specified: diff --git a/tests/InputFiles/NewtonianEuler/RiemannProblem3D.yaml b/tests/InputFiles/NewtonianEuler/RiemannProblem3D.yaml index 8dd91e21fcbd..8d75a5b59147 100644 --- a/tests/InputFiles/NewtonianEuler/RiemannProblem3D.yaml +++ b/tests/InputFiles/NewtonianEuler/RiemannProblem3D.yaml @@ -89,7 +89,7 @@ EvolutionSystem: SourceTerm: NoSource: -EventsAndTriggers: +EventsAndTriggersAtSlabs: - Trigger: Slabs: Specified: diff --git a/tests/InputFiles/Poisson/Lorentzian.yaml b/tests/InputFiles/Poisson/Lorentzian.yaml index 84867a27771c..a001d829376c 100644 --- a/tests/InputFiles/Poisson/Lorentzian.yaml +++ b/tests/InputFiles/Poisson/Lorentzian.yaml @@ -114,7 +114,7 @@ RadiallyCompressedCoordinates: OuterRadius: *outer_radius Compression: *outer_shell_distribution -EventsAndTriggers: +EventsAndTriggersAtIterations: - Trigger: Always Events: - ObserveNorms: diff --git a/tests/InputFiles/Poisson/ProductOfSinusoids1D.yaml b/tests/InputFiles/Poisson/ProductOfSinusoids1D.yaml index a348f3563dc0..35ecae72fabf 100644 --- a/tests/InputFiles/Poisson/ProductOfSinusoids1D.yaml +++ b/tests/InputFiles/Poisson/ProductOfSinusoids1D.yaml @@ -155,7 +155,7 @@ LinearSolver: RadiallyCompressedCoordinates: None -EventsAndTriggers: +EventsAndTriggersAtIterations: - Trigger: Always Events: - ObserveNorms: diff --git a/tests/InputFiles/Poisson/ProductOfSinusoids2D.yaml b/tests/InputFiles/Poisson/ProductOfSinusoids2D.yaml index 86c6c7dfef2b..ed297d7661d5 100644 --- a/tests/InputFiles/Poisson/ProductOfSinusoids2D.yaml +++ b/tests/InputFiles/Poisson/ProductOfSinusoids2D.yaml @@ -96,7 +96,7 @@ LinearSolver: RadiallyCompressedCoordinates: None -EventsAndTriggers: +EventsAndTriggersAtIterations: - Trigger: HasConverged Events: - ObserveNorms: diff --git a/tests/InputFiles/Poisson/ProductOfSinusoids3D.yaml b/tests/InputFiles/Poisson/ProductOfSinusoids3D.yaml index 44c4d6aca63f..29c94979d1d5 100644 --- a/tests/InputFiles/Poisson/ProductOfSinusoids3D.yaml +++ b/tests/InputFiles/Poisson/ProductOfSinusoids3D.yaml @@ -100,7 +100,7 @@ LinearSolver: RadiallyCompressedCoordinates: None -EventsAndTriggers: +EventsAndTriggersAtIterations: - Trigger: HasConverged Events: - ObserveNorms: diff --git a/tests/InputFiles/Punctures/MultiplePunctures.yaml b/tests/InputFiles/Punctures/MultiplePunctures.yaml index bdb62761a010..760bcd6b43eb 100644 --- a/tests/InputFiles/Punctures/MultiplePunctures.yaml +++ b/tests/InputFiles/Punctures/MultiplePunctures.yaml @@ -158,7 +158,7 @@ LinearSolver: RadiallyCompressedCoordinates: None -EventsAndTriggers: +EventsAndTriggersAtIterations: - Trigger: Always Events: - ObserveFields: diff --git a/tests/InputFiles/RadiationTransport/M1Grey/ConstantM1.yaml b/tests/InputFiles/RadiationTransport/M1Grey/ConstantM1.yaml index 063d238449a6..2284046438a3 100644 --- a/tests/InputFiles/RadiationTransport/M1Grey/ConstantM1.yaml +++ b/tests/InputFiles/RadiationTransport/M1Grey/ConstantM1.yaml @@ -62,7 +62,7 @@ Limiter: TvbConstant: 0.0 DisableForDebugging: false -EventsAndTriggers: +EventsAndTriggersAtSlabs: - Trigger: Slabs: EvenlySpaced: diff --git a/tests/InputFiles/ScalarAdvection/Krivodonova1D.yaml b/tests/InputFiles/ScalarAdvection/Krivodonova1D.yaml index 92d76ad0a2ed..683e87034d29 100644 --- a/tests/InputFiles/ScalarAdvection/Krivodonova1D.yaml +++ b/tests/InputFiles/ScalarAdvection/Krivodonova1D.yaml @@ -65,7 +65,7 @@ SpatialDiscretization: InitialData: Krivodonova: -EventsAndTriggers: +EventsAndTriggersAtSlabs: - Trigger: Slabs: Specified: diff --git a/tests/InputFiles/ScalarAdvection/Kuzmin2D.yaml b/tests/InputFiles/ScalarAdvection/Kuzmin2D.yaml index d801cddfb2da..3c2ccb215b60 100644 --- a/tests/InputFiles/ScalarAdvection/Kuzmin2D.yaml +++ b/tests/InputFiles/ScalarAdvection/Kuzmin2D.yaml @@ -66,7 +66,7 @@ SpatialDiscretization: InitialData: Kuzmin: -EventsAndTriggers: +EventsAndTriggersAtSlabs: - Trigger: Slabs: Specified: diff --git a/tests/InputFiles/ScalarAdvection/Sinusoid1D.yaml b/tests/InputFiles/ScalarAdvection/Sinusoid1D.yaml index f26bd8d0d958..79c42091e53f 100644 --- a/tests/InputFiles/ScalarAdvection/Sinusoid1D.yaml +++ b/tests/InputFiles/ScalarAdvection/Sinusoid1D.yaml @@ -65,7 +65,7 @@ SpatialDiscretization: InitialData: Sinusoid: -EventsAndTriggers: +EventsAndTriggersAtSlabs: - Trigger: Slabs: Specified: diff --git a/tests/InputFiles/ScalarTensor/KerrSchildSphericalHarmonic.yaml b/tests/InputFiles/ScalarTensor/KerrSchildSphericalHarmonic.yaml index 5d931e2c1bbe..88e0f1668857 100644 --- a/tests/InputFiles/ScalarTensor/KerrSchildSphericalHarmonic.yaml +++ b/tests/InputFiles/ScalarTensor/KerrSchildSphericalHarmonic.yaml @@ -126,7 +126,7 @@ SpatialDiscretization: Formulation: StrongInertial Quadrature: GaussLobatto -EventsAndTriggers: +EventsAndTriggersAtSlabs: - Trigger: TimeCompares: Comparison: GreaterThan @@ -196,6 +196,8 @@ EventsAndTriggers: Events: - SphericalSurface +EventsAndTriggersAtSteps: + EventsAndDenseTriggers: Observers: diff --git a/tests/InputFiles/ScalarWave/PlaneWave1D.yaml b/tests/InputFiles/ScalarWave/PlaneWave1D.yaml index 21dfdd5deff8..97a1f384dcfd 100644 --- a/tests/InputFiles/ScalarWave/PlaneWave1D.yaml +++ b/tests/InputFiles/ScalarWave/PlaneWave1D.yaml @@ -90,7 +90,7 @@ SpatialDiscretization: # Enable: false # BlocksToFilter: All -EventsAndTriggers: +EventsAndTriggersAtSlabs: - Trigger: Slabs: Specified: diff --git a/tests/InputFiles/ScalarWave/PlaneWave1DEventsAndTriggersExample.yaml b/tests/InputFiles/ScalarWave/PlaneWave1DEventsAndTriggersExample.yaml index 6a2dd9731de7..4afa68cc120e 100644 --- a/tests/InputFiles/ScalarWave/PlaneWave1DEventsAndTriggersExample.yaml +++ b/tests/InputFiles/ScalarWave/PlaneWave1DEventsAndTriggersExample.yaml @@ -81,7 +81,7 @@ SpatialDiscretization: EventsAndDenseTriggers: # [multiple_events] -EventsAndTriggers: +EventsAndTriggersAtSlabs: - Trigger: Slabs: EvenlySpaced: diff --git a/tests/InputFiles/ScalarWave/PlaneWave1DObserveExample.yaml b/tests/InputFiles/ScalarWave/PlaneWave1DObserveExample.yaml index f3c75f6c362f..0842c5044607 100644 --- a/tests/InputFiles/ScalarWave/PlaneWave1DObserveExample.yaml +++ b/tests/InputFiles/ScalarWave/PlaneWave1DObserveExample.yaml @@ -111,7 +111,7 @@ EventsAndDenseTriggers: NormType: L2Norm Components: Sum -EventsAndTriggers: +EventsAndTriggersAtSlabs: - Trigger: Slabs: Specified: diff --git a/tests/InputFiles/ScalarWave/PlaneWave2D.yaml b/tests/InputFiles/ScalarWave/PlaneWave2D.yaml index 43ae5e5a50fc..369189626beb 100644 --- a/tests/InputFiles/ScalarWave/PlaneWave2D.yaml +++ b/tests/InputFiles/ScalarWave/PlaneWave2D.yaml @@ -74,7 +74,7 @@ Filtering: Enable: true BlocksToFilter: All -EventsAndTriggers: +EventsAndTriggersAtSlabs: - Trigger: Slabs: Specified: diff --git a/tests/InputFiles/ScalarWave/PlaneWave3D.yaml b/tests/InputFiles/ScalarWave/PlaneWave3D.yaml index af3e32b0e369..bffb01b47169 100644 --- a/tests/InputFiles/ScalarWave/PlaneWave3D.yaml +++ b/tests/InputFiles/ScalarWave/PlaneWave3D.yaml @@ -70,7 +70,7 @@ SpatialDiscretization: # Enable: false # BlocksToFilter: All -EventsAndTriggers: +EventsAndTriggersAtSlabs: - Trigger: Times: Specified: diff --git a/tests/InputFiles/Xcts/BinaryBlackHole.yaml b/tests/InputFiles/Xcts/BinaryBlackHole.yaml index d24a0df922a7..9fc167c771ae 100644 --- a/tests/InputFiles/Xcts/BinaryBlackHole.yaml +++ b/tests/InputFiles/Xcts/BinaryBlackHole.yaml @@ -234,7 +234,7 @@ RadiallyCompressedCoordinates: OuterRadius: *outer_radius Compression: *outer_shell_distribution -EventsAndTriggers: +EventsAndTriggersAtIterations: - Trigger: Always Events: - ObserveNorms: diff --git a/tests/InputFiles/Xcts/HeadOnBns.yaml b/tests/InputFiles/Xcts/HeadOnBns.yaml index 3a859b4a4772..7c8737888917 100644 --- a/tests/InputFiles/Xcts/HeadOnBns.yaml +++ b/tests/InputFiles/Xcts/HeadOnBns.yaml @@ -173,7 +173,7 @@ RadiallyCompressedCoordinates: OuterRadius: *outer_radius Compression: *outer_shell_distribution -EventsAndTriggers: +EventsAndTriggersAtIterations: - Trigger: HasConverged Events: - ObserveNorms: diff --git a/tests/InputFiles/Xcts/KerrSchild.yaml b/tests/InputFiles/Xcts/KerrSchild.yaml index 60cfe5b12f4a..d17b26cac044 100644 --- a/tests/InputFiles/Xcts/KerrSchild.yaml +++ b/tests/InputFiles/Xcts/KerrSchild.yaml @@ -201,7 +201,7 @@ LinearSolver: RadiallyCompressedCoordinates: None -EventsAndTriggers: +EventsAndTriggersAtIterations: - Trigger: Always Events: - ObserveNorms: diff --git a/tests/InputFiles/Xcts/TovStar.yaml b/tests/InputFiles/Xcts/TovStar.yaml index a830ff5639de..32316f79f4e6 100644 --- a/tests/InputFiles/Xcts/TovStar.yaml +++ b/tests/InputFiles/Xcts/TovStar.yaml @@ -120,7 +120,7 @@ LinearSolver: RadiallyCompressedCoordinates: None -EventsAndTriggers: +EventsAndTriggersAtIterations: - Trigger: HasConverged Events: - ObserveNorms: diff --git a/tests/Unit/Evolution/Actions/Test_RunEventsAndTriggers.cpp b/tests/Unit/Evolution/Actions/Test_RunEventsAndTriggers.cpp index 9a11ce252980..4db44116c60b 100644 --- a/tests/Unit/Evolution/Actions/Test_RunEventsAndTriggers.cpp +++ b/tests/Unit/Evolution/Actions/Test_RunEventsAndTriggers.cpp @@ -23,6 +23,7 @@ #include "ParallelAlgorithms/EventsAndTriggers/EventsAndTriggers.hpp" #include "ParallelAlgorithms/EventsAndTriggers/LogicalTriggers.hpp" #include "ParallelAlgorithms/EventsAndTriggers/Trigger.hpp" +#include "ParallelAlgorithms/EventsAndTriggers/WhenToCheck.hpp" #include "Time/Slab.hpp" #include "Time/Tags/Time.hpp" #include "Time/Tags/TimeStepId.hpp" @@ -81,6 +82,8 @@ PUP::able::PUP_ID TestEvent::my_PUP_ID = 0; // NOLINT template struct Component { + static constexpr bool local_time_stepping = + Metavariables::local_time_stepping; using metavariables = Metavariables; using chare_type = ActionTesting::MockArrayChare; using array_index = int; @@ -92,10 +95,13 @@ struct Component { tmpl::list>>, Parallel::PhaseActions< Parallel::Phase::Testing, - tmpl::list>>; + tmpl::list>>>; }; +template struct Metavariables { + static constexpr bool local_time_stepping = LocalTimeStepping; using component_list = tmpl::list>; struct factory_creation : tt::ConformsTo { @@ -105,38 +111,12 @@ struct Metavariables { ::Triggers::OnSubsteps>>>; }; }; -} // namespace -SPECTRE_TEST_CASE("Unit.Evolution.RunEventsAndTriggers", - "[Unit][ParallelAlgorithms]") { - register_factory_classes_with_charm(); - - using my_component = Component; - std::array runners{ - ActionTesting::MockRuntimeSystem{ - TestHelpers::test_creation( - "- Trigger: Always\n" - " Events:\n" - " - TestEvent\n")}, - ActionTesting::MockRuntimeSystem{ - TestHelpers::test_creation( - "- Trigger:\n" - " Not: Always\n" - " Events:\n" - " - TestEvent\n")}, - ActionTesting::MockRuntimeSystem{ - TestHelpers::test_creation( - "- Trigger:\n" - " OnSubsteps: Always\n" - " Events:\n" - " - TestEvent\n")}, - ActionTesting::MockRuntimeSystem{ - TestHelpers::test_creation( - "- Trigger:\n" - " OnSubsteps:\n" - " Not: Always\n" - " Events:\n" - " - TestEvent\n")}}; +template +void test(std::array< + ActionTesting::MockRuntimeSystem>, + 4>& runners) { + using my_component = Component>; for (size_t test_case = 0; test_case < 4; ++test_case) { auto& runner = runners[test_case]; @@ -175,14 +155,97 @@ SPECTRE_TEST_CASE("Unit.Evolution.RunEventsAndTriggers", const auto step = slab.duration() / 2; const auto center = start + step; - test_all(TimeStepId(true, 0, start), 1.0, {}, 1.0, {}); - test_all(TimeStepId(true, 0, center), {}, {}, {}, {}); - test_all(TimeStepId(true, 1, start), 1.0, {}, 1.0, {}); - test_all(TimeStepId(true, 1, center), {}, {}, {}, {}); - test_all(TimeStepId(true, -1, start), {}, {}, {}, {}); - test_all(TimeStepId(true, -1, center), {}, {}, {}, {}); - test_all(TimeStepId(true, 0, start, 1, step, 1.5), {}, {}, 1000001.0, {}); - test_all(TimeStepId(true, 0, center, 1, step, 2.0), {}, {}, {}, {}); - test_all(TimeStepId(true, 0, start, 2, step, 1.0), {}, {}, 2000001.0, {}); - test_all(TimeStepId(true, 0, center, 2, step, 1.5), {}, {}, {}, {}); + if constexpr (LocalTimeStepping) { + test_all(TimeStepId(true, 0, start), 1.0, {}, 1.0, {}); + test_all(TimeStepId(true, 0, center), 1.5, {}, 1.5, {}); + test_all(TimeStepId(true, 1, start), 1.0, {}, 1.0, {}); + test_all(TimeStepId(true, 1, center), 1.5, {}, 1.5, {}); + test_all(TimeStepId(true, -1, start), {}, {}, {}, {}); + test_all(TimeStepId(true, -1, center), {}, {}, {}, {}); + test_all(TimeStepId(true, 0, start, 1, step, 1.5), {}, {}, 1000001.0, {}); + test_all(TimeStepId(true, 0, center, 1, step, 2.0), {}, {}, 1000001.5, {}); + test_all(TimeStepId(true, 0, start, 2, step, 1.0), {}, {}, 2000001.0, {}); + test_all(TimeStepId(true, 0, center, 2, step, 1.5), {}, {}, 2000001.5, {}); + } else { + test_all(TimeStepId(true, 0, start), 1.0, {}, 1.0, {}); + test_all(TimeStepId(true, 0, center), {}, {}, {}, {}); + test_all(TimeStepId(true, 1, start), 1.0, {}, 1.0, {}); + test_all(TimeStepId(true, 1, center), {}, {}, {}, {}); + test_all(TimeStepId(true, -1, start), {}, {}, {}, {}); + test_all(TimeStepId(true, -1, center), {}, {}, {}, {}); + test_all(TimeStepId(true, 0, start, 1, step, 1.5), {}, {}, 1000001.0, {}); + test_all(TimeStepId(true, 0, center, 1, step, 2.0), {}, {}, {}, {}); + test_all(TimeStepId(true, 0, start, 2, step, 1.0), {}, {}, 2000001.0, {}); + test_all(TimeStepId(true, 0, center, 2, step, 1.5), {}, {}, {}, {}); + } +} +} // namespace + +SPECTRE_TEST_CASE("Unit.Evolution.RunEventsAndTriggers", + "[Unit][ParallelAlgorithms]") { + register_factory_classes_with_charm>(); + std::array gts_runners{ + ActionTesting::MockRuntimeSystem>{ + TestHelpers::test_creation>( + "- Trigger: Always\n" + " Events:\n" + " - TestEvent\n")}, + ActionTesting::MockRuntimeSystem>{ + TestHelpers::test_creation>( + "- Trigger:\n" + " Not: Always\n" + " Events:\n" + " - TestEvent\n")}, + ActionTesting::MockRuntimeSystem>{ + TestHelpers::test_creation>( + "- Trigger:\n" + " OnSubsteps: Always\n" + " Events:\n" + " - TestEvent\n")}, + ActionTesting::MockRuntimeSystem>{ + TestHelpers::test_creation>( + "- Trigger:\n" + " OnSubsteps:\n" + " Not: Always\n" + " Events:\n" + " - TestEvent\n")}}; + test(gts_runners); + std::array lts_runners{ + ActionTesting::MockRuntimeSystem>{tuples::TaggedTuple< + Tags::EventsAndTriggers, + Tags::EventsAndTriggers>{ + EventsAndTriggers{}, + TestHelpers::test_creation>( + "- Trigger: Always\n" + " Events:\n" + " - TestEvent\n")}}, + ActionTesting::MockRuntimeSystem>{tuples::TaggedTuple< + Tags::EventsAndTriggers, + Tags::EventsAndTriggers>{ + EventsAndTriggers{}, + TestHelpers::test_creation>( + "- Trigger:\n" + " Not: Always\n" + " Events:\n" + " - TestEvent\n")}}, + ActionTesting::MockRuntimeSystem>{tuples::TaggedTuple< + Tags::EventsAndTriggers, + Tags::EventsAndTriggers>{ + EventsAndTriggers{}, + TestHelpers::test_creation>( + "- Trigger:\n" + " OnSubsteps: Always\n" + " Events:\n" + " - TestEvent\n")}}, + ActionTesting::MockRuntimeSystem>{tuples::TaggedTuple< + Tags::EventsAndTriggers, + Tags::EventsAndTriggers>{ + EventsAndTriggers{}, + TestHelpers::test_creation>( + "- Trigger:\n" + " OnSubsteps:\n" + " Not: Always\n" + " Events:\n" + " - TestEvent\n")}}}; + test(lts_runners); } diff --git a/tests/Unit/IO/Observers/Test_RegisterEvents.cpp b/tests/Unit/IO/Observers/Test_RegisterEvents.cpp index b11947652ac4..cbc612e3ae97 100644 --- a/tests/Unit/IO/Observers/Test_RegisterEvents.cpp +++ b/tests/Unit/IO/Observers/Test_RegisterEvents.cpp @@ -27,6 +27,8 @@ #include "ParallelAlgorithms/EventsAndTriggers/Event.hpp" #include "ParallelAlgorithms/EventsAndTriggers/EventsAndTriggers.hpp" #include "ParallelAlgorithms/EventsAndTriggers/LogicalTriggers.hpp" +#include "ParallelAlgorithms/EventsAndTriggers/Tags.hpp" +#include "ParallelAlgorithms/EventsAndTriggers/WhenToCheck.hpp" #include "Utilities/ErrorHandling/Error.hpp" #include "Utilities/Gsl.hpp" #include "Utilities/ProtocolHelpers.hpp" @@ -86,7 +88,8 @@ struct Component { using component_being_mocked = void; using chare_type = ActionTesting::MockArrayChare; using array_index = int; - using const_global_cache_tags = tmpl::list; + using const_global_cache_tags = + tmpl::list>; using phase_dependent_action_list = tmpl::list>>; diff --git a/tests/Unit/ParallelAlgorithms/EventsAndTriggers/CMakeLists.txt b/tests/Unit/ParallelAlgorithms/EventsAndTriggers/CMakeLists.txt index 09378139109d..d4d1df84ce7e 100644 --- a/tests/Unit/ParallelAlgorithms/EventsAndTriggers/CMakeLists.txt +++ b/tests/Unit/ParallelAlgorithms/EventsAndTriggers/CMakeLists.txt @@ -8,6 +8,7 @@ set(LIBRARY_SOURCES Test_EventsAndTriggers.cpp Test_RunEventsOnFailure.cpp Test_Tags.cpp + Test_WhenToCheck.cpp ) add_test_library(${LIBRARY} "${LIBRARY_SOURCES}") diff --git a/tests/Unit/ParallelAlgorithms/EventsAndTriggers/Test_Tags.cpp b/tests/Unit/ParallelAlgorithms/EventsAndTriggers/Test_Tags.cpp index 76d032aacef5..af5d5b03567c 100644 --- a/tests/Unit/ParallelAlgorithms/EventsAndTriggers/Test_Tags.cpp +++ b/tests/Unit/ParallelAlgorithms/EventsAndTriggers/Test_Tags.cpp @@ -7,11 +7,19 @@ #include "Helpers/DataStructures/DataBox/TestHelpers.hpp" #include "ParallelAlgorithms/EventsAndTriggers/Tags.hpp" +#include "ParallelAlgorithms/EventsAndTriggers/WhenToCheck.hpp" SPECTRE_TEST_CASE("Unit.ParallelAlgorithms.EventsAndTriggers.Tags", "[Unit][ParallelAlgorithms]") { - TestHelpers::db::test_simple_tag( - "EventsAndTriggers"); + TestHelpers::db::test_simple_tag< + Tags::EventsAndTriggers>( + "EventsAndTriggersAtIterations"); + TestHelpers::db::test_simple_tag< + Tags::EventsAndTriggers>( + "EventsAndTriggersAtSlabs"); + TestHelpers::db::test_simple_tag< + Tags::EventsAndTriggers>( + "EventsAndTriggersAtSteps"); TestHelpers::db::test_simple_tag( "EventsRunAtCleanup"); TestHelpers::db::test_simple_tag( diff --git a/tests/Unit/ParallelAlgorithms/EventsAndTriggers/Test_WhenToCheck.cpp b/tests/Unit/ParallelAlgorithms/EventsAndTriggers/Test_WhenToCheck.cpp new file mode 100644 index 000000000000..43bc9bb355df --- /dev/null +++ b/tests/Unit/ParallelAlgorithms/EventsAndTriggers/Test_WhenToCheck.cpp @@ -0,0 +1,14 @@ +// Distributed under the MIT License. +// See LICENSE.txt for details. + +#include "Framework/TestingFramework.hpp" + +#include "ParallelAlgorithms/EventsAndTriggers/WhenToCheck.hpp" +#include "Utilities/GetOutput.hpp" + +SPECTRE_TEST_CASE("Unit.ParallelAlgorithms.EventsAndTriggers.WhenToCheck", + "[Unit][ParallelAlgorithms]") { + CHECK(get_output(Triggers::WhenToCheck::AtIterations) == "AtIterations"); + CHECK(get_output(Triggers::WhenToCheck::AtSlabs) == "AtSlabs"); + CHECK(get_output(Triggers::WhenToCheck::AtSteps) == "AtSteps"); +} diff --git a/tests/Unit/Time/StepChoosers/Test_ErrorControl.cpp b/tests/Unit/Time/StepChoosers/Test_ErrorControl.cpp index 1dc6d27f8aab..a47da5a0c622 100644 --- a/tests/Unit/Time/StepChoosers/Test_ErrorControl.cpp +++ b/tests/Unit/Time/StepChoosers/Test_ErrorControl.cpp @@ -26,6 +26,7 @@ #include "ParallelAlgorithms/EventsAndTriggers/LogicalTriggers.hpp" #include "ParallelAlgorithms/EventsAndTriggers/Tags.hpp" #include "ParallelAlgorithms/EventsAndTriggers/Trigger.hpp" +#include "ParallelAlgorithms/EventsAndTriggers/WhenToCheck.hpp" #include "Time/ChangeSlabSize/Event.hpp" #include "Time/Slab.hpp" #include "Time/StepChoosers/Constant.hpp" @@ -415,15 +416,16 @@ void test_tags() { { INFO("Compute tag GTS test"); auto box = db::create< - db::AddSimpleTags, + db::AddSimpleTags< + Tags::EventsAndTriggers>, db::AddComputeTags< Tags::IsUsingTimeSteppingErrorControlCompute, Tags::StepperErrorTolerancesCompute, Tags::StepperErrorTolerancesCompute>>(); - db::mutate( - [](const gsl::not_null events) { - *events = TestHelpers::test_creation>( + [](const gsl::not_null events) { + *events = TestHelpers::test_creation>( "- Trigger: Always\n" " Events:\n" @@ -451,9 +453,9 @@ void test_tags() { CHECK(not db::get>(box) .has_value()); - db::mutate( - [](const gsl::not_null events) { - *events = TestHelpers::test_creation>( + [](const gsl::not_null events) { + *events = TestHelpers::test_creation>( "- Trigger: Always\n" " Events:\n" @@ -475,9 +477,9 @@ void test_tags() { CHECK(not db::get>(box) .has_value()); - db::mutate( - [](const gsl::not_null events) { - *events = TestHelpers::test_creation>( + [](const gsl::not_null events) { + *events = TestHelpers::test_creation>( "- Trigger: Always\n" " Events:\n" @@ -493,9 +495,9 @@ void test_tags() { CHECK(not db::get>(box) .has_value()); - db::mutate( - [](const gsl::not_null events) { - *events = TestHelpers::test_creation>( + [](const gsl::not_null events) { + *events = TestHelpers::test_creation>(""); }, make_not_null(&box)); diff --git a/tests/Unit/Visualization/Python/Test_ReadInputFile.py b/tests/Unit/Visualization/Python/Test_ReadInputFile.py index 6479de7c17d1..2b5f243f0efa 100644 --- a/tests/Unit/Visualization/Python/Test_ReadInputFile.py +++ b/tests/Unit/Visualization/Python/Test_ReadInputFile.py @@ -20,8 +20,14 @@ def setUp(self): def test_find_event(self): with self.input_file.open() as open_input_file: _, input_file = yaml.safe_load_all(open_input_file) - self.assertEqual(find_event("Completion", input_file), {}) - self.assertIsNone(find_event("NonexistentEvent", input_file)) + self.assertEqual( + find_event("Completion", "EventsAndTriggersAtSlabs", input_file), {} + ) + self.assertIsNone( + find_event( + "NonexistentEvent", "EventsAndTriggersAtSlabs", input_file + ) + ) def test_find_phase_change(self): with self.input_file.open() as open_input_file: diff --git a/tools/Status/ExecutableStatus/ExecutableStatus.py b/tools/Status/ExecutableStatus/ExecutableStatus.py index 2a6dd354c403..ab3828de1fad 100644 --- a/tools/Status/ExecutableStatus/ExecutableStatus.py +++ b/tools/Status/ExecutableStatus/ExecutableStatus.py @@ -140,7 +140,9 @@ def time_status( assert ( avg_num_slabs >= 2 ), "Need at least 'avg_num_slabs >= 2' to estimate simulation speed." - observe_time_event = find_event("ObserveTimeStep", input_file) + observe_time_event = find_event( + "ObserveTimeStep", "EventsAndTriggers", input_file + ) if observe_time_event is None: return {} subfile_name = observe_time_event["SubfileName"] + ".dat" @@ -208,7 +210,9 @@ def render_time_steps(self, input_file: dict, reduction_files: list): import plotly.express as px import streamlit as st - observe_time_event = find_event("ObserveTimeStep", input_file) + observe_time_event = find_event( + "ObserveTimeStep", "EventsAndTriggers", input_file + ) if observe_time_event is None: st.warning("No 'ObserveTimeStep' event found in input file.") return