From 28bcb113107ea70c2e28e834d6ca02da50f4492d Mon Sep 17 00:00:00 2001 From: Kyle Nelli Date: Fri, 26 Apr 2024 21:00:28 -0700 Subject: [PATCH] Write data synchronously in CCE for monotomic times in output --- .../Cce/Actions/ScriObserveInterpolated.hpp | 24 +++++++++++++------ src/IO/Observer/ReductionActions.hpp | 24 +++++++++++++++---- .../Actions/Test_ScriObserveInterpolated.cpp | 2 +- 3 files changed, 38 insertions(+), 12 deletions(-) diff --git a/src/Evolution/Systems/Cce/Actions/ScriObserveInterpolated.hpp b/src/Evolution/Systems/Cce/Actions/ScriObserveInterpolated.hpp index d939639356c7..d1ff35935acf 100644 --- a/src/Evolution/Systems/Cce/Actions/ScriObserveInterpolated.hpp +++ b/src/Evolution/Systems/Cce/Actions/ScriObserveInterpolated.hpp @@ -63,8 +63,7 @@ void correct_weyl_scalars_for_inertial_time( /*! * \ingroup ActionsGroup * \brief Checks the interpolation managers and if they are ready, performs the - * interpolation and sends the data to file via - * `observers::ThreadedActions::WriteSimpleData`. + * interpolation and sends the data to file. * * \details This uses the `ScriPlusInterpolationManager` to perform the * interpolations of all requested scri quantities (determined by @@ -100,13 +99,17 @@ void correct_weyl_scalars_for_inertial_time( * =& \Psi_4^{(1)}. * \f} * + * \note If \p WriteSynchronously is true, then a local synchronous action will + * be used to write the News value rather than a threaded action. + * * \ref DataBoxGroup changes: * - Adds: nothing * - Removes: nothing * - Modifies: `InterpolagionManager` for each `Tag` in * `Metavariables::scri_values_to_observe` */ -template +template struct ScriObserveInterpolated { using const_global_cache_tags = tmpl::flatten< tmpl::list(cache)[0]; - Parallel::threaded_action< - observers::ThreadedActions::WriteReductionDataRow>( - observer_proxy, "/Cce/" + detail::ScriOutput::name(), legend, - std::make_tuple(*data_to_write_buffer)); + if constexpr (WriteSynchronously) { + Parallel::local_synchronous_action< + observers::ThreadedActions::WriteReductionDataRow>( + observer_proxy, cache, "/Cce/" + detail::ScriOutput::name(), + legend, std::make_tuple(*data_to_write_buffer)); + } else { + Parallel::threaded_action< + observers::ThreadedActions::WriteReductionDataRow>( + observer_proxy, "/Cce/" + detail::ScriOutput::name(), legend, + std::make_tuple(*data_to_write_buffer)); + } } }; } // namespace Actions diff --git a/src/IO/Observer/ReductionActions.hpp b/src/IO/Observer/ReductionActions.hpp index ffb06131274e..842d643c351c 100644 --- a/src/IO/Observer/ReductionActions.hpp +++ b/src/IO/Observer/ReductionActions.hpp @@ -662,16 +662,32 @@ struct WriteReductionData { * values must match the length of the `legend`. */ struct WriteReductionDataRow { + /// \brief The apply call for the threaded action template > + typename Metavariables, typename ArrayIndex, typename... Ts> static void apply(db::DataBox& box, Parallel::GlobalCache& cache, const ArrayIndex& /*array_index*/, - const gsl::not_null /*node_lock*/, + const gsl::not_null node_lock, const std::string& subfile_name, - std::vector&& legend, + std::vector legend, std::tuple&& reduction_data) { + apply(box, node_lock, cache, subfile_name, + std::move(legend), std::move(reduction_data)); + } + + // The local synchronous action + using return_type = void; + + /// \brief The apply call for the local synchronous action + template + static return_type apply( + db::DataBox& box, + const gsl::not_null /*node_lock*/, + Parallel::GlobalCache& cache, + const std::string& subfile_name, std::vector legend, + std::tuple&& reduction_data) { auto& reduction_file_lock = db::get_mutable_reference(make_not_null(&box)); const std::lock_guard hold_lock(reduction_file_lock); diff --git a/tests/Unit/Evolution/Systems/Cce/Actions/Test_ScriObserveInterpolated.cpp b/tests/Unit/Evolution/Systems/Cce/Actions/Test_ScriObserveInterpolated.cpp index ea2ab419f0cb..6168c96dc120 100644 --- a/tests/Unit/Evolution/Systems/Cce/Actions/Test_ScriObserveInterpolated.cpp +++ b/tests/Unit/Evolution/Systems/Cce/Actions/Test_ScriObserveInterpolated.cpp @@ -145,7 +145,7 @@ struct mock_characteristic_evolution { cce_boundary_component>>>, Actions::ScriObserveInterpolated< mock_observer, - typename Metavariables::cce_boundary_component>, + typename Metavariables::cce_boundary_component, false>, ::Actions::AdvanceTime>>>; };