ObserverComponent.hpp
1 // Distributed under the MIT License.
2 // See LICENSE.txt for details.
3 
4 #pragma once
5 
6 #include "AlgorithmGroup.hpp"
7 #include "AlgorithmNodegroup.hpp"
8 #include "IO/Observer/ArrayComponentId.hpp"
9 #include "IO/Observer/Initialize.hpp"
10 #include "IO/Observer/Tags.hpp"
12 #include "Parallel/Invoke.hpp"
13 
14 namespace observers {
15 /*!
16  * \ingroup ObserversGroup
17  * \brief The group parallel component that is responsible for reducing data
18  * to be observed.
19  *
20  * Once the data from all elements on the processing element (usually a core)
21  * has been collected, it is copied (not sent over the network) to the local
22  * nodegroup parallel component, `ObserverWriter`, for writing to disk.
23  */
24 template <class Metavariables>
25 struct Observer {
26  using chare_type = Parallel::Algorithms::Group;
27  using const_global_cache_tag_list = tmpl::list<>;
29  using action_list = tmpl::list<>;
30 
31  using initial_databox = db::compute_databox_type<
32  typename Actions::Initialize<Metavariables>::return_tag_list>;
33 
34  using options = tmpl::list<>;
35 
36  static void initialize(
37  Parallel::CProxy_ConstGlobalCache<Metavariables>& global_cache) noexcept {
38  auto& local_cache = *(global_cache.ckLocalBranch());
39  Parallel::simple_action<Actions::Initialize<Metavariables>>(
40  Parallel::get_parallel_component<Observer>(local_cache));
41  }
42 
43  static void execute_next_phase(
44  const typename Metavariables::Phase /*next_phase*/,
45  Parallel::CProxy_ConstGlobalCache<
46  Metavariables>& /*global_cache*/) noexcept {}
47 };
48 
49 /*!
50  * \ingroup ObserversGroup
51  * \brief The nodegroup parallel component that is responsible for writing data
52  * to disk.
53  */
54 template <class Metavariables>
56  using chare_type = Parallel::Algorithms::Nodegroup;
57  using const_global_cache_tag_list =
58  tmpl::list<OptionTags::ReductionFileName, OptionTags::VolumeFileName>;
60  using action_list = tmpl::list<>;
61 
62  using initial_databox = db::compute_databox_type<
63  typename Actions::InitializeWriter<Metavariables>::return_tag_list>;
64 
65  using options = tmpl::list<>;
66 
67  static void initialize(
68  Parallel::CProxy_ConstGlobalCache<Metavariables>& global_cache) noexcept {
69  auto& local_cache = *(global_cache.ckLocalBranch());
70  Parallel::simple_action<Actions::InitializeWriter<Metavariables>>(
71  Parallel::get_parallel_component<ObserverWriter>(local_cache));
72  }
73 
74  static void execute_next_phase(
75  const typename Metavariables::Phase /*next_phase*/,
76  Parallel::CProxy_ConstGlobalCache<
77  Metavariables>& /*global_cache*/) noexcept {}
78 };
79 } // namespace observers
Definition: Actions.hpp:20
The nodegroup parallel component that is responsible for writing data to disk.
Definition: ObserverComponent.hpp:55
The group parallel component that is responsible for reducing data to be observed.
Definition: ObserverComponent.hpp:25
typename DataBox_detail::compute_dbox_type< get_items< TagList >, get_compute_items< TagList > >::type compute_databox_type
Returns the type of the DataBox that would be constructed from the TagList of tags.
Definition: DataBox.hpp:1827
Definition: SolvePoissonProblem.hpp:38
Defines class template ConstGlobalCache.