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/Measurements/NonFactoryCreatable.hpp" 10 : #include "ControlSystem/Protocols/Measurement.hpp" 11 : #include "ControlSystem/Protocols/Submeasurement.hpp" 12 : #include "ControlSystem/RunCallbacks.hpp" 13 : #include "DataStructures/Tensor/IndexType.hpp" 14 : #include "Domain/Structure/ObjectLabel.hpp" 15 : #include "Domain/TagsTimeDependent.hpp" 16 : #include "NumericalAlgorithms/LinearOperators/PartialDerivatives.hpp" 17 : #include "ParallelAlgorithms/ApparentHorizonFinder/Callbacks/ErrorOnFailedApparentHorizon.hpp" 18 : #include "ParallelAlgorithms/ApparentHorizonFinder/Callbacks/FailedHorizonFind.hpp" 19 : #include "ParallelAlgorithms/ApparentHorizonFinder/Callbacks/FindApparentHorizon.hpp" 20 : #include "ParallelAlgorithms/ApparentHorizonFinder/ComputeExcisionBoundaryVolumeQuantities.hpp" 21 : #include "ParallelAlgorithms/ApparentHorizonFinder/ComputeHorizonVolumeQuantities.hpp" 22 : #include "ParallelAlgorithms/ApparentHorizonFinder/Destination.hpp" 23 : #include "ParallelAlgorithms/ApparentHorizonFinder/Events/FindApparentHorizon.hpp" 24 : #include "ParallelAlgorithms/ApparentHorizonFinder/HorizonAliases.hpp" 25 : #include "ParallelAlgorithms/ApparentHorizonFinder/InterpolationTarget.hpp" 26 : #include "ParallelAlgorithms/ApparentHorizonFinder/Protocols/HorizonMetavars.hpp" 27 : #include "ParallelAlgorithms/Interpolation/Events/Interpolate.hpp" 28 : #include "ParallelAlgorithms/Interpolation/Events/InterpolateWithoutInterpComponent.hpp" 29 : #include "ParallelAlgorithms/Interpolation/Protocols/InterpolationTargetTag.hpp" 30 : #include "ParallelAlgorithms/Interpolation/Targets/Sphere.hpp" 31 : #include "PointwiseFunctions/GeneralRelativity/DetAndInverseSpatialMetric.hpp" 32 : #include "PointwiseFunctions/GeneralRelativity/Tags.hpp" 33 : #include "Time/Tags/TimeAndPrevious.hpp" 34 : #include "Utilities/ProtocolHelpers.hpp" 35 : #include "Utilities/TMPL.hpp" 36 : 37 : /// \cond 38 : class DataVector; 39 : template <size_t VolumeDim> 40 : class ElementId; 41 : template <size_t Dim> 42 : class Mesh; 43 : namespace Parallel { 44 : template <typename Metavariables> 45 : class GlobalCache; 46 : } // namespace Parallel 47 : namespace domain::Tags { 48 : template <size_t Dim> 49 : struct Mesh; 50 : template <size_t Dim, typename Frame> 51 : struct Coordinates; 52 : } // namespace domain::Tags 53 : /// \endcond 54 : 55 : namespace control_system::measurements { 56 : /*! 57 : * \brief A `control_system::protocols::Measurement` that relies on one 58 : * apparent horizon, the template parameter `Object`, and one excision surface. 59 : */ 60 : template <::domain::ObjectLabel Object> 61 1 : struct CharSpeed : tt::ConformsTo<protocols::Measurement> { 62 0 : static std::string name() { return "CharSpeed" + ::domain::name(Object); } 63 : 64 : /*! 65 : * \brief A `control_system::protocols::Submeasurement` that does an 66 : * interpolation to the excision boundary for this `Object` from the elements. 67 : * 68 : * This does not go through the interpolation framework. 69 : */ 70 1 : struct Excision : tt::ConformsTo<protocols::Submeasurement> { 71 0 : static std::string name() { return CharSpeed::name() + "::Excision"; } 72 : 73 : private: 74 : template <typename ControlSystems> 75 0 : struct InterpolationTarget 76 : : tt::ConformsTo<intrp::protocols::InterpolationTargetTag> { 77 0 : static std::string name() { 78 : return "ControlSystemCharSpeedExcision" + ::domain::name(Object); 79 : } 80 : 81 0 : static constexpr size_t index = 82 : Object == ::domain::ObjectLabel::A ? 1_st : 2_st; 83 : 84 0 : using temporal_id = ::Tags::TimeAndPrevious<index>; 85 : 86 0 : using vars_to_interpolate_to_target = tmpl::list< 87 : gr::Tags::Lapse<DataVector>, 88 : ::Tags::deriv<gr::Tags::Lapse<DataVector>, tmpl::size_t<3>, 89 : Frame::Distorted>, 90 : gr::Tags::Shift<DataVector, 3, Frame::Distorted>, 91 : ::Tags::deriv<gr::Tags::Shift<DataVector, 3, Frame::Distorted>, 92 : tmpl::size_t<3>, Frame::Distorted>, 93 : gr::Tags::ShiftyQuantity<DataVector, 3, Frame::Distorted>, 94 : gr::Tags::SpatialMetric<DataVector, 3, Frame::Distorted>, 95 : ::domain::Tags::InverseJacobian<3, Frame::Grid, Frame::Distorted>, 96 : gr::Tags::SpatialChristoffelSecondKind<DataVector, 3, 97 : Frame::Distorted>>; 98 0 : using compute_vars_to_interpolate = 99 : ah::ComputeExcisionBoundaryVolumeQuantities; 100 0 : using compute_items_on_source = 101 : tmpl::list<::Tags::TimeAndPreviousCompute<index>>; 102 0 : using compute_items_on_target = 103 : tmpl::list<gr::Tags::DetAndInverseSpatialMetricCompute< 104 : DataVector, 3, Frame::Distorted>>; 105 0 : using compute_target_points = 106 : intrp::TargetPoints::Sphere<InterpolationTarget, ::Frame::Grid>; 107 0 : using post_interpolation_callbacks = 108 : tmpl::list<control_system::RunCallbacks<Excision, ControlSystems>>; 109 : 110 : template <typename Metavariables> 111 0 : using interpolating_component = 112 : typename Metavariables::gh_dg_element_array; 113 : }; 114 : 115 : public: 116 : template <typename ControlSystems> 117 0 : using interpolation_target_tag = InterpolationTarget<ControlSystems>; 118 : template <typename ControlSystems> 119 0 : using horizon_metavars = void; 120 : 121 : template <typename ControlSystems> 122 0 : using event = NonFactoryCreatableWrapper< 123 : intrp::Events::InterpolateWithoutInterpComponent< 124 : 3, InterpolationTarget<ControlSystems>, ::ah::source_vars<3>>>; 125 : }; 126 : 127 : /*! 128 : * \brief A `control_system::protocols::Submeasurement` that starts the 129 : * interpolation to the interpolation target in order to find the apparent 130 : * horizon. 131 : */ 132 1 : struct Horizon : tt::ConformsTo<protocols::Submeasurement> { 133 0 : static std::string name() { return CharSpeed::name() + "::Horizon"; } 134 : 135 : private: 136 : template <typename ControlSystems> 137 0 : struct InterpolationTarget 138 : : tt::ConformsTo<intrp::protocols::InterpolationTargetTag> { 139 : private: 140 0 : static constexpr size_t index = 141 : Object == ::domain::ObjectLabel::A ? 1_st : 2_st; 142 : 143 : public: 144 0 : static std::string name() { 145 : return "ControlSystemCharSpeedAh" + ::domain::name(Object); 146 : } 147 : 148 : // Separate temporal IDs for each object 149 0 : using temporal_id = ::Tags::TimeAndPrevious<index>; 150 : 151 0 : using vars_to_interpolate_to_target = 152 : ::ah::vars_to_interpolate_to_target<3, ::Frame::Distorted>; 153 0 : using compute_vars_to_interpolate = ::ah::ComputeHorizonVolumeQuantities; 154 0 : using compute_items_on_source = 155 : tmpl::list<::Tags::TimeAndPreviousCompute<index>>; 156 0 : using compute_items_on_target = tmpl::push_back< 157 : ::ah::compute_items_on_target<3, Frame::Distorted>, 158 : ylm::Tags::TimeDerivStrahlkorperCompute<Frame::Distorted>>; 159 0 : using compute_target_points = 160 : ah::TargetPoints::ApparentHorizon<InterpolationTarget, 161 : ::Frame::Distorted>; 162 0 : using post_interpolation_callbacks = 163 : tmpl::list<intrp::callbacks::FindApparentHorizon<InterpolationTarget, 164 : ::Frame::Distorted>>; 165 0 : using horizon_find_failure_callbacks = 166 : tmpl::list<intrp::callbacks::ErrorOnFailedApparentHorizon>; 167 0 : using post_horizon_find_callbacks = 168 : tmpl::list<control_system::RunCallbacks<Horizon, ControlSystems>>; 169 : }; 170 : 171 : template <typename ControlSystems> 172 0 : struct HorizonMetavars : tt::ConformsTo<ah::protocols::HorizonMetavars> { 173 : private: 174 0 : static constexpr size_t index = 175 : Object == ::domain::ObjectLabel::A ? 1_st : 2_st; 176 : 177 : public: 178 0 : static std::string name() { 179 : return "ControlSystemCharSpeedAh" + ::domain::name(Object); 180 : } 181 : 182 : // Separate time tags for each object 183 0 : using time_tag = ::Tags::TimeAndPrevious<index>; 184 : 185 0 : using frame = ::Frame::Distorted; 186 : 187 0 : using horizon_find_callbacks = 188 : tmpl::list<control_system::RunCallbacks<Horizon, ControlSystems>>; 189 0 : using horizon_find_failure_callbacks = 190 : tmpl::list<ah::callbacks::FailedHorizonFind<HorizonMetavars, false>>; 191 : 192 0 : using compute_tags_on_element = 193 : tmpl::list<::Tags::TimeAndPreviousCompute<index>>; 194 : 195 0 : static constexpr ah::Destination destination = 196 : ah::Destination::ControlSystem; 197 : }; 198 : 199 : public: 200 : template <typename ControlSystems> 201 0 : using interpolation_target_tag = void; 202 : template <typename ControlSystems> 203 0 : using horizon_metavars = HorizonMetavars<ControlSystems>; 204 : 205 : template <typename ControlSystems> 206 0 : using event = NonFactoryCreatableWrapper< 207 : ah::Events::FindApparentHorizon<HorizonMetavars<ControlSystems>>>; 208 : }; 209 : 210 0 : using submeasurements = tmpl::list<Horizon, Excision>; 211 : }; 212 : } // namespace control_system::measurements