InterpolationTargetKerrHorizon.hpp
2 // See LICENSE.txt for details.
3
4 #pragma once
5
6 #include <array>
7 #include <cstddef>
8
9 #include "ApparentHorizons/Strahlkorper.hpp"
10 #include "ApparentHorizons/Tags.hpp"
11 #include "ApparentHorizons/YlmSpherepack.hpp"
13 #include "NumericalAlgorithms/Interpolation/SendPointsToInterpolator.hpp"
14 #include "Options/Options.hpp"
16 #include "PointwiseFunctions/AnalyticSolutions/GeneralRelativity/KerrHorizon.hpp"
17 #include "Utilities/Requires.hpp"
18 #include "Utilities/TMPL.hpp"
20
21 /// \cond
22 namespace PUP {
23 class er;
24 } // namespace PUP
25 namespace db {
26 template <typename TagsList>
27 class DataBox;
28 } // namespace db
29 namespace intrp {
30 namespace Tags {
31 template <typename Metavariables>
32 struct TemporalIds;
33 } // namespace Tags
34 } // namespace intrp
35 /// \endcond
36
37 namespace intrp {
38
39 namespace OptionHolders {
40 /// A surface that conforms to the horizon of a Kerr black hole in
41 /// Kerr-Schild coordinates.
42 struct KerrHorizon {
43  struct Lmax {
44  using type = size_t;
45  static constexpr OptionString help = {
46  "KerrHorizon is expanded in Ylms up to l=Lmax"};
47  };
48  struct Center {
50  static constexpr OptionString help = {"Center of black hole"};
51  };
52  struct Mass {
53  using type = double;
54  static constexpr OptionString help = {"Mass of black hole"};
55  };
58  static constexpr OptionString help = {"Dimensionless spin of black hole"};
59  };
60  using options = tmpl::list<Lmax, Center, Mass, DimensionlessSpin>;
61  static constexpr OptionString help = {
62  "A Strahlkorper conforming to the horizon (in Kerr-Schild coordinates)"
63  " of a Kerr black hole with a specified center, mass, and spin."};
64
65  KerrHorizon(size_t l_max_in, std::array<double, 3> center_in, double mass_in,
66  std::array<double, 3> dimensionless_spin_in,
67  const OptionContext& context = {});
68
69  KerrHorizon() = default;
70  KerrHorizon(const KerrHorizon& /*rhs*/) = default;
71  KerrHorizon& operator=(const KerrHorizon& /*rhs*/) = default;
72  KerrHorizon(KerrHorizon&& /*rhs*/) noexcept = default;
73  KerrHorizon& operator=(KerrHorizon&& /*rhs*/) noexcept = default;
74  ~KerrHorizon() = default;
75
76  // clang-tidy non-const reference pointer.
77  void pup(PUP::er& p) noexcept; // NOLINT
78
79  size_t l_max{};
80  std::array<double, 3> center{};
81  double mass{};
82  std::array<double, 3> dimensionless_spin{};
83 };
84
85 bool operator==(const KerrHorizon& lhs, const KerrHorizon& rhs) noexcept;
86 bool operator!=(const KerrHorizon& lhs, const KerrHorizon& rhs) noexcept;
87
88 } // namespace OptionHolders
89
90 namespace Actions {
91 /// \ingroup ActionsGroup
92 /// \brief Sends points on a Kerr horizon to an Interpolator.
93 ///
94 /// The points are such that they conform to the horizon of a Kerr
95 /// black hole (in Kerr-Schild coordinates) with given center, mass,
96 /// and dimensionless spin, as specified in the options.
97 ///
98 /// \note The returned points are not actually on the horizon;
99 /// instead, they are collocation points of a Strahlkorper whose
100 /// spectral representation matches the horizon shape up to order
101 /// Lmax, where Lmax is the spherical-harmonic order specified in the
102 /// options. As Lmax increases, the returned points converge to the
103 /// horizon.
104 ///
105 /// Uses:
106 /// - DataBox:
107 /// - ::Tags::Domain<VolumeDim, Frame>
108 /// - ::Tags::Variables<typename
109 /// InterpolationTargetTag::vars_to_interpolate_to_target>
110 ///
111 /// DataBox changes:
113 /// - Removes: nothing
114 /// - Modifies:
115 /// - Tags::IndicesOfFilledInterpPoints
116 /// - ::Tags::Variables<typename
117 /// InterpolationTargetTag::vars_to_interpolate_to_target>
118 ///
119 /// For requirements on InterpolationTargetTag, see InterpolationTarget
120 template <typename InterpolationTargetTag, typename Frame>
121 struct KerrHorizon {
123  using const_global_cache_tags = tmpl::list<InterpolationTargetTag>;
124  using initialization_tags =
125  tmpl::append<StrahlkorperTags::items_tags<Frame>,
126  StrahlkorperTags::compute_items_tags<Frame>>;
127  template <typename DbTags, typename Metavariables>
128  static auto initialize(
129  db::DataBox<DbTags>&& box,
130  const Parallel::ConstGlobalCache<Metavariables>& cache) noexcept {
131  const auto& options = Parallel::get<InterpolationTargetTag>(cache);
132
133  // Make a Strahlkorper with the correct shape.
134  ::Strahlkorper<Frame> strahlkorper(
135  options.l_max, options.l_max,
137  ::YlmSpherepack(options.l_max, options.l_max).theta_phi_points(),
138  options.mass, options.dimensionless_spin)),
139  options.center);
140
141  // Put Strahlkorper and its ComputeItems into a new DataBox.
142  return db::create_from<
146  std::move(box), std::move(strahlkorper));
147  }
148  template <typename DbTags, typename... InboxTags, typename Metavariables,
149  typename ArrayIndex, typename ActionList,
150  typename ParallelComponent,
151  Requires<tmpl::list_contains_v<
152  DbTags, typename Tags::TemporalIds<Metavariables>>> = nullptr>
153  static void apply(
154  db::DataBox<DbTags>& box,
155  const tuples::TaggedTuple<InboxTags...>& /*inboxes*/,
157  const ArrayIndex& /*array_index*/, const ActionList /*meta*/,
158  const ParallelComponent* const /*meta*/,
159  const typename Metavariables::temporal_id::type& temporal_id) noexcept {
160  // In the future, when we add support for multiple Frames,
161  // the code that transforms coordinates from the Strahlkorper Frame
162  // to Metavariables::domain_frame will go here. That transformation
163  // may depend on temporal_id.
164  send_points_to_interpolator<InterpolationTargetTag>(
165  box, cache,
167  typename Metavariables::domain_frame>>(box),
168  temporal_id);
169  }
170 };
171
172 } // namespace Actions
173 } // namespace intrp
Definition: InterpolationTargetKerrHorizon.hpp:48
Definition: Strahlkorper.hpp:14
Defines class tuples::TaggedTuple.
Definition: InterpolationTargetKerrHorizon.hpp:52
Defines classes and functions for making classes creatable from input files.
C++ interface to SPHEREPACK.
Definition: YlmSpherepack.hpp:21
tmpl::flatten< tmpl::list< Tags... > > RemoveTags
List of Tags to remove from the DataBox.
Definition: DataBox.hpp:1220
Defines the type alias Requires.
constexpr auto apply(F &&f, const DataBox< BoxTags > &box, Args &&... args)
Apply the function f with argument Tags TagsList from DataBox box
Definition: DataBox.hpp:1595
CartesianCoords(i) is , the vector of coordinates of each point on the surface.
Definition: Tags.hpp:105
const char *const OptionString
The string used in option structs.
Definition: Options.hpp:26
A surface that conforms to the horizon of a Kerr black hole in Kerr-Schild coordinates.
Definition: InterpolationTargetKerrHorizon.hpp:42
temporal_ids on which to interpolate.
Definition: InterpolationTargetWedgeSectionTorus.hpp:29
An associative container that is indexed by structs.
Definition: TaggedTuple.hpp:272
Defines classes and functions used for manipulating DataBox&#39;s.
constexpr auto create_from(db::DataBox< TagsList > &&box, Args &&... args) noexcept
Create a new DataBox from an existing one adding or removing items and compute items.
Definition: DataBox.hpp:1414
tmpl::flatten< tmpl::list< Tags... > > AddSimpleTags
List of Tags to add to the DataBox.
Definition: DataBox.hpp:1227
Definition: InterpolationTargetWedgeSectionTorus.hpp:24
Definition: DataBoxTag.hpp:29
A Charm++ chare that caches constant data once per Charm++ node.
Definition: ConstGlobalCache.hpp:76
std::array< DataVector, 2 > theta_phi_points() const noexcept
Collocation points theta and phi.
Definition: YlmSpherepack.cpp:377
Namespace for DataBox related things.
Definition: DataBox.hpp:33
const auto & get(const DataBox< TagList > &box) noexcept
Retrieve the item with tag Tag from the DataBox.
Definition: DataBox.hpp:1211
Definition: InterpolationTargetKerrHorizon.hpp:56
A star-shaped surface expanded in spherical harmonics.
Definition: Strahlkorper.hpp:21
Information about the nested operations being performed by the parser, for use in printing errors...
Definition: Options.hpp:35
Wraps the template metaprogramming library used (brigand)
Definition: InterpolationTargetKerrHorizon.hpp:43
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
Scalar< DataType > kerr_horizon_radius(const std::array< DataType, 2 > &theta_phi, const double &mass, const std::array< double, 3 > &dimensionless_spin) noexcept
Radius of Kerr horizon in Kerr-Schild coordinates.
Definition: KerrHorizon.cpp:18
Sends points on a Kerr horizon to an Interpolator.
Definition: InterpolationTargetKerrHorizon.hpp:121
Identifies a step in the linear solver algorithm.
Definition: IterationId.hpp:25
Definition: SolvePoissonProblem.hpp:38
Defines class template ConstGlobalCache.
Definition: ComputeTimeDerivative.hpp:28
tmpl::flatten< tmpl::list< Tags... > > AddComputeTags
List of Compute Item Tags to add to the DataBox.
Definition: DataBox.hpp:1234