InitializeCharacteristicEvolutionVariables.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/DataBox/PrefixHelpers.hpp"
14 #include "DataStructures/VariablesTag.hpp"
15 #include "Evolution/Systems/Cce/OptionTags.hpp"
16 #include "NumericalAlgorithms/Spectral/SwshInterpolation.hpp"
18 #include "ParallelAlgorithms/Initialization/MergeIntoDataBox.hpp"
19 #include "Utilities/Requires.hpp"
20 #include "Utilities/TMPL.hpp"
21 #include "Utilities/TaggedTuple.hpp"
22 
23 namespace Cce {
24 /// \brief The set of actions for use in the CCE evolution system
25 namespace Actions {
26 
27 /*!
28  * \ingroup ActionsGroup
29  * \brief Initializes the main data storage for the `CharacteristicEvolution`
30  * component, which is the singleton that handles the main evolution system for
31  * CCE computations.
32  *
33  * \details Sets up the \ref DataBoxGroup to be ready to take data from the
34  * worldtube component, calculate initial data, and start the hypersurface
35  * computations.
36  *
37  * \ref DataBoxGroup changes:
38  * - Modifies: nothing
39  * - Adds:
40  * - `metavariables::evolved_coordinates_variables_tag`
41  * -
42  * ```
43  * db::add_tag_prefix<Tags::dt,
44  * metavariables::evolved_coordinates_variables_tag>
45  * ```
46  * - `Tags::Variables<metavariables::cce_angular_coordinate_tags>`
47  * - `Tags::Variables<metavariables::cce_scri_tags>`
48  * -
49  * ```
50  * Tags::Variables<tmpl::append<
51  * metavariables::cce_integrand_tags,
52  * metavariables::cce_integration_independent_tags,
53  * metavariables::cce_temporary_equations_tags>>
54  * ```
55  * - `Tags::Variables<metavariables::cce_pre_swsh_derivatives_tags>`
56  * - `Tags::Variables<metavariables::cce_transform_buffer_tags>`
57  * - `Tags::Variables<metavariables::cce_swsh_derivative_tags>`
58  * - `Spectral::Swsh::Tags::SwshInterpolator< Tags::CauchyAngularCoords>`
59  * - Removes: nothing
60  */
62  using const_global_cache_tags =
63  tmpl::list<Tags::LMax, Tags::NumberOfRadialPoints>;
64 
65  template <
66  typename DbTags, typename... InboxTags, typename Metavariables,
67  typename ArrayIndex, typename ActionList, typename ParallelComponent,
68  Requires<not tmpl::list_contains_v<
69  DbTags, ::Tags::Variables<tmpl::list<
70  typename Metavariables::evolved_swsh_tag>>>> = nullptr>
71  static auto apply(db::DataBox<DbTags>& box,
72  const tuples::TaggedTuple<InboxTags...>& /*inboxes*/,
74  const ArrayIndex& /*array_index*/,
75  const ActionList /*meta*/,
76  const ParallelComponent* const /*meta*/) noexcept {
77  using boundary_value_variables_tag = ::Tags::Variables<
78  tmpl::append<typename Metavariables::cce_boundary_communication_tags,
79  typename Metavariables::cce_gauge_boundary_tags>>;
80  using scri_variables_tag =
82  using volume_variables_tag = ::Tags::Variables<
83  tmpl::append<typename Metavariables::cce_integrand_tags,
84  typename Metavariables::cce_integration_independent_tags,
85  typename Metavariables::cce_temporary_equations_tags>>;
86  using pre_swsh_derivatives_variables_tag = ::Tags::Variables<
87  typename Metavariables::cce_pre_swsh_derivatives_tags>;
88  using transform_buffer_variables_tag =
90  using swsh_derivative_variables_tag =
92  using angular_coordinates_variables_tag =
94  using coordinate_variables_tag =
95  typename Metavariables::evolved_coordinates_variables_tag;
96  using dt_coordinate_variables_tag =
98  using evolved_swsh_variables_tag =
100  using evolved_swsh_dt_variables_tag =
102 
103  const size_t l_max = db::get<Spectral::Swsh::Tags::LMaxBase>(box);
104  const size_t number_of_radial_points =
105  db::get<Spectral::Swsh::Tags::NumberOfRadialPointsBase>(box);
106  const size_t boundary_size =
108  const size_t volume_size = boundary_size * number_of_radial_points;
109  const size_t transform_buffer_size =
110  number_of_radial_points *
112  return std::make_tuple(
116  boundary_value_variables_tag, coordinate_variables_tag,
117  dt_coordinate_variables_tag, evolved_swsh_variables_tag,
118  evolved_swsh_dt_variables_tag,
119  angular_coordinates_variables_tag, scri_variables_tag,
120  volume_variables_tag, pre_swsh_derivatives_variables_tag,
121  transform_buffer_variables_tag, swsh_derivative_variables_tag,
124  db::AddComputeTags<>, Initialization::MergePolicy::Overwrite>(
125  std::move(box),
132  db::item_type<scri_variables_tag>{boundary_size},
135  db::item_type<transform_buffer_variables_tag>{transform_buffer_size,
136  0.0},
139  }
140 
141  template <
142  typename DbTags, typename... InboxTags, typename Metavariables,
143  typename ArrayIndex, typename ActionList, typename ParallelComponent,
144  Requires<tmpl::list_contains_v<
145  DbTags, ::Tags::Variables<tmpl::list<
146  typename Metavariables::evolved_swsh_tag>>>> = nullptr>
147  static std::tuple<db::DataBox<DbTags>&&> apply(
148  const db::DataBox<DbTags>& /*box*/,
149  const tuples::TaggedTuple<InboxTags...>& /*inboxes*/,
151  const ArrayIndex& /*array_index*/, const ActionList /*meta*/,
152  const ParallelComponent* const /*meta*/) noexcept {
153  ERROR(
154  "The DataBox has already been initialized with Cce characteristic "
155  "evolution variables. Only initialize the Cce databox once.");
156  }
157 };
158 
159 } // namespace Actions
160 } // 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: PrefixHelpers.hpp:145
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
Definition: VariablesTag.hpp:21
#define ERROR(m)
prints an error message to the standard error stream and aborts the program.
Definition: Error.hpp:36
The set of utilities for performing Cauchy characteristic evolution and Cauchy characteristic matchin...
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
Performs interpolation for spin-weighted spherical harmonics by taking advantage of the Clenshaw meth...
Definition: SwshInterpolation.hpp:229
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:133
An associative container that is indexed by structs.
Definition: TaggedTuple.hpp:272
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:1150
Definition: InterpolationTargetWedgeSectionTorus.hpp:25
Defines class Variables.
A Charm++ chare that caches constant data once per Charm++ node.
Definition: ConstGlobalCache.hpp:136
Wraps the template metaprogramming library used (brigand)
Definition: Tags.hpp:165
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:246
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
Definition: Test_ActionTesting.cpp:365
Defines classes SimpleTag, PrefixTag, ComputeTag and several functions for retrieving tag info...
Defines class template ConstGlobalCache.
Tag for a SwshInterpolator associated with a particular set of angular coordinates.
Definition: SwshTags.hpp:218
Definition: ComputeTimeDerivative.hpp:29
tmpl::flatten< tmpl::list< Tags... > > AddComputeTags
List of Compute Item Tags to add to the DataBox.
Definition: DataBox.hpp:1171
Initializes the main data storage for the CharacteristicEvolution component, which is the singleton t...
Definition: InitializeCharacteristicEvolutionVariables.hpp:61