SpECTRE  v2024.09.29
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);
constexpr decltype(auto) square(const T &x)
Compute the square of x
Definition: ConstantExpressions.hpp:54
The data to be reduced, and invokables to be called whenever two reduction messages are combined and ...
Definition: Reduction.hpp:66
Functional for computing sqrt on an object.
Definition: Functional.hpp:273

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) {
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)));
}
};
A Charm++ chare that caches global data once per Charm++ node.
Definition: GlobalCache.hpp:222
auto apply(F &&f, const ObservationBox< ComputeTagsList, DataBoxType > &observation_box, Args &&... args)
Apply the function object f using its nested argument_tags list of tags.
Definition: ObservationBox.hpp:238
auto sqrt(const TensorExpression< T, X, Symm, IndexList, tmpl::list< Args... > > &t)
Returns the tensor expression representing the square root of a tensor expression that evaluates to a...
Definition: SquareRoot.hpp:253
#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:40
constexpr bool equal_within_roundoff(const Lhs &lhs, const Rhs &rhs, const double eps=std::numeric_limits< double >::epsilon() *100.0, const double scale=1.0)
Checks if two values lhs and rhs are equal within roundoff, by comparing abs(lhs - rhs) < (max(abs(lh...
Definition: EqualWithinRoundoff.hpp:48

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