SpECTRE  v2024.04.12
observers::Actions::ContributeReductionData Struct Reference

Send reduction data to the observer group. More...

#include <ReductionActions.hpp>

Static Public Member Functions

template<typename ParallelComponent , typename DbTagsList , typename Metavariables , typename ArrayIndex , typename... Ts, typename Formatter = observers::NoFormatter>
static void apply (db::DataBox< DbTagsList > &box, Parallel::GlobalCache< Metavariables > &cache, const ArrayIndex &array_index, const observers::ObservationId &observation_id, const Parallel::ArrayComponentId &sender_array_id, const std::string &subfile_name, const std::vector< std::string > &reduction_names, Parallel::ReductionData< Ts... > &&reduction_data, std::optional< Formatter > &&formatter=std::nullopt, const bool observe_per_core=false)
 

Detailed Description

Send reduction data to the observer group.

Once everything at a specific ObservationId has been contributed to the reduction, the groups reduce to their local nodegroup.

The caller of this Action (which is to be invoked on the Observer parallel component) must pass in an observation_id used to uniquely identify the observation in time, the name of the h5::Dat subfile in the HDF5 file (e.g. /element_data, where the slash is important), a std::vector<std::string> of names of the quantities being reduced (e.g. {"Time", "L1ErrorDensity", "L2ErrorDensity"}), and the Parallel::ReductionData that holds the ReductionDatums containing info on how to do the reduction.

The observer components need to know all expected reduction data types by compile-time, so they rely on the Metavariables::observed_reduction_data_tags alias to collect them in one place. To this end, each Action that contributes reduction data must expose the type alias as:

using observed_reduction_data_tags = observers::make_reduction_data_tags<
tmpl::list<reduction_data_from_doubles, reduction_data_from_vector,
reduction_data_from_ds_and_vs>>;

Then, in the Metavariables collect them from all observing Actions using the observers::collect_reduction_data_tags metafunction.

This action also accepts a "formatter" that will be forwarded along with the reduction data and used to print an informative message when the reduction is complete. The formatter must conform to observers::protocols::ReductionDataFormatter.

This action also supports observing the intermediate stage of the reduction over just the processing element that the element is currently on. This can be useful e.g. to measure performance metric to assess load-balancing such as the number of grid points on each core. Enable per-core observations by passing true for the observe_per_core argument (default: false). The data will be written in one H5 file per node prefixed with the observers::Tags::ReductionFileName, in a Core{core_id} subfile, where core_id is an integer identifying the core across all nodes (see Parallel::my_proc). For example, when running on 2 nodes with 2 cores each you will end up with Reductions0.h5 containing /Core0/{subfile_name}.dat and /Core1/{subfile_name}.dat, and Reductions1.h5 containing /Core2/{subfile_name}.dat and /Core3/{subfile_name}.dat. This is in addition to the usual reduction output over all registered elements, written to Reductions.h5 (no node ID suffix in the file name).


The documentation for this struct was generated from the following file: