Initialize.hpp
1 // Distributed under the MIT License.
2 // See LICENSE.txt for details.
3 
4 #pragma once
5 
8 #include "DataStructures/DataVector.hpp"
9 #include "IO/Observer/ArrayComponentId.hpp"
10 #include "IO/Observer/Tags.hpp"
12 #include "Parallel/NodeLock.hpp"
13 #include "Utilities/TMPL.hpp"
15 
16 namespace observers {
17 namespace Actions {
18 namespace detail {
19 template <class Tag>
20 using reduction_data_to_reduction_names = typename Tag::names_tag;
21 } // namespace detail
22 /*!
23  * \brief Initializes the DataBox on the observer parallel component
24  *
25  * Uses:
26  * - Metavariables:
27  * - `observed_reduction_data_tags` (see ContributeReductionData)
28  */
29 template <class Metavariables>
30 struct Initialize {
31  using simple_tags = tmpl::append<
35  typename Metavariables::observed_reduction_data_tags,
36  tmpl::transform<
37  typename Metavariables::observed_reduction_data_tags,
38  tmpl::bind<detail::reduction_data_to_reduction_names, tmpl::_1>>>;
39  using compute_tags = db::AddComputeTags<>;
40 
41  using return_tag_list = tmpl::append<simple_tags, compute_tags>;
42 
43  template <typename... InboxTags, typename ArrayIndex, typename ActionList,
44  typename ParallelComponent>
45  static auto apply(const db::DataBox<tmpl::list<>>& /*box*/,
46  const tuples::TaggedTuple<InboxTags...>& /*inboxes*/,
48  const ArrayIndex& /*array_index*/,
49  const ActionList /*meta*/,
50  const ParallelComponent* const /*meta*/) noexcept {
51  return helper(typename Metavariables::observed_reduction_data_tags{});
52  }
53 
54  private:
55  template <typename... ReductionTags>
56  static auto helper(tmpl::list<ReductionTags...> /*meta*/) noexcept {
57  return std::make_tuple(db::create<simple_tags>(
65  detail::reduction_data_to_reduction_names<ReductionTags>>{}...));
66  }
67 };
68 
69 /*!
70  * \brief Initializes the DataBox of the observer parallel component that writes
71  * to disk.
72  *
73  * Uses:
74  * - Metavariables:
75  * - `observed_reduction_data_tags` (see ContributeReductionData)
76  */
77 template <class Metavariables>
79  using simple_tags = tmpl::append<
82  typename Metavariables::observed_reduction_data_tags,
83  tmpl::transform<
84  typename Metavariables::observed_reduction_data_tags,
85  tmpl::bind<detail::reduction_data_to_reduction_names, tmpl::_1>>>;
86  using compute_tags = db::AddComputeTags<>;
87 
88  using return_tag_list = tmpl::append<simple_tags, compute_tags>;
89 
90  template <typename... InboxTags, typename ArrayIndex, typename ActionList,
91  typename ParallelComponent>
92  static auto apply(const db::DataBox<tmpl::list<>>& /*box*/,
93  const tuples::TaggedTuple<InboxTags...>& /*inboxes*/,
95  const ArrayIndex& /*array_index*/,
96  const ActionList /*meta*/,
97  const ParallelComponent* const /*meta*/) noexcept {
98  return helper(typename Metavariables::observed_reduction_data_tags{});
99  }
100 
101  private:
102  template <typename... ReductionTags>
103  static auto helper(tmpl::list<ReductionTags...> /*meta*/) noexcept {
104  return std::make_tuple(db::create<simple_tags>(
110  detail::reduction_data_to_reduction_names<ReductionTags>>{}...));
111  }
112 };
113 } // namespace Actions
114 } // namespace observers
Definition: Actions.hpp:20
The number of observer components that have contributed data at the observation ids.
Definition: Tags.hpp:95
CmiNodeLock create_lock() noexcept
Create a converse CmiNodeLock.
Definition: NodeLock.hpp:16
All the ids of all the components registered to an observer for doing reduction observations.
Definition: Tags.hpp:34
Defines class tuples::TaggedTuple.
The number of events registered with the observer.
Definition: Tags.hpp:26
Initializes the DataBox on the observer parallel component.
Definition: Initialize.hpp:30
constexpr auto apply(F &&f, const DataBox< BoxTags > &box, Args &&... args)
Apply the function f with argument Tags TagsList from DataBox box
Definition: DataBox.hpp:1595
Definition: Determinant.hpp:11
An associative container that is indexed by structs.
Definition: TaggedTuple.hpp:272
Defines classes and functions used for manipulating DataBox&#39;s.
tmpl::flatten< tmpl::list< Tags... > > AddSimpleTags
List of Tags to add to the DataBox.
Definition: DataBox.hpp:1227
Definition: InterpolationTargetWedgeSectionTorus.hpp:24
A Charm++ chare that caches constant data once per Charm++ node.
Definition: ConstGlobalCache.hpp:76
All the ids of all the components registered to an observer for doing volume observations.
Definition: Tags.hpp:41
Volume tensor data to be written to disk.
Definition: Tags.hpp:47
Wraps the template metaprogramming library used (brigand)
The number of observer components that have contributed data at the observation ids.
Definition: Tags.hpp:88
typename DataBox_detail::item_type_impl< TagList, Tag >::type item_type
Get the type that is returned by the Tag. If it is a base tag then a TagList must be passed as a seco...
Definition: DataBoxTag.hpp:410
Defines classes SimpleTag, PrefixTag, ComputeTag and several functions for retrieving tag info...
Defines class template ConstGlobalCache.
Node lock used when needing to read/write to H5 files on disk.
Definition: Tags.hpp:105
Definition: ComputeTimeDerivative.hpp:28
tmpl::flatten< tmpl::list< Tags... > > AddComputeTags
List of Compute Item Tags to add to the DataBox.
Definition: DataBox.hpp:1234
Initializes the DataBox of the observer parallel component that writes to disk.
Definition: Initialize.hpp:78