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