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

Generated by: LCOV version 1.14