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/GhInterfaceManager.hpp"
15 #include "Evolution/Systems/Cce/InterfaceManagers/GhLockstep.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 =
53  tmpl::list<Tags::LMax, Tags::EndTimeFromFile, Tags::StartTimeFromFile>;
54 
55  template <class Metavariables>
56  using h5_boundary_manager_simple_tags = db::AddSimpleTags<
58  typename Metavariables::cce_boundary_communication_tags>,
60 
61  template <class Metavariables>
62  using return_tag_list = h5_boundary_manager_simple_tags<Metavariables>;
63 
64  template <typename DbTags, typename... InboxTags, typename Metavariables,
65  typename ArrayIndex, typename ActionList,
66  typename ParallelComponent,
67  Requires<tmpl::list_contains_v<
69  nullptr>
70  static auto apply(db::DataBox<DbTags>& box,
71  const tuples::TaggedTuple<InboxTags...>& /*inboxes*/,
73  const ArrayIndex& /*array_index*/,
74  const ActionList /*meta*/,
75  const ParallelComponent* const /*meta*/) noexcept {
76  const size_t l_max = db::get<Tags::LMax>(box);
77  Variables<typename Metavariables::cce_boundary_communication_tags>
78  boundary_variables{
80 
81  WorldtubeDataManager boundary_data_manager;
82  db::mutate<InitializationTags::H5WorldtubeBoundaryDataManager>(
83  make_not_null(&box),
84  [&boundary_data_manager](const gsl::not_null<WorldtubeDataManager*>
85  initialization_data_manager) noexcept {
86  boundary_data_manager = std::move(*initialization_data_manager);
87  });
88  auto initial_box = Initialization::merge_into_databox<
90  h5_boundary_manager_simple_tags<Metavariables>, db::AddComputeTags<>,
91  Initialization::MergePolicy::Overwrite>(
92  std::move(box), std::move(boundary_variables),
93  std::move(boundary_data_manager));
94 
95  return std::make_tuple(std::move(initial_box));
96  }
97 
98  template <typename DbTags, typename... InboxTags, typename Metavariables,
99  typename ArrayIndex, typename ActionList,
100  typename ParallelComponent,
101  Requires<not tmpl::list_contains_v<
103  nullptr>
104  static auto apply(db::DataBox<DbTags>& box,
105  const tuples::TaggedTuple<InboxTags...>& /*inboxes*/,
107  const ArrayIndex& /*array_index*/,
108  const ActionList /*meta*/,
109  const ParallelComponent* const /*meta*/) noexcept {
110  return std::make_tuple(std::move(box));
111  }
112 };
113 
114 /*!
115  * \ingroup ActionsGroup
116  * \brief Initializes a GhWorldtubeBoundary
117  *
118  * \details Uses:
119  * - initialization tag
120  * `Cce::InitializationTags::GhWorldtubeBoundaryDataManager`,
121  * - const global cache tags `InitializationTags::LMax`,
122  * `InitializationTags::ExtractionRadius`.
123  *
124  * Databox changes:
125  * - Adds:
126  * - `Tags::Variables<typename
127  * Metavariables::cce_boundary_communication_tags>`
128  * - `Tags::GhInterfaceManager` (cloned from
129  * `InitializationTags::GhInterfaceManager`)
130  * - Removes: nothing
131  * - Modifies: nothing
132  */
134  using initialization_tags = tmpl::list<Tags::GhInterfaceManager>;
135 
136  using initialization_tags_to_keep = tmpl::list<Tags::GhInterfaceManager>;
137 
138  using const_global_cache_tags =
141 
142  template <class Metavariables>
143  using gh_boundary_manager_simple_tags = db::AddSimpleTags<
145  typename Metavariables::cce_boundary_communication_tags>,
147 
148  template <typename DbTags, typename... InboxTags, typename Metavariables,
149  typename ArrayIndex, typename ActionList,
150  typename ParallelComponent,
152  nullptr>
153  static auto apply(db::DataBox<DbTags>& box,
154  const tuples::TaggedTuple<InboxTags...>& /*inboxes*/,
156  const ArrayIndex& /*array_index*/,
157  const ActionList /*meta*/,
158  const ParallelComponent* const /*meta*/) noexcept {
159  const size_t l_max = db::get<Tags::LMax>(box);
160  Variables<typename Metavariables::cce_boundary_communication_tags>
161  boundary_variables{
163 
164  auto initial_box = Initialization::merge_into_databox<
166  gh_boundary_manager_simple_tags<Metavariables>, db::AddComputeTags<>,
167  Initialization::MergePolicy::Overwrite>(
168  std::move(box), std::move(boundary_variables),
169  db::get<Tags::GhInterfaceManager>(box).get_clone());
170 
171  return std::make_tuple(std::move(initial_box));
172  }
173 
174  template <
175  typename DbTags, typename... InboxTags, typename Metavariables,
176  typename ArrayIndex, typename ActionList, typename ParallelComponent,
178  nullptr>
179  static auto apply(db::DataBox<DbTags>& box,
180  const tuples::TaggedTuple<InboxTags...>& /*inboxes*/,
182  const ArrayIndex& /*array_index*/,
183  const ActionList /*meta*/,
184  const ParallelComponent* const /*meta*/) noexcept {
185  ERROR(
186  "Required tag `Tags::GhInterfaceManager` is missing from the DataBox");
187  return std::make_tuple(std::move(box));
188  }
189 };
190 } // namespace Actions
191 } // namespace Cce
Parallel::ConstGlobalCache
Definition: ElementReceiveInterpPoints.hpp:16
DataBoxTag.hpp
Cce::Actions::InitializeGhWorldtubeBoundary
Initializes a GhWorldtubeBoundary.
Definition: InitializeWorldtubeBoundary.hpp:133
utility
Tags::Variables
Definition: VariablesTag.hpp:21
db::AddComputeTags
tmpl::flatten< tmpl::list< Tags... > > AddComputeTags
List of Compute Item Tags to add to the DataBox.
Definition: DataBox.hpp:1171
tuple
Info.hpp
Cce::InitializationTags::H5WorldtubeBoundaryDataManager
An initialization tag that constructs a WorldtubeDataManager from options.
Definition: OptionTags.hpp:158
ERROR
#define ERROR(m)
prints an error message to the standard error stream and aborts the program.
Definition: Error.hpp:36
DataBox.hpp
cstddef
Cce::Tags::NoEndTime
Represents the final time of a CCE evolution that should just proceed until it receives no more bound...
Definition: OptionTags.hpp:345
tuples::TaggedTuple
An associative container that is indexed by structs.
Definition: TaggedTuple.hpp:272
Cce::Actions::InitializeH5WorldtubeBoundary
Initializes a H5WorldtubeBoundary.
Definition: InitializeWorldtubeBoundary.hpp:48
db::AddSimpleTags
tmpl::flatten< tmpl::list< Tags... > > AddSimpleTags
List of Tags to add to the DataBox.
Definition: DataBox.hpp:1150
Cce::Tags::GhInterfaceManager
Definition: OptionTags.hpp:368
Cce
The set of utilities for performing Cauchy characteristic evolution and Cauchy characteristic matchin...
Definition: BoundaryComputeAndSendToEvolution.hpp:28
Gsl.hpp
Cce::Tags::H5WorldtubeBoundaryDataManager
A simple tag for the WorldtubeDataManager
Definition: Tags.hpp:336
Requires.hpp
Initialization::merge_into_databox
auto merge_into_databox(db::DataBox< DbTagsList > &&box, Args &&... args) noexcept
Add tags that are not yet in the DataBox.
Definition: MergeIntoDataBox.hpp:133
Cce::Tags::LMax
Definition: OptionTags.hpp:218
make_not_null
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,...
Definition: Gsl.hpp:880
Requires
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
Cce::Tags::SpecifiedStartTime
Represents the start time of a bounded CCE evolution that must be supplied in the input file (for e....
Definition: OptionTags.hpp:308
db::DataBox
Definition: InterpolationTargetWedgeSectionTorus.hpp:24
Cce::WorldtubeDataManager
Manages the cached buffer data associated with a CCE worldtube and interpolates to requested time poi...
Definition: ReadBoundaryDataH5.hpp:378
TMPL.hpp
Cce::InitializationTags::ExtractionRadius
Definition: OptionTags.hpp:196
gsl::not_null
Require a pointer to not be a nullptr
Definition: Gsl.hpp:183
Spectral::Swsh::number_of_swsh_collocation_points
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