Skip to content

Commit

Permalink
Merge pull request #5950 from knelli2/cce_write_sync
Browse files Browse the repository at this point in the history
Write data synchronously in CCE for monotomic times in output
  • Loading branch information
nilsdeppe committed May 1, 2024
2 parents 8d01120 + 28bcb11 commit 3ddfed2
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 12 deletions.
24 changes: 17 additions & 7 deletions src/Evolution/Systems/Cce/Actions/ScriObserveInterpolated.hpp
Expand Up @@ -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
Expand Down Expand Up @@ -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<ComplexDataVector, Tag>` for each `Tag` in
* `Metavariables::scri_values_to_observe`
*/
template <typename ObserverWriterComponent, typename BoundaryComponent>
template <typename ObserverWriterComponent, typename BoundaryComponent,
bool WriteSynchronously = true>
struct ScriObserveInterpolated {
using const_global_cache_tags = tmpl::flatten<
tmpl::list<Tags::ObservationLMax,
Expand Down Expand Up @@ -253,10 +256,17 @@ struct ScriObserveInterpolated {
}
auto observer_proxy =
Parallel::get_parallel_component<ObserverWriterComponent>(cache)[0];
Parallel::threaded_action<
observers::ThreadedActions::WriteReductionDataRow>(
observer_proxy, "/Cce/" + detail::ScriOutput<Tag>::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<Tag>::name(),
legend, std::make_tuple(*data_to_write_buffer));
} else {
Parallel::threaded_action<
observers::ThreadedActions::WriteReductionDataRow>(
observer_proxy, "/Cce/" + detail::ScriOutput<Tag>::name(), legend,
std::make_tuple(*data_to_write_buffer));
}
}
};
} // namespace Actions
Expand Down
24 changes: 20 additions & 4 deletions src/IO/Observer/ReductionActions.hpp
Expand Up @@ -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 ParallelComponent, typename DbTagsList,
typename Metavariables, typename ArrayIndex, typename... Ts,
typename DataBox = db::DataBox<DbTagsList>>
typename Metavariables, typename ArrayIndex, typename... Ts>
static void apply(db::DataBox<DbTagsList>& box,
Parallel::GlobalCache<Metavariables>& cache,
const ArrayIndex& /*array_index*/,
const gsl::not_null<Parallel::NodeLock*> /*node_lock*/,
const gsl::not_null<Parallel::NodeLock*> node_lock,
const std::string& subfile_name,
std::vector<std::string>&& legend,
std::vector<std::string> legend,
std::tuple<Ts...>&& reduction_data) {
apply<ParallelComponent>(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 <typename ParallelComponent, typename DbTagList,
typename Metavariables, typename... Ts>
static return_type apply(
db::DataBox<DbTagList>& box,
const gsl::not_null<Parallel::NodeLock*> /*node_lock*/,
Parallel::GlobalCache<Metavariables>& cache,
const std::string& subfile_name, std::vector<std::string> legend,
std::tuple<Ts...>&& reduction_data) {
auto& reduction_file_lock =
db::get_mutable_reference<Tags::H5FileLock>(make_not_null(&box));
const std::lock_guard hold_lock(reduction_file_lock);
Expand Down
Expand Up @@ -145,7 +145,7 @@ struct mock_characteristic_evolution {
cce_boundary_component>>>,
Actions::ScriObserveInterpolated<
mock_observer<Metavariables>,
typename Metavariables::cce_boundary_component>,
typename Metavariables::cce_boundary_component, false>,
::Actions::AdvanceTime>>>;
};

Expand Down

0 comments on commit 3ddfed2

Please sign in to comment.