InitializeCharacteristicEvolution.hpp
1 // Distributed under the MIT License.
2 // See LICENSE.txt for details.
3 
4 #pragma once
5 
6 #include <cstddef>
7 #include <limits>
8 #include <tuple>
9 #include <utility>
10 
14 #include "Evolution/Systems/Cce/InitializeCce.hpp"
15 #include "Evolution/Systems/Cce/OptionTags.hpp"
16 #include "Evolution/Systems/Cce/Tags.hpp"
17 #include "NumericalAlgorithms/Spectral/SwshInterpolation.hpp"
18 #include "Parallel/Info.hpp"
19 #include "ParallelAlgorithms/Initialization/MergeIntoDataBox.hpp"
20 #include "Time/Tags.hpp"
21 #include "Time/TimeSteppers/TimeStepper.hpp"
22 #include "Utilities/Gsl.hpp"
23 #include "Utilities/NoSuchType.hpp"
24 #include "Utilities/Rational.hpp"
25 #include "Utilities/Requires.hpp"
26 #include "Utilities/TMPL.hpp"
28 
29 namespace Cce {
30 /// \brief The set of actions for use in the CCE evolution system
31 namespace Actions {
32 
33 /*!
34  * \ingroup ActionsGroup
35  * \brief Initializes the `CharacteristicEvolution` component, which is the
36  * singleton that handles the main evolution system for CCE computations.
37  *
38  * \details Sets up the \ref DataBoxGroup to be ready to take data from the
39  * worldtube component and calculate initial data.
40  *
41  * \ref DataBoxGroup changes:
42  * - Modifies: nothing
43  * - Adds:
44  * - `Cce::Tags::BoundaryTime`
45  * - `Tags::TimeStepId`
46  * - `Tags::Next<Tags::TimeStepId>`
47  * - `Tags::TimeStep`
48  * -
49  * ```
50  * Tags::HistoryEvolvedVariables<
51  * metavariables::evolved_coordinates_variables_tag,
52  * db::add_tag_prefix<Tags::dt,
53  * metavariables::evolved_coordinates_variables_tag>>
54  * ```
55  * -
56  * ```
57  * Tags::HistoryEvolvedVariables<
58  *::Tags::Variables<metavariables::evolved_swsh_tag>,
59  * ::Tags::Variables<metavariables::evolved_swsh_dt_tag>>
60  * ```
61  * - `metavariables::evolved_coordinates_variables_tag`
62  * -
63  * ```
64  * db::add_tag_prefix<Tags::dt,
65  * metavariables::evolved_coordinates_variables_tag>
66  * ```
67  * - `Tags::Variables<metavariables::cce_angular_coordinate_tags>`
68  * - `Tags::Variables<metavariables::cce_scri_tags>`
69  * -
70  * ```
71  * Tags::Variables<tmpl::append<
72  * metavariables::cce_integrand_tags,
73  * metavariables::cce_integration_independent_tags,
74  * metavariables::cce_temporary_equations_tags>>
75  * ```
76  * - `Tags::Variables<metavariables::cce_pre_swsh_derivatives_tags>`
77  * - `Tags::Variables<metavariables::cce_transform_buffer_tags>`
78  * - `Tags::Variables<metavariables::cce_swsh_derivative_tags>`
79  * - `Spectral::Swsh::Tags::NumberOfRadialPoints`
80  * - `Tags::EndTime`
81  * - `Spectral::Swsh::Tags::SwshInterpolator<Tags::CauchyAngularCoords>`
82  * - Removes: nothing
83  */
85  using initialization_tags =
88  using const_global_cache_tags =
89  tmpl::list<::Tags::TimeStepper<TimeStepper>, Spectral::Swsh::Tags::LMax,
91 
92  template <typename Metavariables>
93  struct EvolutionTags {
94  using coordinate_variables_tag =
95  typename Metavariables::evolved_coordinates_variables_tag;
96  using dt_coordinate_variables_tag =
98  using evolution_simple_tags = db::AddSimpleTags<
103  tmpl::list<typename Metavariables::evolved_swsh_tag>>>>;
104  using evolution_compute_tags =
106 
107  template <typename TagList>
108  static auto initialize(
109  db::DataBox<TagList>&& box,
110  const Parallel::ConstGlobalCache<Metavariables>& /*cache*/) noexcept {
111  const double initial_time_value =
112  db::get<InitializationTags::StartTime>(box);
113  const double step_size = db::get<InitializationTags::TargetStepSize>(box);
114 
115  const Slab single_step_slab{initial_time_value,
116  initial_time_value + step_size};
117  const Time initial_time = single_step_slab.start();
118  const TimeDelta fixed_time_step =
119  TimeDelta{single_step_slab, Rational{1, 1}};
120  TimeStepId initial_time_id{true, 0, initial_time};
121  const auto& time_stepper = db::get<::Tags::TimeStepper<TimeStepper>>(box);
122  TimeStepId second_time_id =
123  time_stepper.next_time_id(initial_time_id, fixed_time_step);
124 
126  coordinate_history;
127 
130  tmpl::list<typename Metavariables::evolved_swsh_tag>>>>
131  swsh_history;
132 
134  InitializeCharacteristicEvolution, evolution_simple_tags,
135  evolution_compute_tags, Initialization::MergePolicy::Overwrite>(
136  std::move(box), std::move(initial_time_id), // NOLINT
137  std::move(second_time_id), fixed_time_step, // NOLINT
138  std::move(coordinate_history), std::move(swsh_history));
139  }
140  };
141 
142  template <typename Metavariables>
145  tmpl::append<typename Metavariables::cce_boundary_communication_tags,
146  typename Metavariables::cce_gauge_boundary_tags>>;
147 
148  using scri_variables_tag =
151  tmpl::append<typename Metavariables::cce_integrand_tags,
152  typename Metavariables::cce_integration_independent_tags,
153  typename Metavariables::cce_temporary_equations_tags>>;
155  typename Metavariables::cce_pre_swsh_derivatives_tags>;
162  using coordinate_variables_tag =
163  typename Metavariables::evolved_coordinates_variables_tag;
164  using dt_coordinate_variables_tag =
169  tmpl::list<typename Metavariables::evolved_swsh_dt_tag>>;
170  template <typename TagList>
171  static auto initialize(
172  db::DataBox<TagList>&& box,
173  const Parallel::ConstGlobalCache<Metavariables>& cache) noexcept {
174  const size_t l_max = Parallel::get<Spectral::Swsh::Tags::LMax>(cache);
175  const size_t number_of_radial_points =
176  Parallel::get<Spectral::Swsh::Tags::NumberOfRadialPoints>(cache);
177  const size_t boundary_size =
179  const size_t volume_size = boundary_size * number_of_radial_points;
180  const size_t transform_buffer_size =
181  number_of_radial_points *
186  boundary_value_variables_tag, coordinate_variables_tag,
187  dt_coordinate_variables_tag, evolved_swsh_variables_tag,
194  db::AddComputeTags<>, Initialization::MergePolicy::Overwrite>(
195  std::move(box),
202  db::item_type<scri_variables_tag>{boundary_size},
205  db::item_type<transform_buffer_variables_tag>{transform_buffer_size,
206  0.0},
209  }
210  };
211 
212  template <class Metavariables>
213  using return_tag_list = tmpl::append<
214  typename EvolutionTags<Metavariables>::evolution_simple_tags,
215  typename EvolutionTags<Metavariables>::evolution_compute_tags>;
216 
217  template <
218  typename DbTags, typename... InboxTags, typename Metavariables,
219  typename ArrayIndex, typename ActionList, typename ParallelComponent,
221  nullptr>
222  static auto apply(db::DataBox<DbTags>& box,
223  const tuples::TaggedTuple<InboxTags...>& /*inboxes*/,
225  const ArrayIndex& /*array_index*/,
226  const ActionList /*meta*/,
227  const ParallelComponent* const /*meta*/) noexcept {
228  const double initial_time_value =
229  db::get<InitializationTags::StartTime>(box);
230  const double step_size = db::get<InitializationTags::TargetStepSize>(box);
231 
232  auto evolution_box =
233  EvolutionTags<Metavariables>::initialize(std::move(box), cache);
234  auto characteristic_evolution_box =
235  CharacteristicTags<Metavariables>::initialize(std::move(evolution_box),
236  cache);
237  auto initialization_moved_box =
241  std::move(characteristic_evolution_box),
242  db::get<InitializationTags::EndTime>(characteristic_evolution_box));
243  return std::make_tuple(std::move(initialization_moved_box));
244  }
245 
246  template <typename DbTags, typename... InboxTags, typename Metavariables,
247  typename ArrayIndex, typename ActionList,
248  typename ParallelComponent,
249  Requires<not tmpl::list_contains_v<
250  DbTags, InitializationTags::StartTime>> = nullptr>
251  static auto apply(db::DataBox<DbTags>& box,
252  const tuples::TaggedTuple<InboxTags...>& /*inboxes*/,
254  const ArrayIndex& /*array_index*/,
255  const ActionList /*meta*/,
256  const ParallelComponent* const /*meta*/) noexcept {
257  ERROR(
258  "The DataBox is missing required dependency "
259  "`Cce::InitializationTags::LMax.`");
260  // return required for type inference, this code should be unreachable due
261  // to the `ERROR` on the previous line
262  return std::make_tuple(std::move(box));
263  }
264 };
265 } // namespace Actions
266 } // namespace Cce
Prefix< DataBox_detail::dispatch_add_tag_prefix_impl< Prefix, Tag, Args... >, Args... > add_tag_prefix
Wrap Tag in Prefix<_, Args...>, also wrapping variables tags if Tag is a Tags::Variables.
Definition: DataBoxTag.hpp:630
constexpr size_t size_of_libsharp_coefficient_vector(const size_t l_max) noexcept
Convenience function for determining the number of spin-weighted spherical harmonics coefficients tha...
Definition: SwshCoefficients.hpp:34
Tag for step size.
Definition: Tags.hpp:41
Definition: Variables.hpp:46
Defines class tuples::TaggedTuple.
#define ERROR(m)
prints an error message to the standard error stream and aborts the program.
Definition: Error.hpp:36
Defines functions for interfacing with the parallelization framework.
Contains functionality for Cauchy Characteristic Extraction.
Definition: BoundaryComputeAndSendToEvolution.hpp:24
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
The time in a simulation. Times can be safely compared for exact equality as long as they do not belo...
Definition: Time.hpp:29
Performs interpolation for spin-weighted spherical harmonics by taking advantage of the Clenshaw meth...
Definition: SwshInterpolation.hpp:229
Define prefixes for DataBox tags.
A chunk of time. Every element must reach slab boundaries exactly, no matter how it actually takes ti...
Definition: Slab.hpp:27
Defines the type alias Requires.
auto merge_into_databox(db::DataBox< DbTagsList > &&box, Args &&... args) noexcept
Add tags that are not yet in the DataBox.
Definition: MergeIntoDataBox.hpp:132
Tag for TimeStepId for the algorithm state.
Definition: Tags.hpp:32
A unique identifier for the temporal state of an integrated system.
Definition: TimeStepId.hpp:25
Definition: OptionTags.hpp:189
Tag for the number of radial grid points in the three-dimensional representation of radially concentr...
Definition: SwshTags.hpp:195
A rational number.
Definition: Rational.hpp:24
Tag for the TimeStepper history.
Definition: Tags.hpp:82
An associative container that is indexed by structs.
Definition: TaggedTuple.hpp:273
Defines classes and functions used for manipulating DataBox&#39;s.
tmpl::flatten< tmpl::list< Tags... > > AddSimpleTags
List of Tags to add to the DataBox.
Definition: DataBox.hpp:1227
Definition: InitializeCharacteristicEvolution.hpp:143
Represents an interval of time within a single slab.
Definition: Time.hpp:88
Definition: InterpolationTargetWedgeSectionTorus.hpp:24
Definition: InitializeCharacteristicEvolution.hpp:93
A Charm++ chare that caches constant data once per Charm++ node.
Definition: ConstGlobalCache.hpp:135
Tag for the maximum spin-weighted spherical harmonic l; sets angular resolution.
Definition: SwshTags.hpp:187
Wraps the template metaprogramming library used (brigand)
Definition: Tags.hpp:149
Prefix indicating the value a quantity will take on the next iteration of the algorithm.
Definition: Prefixes.hpp:150
typename DataBox_detail::item_type_impl< TagList, Tag >::type item_type
Get the type that can be written to the Tag. If it is a base tag then a TagList must be passed as a s...
Definition: DataBoxTag.hpp:475
Defines functions and classes from the GSL.
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
Defines classes SimpleTag, PrefixTag, ComputeTag and several functions for retrieving tag info...
Definition: OptionTags.hpp:180
Initializes the CharacteristicEvolution component, which is the singleton that handles the main evolu...
Definition: InitializeCharacteristicEvolution.hpp:84
Tag for a SwshInterpolator associated with a particular set of angular coordinates.
Definition: SwshTags.hpp:209
Defines tags related to Time quantities.
Definition: ComputeTimeDerivative.hpp:28
Definition: OptionTags.hpp:164
tmpl::flatten< tmpl::list< Tags... > > AddComputeTags
List of Compute Item Tags to add to the DataBox.
Definition: DataBox.hpp:1248