Line data Source code
1 0 : // Distributed under the MIT License.
2 : // See LICENSE.txt for details.
3 :
4 : #pragma once
5 :
6 : #include <cstddef>
7 : #include <string>
8 :
9 : #include "ControlSystem/Protocols/Measurement.hpp"
10 : #include "ControlSystem/Protocols/Submeasurement.hpp"
11 : #include "ControlSystem/RunCallbacks.hpp"
12 : #include "DataStructures/DataBox/Tag.hpp"
13 : #include "DataStructures/LinkedMessageId.hpp"
14 : #include "DataStructures/Tensor/TypeAliases.hpp"
15 : #include "Domain/Structure/ObjectLabel.hpp"
16 : #include "Domain/TagsTimeDependent.hpp"
17 : #include "Evolution/Systems/GeneralizedHarmonic/Characteristics.hpp"
18 : #include "NumericalAlgorithms/SphericalHarmonics/Tags.hpp"
19 : #include "ParallelAlgorithms/ApparentHorizonFinder/Callbacks/ErrorOnFailedApparentHorizon.hpp"
20 : #include "ParallelAlgorithms/ApparentHorizonFinder/Callbacks/FindApparentHorizon.hpp"
21 : #include "ParallelAlgorithms/ApparentHorizonFinder/ComputeExcisionBoundaryVolumeQuantities.hpp"
22 : #include "ParallelAlgorithms/ApparentHorizonFinder/ComputeHorizonVolumeQuantities.hpp"
23 : #include "ParallelAlgorithms/ApparentHorizonFinder/HorizonAliases.hpp"
24 : #include "ParallelAlgorithms/ApparentHorizonFinder/InterpolationTarget.hpp"
25 : #include "ParallelAlgorithms/Interpolation/Events/InterpolateWithoutInterpComponent.hpp"
26 : #include "ParallelAlgorithms/Interpolation/Interpolate.hpp"
27 : #include "ParallelAlgorithms/Interpolation/PointInfoTag.hpp"
28 : #include "ParallelAlgorithms/Interpolation/Protocols/InterpolationTargetTag.hpp"
29 : #include "ParallelAlgorithms/Interpolation/Targets/Sphere.hpp"
30 : #include "PointwiseFunctions/GeneralRelativity/DetAndInverseSpatialMetric.hpp"
31 : #include "Time/Tags/TimeAndPrevious.hpp"
32 : #include "Utilities/ProtocolHelpers.hpp"
33 : #include "Utilities/TMPL.hpp"
34 :
35 : /// \cond
36 : class DataVector;
37 : template <size_t VolumeDim>
38 : class ElementId;
39 : template <size_t Dim>
40 : class Mesh;
41 : namespace Parallel {
42 : template <typename Metavariables>
43 : class GlobalCache;
44 : } // namespace Parallel
45 : namespace domain::Tags {
46 : template <size_t Dim>
47 : struct Mesh;
48 : template <size_t Dim, typename Frame>
49 : struct Coordinates;
50 : } // namespace domain::Tags
51 : /// \endcond
52 :
53 : namespace control_system::measurements {
54 : /*!
55 : * \brief A `control_system::protocols::Measurement` that relies on one
56 : * apparent horizon, the template parameter `Object`, and one excision surface.
57 : */
58 : template <::domain::ObjectLabel Object>
59 1 : struct CharSpeed : tt::ConformsTo<protocols::Measurement> {
60 0 : static std::string name() { return "CharSpeed" + ::domain::name(Object); }
61 :
62 : /*!
63 : * \brief A `control_system::protocols::Submeasurement` that does an
64 : * interpolation to the excision boundary for this `Object` from the elements.
65 : *
66 : * This does not go through the interpolation framework.
67 : */
68 1 : struct Excision : tt::ConformsTo<protocols::Submeasurement> {
69 0 : static std::string name() { return CharSpeed::name() + "::Excision"; }
70 :
71 : private:
72 : template <typename ControlSystems>
73 0 : struct InterpolationTarget
74 : : tt::ConformsTo<intrp::protocols::InterpolationTargetTag> {
75 0 : static std::string name() {
76 : return "ControlSystemCharSpeedExcision" + ::domain::name(Object);
77 : }
78 :
79 0 : using temporal_id = ::Tags::TimeAndPrevious<1>;
80 :
81 0 : using vars_to_interpolate_to_target =
82 : tmpl::list<gr::Tags::Lapse<DataVector>,
83 : gr::Tags::Shift<DataVector, 3, Frame::Distorted>,
84 : gr::Tags::ShiftyQuantity<DataVector, 3, Frame::Distorted>,
85 : gr::Tags::SpatialMetric<DataVector, 3, Frame::Distorted>,
86 : gh::ConstraintDamping::Tags::ConstraintGamma1>;
87 0 : using compute_vars_to_interpolate =
88 : ah::ComputeExcisionBoundaryVolumeQuantities;
89 0 : using compute_items_on_source = tmpl::list<>;
90 0 : using compute_items_on_target =
91 : tmpl::list<gr::Tags::DetAndInverseSpatialMetricCompute<
92 : DataVector, 3, Frame::Distorted>>;
93 0 : using compute_target_points =
94 : intrp::TargetPoints::Sphere<InterpolationTarget, ::Frame::Grid>;
95 0 : using post_interpolation_callbacks =
96 : tmpl::list<control_system::RunCallbacks<Excision, ControlSystems>>;
97 :
98 : template <typename Metavariables>
99 0 : using interpolating_component =
100 : typename Metavariables::gh_dg_element_array;
101 : };
102 :
103 : public:
104 : template <typename ControlSystems>
105 0 : using interpolation_target_tag = InterpolationTarget<ControlSystems>;
106 :
107 0 : using compute_tags_for_observation_box = tmpl::list<>;
108 :
109 0 : using argument_tags =
110 : tmpl::push_front<::ah::source_vars<3>, intrp::Tags::InterpPointInfoBase,
111 : domain::Tags::Mesh<3>,
112 : domain::Tags::Coordinates<3, ::Frame::Grid>>;
113 :
114 : template <typename Metavariables, typename ParallelComponent,
115 : typename ControlSystems>
116 0 : static void apply(
117 : const typename intrp::Tags::InterpPointInfo<Metavariables>::type&
118 : point_infos,
119 : const Mesh<3>& mesh,
120 : const tnsr::I<DataVector, 3, ::Frame::Grid>& grid_coords,
121 : const tnsr::aa<DataVector, 3, ::Frame::Inertial>& spacetime_metric,
122 : const tnsr::aa<DataVector, 3, ::Frame::Inertial>& pi,
123 : const tnsr::iaa<DataVector, 3, ::Frame::Inertial>& phi,
124 : const tnsr::ijaa<DataVector, 3, ::Frame::Inertial>& deriv_phi,
125 : const Scalar<DataVector>& constraint_gamma1,
126 : const LinkedMessageId<double>& measurement_id,
127 : Parallel::GlobalCache<Metavariables>& cache,
128 : const ElementId<3>& array_index,
129 : const ParallelComponent* const component, ControlSystems /*meta*/) {
130 : using Event = typename intrp::Events::InterpolateWithoutInterpComponent<
131 : 3, InterpolationTarget<ControlSystems>, ::ah::source_vars<3>>;
132 :
133 : Event event{};
134 :
135 : // ObservationValue unused
136 : event(measurement_id, point_infos, mesh, grid_coords, spacetime_metric,
137 : pi, phi, deriv_phi, constraint_gamma1, cache, array_index,
138 : component, ::Event::ObservationValue{});
139 : }
140 : };
141 :
142 : /*!
143 : * \brief A `control_system::protocols::Submeasurement` that starts the
144 : * interpolation to the interpolation target in order to find the apparent
145 : * horizon.
146 : */
147 1 : struct Horizon : tt::ConformsTo<protocols::Submeasurement> {
148 0 : static std::string name() { return CharSpeed::name() + "::Horizon"; }
149 :
150 : private:
151 : template <typename ControlSystems>
152 0 : struct InterpolationTarget
153 : : tt::ConformsTo<intrp::protocols::InterpolationTargetTag> {
154 0 : static std::string name() {
155 : return "ControlSystemCharSpeedAh" + ::domain::name(Object);
156 : }
157 :
158 : // Separate temporal IDs for each object
159 0 : using temporal_id =
160 : ::Tags::TimeAndPrevious<Object == ::domain::ObjectLabel::A ? 1_st
161 : : 2_st>;
162 :
163 0 : using vars_to_interpolate_to_target =
164 : ::ah::vars_to_interpolate_to_target<3, ::Frame::Distorted>;
165 0 : using compute_vars_to_interpolate = ::ah::ComputeHorizonVolumeQuantities;
166 0 : using compute_items_on_target = tmpl::push_back<
167 : ::ah::compute_items_on_target<3, Frame::Distorted>,
168 : ylm::Tags::TimeDerivStrahlkorperCompute<Frame::Distorted>>;
169 0 : using compute_target_points =
170 : intrp::TargetPoints::ApparentHorizon<InterpolationTarget,
171 : ::Frame::Distorted>;
172 0 : using post_interpolation_callbacks =
173 : tmpl::list<intrp::callbacks::FindApparentHorizon<InterpolationTarget,
174 : ::Frame::Distorted>>;
175 0 : using horizon_find_failure_callback =
176 : intrp::callbacks::ErrorOnFailedApparentHorizon;
177 0 : using post_horizon_find_callbacks =
178 : tmpl::list<control_system::RunCallbacks<Horizon, ControlSystems>>;
179 : };
180 :
181 : public:
182 : template <typename ControlSystems>
183 0 : using interpolation_target_tag = InterpolationTarget<ControlSystems>;
184 :
185 0 : using compute_tags_for_observation_box = tmpl::list<>;
186 :
187 0 : using argument_tags =
188 : tmpl::push_front<::ah::source_vars<3>, domain::Tags::Mesh<3>>;
189 :
190 : template <typename Metavariables, typename ParallelComponent,
191 : typename ControlSystems>
192 0 : static void apply(
193 : const Mesh<3>& mesh,
194 : const tnsr::aa<DataVector, 3, ::Frame::Inertial>& spacetime_metric,
195 : const tnsr::aa<DataVector, 3, ::Frame::Inertial>& pi,
196 : const tnsr::iaa<DataVector, 3, ::Frame::Inertial>& phi,
197 : const tnsr::ijaa<DataVector, 3, ::Frame::Inertial>& deriv_phi,
198 : const Scalar<DataVector>& constraint_gamma1,
199 : const LinkedMessageId<double>& measurement_id,
200 : Parallel::GlobalCache<Metavariables>& cache,
201 : const ElementId<3>& array_index,
202 : const ParallelComponent* const /*meta*/, ControlSystems /*meta*/) {
203 : intrp::interpolate<interpolation_target_tag<ControlSystems>>(
204 : measurement_id, mesh, cache, array_index, spacetime_metric, pi, phi,
205 : deriv_phi, constraint_gamma1);
206 : }
207 : };
208 :
209 0 : using submeasurements = tmpl::list<Horizon, Excision>;
210 : };
211 : } // namespace control_system::measurements
|