Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add LTS support to Adams-Moulton time steppers #6043

Merged
merged 9 commits into from
Jun 12, 2024
3 changes: 3 additions & 0 deletions .clang-tidy
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,9 @@ CheckOptions:
value: true
- key: performance-move-const-arg.CheckTriviallyCopyableMove
value: false
# The fix for this is not supported by GCC 9.
- key: modernize-loop-convert.UseCxx20ReverseRanges
value: false
WarningsAsErrors: '*'
# It is unclear if the header filter actually works or how to use it so
# just include all headers
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -488,7 +488,9 @@ struct EvolutionMetavars {
tmpl::pair<
gh::gauges::GaugeCondition,
tmpl::list<gh::gauges::DampedHarmonic, gh::gauges::Harmonic>>,
tmpl::pair<LtsTimeStepper, TimeSteppers::lts_time_steppers>,
// Restrict to monotonic time steppers in LTS to avoid control
// systems deadlocking.
tmpl::pair<LtsTimeStepper, TimeSteppers::monotonic_lts_time_steppers>,
tmpl::pair<PhaseChange, PhaseControl::factory_creatable_classes>,
tmpl::pair<StepChooser<StepChooserUse::LtsStep>,
StepChoosers::standard_step_choosers<system>>,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,13 @@ struct EvolutionMetavars : public GeneralizedHarmonicTemplateBase<3, UseLts> {
struct factory_creation
: tt::ConformsTo<Options::protocols::FactoryCreation> {
using factory_classes = Options::add_factory_classes<
typename gh_base::factory_creation::factory_classes,
// Restrict to monotonic time steppers in LTS to avoid control
// systems deadlocking.
tmpl::insert<
tmpl::erase<typename gh_base::factory_creation::factory_classes,
LtsTimeStepper>,
tmpl::pair<LtsTimeStepper,
TimeSteppers::monotonic_lts_time_steppers>>,
tmpl::pair<Event,
tmpl::flatten<tmpl::list<
intrp::Events::Interpolate<3, ApparentHorizon,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -616,7 +616,13 @@ struct GhValenciaDivCleanTemplateBase<
boundary_conditions>,
tmpl::pair<gh::gauges::GaugeCondition, gh::gauges::all_gauges>,
tmpl::pair<evolution::initial_data::InitialData, initial_data_list>,
tmpl::pair<LtsTimeStepper, TimeSteppers::lts_time_steppers>,
// Restrict to monotonic time steppers in LTS to avoid control
// systems deadlocking.
tmpl::pair<
LtsTimeStepper,
tmpl::conditional_t<use_control_systems,
TimeSteppers::monotonic_lts_time_steppers,
TimeSteppers::lts_time_steppers>>,
tmpl::pair<PhaseChange, PhaseControl::factory_creatable_classes>,
tmpl::pair<StepChooser<StepChooserUse::LtsStep>,
StepChoosers::standard_step_choosers<system>>,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,13 @@ struct EvolutionMetavars : public ScalarTensorTemplateBase<EvolutionMetavars> {
struct factory_creation
: tt::ConformsTo<Options::protocols::FactoryCreation> {
using factory_classes = Options::add_factory_classes<
typename st_base::factory_creation::factory_classes,
// Restrict to monotonic time steppers in LTS to avoid control
// systems deadlocking.
tmpl::insert<
tmpl::erase<typename st_base::factory_creation::factory_classes,
LtsTimeStepper>,
tmpl::pair<LtsTimeStepper,
TimeSteppers::monotonic_lts_time_steppers>>,
tmpl::pair<Event,
tmpl::flatten<tmpl::list<
intrp::Events::Interpolate<volume_dim, AhA,
Expand Down
5 changes: 2 additions & 3 deletions src/Time/Actions/ChangeStepSize.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -114,9 +114,8 @@ bool change_step_size(const gsl::not_null<db::DataBox<DbTags>*> box) {
<< time_step_id.substep_time() << ".");
}

const auto& next_time_id = db::get<Tags::Next<Tags::TimeStepId>>(*box);
const auto new_step =
choose_lts_step_size(next_time_id.step_time(), desired_step);
const auto new_step = choose_lts_step_size(
time_step_id.step_time() + current_step, desired_step);
db::mutate<Tags::Next<Tags::TimeStep>>(
[&new_step](const gsl::not_null<TimeDelta*> next_step) {
*next_step = new_step;
Expand Down
9 changes: 2 additions & 7 deletions src/Time/BoundaryHistory.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@

#include "DataStructures/CircularDeque.hpp"
#include "DataStructures/MathWrapper.hpp"
#include "DataStructures/StaticDeque.hpp"
#include "Time/History.hpp"
#include "Time/TimeStepId.hpp"
#include "Utilities/Algorithm.hpp"
Expand Down Expand Up @@ -342,20 +341,16 @@ class BoundaryHistory {
void clear_substeps_local(size_t n);
void clear_substeps_remote(size_t n);

StaticDeque<StepData<LocalData>, history_max_past_steps + 2> local_data_{};
CircularDeque<StepData<LocalData>> local_data_{};
CircularDeque<StepData<RemoteData>> remote_data_{};

template <typename Data>
using CouplingSubsteps =
boost::container::static_vector<Data, history_max_substeps + 1>;

// Putting the CircularDeque outermost means that we are inserting
// and removing containers that do not allocate, so we don't have to
// worry about that.
// NOLINTNEXTLINE(spectre-mutable)
mutable CircularDeque<CouplingSubsteps<
StaticDeque<CouplingSubsteps<std::optional<CouplingResult>>,
decltype(local_data_)::max_size()>>>
CircularDeque<CouplingSubsteps<std::optional<CouplingResult>>>>>
couplings_;
};

Expand Down
Loading
Loading