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

Generated by: LCOV version 1.14