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 <optional>
8 : #include <string>
9 :
10 : #include "ControlSystem/Component.hpp"
11 : #include "ControlSystem/ControlErrors/Skew.hpp"
12 : #include "ControlSystem/Measurements/BothHorizons.hpp"
13 : #include "ControlSystem/Protocols/ControlError.hpp"
14 : #include "ControlSystem/Protocols/ControlSystem.hpp"
15 : #include "ControlSystem/Protocols/Measurement.hpp"
16 : #include "ControlSystem/Tags/QueueTags.hpp"
17 : #include "ControlSystem/Tags/SystemTags.hpp"
18 : #include "ControlSystem/UpdateControlSystem.hpp"
19 : #include "DataStructures/DataBox/Tag.hpp"
20 : #include "DataStructures/DataVector.hpp"
21 : #include "DataStructures/LinkedMessageId.hpp"
22 : #include "DataStructures/LinkedMessageQueue.hpp"
23 : #include "Domain/Structure/ObjectLabel.hpp"
24 : #include "NumericalAlgorithms/Strahlkorper/Strahlkorper.hpp"
25 : #include "NumericalAlgorithms/Strahlkorper/Tags.hpp"
26 : #include "Parallel/GlobalCache.hpp"
27 : #include "Parallel/Printf/Printf.hpp"
28 : #include "ParallelAlgorithms/Actions/UpdateMessageQueue.hpp"
29 : #include "Utilities/ErrorHandling/Assert.hpp"
30 : #include "Utilities/PrettyType.hpp"
31 : #include "Utilities/ProtocolHelpers.hpp"
32 : #include "Utilities/TMPL.hpp"
33 :
34 : /// \cond
35 : namespace Frame {
36 : struct Distorted;
37 : } // namespace Frame
38 : /// \endcond
39 :
40 : namespace control_system::Systems {
41 : /*!
42 : * \brief Controls the 3D \link
43 : * domain::CoordinateMaps::TimeDependent::Skew Skew \endlink map
44 : *
45 : * \details Controls the map parameters $F_y(t)$ and $F_z(t)$ from the \link
46 : * domain::CoordinateMaps::TimeDependent::Skew Skew \endlink map.
47 : *
48 : * Requirements:
49 : * - This control system requires that there be exactly two objects in the
50 : * simulation
51 : * - Currently both these objects must be black holes
52 : * - Currently this control system can only be used with the \link
53 : * control_system::measurements::BothHorizons BothHorizons \endlink
54 : * measurement
55 : * - Currently this control system can only be used with the \link
56 : * control_system::ControlErrors::Skew Skew \endlink control error
57 : */
58 : template <size_t DerivOrder, typename Measurement>
59 1 : struct Skew : tt::ConformsTo<protocols::ControlSystem> {
60 0 : static constexpr size_t deriv_order = DerivOrder;
61 :
62 0 : static std::string name() {
63 : return pretty_type::short_name<Skew<DerivOrder, Measurement>>();
64 : }
65 :
66 : // Skew has two components, Y and Z
67 0 : static std::optional<std::string> component_name(
68 : const size_t i, const size_t num_components) {
69 : ASSERT(num_components == 2,
70 : "Skew control expects 2 component but there are " << num_components
71 : << " instead.");
72 : return i == 0 ? "Y" : "Z";
73 : }
74 :
75 0 : using measurement = Measurement;
76 : static_assert(
77 : tt::conforms_to_v<measurement, control_system::protocols::Measurement>);
78 :
79 0 : using control_error = ControlErrors::Skew;
80 : static_assert(tt::conforms_to_v<control_error,
81 : control_system::protocols::ControlError>);
82 :
83 : // tag goes in control component
84 0 : struct MeasurementQueue : db::SimpleTag {
85 0 : using type = LinkedMessageQueue<
86 : double,
87 : tmpl::list<
88 : QueueTags::Horizon<Frame::Distorted, ::domain::ObjectLabel::A>,
89 : QueueTags::Horizon<Frame::Distorted, ::domain::ObjectLabel::B>>>;
90 : };
91 :
92 0 : using simple_tags = tmpl::list<MeasurementQueue>;
93 :
94 0 : struct process_measurement {
95 : template <typename Submeasurement>
96 0 : using argument_tags = tmpl::list<ylm::Tags::Strahlkorper<Frame::Distorted>>;
97 :
98 : template <::domain::ObjectLabel Horizon, typename Metavariables>
99 0 : static void apply(
100 : measurements::BothHorizons::FindHorizon<Horizon> submeasurement,
101 : const ylm::Strahlkorper<Frame::Distorted>& horizon_strahlkorper,
102 : Parallel::GlobalCache<Metavariables>& cache,
103 : const LinkedMessageId<double>& measurement_id) {
104 : auto& control_sys_proxy = Parallel::get_parallel_component<
105 : ControlComponent<Metavariables, Skew<DerivOrder, Measurement>>>(
106 : cache);
107 :
108 : Parallel::simple_action<::Actions::UpdateMessageQueue<
109 : MeasurementQueue, UpdateControlSystem<Skew>,
110 : QueueTags::Horizon<Frame::Distorted, Horizon>>>(
111 : control_sys_proxy, measurement_id, horizon_strahlkorper);
112 :
113 : if (Parallel::get<Tags::Verbosity>(cache) >= ::Verbosity::Verbose) {
114 : Parallel::printf("%s, time = %.16f: Received measurement '%s'.\n",
115 : name(), measurement_id.id,
116 : pretty_type::name(submeasurement));
117 : }
118 : }
119 : };
120 : };
121 : } // namespace control_system::Systems
|