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

Write data synchronously in CCE for monotomic times in output #5950

Merged
merged 1 commit into from
May 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 17 additions & 7 deletions src/Evolution/Systems/Cce/Actions/ScriObserveInterpolated.hpp
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Loading