InitializeWorldtubeBoundary.hpp
1 // Distributed under the MIT License.
2 // See LICENSE.txt for details.
3 
4 #pragma once
5 
6 #include <cstddef>
7 #include <tuple>
8 #include <utility>
9 
12 #include "DataStructures/VariablesTag.hpp"
13 #include "Evolution/Systems/Cce/BoundaryData.hpp"
14 #include "Evolution/Systems/Cce/InterfaceManagers/GhLockstepInterfaceManager.hpp"
15 #include "Evolution/Systems/Cce/InterfaceManagers/WorldtubeInterfaceManager.hpp"
16 #include "Evolution/Systems/Cce/OptionTags.hpp"
17 #include "Evolution/Systems/Cce/ReadBoundaryDataH5.hpp"
18 #include "Evolution/Systems/Cce/Tags.hpp"
19 #include "NumericalAlgorithms/Interpolation/SpanInterpolator.hpp"
20 #include "Parallel/Algorithm.hpp"
21 #include "Parallel/Info.hpp"
22 #include "Parallel/Invoke.hpp"
23 #include "ParallelAlgorithms/Initialization/MergeIntoDataBox.hpp"
24 #include "Utilities/Gsl.hpp"
25 #include "Utilities/Requires.hpp"
26 #include "Utilities/TMPL.hpp"
27 #include "Utilities/TaggedTuple.hpp"
28 
29 namespace Cce {
30 namespace Actions {
31 /*!
32  * \ingroup ActionsGroup
33  * \brief Initializes a H5WorldtubeBoundary
34  *
35  * \details Uses:
36  * - initialization tag
37  * `Cce::InitializationTags::H5WorldtubeBoundaryDataManager`,
38  * - const global cache tag `Cce::Tags::LMax`.
39  *
40  * Databox changes:
41  * - Adds:
42  * - `Cce::Tags::H5WorldtubeBoundaryDataManager`
43  * - `Tags::Variables<typename
44  * Metavariables::cce_boundary_communication_tags>`
45  * - Removes: nothing
46  * - Modifies: nothing
47  */
49  using initialization_tags =
50  tmpl::list<InitializationTags::H5WorldtubeBoundaryDataManager>;
51 
52  using const_global_cache_tags = tmpl::list<Tags::LMax>;
53 
54  template <class Metavariables>
55  using h5_boundary_manager_simple_tags = db::AddSimpleTags<
57  typename Metavariables::cce_boundary_communication_tags>,
59 
60  template <class Metavariables>
61  using return_tag_list = h5_boundary_manager_simple_tags<Metavariables>;
62 
63  template <typename DbTags, typename... InboxTags, typename Metavariables,
64  typename ArrayIndex, typename ActionList,
65  typename ParallelComponent,
66  Requires<tmpl::list_contains_v<
68  nullptr>
69  static auto apply(db::DataBox<DbTags>& box,
70  const tuples::TaggedTuple<InboxTags...>& /*inboxes*/,
72  const ArrayIndex& /*array_index*/,
73  const ActionList /*meta*/,
74  const ParallelComponent* const /*meta*/) noexcept {
75  const size_t l_max = db::get<Tags::LMax>(box);
76  Variables<typename Metavariables::cce_boundary_communication_tags>
77  boundary_variables{
79 
80  WorldtubeDataManager boundary_data_manager;
81  db::mutate<InitializationTags::H5WorldtubeBoundaryDataManager>(
82  make_not_null(&box),
83  [&boundary_data_manager](const gsl::not_null<WorldtubeDataManager*>
84  initialization_data_manager) noexcept {
85  boundary_data_manager = std::move(*initialization_data_manager);
86  });
87  auto initial_box = Initialization::merge_into_databox<
89  h5_boundary_manager_simple_tags<Metavariables>, db::AddComputeTags<>,
90  Initialization::MergePolicy::Overwrite>(
91  std::move(box), std::move(boundary_variables),
92  std::move(boundary_data_manager));
93 
94  return std::make_tuple(std::move(initial_box));
95  }
96 
97  template <typename DbTags, typename... InboxTags, typename Metavariables,
98  typename ArrayIndex, typename ActionList,
99  typename ParallelComponent,
100  Requires<not tmpl::list_contains_v<
101  DbTags, InitializationTags::H5WorldtubeBoundaryDataManager>> =
102  nullptr>
103  static auto apply(db::DataBox<DbTags>& box,
104  const tuples::TaggedTuple<InboxTags...>& /*inboxes*/,
106  const ArrayIndex& /*array_index*/,
107  const ActionList /*meta*/,
108  const ParallelComponent* const /*meta*/) noexcept {
109  return std::make_tuple(std::move(box));
110  }
111 };
112 
113 /*!
114  * \ingroup ActionsGroup
115  * \brief Initializes a GhWorldtubeBoundary
116  *
117  * \details Uses:
118  * - initialization tag
119  * `Cce::InitializationTags::GhWorldtubeBoundaryDataManager`,
120  * - const global cache tags `InitializationTags::LMax`,
121  * `InitializationTags::ExtractionRadius`.
122  *
123  * Databox changes:
124  * - Adds:
125  * - `Tags::Variables<typename
126  * Metavariables::cce_boundary_communication_tags>`
127  * - `Tags::GhInterfaceManager` (cloned from
128  * `InitializationTags::GhInterfaceManager`)
129  * - Removes: nothing
130  * - Modifies: nothing
131  */
133  using initialization_tags = tmpl::list<Tags::GhInterfaceManager>;
134 
135  using initialization_tags_to_keep = tmpl::list<Tags::GhInterfaceManager>;
136 
137  using const_global_cache_tags =
138  tmpl::list<Tags::LMax, InitializationTags::ExtractionRadius>;
139 
140  template <class Metavariables>
141  using gh_boundary_manager_simple_tags = db::AddSimpleTags<
143  typename Metavariables::cce_boundary_communication_tags>,
145 
146  template <typename DbTags, typename... InboxTags, typename Metavariables,
147  typename ArrayIndex, typename ActionList,
148  typename ParallelComponent,
150  nullptr>
151  static auto apply(db::DataBox<DbTags>& box,
152  const tuples::TaggedTuple<InboxTags...>& /*inboxes*/,
154  const ArrayIndex& /*array_index*/,
155  const ActionList /*meta*/,
156  const ParallelComponent* const /*meta*/) noexcept {
157  const size_t l_max = db::get<Tags::LMax>(box);
158  Variables<typename Metavariables::cce_boundary_communication_tags>
159  boundary_variables{
161 
162  auto initial_box = Initialization::merge_into_databox<
164  gh_boundary_manager_simple_tags<Metavariables>, db::AddComputeTags<>,
165  Initialization::MergePolicy::Overwrite>(
166  std::move(box), std::move(boundary_variables),
167  db::get<Tags::GhInterfaceManager>(box).get_clone());
168 
169  return std::make_tuple(std::move(initial_box));
170  }
171 
172  template <
173  typename DbTags, typename... InboxTags, typename Metavariables,
174  typename ArrayIndex, typename ActionList, typename ParallelComponent,
176  nullptr>
177  static auto apply(db::DataBox<DbTags>& box,
178  const tuples::TaggedTuple<InboxTags...>& /*inboxes*/,
180  const ArrayIndex& /*array_index*/,
181  const ActionList /*meta*/,
182  const ParallelComponent* const /*meta*/) noexcept {
183  ERROR(
184  "Required tag `Tags::GhInterfaceManager` is missing from the DataBox");
185  return std::make_tuple(std::move(box));
186  }
187 };
188 } // namespace Actions
189 } // namespace Cce
Definition: VariablesTag.hpp:21
#define ERROR(m)
prints an error message to the standard error stream and aborts the program.
Definition: Error.hpp:36
A simple tag for the WorldtubeDataManager
Definition: Tags.hpp:335
Defines functions for interfacing with the parallelization framework.
The set of utilities for performing Cauchy characteristic evolution and Cauchy characteristic matchin...
Definition: BoundaryComputeAndSendToEvolution.hpp:28
constexpr size_t number_of_swsh_collocation_points(const size_t l_max) noexcept
Convenience function for determining the number of spin-weighted spherical harmonic collocation value...
Definition: SwshCollocation.hpp:25
Definition: OptionTags.hpp:325
Defines the type alias Requires.
Initializes a H5WorldtubeBoundary.
Definition: InitializeWorldtubeBoundary.hpp:48
auto merge_into_databox(db::DataBox< DbTagsList > &&box, Args &&... args) noexcept
Add tags that are not yet in the DataBox.
Definition: MergeIntoDataBox.hpp:133
An associative container that is indexed by structs.
Definition: TaggedTuple.hpp:272
Defines classes and functions used for manipulating DataBox&#39;s.
An initialization tag that constructs a WorldtubeDataManager from options.
Definition: OptionTags.hpp:161
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
Initializes a GhWorldtubeBoundary.
Definition: InitializeWorldtubeBoundary.hpp:132
Wraps the template metaprogramming library used (brigand)
Defines functions and classes from the GSL.
gsl::not_null< T * > make_not_null(T *ptr) noexcept
Construct a not_null from a pointer. Often this will be done as an implicit conversion, but it may be necessary to perform the conversion explicitly when type deduction is desired.
Definition: Gsl.hpp:879
typename Requires_detail::requires_impl< B >::template_error_type_failed_to_meet_requirements_on_template_parameters Requires
Express requirements on the template parameters of a function or class, replaces std::enable_if_t ...
Definition: Requires.hpp:67
Definition: Test_ActionTesting.cpp:365
Defines classes SimpleTag, PrefixTag, ComputeTag and several functions for retrieving tag info...
Manages the cached buffer data associated with a CCE worldtube and interpolates to requested time poi...
Definition: ReadBoundaryDataH5.hpp:378
Definition: ComputeTimeDerivative.hpp:29
Require a pointer to not be a nullptr
Definition: Gsl.hpp:182
tmpl::flatten< tmpl::list< Tags... > > AddComputeTags
List of Compute Item Tags to add to the DataBox.
Definition: DataBox.hpp:1171