SpECTRE  v2026.04.01
Loading...
Searching...
No Matches
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". It should end with a newline character.
  • 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) + "\n";
}
// NOLINTNEXTLINE
void pup(PUP::er& /*p*/) {}
};

The documentation for this struct was generated from the following file:
  • src/IO/Observer/Protocols/ReductionDataFormatter.hpp