InterpolationTargetApparentHorizon.hpp
1 // Distributed under the MIT License.
2 // See LICENSE.txt for details.
3 
4 #pragma once
5 
6 #include <cstddef>
7 
8 #include "ApparentHorizons/FastFlow.hpp"
9 #include "ApparentHorizons/Strahlkorper.hpp"
10 #include "ApparentHorizons/Tags.hpp"
12 #include "Informer/Verbosity.hpp"
13 #include "NumericalAlgorithms/Interpolation/SendPointsToInterpolator.hpp"
14 #include "Options/Options.hpp"
16 #include "Utilities/Requires.hpp"
17 #include "Utilities/TMPL.hpp"
19 
20 /// \cond
21 namespace PUP {
22 class er;
23 } // namespace PUP
24 namespace db {
25 template <typename TagsList>
26 class DataBox;
27 } // namespace db
28 namespace intrp {
29 namespace Tags {
30 template <typename Metavariables>
31 struct TemporalIds;
32 } // namespace Tags
33 } // namespace intrp
34 namespace OptionTags {
35 struct Verbosity;
36 } // namespace OptionTags
37 namespace Tags {
38 struct Verbosity;
39 } // namespace Tags
40 /// \endcond
41 
42 namespace intrp {
43 
44 namespace OptionHolders {
45 /// Options for finding an apparent horizon.
46 template <typename Frame>
48  /// See Strahlkorper for suboptions.
49  struct InitialGuess {
50  static constexpr OptionString help = {"Initial guess"};
51  using type = Strahlkorper<Frame>;
52  };
53  /// See ::FastFlow for suboptions.
54  struct FastFlow {
55  static constexpr OptionString help = {"FastFlow options"};
56  using type = ::FastFlow;
57  };
58  using options = tmpl::list<InitialGuess, FastFlow, ::OptionTags::Verbosity>;
59  static constexpr OptionString help = {
60  "Provide an initial guess for the apparent horizon surface\n"
61  "(Strahlkorper) and apparent-horizon-finding-algorithm (FastFlow)\n"
62  "options."};
63 
64  ApparentHorizon(Strahlkorper<Frame> initial_guess_in, ::FastFlow fast_flow_in,
65  Verbosity verbosity_in) noexcept;
66 
67  ApparentHorizon() = default;
68  ApparentHorizon(const ApparentHorizon& /*rhs*/) = delete;
69  ApparentHorizon& operator=(const ApparentHorizon& /*rhs*/) = delete;
70  ApparentHorizon(ApparentHorizon&& /*rhs*/) noexcept = default;
71  ApparentHorizon& operator=(ApparentHorizon&& /*rhs*/) noexcept = default;
72  ~ApparentHorizon() = default;
73 
74  // clang-tidy non-const reference pointer.
75  void pup(PUP::er& p) noexcept; // NOLINT
76 
77  Strahlkorper<Frame> initial_guess{};
78  ::FastFlow fast_flow{};
79  Verbosity verbosity{Verbosity::Quiet};
80 };
81 
82 template <typename Frame>
83 bool operator==(const ApparentHorizon<Frame>& lhs,
84  const ApparentHorizon<Frame>& rhs) noexcept;
85 template <typename Frame>
86 bool operator!=(const ApparentHorizon<Frame>& lhs,
87  const ApparentHorizon<Frame>& rhs) noexcept;
88 
89 } // namespace OptionHolders
90 
91 namespace Actions {
92 /// \ingroup ActionsGroup
93 /// \brief Sends points on a trial apparent horizon to an `Interpolator`.
94 ///
95 /// This differs from `KerrHorizon` in the following ways:
96 /// - It supplies points on a prolonged Strahlkorper, at a higher resolution
97 /// than the Strahlkorper in the DataBox, as needed for horizon finding.
98 /// - It uses a `FastFlow` in the DataBox.
99 /// - It has different options (including those for `FastFlow`).
100 ///
101 /// Uses:
102 /// - DataBox:
103 /// - `::Tags::Domain<VolumeDim, Frame>`
104 /// - `::ah::Tags::FastFlow`
105 /// - `StrahlkorperTags::CartesianCoords<Frame>`
106 /// - `::Tags::Variables<typename
107 /// InterpolationTargetTag::vars_to_interpolate_to_target>`
108 ///
109 /// DataBox changes:
110 /// - Adds: nothing
111 /// - Removes: nothing
112 /// - Modifies:
113 /// - `Tags::IndicesOfFilledInterpPoints`
114 /// - `::Tags::Variables<typename
115 /// InterpolationTargetTag::vars_to_interpolate_to_target>`
116 ///
117 /// This Action also has an initialize function that adds to the DataBox:
118 /// - `StrahlkorperTags::items_tags<Frame>`
119 /// - `StrahlkorperTags::compute_items_tags<Frame>`
120 /// - `::ah::Tags::FastFlow`
121 /// - `::Tags::Verbosity`
122 ///
123 /// For requirements on InterpolationTargetTag, see InterpolationTarget
124 template <typename InterpolationTargetTag, typename Frame>
127  using const_global_cache_tags = tmpl::list<InterpolationTargetTag>;
128  using initialization_tags =
129  tmpl::append<StrahlkorperTags::items_tags<Frame>,
130  tmpl::list<::ah::Tags::FastFlow, ::Tags::Verbosity>,
131  StrahlkorperTags::compute_items_tags<Frame>>;
132  template <typename DbTags, typename Metavariables>
133  static auto initialize(
134  db::DataBox<DbTags>&& box,
135  const Parallel::ConstGlobalCache<Metavariables>& cache) noexcept {
136  const auto& options = Parallel::get<InterpolationTargetTag>(cache);
137 
138  // Put Strahlkorper and its ComputeItems, FastFlow,
139  // and verbosity into a new DataBox.
140  return db::create_from<
143  tmpl::push_back<StrahlkorperTags::items_tags<Frame>,
146  std::move(box), options.initial_guess, options.fast_flow,
147  options.verbosity);
148  }
149  template <typename DbTags, typename... InboxTags, typename Metavariables,
150  typename ArrayIndex, typename ActionList,
151  typename ParallelComponent,
152  Requires<tmpl::list_contains_v<
153  DbTags, typename Tags::TemporalIds<Metavariables>>> = nullptr>
154  static void apply(
155  db::DataBox<DbTags>& box,
156  const tuples::TaggedTuple<InboxTags...>& /*inboxes*/,
158  const ArrayIndex& /*array_index*/, const ActionList /*meta*/,
159  const ParallelComponent* const /*meta*/,
160  const typename Metavariables::temporal_id::type& temporal_id) noexcept {
161  const auto& fast_flow = db::get<::ah::Tags::FastFlow>(box);
162  const auto& strahlkorper =
163  db::get<StrahlkorperTags::Strahlkorper<Frame>>(box);
164 
165  const size_t L_mesh = fast_flow.current_l_mesh(strahlkorper);
166  const auto prolonged_strahlkorper =
167  Strahlkorper<Frame>(L_mesh, L_mesh, strahlkorper);
168 
169  const auto prolonged_coords =
171  prolonged_strahlkorper,
172  StrahlkorperTags::Radius<Frame>::function(prolonged_strahlkorper),
175  prolonged_strahlkorper)));
176 
177  // In the future, when we add support for multiple Frames,
178  // the code that transforms coordinates from the Strahlkorper Frame
179  // to `Metavariables::domain_frame` will go here. That transformation
180  // may depend on `temporal_id`.
181 
182  send_points_to_interpolator<InterpolationTargetTag>(
183  box, cache, prolonged_coords, temporal_id);
184  }
185 };
186 
187 } // namespace Actions
188 } // namespace intrp
Definition: Strahlkorper.hpp:14
Defines class tuples::TaggedTuple.
See Strahlkorper for suboptions.
Definition: InterpolationTargetApparentHorizon.hpp:49
Tag for putting Verbosity in a DataBox.
Definition: Tags.hpp:18
Definition: AddTemporalIdsToInterpolationTarget.hpp:17
Rhat(i) is on the grid. Doesn&#39;t depend on the shape of the surface.
Definition: Tags.hpp:57
Defines classes and functions for making classes creatable from input files.
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:1609
CartesianCoords(i) is , the vector of coordinates of each point on the surface.
Definition: Tags.hpp:118
See FastFlow for suboptions.
Definition: InterpolationTargetApparentHorizon.hpp:54
const char *const OptionString
The string used in option structs.
Definition: Options.hpp:27
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:1428
Verbosity
Indicates how much informative output a class should output.
Definition: Verbosity.hpp:16
tmpl::flatten< tmpl::list< Tags... > > AddSimpleTags
List of Tags to add to the DataBox.
Definition: DataBox.hpp:1227
Definition: Strahlkorper.hpp:167
Definition: InterpolationTargetWedgeSectionTorus.hpp:24
(Euclidean) distance from the center to each point of the surface.
Definition: Tags.hpp:104
Definition: DataBoxTag.hpp:29
A Charm++ chare that caches constant data once per Charm++ node.
Definition: ConstGlobalCache.hpp:76
Namespace for DataBox related things.
Definition: DataBox.hpp:33
Options for finding an apparent horizon.
Definition: InterpolationTargetApparentHorizon.hpp:47
A star-shaped surface expanded in spherical harmonics.
Definition: Strahlkorper.hpp:21
Sends points on a trial apparent horizon to an Interpolator.
Definition: InterpolationTargetApparentHorizon.hpp:125
Wraps the template metaprogramming library used (brigand)
on the grid. Doesn&#39;t depend on the shape of the surface.
Definition: Tags.hpp:47
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: Tags.hpp:26
Definition: SolvePoissonProblem.hpp:37
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:1248