Line data Source code
1 0 : // Distributed under the MIT License.
2 : // See LICENSE.txt for details.
3 :
4 : #pragma once
5 :
6 : #include <cstddef>
7 : #include <optional>
8 : #include <tuple>
9 : #include <utility>
10 :
11 : #include "DataStructures/DataBox/DataBox.hpp"
12 : #include "DataStructures/VariablesTag.hpp"
13 : #include "Evolution/Systems/Cce/AnalyticBoundaryDataManager.hpp"
14 : #include "Evolution/Systems/Cce/AnalyticSolutions/RobinsonTrautman.hpp"
15 : #include "Evolution/Systems/Cce/BoundaryData.hpp"
16 : #include "Evolution/Systems/Cce/InterfaceManagers/GhInterfaceManager.hpp"
17 : #include "Evolution/Systems/Cce/InterfaceManagers/GhLocalTimeStepping.hpp"
18 : #include "Evolution/Systems/Cce/InterfaceManagers/GhLockstep.hpp"
19 : #include "Evolution/Systems/Cce/OptionTags.hpp"
20 : #include "Evolution/Systems/Cce/Tags.hpp"
21 : #include "NumericalAlgorithms/Interpolation/SpanInterpolator.hpp"
22 : #include "NumericalAlgorithms/SpinWeightedSphericalHarmonics/SwshCollocation.hpp"
23 : #include "Parallel/AlgorithmExecution.hpp"
24 : #include "Parallel/Invoke.hpp"
25 : #include "ParallelAlgorithms/Initialization/MutateAssign.hpp"
26 : #include "Time/Tags/TimeStepper.hpp"
27 : #include "Time/TimeSteppers/LtsTimeStepper.hpp"
28 : #include "Time/TimeSteppers/TimeStepper.hpp"
29 : #include "Utilities/Gsl.hpp"
30 : #include "Utilities/MakeString.hpp"
31 : #include "Utilities/Requires.hpp"
32 : #include "Utilities/TMPL.hpp"
33 : #include "Utilities/TaggedTuple.hpp"
34 :
35 : namespace Cce {
36 : /// \cond
37 : template <typename Metavariables>
38 : struct H5WorldtubeBoundary;
39 : template <typename Metavariables>
40 : struct AnalyticWorldtubeBoundary;
41 : template <typename Metavariables>
42 : struct KleinGordonH5WorldtubeBoundary;
43 : template <typename Metavariables>
44 : struct GhWorldtubeBoundary;
45 : /// \endcond
46 : namespace Actions {
47 :
48 : namespace detail {
49 : template <typename Initializer, typename ManagerTags,
50 : typename... BoundaryCommunicationTagsList>
51 : struct InitializeWorldtubeBoundaryBase {
52 : using simple_tags_from_options = ManagerTags;
53 : using const_global_cache_tags = tmpl::list<Tags::LMax>;
54 :
55 : using simple_tags =
56 : tmpl::list<::Tags::Variables<BoundaryCommunicationTagsList>...>;
57 :
58 : template <typename DataBoxTagsList, typename... InboxTags,
59 : typename ArrayIndex, typename Metavariables, typename ActionList,
60 : typename ParallelComponent>
61 : static Parallel::iterable_action_return_t apply(
62 : db::DataBox<DataBoxTagsList>& box,
63 : const tuples::TaggedTuple<InboxTags...>& /*inboxes*/,
64 : const Parallel::GlobalCache<Metavariables>& /*cache*/,
65 : const ArrayIndex& /*array_index*/, const ActionList /*meta*/,
66 : const ParallelComponent* const /*meta*/) {
67 : if constexpr (std::is_same_v<Tags::AnalyticBoundaryDataManager,
68 : tmpl::front<ManagerTags>>) {
69 : if (dynamic_cast<const Solutions::RobinsonTrautman*>(
70 : &(db::get<Tags::AnalyticBoundaryDataManager>(box)
71 : .get_generator())) != nullptr) {
72 : if (db::get<Tags::CceEvolutionPrefix<
73 : ::Tags::ConcreteTimeStepper<LtsTimeStepper>>>(box)
74 : .number_of_substeps() != 1) {
75 : ERROR(
76 : "Do not use RobinsonTrautman analytic solution with a "
77 : "substep-based timestepper. This is to prevent severe slowdowns "
78 : "in the current RobinsonTrautman implementation. See the "
79 : "documentation for the RobinsonTrautman solution for details.");
80 : }
81 : }
82 : }
83 : const size_t l_max = db::get<Tags::LMax>(box);
84 :
85 : Initialization::mutate_assign<simple_tags>(
86 : make_not_null(&box),
87 : Variables<BoundaryCommunicationTagsList>{
88 : Spectral::Swsh::number_of_swsh_collocation_points(l_max)}...);
89 : return {Parallel::AlgorithmExecution::Continue, std::nullopt};
90 : }
91 : };
92 : } // namespace detail
93 :
94 : /*!
95 : * \ingroup ActionsGroup
96 : * \brief Generic action for initializing various worldtube boundary components.
97 : *
98 : * \details See specializations of this class for initialization details for
99 : * individual worldtube components.
100 : */
101 : template <typename WorldtubeComponent>
102 1 : struct InitializeWorldtubeBoundary;
103 :
104 : /*!
105 : * \ingroup ActionsGroup
106 : * \brief Initializes a H5WorldtubeBoundary
107 : *
108 : * \details Uses:
109 : * - simple tags from options
110 : * `Cce::Tags::H5WorldtubeBoundaryDataManager`,
111 : * - const global cache tag `Cce::Tags::LMax`, `Tags::ExtractionRadiusFromH5`.
112 : *
113 : * Databox changes:
114 : * - Adds:
115 : * - `Cce::Tags::H5WorldtubeBoundaryDataManager`
116 : * - `Tags::Variables<typename
117 : * Metavariables::cce_boundary_communication_tags>`
118 : * - Removes: nothing
119 : * - Modifies: nothing
120 : */
121 : template <typename Metavariables>
122 1 : struct InitializeWorldtubeBoundary<H5WorldtubeBoundary<Metavariables>>
123 : : public detail::InitializeWorldtubeBoundaryBase<
124 : InitializeWorldtubeBoundary<H5WorldtubeBoundary<Metavariables>>,
125 : tmpl::list<Tags::H5WorldtubeBoundaryDataManager>,
126 : typename Metavariables::cce_boundary_communication_tags> {
127 0 : using base_type = detail::InitializeWorldtubeBoundaryBase<
128 : InitializeWorldtubeBoundary<H5WorldtubeBoundary<Metavariables>>,
129 : tmpl::list<Tags::H5WorldtubeBoundaryDataManager>,
130 : typename Metavariables::cce_boundary_communication_tags>;
131 : using base_type::apply;
132 : using typename base_type::simple_tags;
133 0 : using const_global_cache_tags =
134 : tmpl::list<Tags::LMax, Tags::ExtractionRadiusFromH5,
135 : Tags::EndTimeFromFile, Tags::StartTimeFromFile>;
136 : using typename base_type::simple_tags_from_options;
137 : };
138 :
139 : /*!
140 : * \ingroup ActionsGroup
141 : * \brief Initializes a KleinGordonH5WorldtubeBoundary
142 : *
143 : * \details Uses:
144 : * - simple tags from options
145 : * `Cce::Tags::H5WorldtubeBoundaryDataManager`,
146 : * `Cce::Tags::KleinGordonH5WorldtubeBoundaryDataManager`.
147 : * - const global cache tag `Cce::Tags::LMax`, `Tags::ExtractionRadiusFromH5`.
148 : *
149 : * Databox changes:
150 : * - Adds:
151 : * - `Cce::Tags::H5WorldtubeBoundaryDataManager`
152 : * - `Cce::Tags::KleinGordonH5WorldtubeBoundaryDataManager`
153 : * - `Tags::Variables<typename
154 : * Metavariables::cce_boundary_communication_tags>`
155 : * - `Tags::Variables<typename
156 : * Metavariables::klein_gordon_boundary_communication_tags>`
157 : * - Removes: nothing
158 : * - Modifies: nothing
159 : */
160 : template <typename Metavariables>
161 1 : struct InitializeWorldtubeBoundary<
162 : KleinGordonH5WorldtubeBoundary<Metavariables>>
163 : : public detail::InitializeWorldtubeBoundaryBase<
164 : InitializeWorldtubeBoundary<
165 : KleinGordonH5WorldtubeBoundary<Metavariables>>,
166 : tmpl::list<Tags::H5WorldtubeBoundaryDataManager,
167 : Tags::KleinGordonH5WorldtubeBoundaryDataManager>,
168 : typename Metavariables::cce_boundary_communication_tags,
169 : typename Metavariables::klein_gordon_boundary_communication_tags> {
170 0 : using base_type = detail::InitializeWorldtubeBoundaryBase<
171 : InitializeWorldtubeBoundary<
172 : KleinGordonH5WorldtubeBoundary<Metavariables>>,
173 : tmpl::list<Tags::H5WorldtubeBoundaryDataManager,
174 : Tags::KleinGordonH5WorldtubeBoundaryDataManager>,
175 : typename Metavariables::cce_boundary_communication_tags,
176 : typename Metavariables::klein_gordon_boundary_communication_tags>;
177 : using base_type::apply;
178 : using typename base_type::simple_tags;
179 0 : using const_global_cache_tags =
180 : tmpl::list<Tags::LMax, Tags::ExtractionRadiusFromH5,
181 : Tags::EndTimeFromFile, Tags::StartTimeFromFile>;
182 : using typename base_type::simple_tags_from_options;
183 : };
184 :
185 : /*!
186 : * \ingroup ActionsGroup
187 : * \brief Initializes a GhWorldtubeBoundary
188 : *
189 : * \details Uses:
190 : * - simple tags from options
191 : * `Cce::Tags::GhWorldtubeBoundaryDataManager`, `Tags::GhInterfaceManager`
192 : * - const global cache tags `Tags::LMax`, `Tags::ExtractionRadiusSimple`.
193 : *
194 : * Databox changes:
195 : * - Adds:
196 : * - `Tags::Variables<typename
197 : * Metavariables::cce_boundary_communication_tags>`
198 : * - Removes: nothing
199 : * - Modifies: nothing
200 : */
201 : template <typename Metavariables>
202 1 : struct InitializeWorldtubeBoundary<GhWorldtubeBoundary<Metavariables>>
203 : : public detail::InitializeWorldtubeBoundaryBase<
204 : InitializeWorldtubeBoundary<GhWorldtubeBoundary<Metavariables>>,
205 : tmpl::list<Tags::GhInterfaceManager,
206 : Tags::SelfStartGhInterfaceManager>,
207 : typename Metavariables::cce_boundary_communication_tags> {
208 0 : using base_type = detail::InitializeWorldtubeBoundaryBase<
209 : InitializeWorldtubeBoundary<GhWorldtubeBoundary<Metavariables>>,
210 : tmpl::list<Tags::GhInterfaceManager, Tags::SelfStartGhInterfaceManager>,
211 : typename Metavariables::cce_boundary_communication_tags>;
212 : using base_type::apply;
213 : using typename base_type::simple_tags;
214 :
215 0 : using const_global_cache_tags =
216 : tmpl::list<Tags::LMax, Tags::ExtractionRadiusSimple, Tags::NoEndTime,
217 : Tags::SpecifiedStartTime>;
218 : using typename base_type::simple_tags_from_options;
219 : };
220 :
221 : /*!
222 : * \ingroup ActionsGroup
223 : * \brief Initializes an AnalyticWorldtubeBoundary
224 : *
225 : * \details Uses:
226 : * - simple tags from options
227 : * `Cce::Tags::AnalyticBoundaryDataManager`,
228 : * - const global cache tags `Tags::LMax`,
229 : * `Tags::ExtractionRadiusSimple`.
230 : *
231 : * Databox changes:
232 : * - Adds:
233 : * - `Tags::Variables<typename
234 : * Metavariables::cce_boundary_communication_tags>`
235 : * - Removes: nothing
236 : * - Modifies: nothing
237 : */
238 : template <typename Metavariables>
239 1 : struct InitializeWorldtubeBoundary<AnalyticWorldtubeBoundary<Metavariables>>
240 : : public detail::InitializeWorldtubeBoundaryBase<
241 : InitializeWorldtubeBoundary<AnalyticWorldtubeBoundary<Metavariables>>,
242 : tmpl::list<Tags::AnalyticBoundaryDataManager>,
243 : typename Metavariables::cce_boundary_communication_tags> {
244 0 : using base_type = detail::InitializeWorldtubeBoundaryBase<
245 : InitializeWorldtubeBoundary<AnalyticWorldtubeBoundary<Metavariables>>,
246 : tmpl::list<Tags::AnalyticBoundaryDataManager>,
247 : typename Metavariables::cce_boundary_communication_tags>;
248 : using base_type::apply;
249 : using typename base_type::simple_tags;
250 0 : using compute_tags = tmpl::list<>;
251 0 : using const_global_cache_tags =
252 : tmpl::list<Tags::LMax, Tags::ExtractionRadiusSimple,
253 : Tags::SpecifiedEndTime, Tags::SpecifiedStartTime>;
254 : using typename base_type::simple_tags_from_options;
255 : };
256 : } // namespace Actions
257 : } // namespace Cce
|