SpECTRE  v2024.03.19
observers::protocols::ReductionDataFormatter Struct Reference

Conforming classes can create an informative message from reduction data. The message will be printed to screen when the formatter is passed to a reduction action such as observers::Actions::ContributeReductionData. More...

#include <ReductionDataFormatter.hpp>

Classes

struct  test
 

Detailed Description

Conforming classes can create an informative message from reduction data. The message will be printed to screen when the formatter is passed to a reduction action such as observers::Actions::ContributeReductionData.

Conforming classes must provide the following type aliases:

  • reduction_data: The Parallel::ReductionData that the formatter is applicable to.

Conforming classes must implement the following member functions:

  • operator(): A call operator that takes the values of the reduction data and returns a std::string. The string should be an informative message such as "Global minimum grid spacing at time 5.4 is: 0.1".
  • pup: A PUP function for serialization.

Here's an example for a formatter:

struct FormatErrors
: tt::ConformsTo<observers::protocols::ReductionDataFormatter> {
using reduction_data = helpers::reduction_data_from_doubles;
std::string operator()(const double time, const size_t num_points,
const double error1, const double error2) const {
return "Errors at time " + std::to_string(time) + " over " +
std::to_string(num_points) +
" grid points:\n Field1: " + std::to_string(error1) +
"\n Field2: " + std::to_string(error2);
}
// NOLINTNEXTLINE
void pup(PUP::er& /*p*/) {}
};
Parallel::ReductionData< Parallel::ReductionDatum< tuples::tagged_tuple_from_typelist< TagsAndCombinesPresent >, TaggedTupleCombine > > reduction_data
A Parallel::ReductionData with a single Parallel::ReductionDatum for a given tagged tuple type determ...
Definition: PhaseControlReductionHelpers.hpp:81
Indicate a class conforms to the Protocol.
Definition: ProtocolHelpers.hpp:22

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