SpECTRE Documentation Coverage Report
Current view: top level - Evolution/Executables/GeneralizedHarmonic - EvolveGhSingleBlackHole.hpp Hit Total Coverage
Commit: 1f2210958b4f38fdc0400907ee7c6d5af5111418 Lines: 0 45 0.0 %
Date: 2025-12-05 05:03:31
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 <cstdint>
       7             : #include <string>
       8             : #include <vector>
       9             : 
      10             : #include "ControlSystem/Actions/InitializeMeasurements.hpp"
      11             : #include "ControlSystem/Component.hpp"
      12             : #include "ControlSystem/ControlErrors/Size/Factory.hpp"
      13             : #include "ControlSystem/ControlErrors/Size/State.hpp"
      14             : #include "ControlSystem/Measurements/SingleHorizon.hpp"
      15             : #include "ControlSystem/Metafunctions.hpp"
      16             : #include "ControlSystem/Systems/Shape.hpp"
      17             : #include "ControlSystem/Systems/Size.hpp"
      18             : #include "ControlSystem/Systems/Translation.hpp"
      19             : #include "ControlSystem/Trigger.hpp"
      20             : #include "DataStructures/Tensor/IndexType.hpp"
      21             : #include "Domain/Structure/ObjectLabel.hpp"
      22             : #include "Evolution/Actions/RunEventsAndTriggers.hpp"
      23             : #include "Evolution/Executables/GeneralizedHarmonic/Deadlock.hpp"
      24             : #include "Evolution/Executables/GeneralizedHarmonic/GeneralizedHarmonicBase.hpp"
      25             : #include "Evolution/Systems/Cce/Callbacks/DumpBondiSachsOnWorldtube.hpp"
      26             : #include "Evolution/Systems/GeneralizedHarmonic/Actions/SetInitialData.hpp"
      27             : #include "Options/FactoryHelpers.hpp"
      28             : #include "Options/Protocols/FactoryCreation.hpp"
      29             : #include "Options/String.hpp"
      30             : #include "Parallel/ArrayCollection/DgElementCollection.hpp"
      31             : #include "Parallel/GlobalCache.hpp"
      32             : #include "Parallel/Invoke.hpp"
      33             : #include "Parallel/MemoryMonitor/MemoryMonitor.hpp"
      34             : #include "Parallel/PhaseControl/ExecutePhaseChange.hpp"
      35             : #include "Parallel/Protocols/RegistrationMetavariables.hpp"
      36             : #include "ParallelAlgorithms/Actions/FunctionsOfTimeAreReady.hpp"
      37             : #include "ParallelAlgorithms/Actions/MutateApply.hpp"
      38             : #include "ParallelAlgorithms/Amr/Events/ObserveAmrCriteria.hpp"
      39             : #include "ParallelAlgorithms/Amr/Events/ObserveAmrStats.hpp"
      40             : #include "ParallelAlgorithms/Amr/Events/RefineMesh.hpp"
      41             : #include "ParallelAlgorithms/Amr/Projectors/CopyFromCreatorOrLeaveAsIs.hpp"
      42             : #include "ParallelAlgorithms/ApparentHorizonFinder/Callbacks/ErrorOnFailedApparentHorizon.hpp"
      43             : #include "ParallelAlgorithms/ApparentHorizonFinder/Callbacks/FailedHorizonFind.hpp"
      44             : #include "ParallelAlgorithms/ApparentHorizonFinder/Callbacks/FindApparentHorizon.hpp"
      45             : #include "ParallelAlgorithms/ApparentHorizonFinder/Callbacks/IgnoreFailedApparentHorizon.hpp"
      46             : #include "ParallelAlgorithms/ApparentHorizonFinder/Callbacks/ObserveFieldsOnHorizon.hpp"
      47             : #include "ParallelAlgorithms/ApparentHorizonFinder/Callbacks/ObserveTimeSeriesOnHorizon.hpp"
      48             : #include "ParallelAlgorithms/ApparentHorizonFinder/Component.hpp"
      49             : #include "ParallelAlgorithms/ApparentHorizonFinder/ComputeExcisionBoundaryVolumeQuantities.hpp"
      50             : #include "ParallelAlgorithms/ApparentHorizonFinder/ComputeExcisionBoundaryVolumeQuantities.tpp"
      51             : #include "ParallelAlgorithms/ApparentHorizonFinder/ComputeHorizonVolumeQuantities.hpp"
      52             : #include "ParallelAlgorithms/ApparentHorizonFinder/ComputeHorizonVolumeQuantities.tpp"
      53             : #include "ParallelAlgorithms/ApparentHorizonFinder/Criteria/Criterion.hpp"
      54             : #include "ParallelAlgorithms/ApparentHorizonFinder/Criteria/Factory.hpp"
      55             : #include "ParallelAlgorithms/ApparentHorizonFinder/Events/FindApparentHorizon.hpp"
      56             : #include "ParallelAlgorithms/ApparentHorizonFinder/HorizonAliases.hpp"
      57             : #include "ParallelAlgorithms/ApparentHorizonFinder/InterpolationTarget.hpp"
      58             : #include "ParallelAlgorithms/ApparentHorizonFinder/Protocols/HorizonMetavars.hpp"
      59             : #include "ParallelAlgorithms/EventsAndTriggers/Actions/RunEventsOnFailure.hpp"
      60             : #include "ParallelAlgorithms/Interpolation/Actions/CleanUpInterpolator.hpp"
      61             : #include "ParallelAlgorithms/Interpolation/Actions/ElementInitInterpPoints.hpp"
      62             : #include "ParallelAlgorithms/Interpolation/Actions/InitializeInterpolationTarget.hpp"
      63             : #include "ParallelAlgorithms/Interpolation/Actions/InterpolationTargetReceiveVars.hpp"
      64             : #include "ParallelAlgorithms/Interpolation/Actions/InterpolatorReceivePoints.hpp"
      65             : #include "ParallelAlgorithms/Interpolation/Actions/InterpolatorReceiveVolumeData.hpp"
      66             : #include "ParallelAlgorithms/Interpolation/Actions/InterpolatorRegisterElement.hpp"
      67             : #include "ParallelAlgorithms/Interpolation/Actions/TryToInterpolate.hpp"
      68             : #include "ParallelAlgorithms/Interpolation/Callbacks/ObserveSurfaceData.hpp"
      69             : #include "ParallelAlgorithms/Interpolation/Callbacks/ObserveTimeSeriesOnSurface.hpp"
      70             : #include "ParallelAlgorithms/Interpolation/Events/Interpolate.hpp"
      71             : #include "ParallelAlgorithms/Interpolation/Events/InterpolateWithoutInterpComponent.hpp"
      72             : #include "ParallelAlgorithms/Interpolation/InterpolationTarget.hpp"
      73             : #include "ParallelAlgorithms/Interpolation/Interpolator.hpp"
      74             : #include "ParallelAlgorithms/Interpolation/Protocols/InterpolationTargetTag.hpp"
      75             : #include "ParallelAlgorithms/Interpolation/Tags.hpp"
      76             : #include "ParallelAlgorithms/Interpolation/Targets/Sphere.hpp"
      77             : #include "PointwiseFunctions/GeneralRelativity/DetAndInverseSpatialMetric.hpp"
      78             : #include "PointwiseFunctions/GeneralRelativity/Surfaces/Tags.hpp"
      79             : #include "Time/Actions/SelfStartActions.hpp"
      80             : #include "Time/AdvanceTime.hpp"
      81             : #include "Time/ChangeSlabSize/Action.hpp"
      82             : #include "Time/ChangeSlabSize/Tags.hpp"
      83             : #include "Time/StepChoosers/Factory.hpp"
      84             : #include "Time/Tags/StepperErrors.hpp"
      85             : #include "Time/Tags/Time.hpp"
      86             : #include "Time/Tags/TimeAndPrevious.hpp"
      87             : #include "Utilities/Algorithm.hpp"
      88             : #include "Utilities/ErrorHandling/Error.hpp"
      89             : #include "Utilities/PrettyType.hpp"
      90             : #include "Utilities/ProtocolHelpers.hpp"
      91             : 
      92             : template <bool UseLts>
      93             : struct EvolutionMetavars : public GeneralizedHarmonicTemplateBase<3, UseLts> {
      94             :   static constexpr bool local_time_stepping = UseLts;
      95             :   static constexpr size_t volume_dim = 3;
      96           0 :   using gh_base = GeneralizedHarmonicTemplateBase<volume_dim, UseLts>;
      97           0 :   using typename gh_base::initialize_initial_data_dependent_quantities_actions;
      98           0 :   using typename gh_base::system;
      99             : 
     100             :   static constexpr Options::String help{
     101             :       "Evolve the Einstein field equations using the Generalized Harmonic "
     102             :       "formulation,\n"
     103             :       "on a domain with a single horizon and corresponding excised region"};
     104             : 
     105           0 :   struct ApparentHorizon : tt::ConformsTo<ah::protocols::HorizonMetavars> {
     106           0 :     using time_tag = ah::Tags::ObservationTime<0>;
     107             : 
     108           0 :     using frame = ::Frame::Inertial;
     109             : 
     110           0 :     using horizon_find_callbacks = tmpl::list<
     111             :         ah::callbacks::ObserveTimeSeriesOnHorizon<
     112             :             ::ah::tags_for_observing<Frame::Inertial>, ApparentHorizon>,
     113             :         ah::callbacks::ObserveFieldsOnHorizon<::ah::surface_tags_for_observing,
     114             :                                               ApparentHorizon>>;
     115           0 :     using horizon_find_failure_callbacks =
     116             :         tmpl::list<ah::callbacks::FailedHorizonFind<ApparentHorizon, false>>;
     117             : 
     118           0 :     using compute_tags_on_element =
     119             :         tmpl::list<ah::Tags::ObservationTimeCompute<0>>;
     120             : 
     121           0 :     static constexpr ah::Destination destination = ah::Destination::Observation;
     122             : 
     123           0 :     static std::string name() { return "ApparentHorizon"; }
     124             :   };
     125             : 
     126             :   struct ExcisionBoundary
     127             :       : tt::ConformsTo<intrp::protocols::InterpolationTargetTag> {
     128           0 :     using temporal_id = ::Tags::Time;
     129           0 :     using tags_to_observe =
     130             :         tmpl::list<gr::Tags::Lapse<DataVector>,
     131             :                    gr::Tags::Shift<DataVector, 3, Frame::Grid>>;
     132           0 :     using compute_vars_to_interpolate =
     133             :         ah::ComputeExcisionBoundaryVolumeQuantities;
     134           0 :     using vars_to_interpolate_to_target = tags_to_observe;
     135           0 :     using compute_items_on_source = tmpl::list<>;
     136           0 :     using compute_items_on_target = tmpl::list<>;
     137           0 :     using compute_target_points =
     138             :         intrp::TargetPoints::Sphere<ExcisionBoundary, ::Frame::Grid>;
     139           0 :     using post_interpolation_callbacks =
     140             :         tmpl::list<intrp::callbacks::ObserveSurfaceData<
     141             :             tags_to_observe, ExcisionBoundary, ::Frame::Grid>>;
     142             :     // run_callbacks
     143             :     template <typename metavariables>
     144           0 :     using interpolating_component = typename metavariables::gh_dg_element_array;
     145             :   };
     146             : 
     147           0 :   using control_systems =
     148             :       tmpl::list<control_system::Systems::Shape<
     149             :                      ::domain::ObjectLabel::None, 2,
     150             :                      control_system::measurements::SingleHorizon<
     151             :                          ::domain::ObjectLabel::None>>,
     152             :                  control_system::Systems::Translation<
     153             :                      2,
     154             :                      control_system::measurements::SingleHorizon<
     155             :                          ::domain::ObjectLabel::None>,
     156             :                      1>,
     157             :                  control_system::Systems::Size<::domain::ObjectLabel::None, 2>>;
     158             : 
     159             :   static constexpr bool use_control_systems =
     160             :       tmpl::size<control_systems>::value > 0;
     161             : 
     162             :   struct BondiSachs;
     163             : 
     164           0 :   using interpolation_target_tags = tmpl::push_back<
     165             :       control_system::metafunctions::interpolation_target_tags<control_systems>,
     166             :       ExcisionBoundary, BondiSachs>;
     167           0 :   using source_vars_no_deriv =
     168             :       tmpl::list<gr::Tags::SpacetimeMetric<DataVector, volume_dim>,
     169             :                  gh::Tags::Pi<DataVector, volume_dim>,
     170             :                  gh::Tags::Phi<DataVector, volume_dim>>;
     171             : 
     172             :   struct BondiSachs : tt::ConformsTo<intrp::protocols::InterpolationTargetTag> {
     173           0 :     static std::string name() { return "BondiSachsInterpolation"; }
     174           0 :     using temporal_id = ::Tags::Time;
     175           0 :     using vars_to_interpolate_to_target = source_vars_no_deriv;
     176           0 :     using compute_target_points =
     177             :         intrp::TargetPoints::Sphere<BondiSachs, ::Frame::Inertial>;
     178           0 :     using post_interpolation_callbacks =
     179             :         tmpl::list<intrp::callbacks::DumpBondiSachsOnWorldtube<BondiSachs>>;
     180           0 :     using compute_items_on_target = tmpl::list<>;
     181             :     template <typename Metavariables>
     182           0 :     using interpolating_component = typename Metavariables::gh_dg_element_array;
     183             :   };
     184             : 
     185             :   // The interpolator_source_vars need to be the same in both the Interpolate
     186             :   // event and the InterpolateWithoutInterpComponent event.  The Interpolate
     187             :   // event interpolates to the horizon, and the
     188             :   // InterpolateWithoutInterpComponent event interpolates to the excision
     189             :   // boundary. Every Target gets the same interpolator_source_vars, so they need
     190             :   // to be made the same. Otherwise a static assert is triggered.
     191             :   struct factory_creation
     192             :       : tt::ConformsTo<Options::protocols::FactoryCreation> {
     193           0 :     using factory_classes = Options::add_factory_classes<
     194             :         // Restrict to monotonic time steppers in LTS to avoid control
     195             :         // systems deadlocking.
     196             :         tmpl::insert<
     197             :             tmpl::erase<typename gh_base::factory_creation::factory_classes,
     198             :                         LtsTimeStepper>,
     199             :             tmpl::pair<LtsTimeStepper,
     200             :                        TimeSteppers::monotonic_lts_time_steppers>>,
     201             :         tmpl::pair<ah::Criterion, ah::Criteria::standard_criteria>,
     202             :         tmpl::pair<Event,
     203             :                    tmpl::flatten<tmpl::list<
     204             :                        ah::Events::FindApparentHorizon<ApparentHorizon>,
     205             :                        control_system::metafunctions::control_system_events<
     206             :                            control_systems>,
     207             :                        intrp::Events::InterpolateWithoutInterpComponent<
     208             :                            3, BondiSachs, source_vars_no_deriv>,
     209             :                        intrp::Events::InterpolateWithoutInterpComponent<
     210             :                            3, ExcisionBoundary, ::ah::source_vars<volume_dim>>,
     211             :                        amr::Events::RefineMesh,
     212             :                        amr::Events::ObserveAmrStats<volume_dim>>>>,
     213             :         tmpl::pair<DenseTrigger,
     214             :                    control_system::control_system_triggers<control_systems>>,
     215             :         tmpl::pair<control_system::size::State,
     216             :                    control_system::size::States::factory_creatable_states>>;
     217             :   };
     218             : 
     219           0 :   using typename gh_base::const_global_cache_tags;
     220             : 
     221           0 :   using observed_reduction_data_tags =
     222             :       observers::collect_reduction_data_tags<tmpl::push_back<
     223             :           tmpl::at<typename factory_creation::factory_classes, Event>,
     224             :           typename ExcisionBoundary::post_interpolation_callbacks>>;
     225             : 
     226           0 :   using dg_registration_list = typename gh_base::dg_registration_list;
     227             : 
     228           0 :   using step_actions =
     229             :       typename gh_base::template step_actions<EvolutionMetavars,
     230             :                                               control_systems>;
     231             : 
     232           0 :   using initialization_actions = tmpl::push_back<
     233             :       tmpl::pop_back<typename gh_base::template initialization_actions<
     234             :           EvolutionMetavars, use_control_systems>>,
     235             :       control_system::Actions::InitializeMeasurements<control_systems>,
     236             :       intrp::Actions::ElementInitInterpPoints<volume_dim,
     237             :                                               interpolation_target_tags>,
     238             :       tmpl::back<typename gh_base::template initialization_actions<
     239             :           EvolutionMetavars, use_control_systems>>>;
     240             : 
     241           0 :   using gh_dg_element_array = DgElementArray<
     242             :       EvolutionMetavars,
     243             :       tmpl::flatten<tmpl::list<
     244             :           Parallel::PhaseActions<Parallel::Phase::Initialization,
     245             :                                  initialization_actions>,
     246             :           Parallel::PhaseActions<
     247             :               Parallel::Phase::RegisterWithElementDataReader,
     248             :               tmpl::list<importers::Actions::RegisterWithElementDataReader,
     249             :                          Parallel::Actions::TerminatePhase>>,
     250             :           Parallel::PhaseActions<
     251             :               Parallel::Phase::ImportInitialData,
     252             :               tmpl::list<gh::Actions::SetInitialData,
     253             :                          gh::Actions::ReceiveNumericInitialData,
     254             :                          Parallel::Actions::TerminatePhase>>,
     255             :           Parallel::PhaseActions<
     256             :               Parallel::Phase::InitializeInitialDataDependentQuantities,
     257             :               initialize_initial_data_dependent_quantities_actions>,
     258             :           Parallel::PhaseActions<
     259             :               Parallel::Phase::InitializeTimeStepperHistory,
     260             :               SelfStart::self_start_procedure<step_actions, system>>,
     261             :           Parallel::PhaseActions<Parallel::Phase::Register,
     262             :                                  tmpl::list<dg_registration_list,
     263             :                                             Parallel::Actions::TerminatePhase>>,
     264             :           Parallel::PhaseActions<Parallel::Phase::Restart,
     265             :                                  tmpl::list<dg_registration_list,
     266             :                                             Parallel::Actions::TerminatePhase>>,
     267             :           Parallel::PhaseActions<
     268             :               Parallel::Phase::WriteCheckpoint,
     269             :               tmpl::list<evolution::Actions::RunEventsAndTriggers<
     270             :                              Triggers::WhenToCheck::AtCheckpoints>,
     271             :                          Parallel::Actions::TerminatePhase>>,
     272             :           Parallel::PhaseActions<Parallel::Phase::CheckDomain,
     273             :                                  tmpl::list<::amr::Actions::SendAmrDiagnostics,
     274             :                                             Parallel::Actions::TerminatePhase>>,
     275             :           Parallel::PhaseActions<
     276             :               Parallel::Phase::Evolve,
     277             :               tmpl::flatten<tmpl::list<
     278             :                   ::domain::Actions::CheckFunctionsOfTimeAreReady<volume_dim>,
     279             :                   std::conditional_t<local_time_stepping,
     280             :                                      evolution::Actions::RunEventsAndTriggers<
     281             :                                          Triggers::WhenToCheck::AtSteps>,
     282             :                                      tmpl::list<>>,
     283             :                   evolution::Actions::RunEventsAndTriggers<
     284             :                       Triggers::WhenToCheck::AtSlabs>,
     285             :                   Actions::ChangeSlabSize, step_actions,
     286             :                   Actions::MutateApply<AdvanceTime>,
     287             :                   PhaseControl::Actions::ExecutePhaseChange>>>,
     288             :           Parallel::PhaseActions<
     289             :               Parallel::Phase::PostFailureCleanup,
     290             :               tmpl::list<Actions::RunEventsOnFailure<::Tags::Time>,
     291             :                          Parallel::Actions::TerminatePhase>>>>>;
     292             : 
     293             :   struct amr : tt::ConformsTo<::amr::protocols::AmrMetavariables> {
     294           0 :     using element_array = gh_dg_element_array;
     295           0 :     using projectors = tmpl::list<
     296             :         Initialization::ProjectTimeStepping<volume_dim>,
     297             :         evolution::dg::Initialization::ProjectDomain<volume_dim>,
     298             :         Initialization::ProjectTimeStepperHistory<EvolutionMetavars>,
     299             :         ::amr::projectors::ProjectVariables<volume_dim,
     300             :                                             typename system::variables_tag>,
     301             :         evolution::dg::Initialization::ProjectMortars<EvolutionMetavars>,
     302             :         evolution::Actions::ProjectRunEventsAndDenseTriggers,
     303             :         ::amr::projectors::DefaultInitialize<
     304             :             Initialization::Tags::InitialTimeDelta,
     305             :             Initialization::Tags::InitialSlabSize<gh_base::local_time_stepping>,
     306             :             ::domain::Tags::InitialExtents<volume_dim>,
     307             :             ::domain::Tags::InitialRefinementLevels<volume_dim>,
     308             :             evolution::dg::Tags::Quadrature,
     309             :             Tags::StepperErrors<typename system::variables_tag>,
     310             :             SelfStart::Tags::InitialValue<typename system::variables_tag>,
     311             :             SelfStart::Tags::InitialValue<Tags::TimeStep>>,
     312             :         ::amr::projectors::CopyFromCreatorOrLeaveAsIs<tmpl::push_back<
     313             :             tmpl::append<
     314             :                 typename control_system::Actions::InitializeMeasurements<
     315             :                     control_systems>::simple_tags,
     316             :                 tmpl::transform<
     317             :                     intrp::InterpolationTarget_detail::
     318             :                         get_non_sequential_target_tags<
     319             :                             interpolation_target_tags>,
     320             :                     tmpl::bind<intrp::Tags::PointInfo, tmpl::_1,
     321             :                                tmpl::pin<tmpl::size_t<volume_dim>>>>>,
     322             :             Tags::ChangeSlabSize::NumberOfExpectedMessages,
     323             :             Tags::ChangeSlabSize::NewSlabSize>>>;
     324             :     static constexpr bool keep_coarse_grids = false;
     325             :     static constexpr bool p_refine_only_in_event = true;
     326             :   };
     327             : 
     328             :   struct registration
     329             :       : tt::ConformsTo<Parallel::protocols::RegistrationMetavariables> {
     330           0 :     using element_registrars =
     331             :         tmpl::map<tmpl::pair<gh_dg_element_array, dg_registration_list>>;
     332             :   };
     333             : 
     334           0 :   using control_system_horizon_metavars =
     335             :       control_system::metafunctions::horizon_metavars<control_systems>;
     336           0 :   using control_components =
     337             :       control_system::control_components<EvolutionMetavars, control_systems>;
     338             : 
     339           0 :   static void run_deadlock_analysis_simple_actions(
     340             :       Parallel::GlobalCache<EvolutionMetavars>& cache,
     341             :       const std::vector<std::string>& deadlocked_components) {
     342             :     gh::deadlock::run_deadlock_analysis_simple_actions<
     343             :         gh_dg_element_array, control_components, interpolation_target_tags,
     344             :         tmpl::list<ApparentHorizon>, false>(cache, deadlocked_components);
     345             :   }
     346             : 
     347           0 :   using component_list = tmpl::flatten<tmpl::list<
     348             :       ::amr::Component<EvolutionMetavars>,
     349             :       observers::Observer<EvolutionMetavars>,
     350             :       observers::ObserverWriter<EvolutionMetavars>,
     351             :       mem_monitor::MemoryMonitor<EvolutionMetavars>,
     352             :       importers::ElementDataReader<EvolutionMetavars>, gh_dg_element_array,
     353             :       ah::Component<EvolutionMetavars, ApparentHorizon>, control_components,
     354             :       tmpl::transform<
     355             :           control_system_horizon_metavars,
     356             :           tmpl::bind<ah::Component, tmpl::pin<EvolutionMetavars>, tmpl::_1>>,
     357             :       tmpl::transform<interpolation_target_tags,
     358             :                       tmpl::bind<intrp::InterpolationTarget,
     359             :                                  tmpl::pin<EvolutionMetavars>, tmpl::_1>>>>;
     360             : };

Generated by: LCOV version 1.14