Public Types | Public Attributes | List of all members
Parallel::ReductionDatum< T, InvokeCombine, InvokeFinal, InvokeFinalExtraArgsIndices > Struct Template Reference

The data to be reduced, and invokables to be called whenever two reduction messages are combined and after the reduction has been completed. More...

#include <Reduction.hpp>

Public Types

using value_type = T
 
using invoke_combine = InvokeCombine
 
using invoke_final = InvokeFinal
 
using invoke_final_extra_args_indices = InvokeFinalExtraArgsIndices
 

Public Attributes

value
 

Detailed Description

template<class T, class InvokeCombine, class InvokeFinal = funcl::Identity, class InvokeFinalExtraArgsIndices = std::index_sequence<>>
struct Parallel::ReductionDatum< T, InvokeCombine, InvokeFinal, InvokeFinalExtraArgsIndices >

The data to be reduced, and invokables to be called whenever two reduction messages are combined and after the reduction has been completed.

InvokeCombine is a binary invokable that maps (T current_state, T element) -> T, where the current_state is the result of reductions so far. The InvokeFinal is an n-ary that takes as its first argument a T result_of_reduction and is invoked once after the reduction is completed. The additional arguments correspond to the resultant data of earlier ReductionDatum template parameters in the ReductionData, and are identified via the InvokeFinalExtraArgsIndices, which must be a std::index_sequence. Specifically, say you want the third ReductionDatum's InvokeFinal to be passed the first ReductionDatum then std::index_sequence<0> would be passed for InvokeFinalExtraArgsIndices. Here is an example of computing the RMS error of the evolved variables u and v:

Parallel::ReductionData<Parallel::ReductionDatum<size_t, funcl::Plus<>>,
RmsRed, RmsRed>
error_reduction{3, square(1.0e-3), square(1.0e-4)};
Parallel::contribute_to_reduction<ProcessErrorNorms>(error_reduction,
my_proxy, array_proxy);

with the receiving action:

struct ProcessErrorNorms {
template <typename ParallelComponent, typename DbTags, typename Metavariables,
typename ArrayIndex>
static void apply(db::DataBox<DbTags>& /*box*/,
const ArrayIndex& /*array_index*/, const int points,
const double error_u, const double error_v) noexcept {
SPECTRE_PARALLEL_REQUIRE(number_of_1d_array_elements * 3 == points);
error_u, sqrt(number_of_1d_array_elements * square(1.0e-3) / points)));
error_v, sqrt(number_of_1d_array_elements * square(1.0e-4) / points)));
}
};

The documentation for this struct was generated from the following file:
Parallel::GlobalCache
Definition: ElementReceiveInterpPoints.hpp:16
Parallel::ReductionDatum
The data to be reduced, and invokables to be called whenever two reduction messages are combined and ...
Definition: Reduction.hpp:63
std::index_sequence
square
constexpr decltype(auto) square(const T &x)
Compute the square of x
Definition: ConstantExpressions.hpp:55
SPECTRE_PARALLEL_REQUIRE
#define SPECTRE_PARALLEL_REQUIRE(expr)
A similar to Catch's REQUIRE statement, but can be used in tests that spawn several chares with possi...
Definition: TestingFramework.hpp:65
std::sqrt
T sqrt(T... args)
funcl::Sqrt
Functional for computing sqrt on an object.
Definition: Functional.hpp:273
db::apply
constexpr auto apply(F &&f, const DataBox< BoxTags > &box, Args &&... args) noexcept
Apply the invokable f with argument Tags TagsList from DataBox box
Definition: DataBox.hpp:1424
equal_within_roundoff
constexpr bool equal_within_roundoff(const double a, const double b, const double eps=std::numeric_limits< double >::epsilon() *100.0, const double scale=1.0) noexcept
Definition: EqualWithinRoundoff.hpp:15
db::DataBox
Definition: InterpolationTargetWedgeSectionTorus.hpp:24