diff --git a/src/Evolution/Systems/Cce/Actions/ScriObserveInterpolated.hpp b/src/Evolution/Systems/Cce/Actions/ScriObserveInterpolated.hpp index b84385610de7..961f91652175 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 0309ff6a6f9a..76ceae838689 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>>>; };