InitializeCharacteristicEvolutionScri.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 "Evolution/Systems/Cce/OptionTags.hpp"
12 #include "Evolution/Systems/Cce/ScriPlusInterpolationManager.hpp"
13 #include "Parallel/GlobalCache.hpp"
14 #include "ParallelAlgorithms/Initialization/MutateAssign.hpp"
15 #include "Utilities/Rational.hpp"
16 #include "Utilities/Requires.hpp"
17 #include "Utilities/TMPL.hpp"
18 #include "Utilities/TaggedTuple.hpp"
19 #include "Utilities/TypeTraits/IsA.hpp"
20 
21 namespace Cce {
22 
23 /// \cond
24 template <class Metavariables>
25 struct AnalyticWorldtubeBoundary;
26 /// \endcond
27 namespace Actions {
28 
29 /*!
30  * \ingroup ActionsGroup
31  * \brief Initializes the `CharacteristicEvolution` component with contents
32  * needed to perform the interpolation at scri+.
33  *
34  * \details Sets up the \ref DataBoxGroup to be ready to store data in the scri+
35  * interpolators and perform interpolation for the final scri+ outputs.
36  *
37  * \ref DataBoxGroup changes:
38  * - Modifies: nothing
39  * - Adds:
40  * - `Cce::Tags::InterpolationManager<ComplexDataVector, Tag>` for each `Tag`
41  * in `scri_values_to_observe`
42  * - Removes: nothing
43  *
44  * \note This action relies on the `SetupDataBox` aggregated initialization
45  * mechanism, so `Actions::SetupDataBox` must be present in the `Initialization`
46  * phase action list prior to this action.
47  */
48 template <typename ScriValuesToObserve, typename BoundaryComponent>
50  using initialization_tags = tmpl::flatten<tmpl::list<
52  tmpl::conditional_t<
53  tt::is_a_v<AnalyticWorldtubeBoundary, BoundaryComponent>,
54  tmpl::list<Tags::AnalyticBoundaryDataManager>, tmpl::list<>>>>;
55  using initialization_tags_to_keep = tmpl::conditional_t<
56  tt::is_a_v<AnalyticWorldtubeBoundary, BoundaryComponent>,
57  tmpl::list<Tags::AnalyticBoundaryDataManager>, tmpl::list<>>;
58  using const_global_cache_tags =
59  tmpl::list<Tags::LMax, Tags::NumberOfRadialPoints>;
60 
61  using simple_tags =
62  tmpl::transform<ScriValuesToObserve,
63  tmpl::bind<Tags::InterpolationManager,
64  tmpl::pin<ComplexDataVector>, tmpl::_1>>;
65 
66  using compute_tags = tmpl::list<>;
67 
68  template <typename DbTags, typename... InboxTags, typename Metavariables,
69  typename ArrayIndex, typename ActionList,
70  typename ParallelComponent>
71  static auto apply(db::DataBox<DbTags>& box,
72  const tuples::TaggedTuple<InboxTags...>& /*inboxes*/,
73  const Parallel::GlobalCache<Metavariables>& /*cache*/,
74  const ArrayIndex& /*array_index*/,
75  const ActionList /*meta*/,
76  const ParallelComponent* const /*meta*/) noexcept {
77  initialize_impl(make_not_null(&box),
78  typename Metavariables::scri_values_to_observe{});
79  return std::make_tuple(std::move(box));
80  }
81 
82  template <typename TagList, typename... TagPack>
83  static void initialize_impl(const gsl::not_null<db::DataBox<TagList>*> box,
84  tmpl::list<TagPack...> /*meta*/) noexcept {
85  const size_t target_number_of_points =
86  db::get<InitializationTags::ScriInterpolationOrder>(*box);
87  const size_t vector_size =
89  db::get<Spectral::Swsh::Tags::LMaxBase>(*box));
90  // silence compiler warnings when pack is empty
91  (void)vector_size;
92  if constexpr (sizeof...(TagPack) > 0) {
93  Initialization::mutate_assign<simple_tags>(
95  target_number_of_points, vector_size,
96  std::make_unique<intrp::BarycentricRationalSpanInterpolator>(
97  2 * target_number_of_points - 1,
98  2 * target_number_of_points + 2)}...);
99  }
100  }
101 };
102 } // namespace Actions
103 } // namespace Cce
utility
Parallel::GlobalCache
Definition: ElementReceiveInterpPoints.hpp:15
GlobalCache.hpp
Cce::Tags::InterpolationManager
Definition: Tags.hpp:369
Cce::Actions::InitializeCharacteristicEvolutionScri
Initializes the CharacteristicEvolution component with contents needed to perform the interpolation a...
Definition: InitializeCharacteristicEvolutionScri.hpp:49
tuple
DataBox.hpp
cstddef
tuples::TaggedTuple
An associative container that is indexed by structs.
Definition: TaggedTuple.hpp:271
Cce
The set of utilities for performing Cauchy characteristic evolution and Cauchy characteristic matchin...
Definition: CharacteristicExtractFwd.hpp:6
Requires.hpp
Cce::ScriPlusInterpolationManager
Stores necessary data and interpolates on to new time points at scri+.
Definition: ScriPlusInterpolationManager.hpp:48
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::InitializationTags::ScriInterpolationOrder
Definition: OptionTags.hpp:214
TMPL.hpp
gsl::not_null
Require a pointer to not be a nullptr
Definition: ReadSpecPiecewisePolynomial.hpp:13
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