SpECTRE Documentation Coverage Report
Current view: top level - ControlSystem/Systems - Size.hpp Hit Total Coverage
Commit: 3ddfed217f4ad7ff185c653c2ab25b955494084a Lines: 1 14 7.1 %
Date: 2024-05-01 02:01:53
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/LinkedMessageQueue.hpp"
      23             : #include "DataStructures/Variables.hpp"
      24             : #include "DataStructures/VariablesTag.hpp"
      25             : #include "Domain/StrahlkorperTransformations.hpp"
      26             : #include "Domain/Structure/ObjectLabel.hpp"
      27             : #include "NumericalAlgorithms/SphericalHarmonics/Tags.hpp"
      28             : #include "Parallel/GlobalCache.hpp"
      29             : #include "Parallel/Printf/Printf.hpp"
      30             : #include "ParallelAlgorithms/Actions/UpdateMessageQueue.hpp"
      31             : #include "PointwiseFunctions/GeneralRelativity/Surfaces/Tags.hpp"
      32             : #include "PointwiseFunctions/GeneralRelativity/Tags.hpp"
      33             : #include "Utilities/GetOutput.hpp"
      34             : #include "Utilities/ProtocolHelpers.hpp"
      35             : #include "Utilities/TMPL.hpp"
      36             : 
      37             : /// \cond
      38             : namespace Frame {
      39             : struct Grid;
      40             : struct Distorted;
      41             : }  // namespace Frame
      42             : namespace control_system {
      43             : template <typename ControlSystem>
      44             : struct UpdateControlSystem;
      45             : }
      46             : /// \endcond
      47             : 
      48             : namespace control_system::Systems {
      49             : /*!
      50             :  * \brief Controls the \f$l=0\f$ component of the \link
      51             :  * domain::CoordinateMaps::TimeDependent::Shape Shape \endlink map
      52             :  *
      53             :  * Requirements:
      54             :  * - This control system requires that there be at least one object in the
      55             :  *   simulation
      56             :  * - This object must be a black hole (have an excision)
      57             :  * - Currently this control system can only be used with the \link
      58             :  *   control_system::measurements::CharSpeed CharSpeed \endlink
      59             :  * measurement
      60             :  * - Currently this control system can only be used with the \link
      61             :  *   control_system::ControlErrors::Size Size \endlink control error
      62             :  */
      63             : template <::domain::ObjectLabel Horizon, size_t DerivOrder>
      64           1 : struct Size : tt::ConformsTo<protocols::ControlSystem> {
      65           0 :   static constexpr size_t deriv_order = DerivOrder;
      66             : 
      67           0 :   static std::string name() { return "Size"s + ::domain::name(Horizon); }
      68             : 
      69           0 :   static std::optional<std::string> component_name(
      70             :       const size_t /*i*/, const size_t /*num_components*/) {
      71             :     return "Size";
      72             :   }
      73             : 
      74           0 :   using measurement = control_system::measurements::CharSpeed<Horizon>;
      75             :   static_assert(
      76             :       tt::conforms_to_v<measurement, control_system::protocols::Measurement>);
      77             : 
      78           0 :   using control_error = ControlErrors::Size<deriv_order, Horizon>;
      79             :   static_assert(tt::conforms_to_v<control_error,
      80             :                                   control_system::protocols::ControlError>);
      81             : 
      82             :   // tag goes in control component
      83           0 :   struct MeasurementQueue : db::SimpleTag {
      84           0 :     using type = LinkedMessageQueue<
      85             :         double, tmpl::list<QueueTags::SizeExcisionQuantities<Frame::Distorted>,
      86             :                            QueueTags::SizeHorizonQuantities<Frame::Distorted>>>;
      87             :   };
      88             : 
      89           0 :   using simple_tags = tmpl::list<MeasurementQueue>;
      90             : 
      91           0 :   struct process_measurement {
      92             :     template <typename Submeasurement>
      93           0 :     using argument_tags = tmpl::conditional_t<
      94             :         std::is_same_v<Submeasurement,
      95             :                        typename measurements::CharSpeed<Horizon>::Excision>,
      96             :         tmpl::list<
      97             :             ylm::Tags::Strahlkorper<Frame::Grid>, gr::Tags::Lapse<DataVector>,
      98             :             gr::Tags::ShiftyQuantity<DataVector, 3, Frame::Distorted>,
      99             :             gr::Tags::SpatialMetric<DataVector, 3, Frame::Distorted>,
     100             :             gr::Tags::InverseSpatialMetric<DataVector, 3, Frame::Distorted>>,
     101             :         tmpl::list<ylm::Tags::Strahlkorper<Frame::Distorted>,
     102             :                    ylm::Tags::TimeDerivStrahlkorper<Frame::Distorted>>>;
     103             : 
     104             :     template <typename Metavariables>
     105           0 :     static void apply(
     106             :         typename measurements::CharSpeed<Horizon>::Excision /*meta*/,
     107             :         const ylm::Strahlkorper<Frame::Grid>& grid_excision_surface,
     108             :         const Scalar<DataVector>& lapse,
     109             :         const tnsr::I<DataVector, 3, Frame::Distorted>& shifty_quantity,
     110             :         const tnsr::ii<DataVector, 3, Frame::Distorted>&
     111             :             spatial_metric_on_excision_surface,
     112             :         const tnsr::II<DataVector, 3, Frame::Distorted>&
     113             :             inverse_spatial_metric_on_excision_surface,
     114             :         Parallel::GlobalCache<Metavariables>& cache,
     115             :         const LinkedMessageId<double>& measurement_id) {
     116             :       auto& control_sys_proxy = Parallel::get_parallel_component<
     117             :           ControlComponent<Metavariables, Size>>(cache);
     118             : 
     119             :       if (Parallel::get<Tags::Verbosity>(cache) >= ::Verbosity::Verbose) {
     120             :         Parallel::printf("%s, time = %s: Received excision measurement\n",
     121             :                          name(), measurement_id);
     122             :       }
     123             : 
     124             :       ylm::Strahlkorper<Frame::Distorted> distorted_excision_surface{};
     125             :       strahlkorper_in_different_frame_aligned(
     126             :           make_not_null(&distorted_excision_surface), grid_excision_surface,
     127             :           Parallel::get<domain::Tags::Domain<3>>(cache),
     128             :           Parallel::get<domain::Tags::FunctionsOfTime>(cache),
     129             :           measurement_id.id);
     130             : 
     131             :       Parallel::simple_action<::Actions::UpdateMessageQueue<
     132             :           QueueTags::SizeExcisionQuantities<Frame::Distorted>, MeasurementQueue,
     133             :           UpdateControlSystem<Size>>>(
     134             :           control_sys_proxy, measurement_id,
     135             :           QueueTags::SizeExcisionQuantities<Frame::Distorted>::type{
     136             :               std::move(distorted_excision_surface), lapse, shifty_quantity,
     137             :               spatial_metric_on_excision_surface,
     138             :               inverse_spatial_metric_on_excision_surface});
     139             :     }
     140             : 
     141             :     template <typename Metavariables>
     142           0 :     static void apply(
     143             :         typename measurements::CharSpeed<Horizon>::Horizon /*meta*/,
     144             :         const ylm::Strahlkorper<Frame::Distorted>& horizon,
     145             :         const ylm::Strahlkorper<Frame::Distorted>& time_deriv_horizon,
     146             :         Parallel::GlobalCache<Metavariables>& cache,
     147             :         const LinkedMessageId<double>& measurement_id) {
     148             :       auto& control_sys_proxy = Parallel::get_parallel_component<
     149             :           ControlComponent<Metavariables, Size>>(cache);
     150             : 
     151             :       if (Parallel::get<Tags::Verbosity>(cache) >= ::Verbosity::Verbose) {
     152             :         Parallel::printf("%s, time = %s: Received horizon measurement\n",
     153             :                          name(), measurement_id);
     154             :       }
     155             : 
     156             :       Parallel::simple_action<::Actions::UpdateMessageQueue<
     157             :           QueueTags::SizeHorizonQuantities<Frame::Distorted>, MeasurementQueue,
     158             :           UpdateControlSystem<Size>>>(
     159             :           control_sys_proxy, measurement_id,
     160             :           QueueTags::SizeHorizonQuantities<Frame::Distorted>::type{
     161             :               horizon, time_deriv_horizon});
     162             :     }
     163             :   };
     164             : };
     165             : }  // namespace control_system::Systems

Generated by: LCOV version 1.14