Helpers.hpp
1 // Distributed under the MIT License.
2 // See LICENSE.txt for details.
3 
4 #pragma once
5 
6 #include "IO/Observer/Tags.hpp"
7 #include "Parallel/Reduction.hpp"
8 #include "Utilities/TMPL.hpp"
10 
11 namespace observers {
12 namespace detail {
13 template <class ObservingAction, class = cpp17::void_t<>>
14 struct get_reduction_data_tags {
15  using type = tmpl::list<>;
16 };
17 
18 template <class ObservingAction>
19 struct get_reduction_data_tags<
20  ObservingAction,
21  cpp17::void_t<typename ObservingAction::observed_reduction_data_tags>> {
22  using type = typename ObservingAction::observed_reduction_data_tags;
23 };
24 
25 template <class ReductionDataType>
26 struct make_reduction_data_tag_impl {
27  using type = tmpl::wrap<typename ReductionDataType::datum_list,
29 };
30 } // namespace detail
31 
32 /// Each Action that sends data to the reduction Observer must specify
33 /// a type alias `observed_reduction_data_tags` that describes the data it
34 /// sends. Given a list of such Actions (or other types that expose the alias),
35 /// this metafunction is used to create
36 /// `Metavariables::observed_reduction_data_tags` (which is required to
37 /// initialize the Observer).
38 template <class ObservingActionList>
39 using collect_reduction_data_tags =
40  tmpl::remove_duplicates<tmpl::flatten<tmpl::transform<
41  ObservingActionList, detail::get_reduction_data_tags<tmpl::_1>>>>;
42 
43 /// Produces the `tmpl::list` of `observers::Tags::ReductionData` tags that
44 /// corresponds to the `tmpl::list` of `Parallel::ReductionData` passed into
45 /// this metafunction.
46 template <typename ReductionDataList>
47 using make_reduction_data_tags = tmpl::remove_duplicates<tmpl::transform<
48  ReductionDataList, detail::make_reduction_data_tag_impl<tmpl::_1>>>;
49 } // namespace observers
Definition: Actions.hpp:20
void void_t
Given a set of types, returns void
Definition: TypeTraits.hpp:214
Definition: Determinant.hpp:11
Reduction data to be written to disk.
Definition: Tags.hpp:62
Wraps the template metaprogramming library used (brigand)
C++ STL code present in C++17.
Definition: Array.hpp:16
Defines type traits, some of which are future STL type_traits header.