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

Generated by: LCOV version 1.14