VolumeDataReader.hpp
1 // Distributed under the MIT License.
2 // See LICENSE.txt for details.
3 
4 #pragma once
5 
6 #include "AlgorithmNodegroup.hpp"
7 #include "IO/Importers/Tags.hpp"
9 #include "Parallel/ParallelComponentHelpers.hpp"
10 #include "Parallel/PhaseDependentActionList.hpp"
11 #include "ParallelAlgorithms/Initialization/MergeIntoDataBox.hpp"
12 
13 namespace importers {
14 
15 namespace detail {
16 struct InitializeVolumeDataReader;
17 } // namespace detail
18 
19 /*!
20  * \brief A nodegroup parallel component that reads in a volume data file and
21  * distributes its data to elements of an array parallel component.
22  *
23  * Each element of the array parallel component must register itself before
24  * data can be sent to it. To do so, invoke
25  * `importers::Actions::RegisterWithVolumeDataReader` on each element. In a
26  * subsequent phase you can then invoke
27  * `importers::ThreadedActions::ReadVolumeData` on the `VolumeDataReader`
28  * component to read in the file and distribute its data to the registered
29  * elements.
30  */
31 template <typename Metavariables>
33  using chare_type = Parallel::Algorithms::Nodegroup;
34  using metavariables = Metavariables;
35  using phase_dependent_action_list = tmpl::list<Parallel::PhaseActions<
36  typename Metavariables::Phase, Metavariables::Phase::Initialization,
37  tmpl::list<detail::InitializeVolumeDataReader>>>;
38  using initialization_tags = Parallel::get_initialization_tags<
40 
41  static void initialize(Parallel::CProxy_ConstGlobalCache<
42  Metavariables>& /*global_cache*/) noexcept {}
43 
44  static void execute_next_phase(
45  const typename Metavariables::Phase next_phase,
46  Parallel::CProxy_ConstGlobalCache<Metavariables>& global_cache) noexcept {
47  auto& local_cache = *(global_cache.ckLocalBranch());
48  Parallel::get_parallel_component<VolumeDataReader>(local_cache)
49  .start_phase(next_phase);
50  }
51 };
52 
53 namespace detail {
54 struct InitializeVolumeDataReader {
55  template <typename DbTagsList, typename... InboxTags, typename Metavariables,
56  typename ArrayIndex, typename ActionList,
57  typename ParallelComponent>
58  static auto apply(db::DataBox<DbTagsList>& box,
59  const tuples::TaggedTuple<InboxTags...>& /*inboxes*/,
61  const ArrayIndex& /*array_index*/,
62  const ActionList /*meta*/,
63  const ParallelComponent* const /*meta*/) noexcept {
65  using compute_tags = db::AddComputeTags<>;
66 
67  return std::make_tuple(
68  ::Initialization::merge_into_databox<InitializeVolumeDataReader,
69  simple_tags, compute_tags>(
70  std::move(box), db::item_type<Tags::RegisteredElements>{}),
71  true);
72  }
73 };
74 } // namespace detail
75 
76 } // namespace importers
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:140
A nodegroup parallel component that reads in a volume data file and distributes its data to elements ...
Definition: VolumeDataReader.hpp:32
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:104
auto merge_into_databox(db::DataBox< DbTagsList > &&box, Args &&... args) noexcept
Add tags that are not yet in the DataBox.
Definition: MergeIntoDataBox.hpp:133
Definition: Determinant.hpp:11
An associative container that is indexed by structs.
Definition: TaggedTuple.hpp:272
tmpl::flatten< tmpl::list< Tags... > > AddSimpleTags
List of Tags to add to the DataBox.
Definition: DataBox.hpp:1150
Definition: InterpolationTargetWedgeSectionTorus.hpp:25
A Charm++ chare that caches constant data once per Charm++ node.
Definition: ConstGlobalCache.hpp:136
constexpr auto apply(F &&f, const DataBox< BoxTags > &box, Args &&... args) noexcept
Apply the invokable f with argument Tags TagsList from DataBox box
Definition: DataBox.hpp:1444
Items related to loading data from files.
Definition: ElementActions.hpp:18
List of all the actions to be executed in the specified phase.
Definition: PhaseDependentActionList.hpp:16
typename DataBox_detail::item_type_impl< TagList, Tag >::type item_type
Get the type that can be written to the Tag. If it is a base tag then a TagList must be passed as a s...
Definition: DataBoxTag.hpp:246
Definition: Test_ActionTesting.cpp:365
Defines class template ConstGlobalCache.
tmpl::flatten< tmpl::list< Tags... > > AddComputeTags
List of Compute Item Tags to add to the DataBox.
Definition: DataBox.hpp:1171