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 
11 #include "DataStructures/VariablesTag.hpp"
12 #include "Evolution/Systems/Cce/AnalyticBoundaryDataManager.hpp"
13 #include "Evolution/Systems/Cce/AnalyticSolutions/RobinsonTrautman.hpp"
14 #include "Evolution/Systems/Cce/BoundaryData.hpp"
15 #include "Evolution/Systems/Cce/InterfaceManagers/GhInterfaceManager.hpp"
16 #include "Evolution/Systems/Cce/InterfaceManagers/GhLocalTimeStepping.hpp"
17 #include "Evolution/Systems/Cce/InterfaceManagers/GhLockstep.hpp"
18 #include "Evolution/Systems/Cce/OptionTags.hpp"
19 #include "Evolution/Systems/Cce/Tags.hpp"
20 #include "NumericalAlgorithms/Interpolation/SpanInterpolator.hpp"
21 #include "NumericalAlgorithms/Spectral/SwshCollocation.hpp"
22 #include "Parallel/Invoke.hpp"
23 #include "ParallelAlgorithms/Initialization/MutateAssign.hpp"
24 #include "Utilities/Gsl.hpp"
25 #include "Utilities/MakeString.hpp"
26 #include "Utilities/Requires.hpp"
27 #include "Utilities/TMPL.hpp"
28 #include "Utilities/TaggedTuple.hpp"
29 
30 namespace Cce {
31 /// \cond
32 template <typename Metavariables>
33 struct H5WorldtubeBoundary;
34 template <typename Metavariables>
35 struct AnalyticWorldtubeBoundary;
36 template <typename Metavariables>
37 struct GhWorldtubeBoundary;
38 /// \endcond
39 namespace Actions {
40 
41 namespace detail {
42 template <typename Initializer, typename ManagerTags,
43  typename BoundaryCommunicationTagsList>
44 struct InitializeWorldtubeBoundaryBase {
45  using initialization_tags = ManagerTags;
46  using initialization_tags_to_keep = ManagerTags;
47  using const_global_cache_tags = tmpl::list<Tags::LMax>;
48 
49  using simple_tags =
50  tmpl::list<::Tags::Variables<BoundaryCommunicationTagsList>>;
51 
52  template <typename DataBoxTagsList, typename... InboxTags,
53  typename ArrayIndex, typename Metavariables, typename ActionList,
54  typename ParallelComponent>
55  static auto apply(db::DataBox<DataBoxTagsList>& box,
56  const tuples::TaggedTuple<InboxTags...>& /*inboxes*/,
57  const Parallel::GlobalCache<Metavariables>& /*cache*/,
58  const ArrayIndex& /*array_index*/,
59  const ActionList /*meta*/,
60  const ParallelComponent* const /*meta*/) noexcept {
61  if constexpr (std::is_same_v<Tags::AnalyticBoundaryDataManager,
62  tmpl::front<ManagerTags>>) {
63  if (dynamic_cast<const Solutions::RobinsonTrautman*>(
64  &(db::get<Tags::AnalyticBoundaryDataManager>(box)
65  .get_generator())) != nullptr) {
66  if(db::get<::Tags::TimeStepper<>>(box).number_of_substeps() != 1) {
67  ERROR(
68  "Do not use RobinsonTrautman analytic solution with a "
69  "substep-based timestepper. This is to prevent severe slowdowns "
70  "in the current RobinsonTrautman implementation. See the "
71  "documentation for the RobinsonTrautman solution for details.");
72  }
73  }
74  }
75  if constexpr (tmpl::list_contains_v<DataBoxTagsList,
76  tmpl::front<ManagerTags>>) {
77  const size_t l_max = db::get<Tags::LMax>(box);
78  Variables<BoundaryCommunicationTagsList> boundary_variables{
80 
81  Initialization::mutate_assign<simple_tags>(make_not_null(&box),
82  std::move(boundary_variables));
83  return std::make_tuple(std::move(box));
84  } else {
85  ERROR(MakeString{} << "Missing required boundary manager tag : "
86  << db::tag_name<tmpl::front<ManagerTags>>);
87  }
88  }
89 };
90 } // namespace detail
91 
92 /*!
93  * \ingroup ActionsGroup
94  * \brief Generic action for initializing various worldtube boundary components.
95  *
96  * \details See specializations of this class for initialization details for
97  * individual worldtube components.
98  */
99 template <typename WorldtubeComponent>
101 
102 /*!
103  * \ingroup ActionsGroup
104  * \brief Initializes a H5WorldtubeBoundary
105  *
106  * \details Uses:
107  * - initialization tag
108  * `Cce::Tags::H5WorldtubeBoundaryDataManager`,
109  * - const global cache tag `Cce::Tags::LMax`.
110  *
111  * Databox changes:
112  * - Adds:
113  * - `Cce::Tags::H5WorldtubeBoundaryDataManager`
114  * - `Tags::Variables<typename
115  * Metavariables::cce_boundary_communication_tags>`
116  * - Removes: nothing
117  * - Modifies: nothing
118  *
119  * \note This action relies on the `SetupDataBox` aggregated initialization
120  * mechanism, so `Actions::SetupDataBox` must be present in the `Initialization`
121  * phase action list prior to this action.
122  */
123 template <typename Metavariables>
125  : public detail::InitializeWorldtubeBoundaryBase<
126  InitializeWorldtubeBoundary<H5WorldtubeBoundary<Metavariables>>,
127  tmpl::list<Tags::H5WorldtubeBoundaryDataManager>,
128  typename Metavariables::cce_boundary_communication_tags> {
129  using base_type = detail::InitializeWorldtubeBoundaryBase<
131  tmpl::list<Tags::H5WorldtubeBoundaryDataManager>,
132  typename Metavariables::cce_boundary_communication_tags>;
133  using base_type::apply;
134  using typename base_type::simple_tags;
135  using const_global_cache_tags =
136  tmpl::list<Tags::LMax, Tags::EndTimeFromFile, Tags::StartTimeFromFile>;
137  using typename base_type::initialization_tags;
138  using typename base_type::initialization_tags_to_keep;
139 };
140 
141 /*!
142  * \ingroup ActionsGroup
143  * \brief Initializes a GhWorldtubeBoundary
144  *
145  * \details Uses:
146  * - initialization tags
147  * `Cce::Tags::GhWorldtubeBoundaryDataManager`, `Tags::GhInterfaceManager`
148  * - const global cache tags `Tags::LMax`, `Tags::ExtractionRadius`.
149  *
150  * Databox changes:
151  * - Adds:
152  * - `Tags::Variables<typename
153  * Metavariables::cce_boundary_communication_tags>`
154  * - Removes: nothing
155  * - Modifies: nothing
156  *
157  * \note This action relies on the `SetupDataBox` aggregated initialization
158  * mechanism, so `Actions::SetupDataBox` must be present in the `Initialization`
159  * phase action list prior to this action.
160  */
161 template <typename Metavariables>
163  : public detail::InitializeWorldtubeBoundaryBase<
164  InitializeWorldtubeBoundary<GhWorldtubeBoundary<Metavariables>>,
165  tmpl::list<Tags::GhInterfaceManager,
166  Tags::SelfStartGhInterfaceManager>,
167  typename Metavariables::cce_boundary_communication_tags> {
168  using base_type = detail::InitializeWorldtubeBoundaryBase<
170  tmpl::list<Tags::GhInterfaceManager, Tags::SelfStartGhInterfaceManager>,
171  typename Metavariables::cce_boundary_communication_tags>;
172  using base_type::apply;
173  using typename base_type::simple_tags;
174 
175  using const_global_cache_tags =
179  using typename base_type::initialization_tags;
180  using typename base_type::initialization_tags_to_keep;
181 };
182 
183 /*!
184  * \ingroup ActionsGroup
185  * \brief Initializes an AnalyticWorldtubeBoundary
186  *
187  * \details Uses:
188  * - initialization tag
189  * `Cce::Tags::AnalyticBoundaryDataManager`,
190  * - const global cache tags `Tags::LMax`,
191  * `Tags::ExtractionRadius`.
192  *
193  * Databox changes:
194  * - Adds:
195  * - `Tags::Variables<typename
196  * Metavariables::cce_boundary_communication_tags>`
197  * - Removes: nothing
198  * - Modifies: nothing
199  *
200  * \note This action relies on the `SetupDataBox` aggregated initialization
201  * mechanism, so `Actions::SetupDataBox` must be present in the `Initialization`
202  * phase action list prior to this action.
203  */
204 template <typename Metavariables>
206  : public detail::InitializeWorldtubeBoundaryBase<
207  InitializeWorldtubeBoundary<AnalyticWorldtubeBoundary<Metavariables>>,
208  tmpl::list<Tags::AnalyticBoundaryDataManager,
209  Tags::CceEvolutionPrefix<::Tags::TimeStepper<
210  tmpl::conditional_t<Metavariables::local_time_stepping,
211  LtsTimeStepper, TimeStepper>>>>,
212  typename Metavariables::cce_boundary_communication_tags> {
213  using base_type = detail::InitializeWorldtubeBoundaryBase<
217  tmpl::conditional_t<Metavariables::local_time_stepping,
219  typename Metavariables::cce_boundary_communication_tags>;
220  using base_type::apply;
221  using typename base_type::simple_tags;
222  using const_global_cache_tags =
223  tmpl::list<Tags::LMax, Tags::SpecifiedEndTime, Tags::SpecifiedStartTime>;
224  using typename base_type::initialization_tags;
225  using typename base_type::initialization_tags_to_keep;
226 };
227 } // namespace Actions
228 } // namespace Cce
std::apply
T apply(T... args)
Cce::Tags::CceEvolutionPrefix
Tag for duplicating functionality of another tag, but allows creation from options in the Cce::Evolut...
Definition: OptionTags.hpp:250
utility
Parallel::GlobalCache
Definition: ElementReceiveInterpPoints.hpp:15
Cce::Tags::InterfaceManagerInterpolationStrategy
Intended for use in the const global cache to communicate to the sending elements when they should be...
Definition: OptionTags.hpp:508
tuple
db::get
const auto & get(const DataBox< TagList > &box) noexcept
Retrieve the item with tag Tag from the DataBox.
Definition: DataBox.hpp:791
Cce::H5WorldtubeBoundary
Component that supplies CCE worldtube boundary data.
Definition: CharacteristicExtractFwd.hpp:8
ERROR
#define ERROR(m)
prints an error message to the standard error stream and aborts the program.
Definition: Error.hpp:37
DataBox.hpp
cstddef
TimeStepper
Definition: TimeStepper.hpp:47
Cce::Tags::NoEndTime
Represents the final time of a CCE evolution that should just proceed until it receives no more bound...
Definition: OptionTags.hpp:455
tuples::TaggedTuple
An associative container that is indexed by structs.
Definition: TaggedTuple.hpp:271
Cce::Tags::AnalyticBoundaryDataManager
A tag that constructs a AnalyticBoundaryDataManager from options.
Definition: OptionTags.hpp:552
Cce
The set of utilities for performing Cauchy characteristic evolution and Cauchy characteristic matchin...
Definition: CharacteristicExtractFwd.hpp:6
Gsl.hpp
LtsTimeStepper
Definition: TimeStepper.hpp:159
Tags::TimeStepper
Tag for a TimeStepper of type StepperType.
Definition: Tags.hpp:214
Requires.hpp
Cce::Tags::LMax
Definition: OptionTags.hpp:308
Cce::GhWorldtubeBoundary
Component that supplies CCE worldtube boundary data sourced from a running GH system.
Definition: WorldtubeBoundary.hpp:166
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
Cce::Actions::InitializeWorldtubeBoundary
Generic action for initializing various worldtube boundary components.
Definition: InitializeWorldtubeBoundary.hpp:100
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:405
Cce::AnalyticWorldtubeBoundary
Component that supplies CCE worldtube boundary data sourced from an analytic solution.
Definition: CharacteristicExtractFwd.hpp:11
TMPL.hpp
Cce::InitializationTags::ExtractionRadius
Definition: OptionTags.hpp:225
MakeString
Make a string by streaming into object.
Definition: MakeString.hpp:18
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:24