SpECTRE Documentation Coverage Report
Current view: top level - ControlSystem/Systems - Size.hpp Hit Total Coverage
Commit: fbcce2ed065a8e48da2f38009a84bbfbc0c260ee Lines: 1 14 7.1 %
Date: 2025-11-14 20:55:50
Legend: Lines: hit not hit

          Line data    Source code
       1           0 : // Distributed under the MIT License.
       2             : // See LICENSE.txt for details.
       3             : 
       4             : #pragma once
       5             : 
       6             : #include <array>
       7             : #include <cmath>
       8             : #include <cstddef>
       9             : #include <optional>
      10             : #include <string>
      11             : 
      12             : #include "ControlSystem/Component.hpp"
      13             : #include "ControlSystem/ControlErrors/Size.hpp"
      14             : #include "ControlSystem/Measurements/CharSpeed.hpp"
      15             : #include "ControlSystem/Protocols/ControlError.hpp"
      16             : #include "ControlSystem/Protocols/ControlSystem.hpp"
      17             : #include "ControlSystem/Protocols/Measurement.hpp"
      18             : #include "ControlSystem/Tags/QueueTags.hpp"
      19             : #include "ControlSystem/Tags/SystemTags.hpp"
      20             : #include "DataStructures/DataBox/DataBox.hpp"
      21             : #include "DataStructures/DataBox/Tag.hpp"
      22             : #include "DataStructures/DataVector.hpp"
      23             : #include "DataStructures/LinkedMessageQueue.hpp"
      24             : #include "DataStructures/Tensor/TypeAliases.hpp"
      25             : #include "DataStructures/Variables.hpp"
      26             : #include "DataStructures/VariablesTag.hpp"
      27             : #include "Domain/StrahlkorperTransformations.hpp"
      28             : #include "Domain/Structure/ObjectLabel.hpp"
      29             : #include "Domain/Tags.hpp"
      30             : #include "NumericalAlgorithms/LinearOperators/PartialDerivatives.hpp"
      31             : #include "NumericalAlgorithms/SphericalHarmonics/Tags.hpp"
      32             : #include "Parallel/GlobalCache.hpp"
      33             : #include "Parallel/Printf/Printf.hpp"
      34             : #include "ParallelAlgorithms/Actions/UpdateMessageQueue.hpp"
      35             : #include "PointwiseFunctions/GeneralRelativity/Surfaces/Tags.hpp"
      36             : #include "PointwiseFunctions/GeneralRelativity/Tags.hpp"
      37             : #include "Utilities/GetOutput.hpp"
      38             : #include "Utilities/ProtocolHelpers.hpp"
      39             : #include "Utilities/TMPL.hpp"
      40             : 
      41             : /// \cond
      42             : namespace Frame {
      43             : struct Grid;
      44             : struct Distorted;
      45             : }  // namespace Frame
      46             : namespace control_system {
      47             : template <typename ControlSystem>
      48             : struct UpdateControlSystem;
      49             : }
      50             : /// \endcond
      51             : 
      52             : namespace control_system::Systems {
      53             : /*!
      54             :  * \brief Controls the \f$l=0\f$ component of the \link
      55             :  * domain::CoordinateMaps::TimeDependent::Shape Shape \endlink map
      56             :  *
      57             :  * Requirements:
      58             :  * - This control system requires that there be at least one object in the
      59             :  *   simulation
      60             :  * - This object must be a black hole (have an excision)
      61             :  * - Currently this control system can only be used with the \link
      62             :  *   control_system::measurements::CharSpeed CharSpeed \endlink
      63             :  * measurement
      64             :  * - Currently this control system can only be used with the \link
      65             :  *   control_system::ControlErrors::Size Size \endlink control error
      66             :  */
      67             : template <::domain::ObjectLabel Horizon, size_t DerivOrder>
      68           1 : struct Size : tt::ConformsTo<protocols::ControlSystem> {
      69           0 :   static constexpr size_t deriv_order = DerivOrder;
      70             : 
      71           0 :   static std::string name() { return "Size"s + ::domain::name(Horizon); }
      72             : 
      73           0 :   static std::optional<std::string> component_name(
      74             :       const size_t /*i*/, const size_t /*num_components*/) {
      75             :     return "Size";
      76             :   }
      77             : 
      78           0 :   using measurement = control_system::measurements::CharSpeed<Horizon>;
      79             :   static_assert(
      80             :       tt::conforms_to_v<measurement, control_system::protocols::Measurement>);
      81             : 
      82           0 :   using control_error = ControlErrors::Size<deriv_order, Horizon>;
      83             :   static_assert(tt::conforms_to_v<control_error,
      84             :                                   control_system::protocols::ControlError>);
      85             : 
      86             :   // tag goes in control component
      87           0 :   struct MeasurementQueue : db::SimpleTag {
      88           0 :     using type = LinkedMessageQueue<
      89             :         double, tmpl::list<QueueTags::SizeExcisionQuantities<Frame::Distorted>,
      90             :                            QueueTags::SizeHorizonQuantities<Frame::Distorted>>>;
      91             :   };
      92             : 
      93           0 :   using simple_tags = tmpl::list<MeasurementQueue>;
      94             : 
      95           0 :   struct process_measurement {
      96             :     template <typename Submeasurement>
      97           0 :     using argument_tags = tmpl::conditional_t<
      98             :         std::is_same_v<Submeasurement,
      99             :                        typename measurements::CharSpeed<Horizon>::Excision>,
     100             :         tmpl::list<
     101             :             ylm::Tags::Strahlkorper<Frame::Grid>, gr::Tags::Lapse<DataVector>,
     102             :             gr::Tags::ShiftyQuantity<DataVector, 3, Frame::Distorted>,
     103             :             gr::Tags::SpatialMetric<DataVector, 3, Frame::Distorted>,
     104             :             gr::Tags::InverseSpatialMetric<DataVector, 3, Frame::Distorted>,
     105             :             gr::Tags::SpatialChristoffelSecondKind<DataVector, 3,
     106             :                                                    Frame::Distorted>,
     107             :             ::Tags::deriv<gr::Tags::Lapse<DataVector>, tmpl::size_t<3>,
     108             :                           Frame::Distorted>,
     109             :             ::Tags::deriv<gr::Tags::Shift<DataVector, 3, Frame::Distorted>,
     110             :                           tmpl::size_t<3>, Frame::Distorted>,
     111             :             domain::Tags::InverseJacobian<3, Frame::Grid, Frame::Distorted>>,
     112             :         tmpl::list<ylm::Tags::Strahlkorper<Frame::Distorted>,
     113             :                    ylm::Tags::TimeDerivStrahlkorper<Frame::Distorted>>>;
     114             : 
     115             :     template <typename Metavariables>
     116           0 :     static void apply(
     117             :         typename measurements::CharSpeed<Horizon>::Excision /*meta*/,
     118             :         const ylm::Strahlkorper<Frame::Grid>& grid_excision_surface,
     119             :         const Scalar<DataVector>& lapse,
     120             :         const tnsr::I<DataVector, 3, Frame::Distorted>& shifty_quantity,
     121             :         const tnsr::ii<DataVector, 3, Frame::Distorted>&
     122             :             spatial_metric_on_excision_surface,
     123             :         const tnsr::II<DataVector, 3, Frame::Distorted>&
     124             :             inverse_spatial_metric_on_excision_surface,
     125             :         const tnsr::Ijj<DataVector, 3, Frame::Distorted>& spatial_christoffel,
     126             :         const tnsr::i<DataVector, 3, Frame::Distorted>& deriv_lapse,
     127             :         const tnsr::iJ<DataVector, 3, Frame::Distorted>& deriv_shift,
     128             :         const ::InverseJacobian<DataVector, 3, Frame::Grid, Frame::Distorted>&
     129             :             inv_jac_grid_to_distorted,
     130             :         Parallel::GlobalCache<Metavariables>& cache,
     131             :         const LinkedMessageId<double>& measurement_id) {
     132             :       auto& control_sys_proxy = Parallel::get_parallel_component<
     133             :           ControlComponent<Metavariables, Size>>(cache);
     134             : 
     135             :       if (Parallel::get<Tags::Verbosity>(cache) >= ::Verbosity::Verbose) {
     136             :         Parallel::printf("%s, time = %s: Received excision measurement\n",
     137             :                          name(), measurement_id);
     138             :       }
     139             : 
     140             :       ylm::Strahlkorper<Frame::Distorted> distorted_excision_surface{};
     141             :       strahlkorper_in_different_frame_aligned(
     142             :           make_not_null(&distorted_excision_surface), grid_excision_surface,
     143             :           Parallel::get<domain::Tags::Domain<3>>(cache),
     144             :           Parallel::get<domain::Tags::FunctionsOfTime>(cache),
     145             :           measurement_id.id);
     146             : 
     147             :       Parallel::simple_action<::Actions::UpdateMessageQueue<
     148             :           MeasurementQueue, UpdateControlSystem<Size>,
     149             :           QueueTags::SizeExcisionQuantities<Frame::Distorted>>>(
     150             :           control_sys_proxy, measurement_id,
     151             :           QueueTags::SizeExcisionQuantities<Frame::Distorted>::type{
     152             :               std::move(distorted_excision_surface), lapse, shifty_quantity,
     153             :               spatial_metric_on_excision_surface,
     154             :               inverse_spatial_metric_on_excision_surface, spatial_christoffel,
     155             :               deriv_lapse, deriv_shift, inv_jac_grid_to_distorted});
     156             :     }
     157             : 
     158             :     template <typename Metavariables>
     159           0 :     static void apply(
     160             :         typename measurements::CharSpeed<Horizon>::Horizon /*meta*/,
     161             :         const ylm::Strahlkorper<Frame::Distorted>& horizon,
     162             :         const ylm::Strahlkorper<Frame::Distorted>& time_deriv_horizon,
     163             :         Parallel::GlobalCache<Metavariables>& cache,
     164             :         const LinkedMessageId<double>& measurement_id) {
     165             :       auto& control_sys_proxy = Parallel::get_parallel_component<
     166             :           ControlComponent<Metavariables, Size>>(cache);
     167             : 
     168             :       if (Parallel::get<Tags::Verbosity>(cache) >= ::Verbosity::Verbose) {
     169             :         Parallel::printf("%s, time = %s: Received horizon measurement\n",
     170             :                          name(), measurement_id);
     171             :       }
     172             : 
     173             :       Parallel::simple_action<::Actions::UpdateMessageQueue<
     174             :           MeasurementQueue, UpdateControlSystem<Size>,
     175             :           QueueTags::SizeHorizonQuantities<Frame::Distorted>>>(
     176             :           control_sys_proxy, measurement_id,
     177             :           QueueTags::SizeHorizonQuantities<Frame::Distorted>::type{
     178             :               horizon, time_deriv_horizon});
     179             :     }
     180             :   };
     181             : };
     182             : }  // namespace control_system::Systems

Generated by: LCOV version 1.14