ElementDataReader.hpp
1 // Distributed under the MIT License.
2 // See LICENSE.txt for details.
3 
4 #pragma once
5 
6 #include <string>
7 #include <unordered_set>
8 
9 #include "IO/Importers/Tags.hpp"
10 #include "Parallel/Actions/SetupDataBox.hpp"
12 #include "Parallel/GlobalCache.hpp"
13 #include "Parallel/ParallelComponentHelpers.hpp"
14 #include "Parallel/PhaseDependentActionList.hpp"
15 #include "ParallelAlgorithms/Initialization/MergeIntoDataBox.hpp"
16 
17 namespace importers {
18 
19 namespace detail {
20 struct InitializeElementDataReader;
21 } // namespace detail
22 
23 /*!
24  * \brief A nodegroup parallel component that reads in a volume data file and
25  * distributes its data to elements of an array parallel component.
26  *
27  * Each element of the array parallel component must register itself before
28  * data can be sent to it. To do so, invoke
29  * `importers::Actions::RegisterWithElementDataReader` on each element. In a
30  * subsequent phase you can then invoke
31  * `importers::ThreadedActions::ReadVolumeData` on the `ElementDataReader`
32  * component to read in the file and distribute its data to the registered
33  * elements.
34  *
35  * \see Dev guide on \ref dev_guide_importing
36  */
37 template <typename Metavariables>
40  using metavariables = Metavariables;
41  using phase_dependent_action_list = tmpl::list<Parallel::PhaseActions<
42  typename Metavariables::Phase, Metavariables::Phase::Initialization,
43  tmpl::list<::Actions::SetupDataBox,
44  detail::InitializeElementDataReader>>>;
45  using initialization_tags = Parallel::get_initialization_tags<
47 
48  static void initialize(Parallel::CProxy_GlobalCache<
49  Metavariables>& /*global_cache*/) noexcept {}
50 
51  static void execute_next_phase(
52  const typename Metavariables::Phase next_phase,
53  Parallel::CProxy_GlobalCache<Metavariables>& global_cache) noexcept {
54  auto& local_cache = *(global_cache.ckLocalBranch());
55  Parallel::get_parallel_component<ElementDataReader>(local_cache)
56  .start_phase(next_phase);
57  }
58 };
59 
60 namespace detail {
61 struct InitializeElementDataReader {
62  using simple_tags =
63  tmpl::list<Tags::RegisteredElements, Tags::ElementDataAlreadyRead>;
64  using compute_tags = tmpl::list<>;
65 
66  template <typename DbTagsList, typename... InboxTags, typename Metavariables,
67  typename ArrayIndex, typename ActionList,
68  typename ParallelComponent>
69  static auto apply(db::DataBox<DbTagsList>& box,
70  const tuples::TaggedTuple<InboxTags...>& /*inboxes*/,
71  const Parallel::GlobalCache<Metavariables>& /*cache*/,
72  const ArrayIndex& /*array_index*/,
73  const ActionList /*meta*/,
74  const ParallelComponent* const /*meta*/) noexcept {
75  return std::make_tuple(std::move(box), true);
76  }
77 };
78 } // namespace detail
79 
80 } // namespace importers
Actions::SetupDataBox
Add into the DataBox default constructed items for the collection of tags requested by any of the act...
Definition: SetupDataBox.hpp:102
Parallel::GlobalCache
Definition: ElementReceiveInterpPoints.hpp:15
unordered_set
GlobalCache.hpp
importers
Items related to loading data from files.
Definition: ReadVolumeData.hpp:39
Parallel::get_initialization_tags
tmpl::remove_duplicates< tmpl::flatten< tmpl::list< AllocationTagsList, tmpl::transform< InitializationActionsList, detail::get_initialization_tags_from_action< tmpl::_1 > >> >> get_initialization_tags
Given a list of initialization actions, and possibly a list of tags needed for allocation of an array...
Definition: ParallelComponentHelpers.hpp:254
Parallel::get_initialization_actions_list
tmpl::flatten< tmpl::transform< PhaseDepActionList, detail::get_initialization_actions_list< tmpl::_1 > >> get_initialization_actions_list
Given the phase dependent action list, return the list of actions in the Initialization phase (or an ...
Definition: ParallelComponentHelpers.hpp:218
Parallel::PhaseActions
List of all the actions to be executed in the specified phase.
Definition: PhaseDependentActionList.hpp:16
importers::ElementDataReader
A nodegroup parallel component that reads in a volume data file and distributes its data to elements ...
Definition: ElementDataReader.hpp:38
tuples::TaggedTuple
An associative container that is indexed by structs.
Definition: TaggedTuple.hpp:271
Parallel::Algorithms::Nodegroup
A struct that stores the charm++ types relevant for a particular nodegroup component.
Definition: AlgorithmNodegroupDeclarations.hpp:31
AlgorithmNodegroup.hpp
string