SpECTRE Documentation Coverage Report
Current view: top level - Elliptic/Executables/Xcts - SolveXcts.hpp Hit Total Coverage
Commit: 1f2210958b4f38fdc0400907ee7c6d5af5111418 Lines: 0 1 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 <cstddef>
       7             : 
       8             : #include "DataStructures/DataBox/PrefixHelpers.hpp"
       9             : #include "DataStructures/Tensor/EagerMath/Magnitude.hpp"
      10             : #include "Domain/Creators/Factory3D.hpp"
      11             : #include "Domain/RadiallyCompressedCoordinates.hpp"
      12             : #include "Domain/Tags.hpp"
      13             : #include "Elliptic/Actions/RunEventsAndTriggers.hpp"
      14             : #include "Elliptic/BoundaryConditions/BoundaryCondition.hpp"
      15             : #include "Elliptic/DiscontinuousGalerkin/DgElementArray.hpp"
      16             : #include "Elliptic/Executables/Solver.hpp"
      17             : #include "Elliptic/Systems/Xcts/BoundaryConditions/Factory.hpp"
      18             : #include "Elliptic/Systems/Xcts/Events/ObserveAdmIntegrals.hpp"
      19             : #include "Elliptic/Systems/Xcts/FirstOrderSystem.hpp"
      20             : #include "Elliptic/Systems/Xcts/HydroQuantities.hpp"
      21             : #include "Elliptic/Triggers/Factory.hpp"
      22             : #include "IO/Observer/Actions/RegisterEvents.hpp"
      23             : #include "IO/Observer/Helpers.hpp"
      24             : #include "IO/Observer/ObserverComponent.hpp"
      25             : #include "Options/Protocols/FactoryCreation.hpp"
      26             : #include "Options/String.hpp"
      27             : #include "Parallel/GlobalCache.hpp"
      28             : #include "Parallel/Phase.hpp"
      29             : #include "Parallel/PhaseControl/VisitAndReturn.hpp"
      30             : #include "Parallel/PhaseDependentActionList.hpp"
      31             : #include "Parallel/Protocols/RegistrationMetavariables.hpp"
      32             : #include "Parallel/Reduction.hpp"
      33             : #include "ParallelAlgorithms/Actions/TerminatePhase.hpp"
      34             : #include "ParallelAlgorithms/Amr/Actions/SendAmrDiagnostics.hpp"
      35             : #include "ParallelAlgorithms/Amr/Criteria/Factory.hpp"
      36             : #include "ParallelAlgorithms/Amr/Protocols/AmrMetavariables.hpp"
      37             : #include "ParallelAlgorithms/Amr/Tags.hpp"
      38             : #include "ParallelAlgorithms/Events/Factory.hpp"
      39             : #include "ParallelAlgorithms/Events/Tags.hpp"
      40             : #include "ParallelAlgorithms/EventsAndTriggers/Completion.hpp"
      41             : #include "ParallelAlgorithms/EventsAndTriggers/Event.hpp"
      42             : #include "ParallelAlgorithms/EventsAndTriggers/Trigger.hpp"
      43             : #include "ParallelAlgorithms/LinearSolver/Multigrid/ElementsAllocator.hpp"
      44             : #include "ParallelAlgorithms/LinearSolver/Multigrid/Tags.hpp"
      45             : #include "PointwiseFunctions/AnalyticData/Xcts/Binary.hpp"
      46             : #include "PointwiseFunctions/AnalyticSolutions/Xcts/Factory.hpp"
      47             : #include "PointwiseFunctions/Hydro/LowerSpatialFourVelocity.hpp"
      48             : #include "PointwiseFunctions/Hydro/Tags.hpp"
      49             : #include "PointwiseFunctions/InitialDataUtilities/AnalyticSolution.hpp"
      50             : #include "PointwiseFunctions/InitialDataUtilities/Background.hpp"
      51             : #include "PointwiseFunctions/InitialDataUtilities/InitialGuess.hpp"
      52             : #include "PointwiseFunctions/InitialDataUtilities/NumericData.hpp"
      53             : #include "PointwiseFunctions/Xcts/SpacetimeQuantities.hpp"
      54             : #include "Utilities/Functional.hpp"
      55             : #include "Utilities/ProtocolHelpers.hpp"
      56             : #include "Utilities/TMPL.hpp"
      57             : 
      58             : /// \cond
      59             : struct Metavariables {
      60             :   static constexpr size_t volume_dim = 3;
      61             :   static constexpr int conformal_matter_scale = 0;
      62             :   using system =
      63             :       Xcts::FirstOrderSystem<Xcts::Equations::HamiltonianLapseAndShift,
      64             :                              Xcts::Geometry::Curved, conformal_matter_scale>;
      65             :   using solver = elliptic::Solver<Metavariables, volume_dim, system>;
      66             : 
      67             :   static constexpr Options::String help{
      68             :       "Find the solution to an XCTS problem."};
      69             : 
      70             :   using analytic_solution_fields = tmpl::append<typename system::primal_fields>;
      71             :   using spacetime_quantities_compute =
      72             :       Xcts::Tags::SpacetimeQuantitiesCompute<tmpl::list<
      73             :           Xcts::Tags::ConformalFactor<DataVector>,
      74             :           Xcts::Tags::LapseTimesConformalFactor<DataVector>,
      75             :           ::Tags::deriv<Xcts::Tags::ConformalFactor<DataVector>,
      76             :                         tmpl::size_t<3>, Frame::Inertial>,
      77             :           gr::Tags::HamiltonianConstraint<DataVector>,
      78             :           gr::Tags::MomentumConstraint<DataVector, 3>,
      79             :           gr::Tags::SpatialMetric<DataVector, 3>,
      80             :           gr::Tags::InverseSpatialMetric<DataVector, 3>,
      81             :           ::Tags::deriv<gr::Tags::InverseSpatialMetric<DataVector, 3>,
      82             :                         tmpl::size_t<3>, Frame::Inertial>,
      83             :           gr::Tags::SpatialChristoffelSecondKind<DataVector, 3>,
      84             :           gr::Tags::SpatialRicci<DataVector, 3>, gr::Tags::Lapse<DataVector>,
      85             :           ::Tags::deriv<gr::Tags::Lapse<DataVector>, tmpl::size_t<3>,
      86             :                         Frame::Inertial>,
      87             :           gr::Tags::Shift<DataVector, 3>,
      88             :           ::Tags::deriv<gr::Tags::Shift<DataVector, 3>, tmpl::size_t<3>,
      89             :                         Frame::Inertial>,
      90             :           gr::Tags::ExtrinsicCurvature<DataVector, 3>>>;
      91             :   using hydro_quantities_compute = Xcts::Tags::HydroQuantitiesCompute<
      92             :       tmpl::list<hydro::Tags::RestMassDensity<DataVector>,
      93             :                  hydro::Tags::SpecificEnthalpy<DataVector>,
      94             :                  hydro::Tags::Pressure<DataVector>,
      95             :                  hydro::Tags::SpatialVelocity<DataVector, 3>,
      96             :                  hydro::Tags::LorentzFactor<DataVector>,
      97             :                  hydro::Tags::MagneticField<DataVector, 3>>>;
      98             :   using error_compute = ::Tags::ErrorsCompute<analytic_solution_fields>;
      99             :   using error_tags = db::wrap_tags_in<Tags::Error, analytic_solution_fields>;
     100             :   using observe_fields = tmpl::append<
     101             :       analytic_solution_fields, typename system::background_fields,
     102             :       typename spacetime_quantities_compute::tags_list,
     103             :       typename hydro_quantities_compute::tags_list, error_tags,
     104             :       typename solver::observe_fields,
     105             :       tmpl::list<domain::Tags::Coordinates<volume_dim, Frame::Inertial>,
     106             :                  domain::Tags::RadiallyCompressedCoordinatesCompute<
     107             :                      volume_dim, Frame::Inertial>,
     108             :                  ::Tags::NonEuclideanMagnitude<
     109             :                      Xcts::Tags::ShiftExcess<DataVector, 3, Frame::Inertial>,
     110             :                      gr::Tags::SpatialMetric<DataVector, 3>>,
     111             :                  hydro::Tags::LowerSpatialFourVelocityCompute>>;
     112             :   using observer_compute_tags = tmpl::list<
     113             :       ::Events::Tags::ObserverMeshCompute<volume_dim>,
     114             :       ::Events::Tags::ObserverDetInvJacobianCompute<Frame::ElementLogical,
     115             :                                                     Frame::Inertial>,
     116             :       spacetime_quantities_compute, hydro_quantities_compute, error_compute>;
     117             : 
     118             :   // Collect all items to store in the cache.
     119             :   using const_global_cache_tags =
     120             :       tmpl::list<domain::Tags::RadiallyCompressedCoordinatesOptions>;
     121             : 
     122             :   struct factory_creation
     123             :       : tt::ConformsTo<Options::protocols::FactoryCreation> {
     124             :     using analytic_solutions_and_data = tmpl::push_back<
     125             :         Xcts::Solutions::all_analytic_solutions,
     126             :         Xcts::AnalyticData::Binary<elliptic::analytic_data::AnalyticSolution,
     127             :                                    Xcts::Solutions::all_analytic_solutions>,
     128             :         elliptic::analytic_data::NumericData>;
     129             : 
     130             :     using factory_classes = tmpl::map<
     131             :         tmpl::pair<DomainCreator<volume_dim>, domain_creators<volume_dim>>,
     132             :         tmpl::pair<elliptic::analytic_data::Background,
     133             :                    analytic_solutions_and_data>,
     134             :         tmpl::pair<elliptic::analytic_data::InitialGuess,
     135             :                    analytic_solutions_and_data>,
     136             :         tmpl::pair<elliptic::analytic_data::AnalyticSolution,
     137             :                    Xcts::Solutions::all_analytic_solutions>,
     138             :         tmpl::pair<
     139             :             elliptic::BoundaryConditions::BoundaryCondition<volume_dim>,
     140             :             Xcts::BoundaryConditions::standard_boundary_conditions<system>>,
     141             :         tmpl::pair<::amr::Criterion,
     142             :                    ::amr::Criteria::standard_criteria<
     143             :                        volume_dim, typename system::primal_fields>>,
     144             :         tmpl::pair<Event,
     145             :                    tmpl::flatten<tmpl::list<
     146             :                        Events::Completion,
     147             :                        Events::ObserveAdmIntegrals<::amr::Tags::IsFinestGrid>,
     148             :                        dg::Events::field_observations<
     149             :                            volume_dim, observe_fields, observer_compute_tags,
     150             :                            ::amr::Tags::IsFinestGrid>>>>,
     151             :         tmpl::pair<Trigger, elliptic::Triggers::all_triggers<
     152             :                                 ::amr::OptionTags::AmrGroup>>,
     153             :         tmpl::pair<
     154             :             PhaseChange,
     155             :             tmpl::list<
     156             :                 PhaseControl::VisitAndReturn<
     157             :                     Parallel::Phase::EvaluateAmrCriteria>,
     158             :                 PhaseControl::VisitAndReturn<Parallel::Phase::AdjustDomain>,
     159             :                 PhaseControl::VisitAndReturn<Parallel::Phase::UpdateSections>,
     160             :                 PhaseControl::VisitAndReturn<Parallel::Phase::CheckDomain>>>,
     161             :         tmpl::pair<
     162             :             grmhd::AnalyticData::InitialMagneticFields::InitialMagneticField,
     163             :             grmhd::AnalyticData::InitialMagneticFields::
     164             :                 initial_magnetic_fields>>;
     165             :   };
     166             : 
     167             :   // Collect all reduction tags for observers
     168             :   using observed_reduction_data_tags =
     169             :       observers::collect_reduction_data_tags<tmpl::flatten<tmpl::list<
     170             :           tmpl::at<factory_creation::factory_classes, Event>, solver>>>;
     171             : 
     172             :   using initialization_actions =
     173             :       tmpl::push_back<typename solver::initialization_actions,
     174             :                       Parallel::Actions::TerminatePhase>;
     175             : 
     176             :   using register_actions =
     177             :       tmpl::push_back<typename solver::register_actions,
     178             :                       observers::Actions::RegisterEventsWithObservers>;
     179             : 
     180             :   using solve_actions = typename solver::template solve_actions<tmpl::list<>>;
     181             : 
     182             :   using dg_element_array = elliptic::DgElementArray<
     183             :       Metavariables,
     184             :       tmpl::list<Parallel::PhaseActions<Parallel::Phase::Initialization,
     185             :                                         initialization_actions>,
     186             :                  Parallel::PhaseActions<
     187             :                      Parallel::Phase::Register,
     188             :                      tmpl::push_back<register_actions,
     189             :                                      Parallel::Actions::TerminatePhase>>,
     190             :                  Parallel::PhaseActions<
     191             :                      Parallel::Phase::Restart,
     192             :                      tmpl::push_back<register_actions,
     193             :                                      Parallel::Actions::TerminatePhase>>,
     194             :                  Parallel::PhaseActions<Parallel::Phase::Solve, solve_actions>,
     195             :                  Parallel::PhaseActions<
     196             :                      Parallel::Phase::CheckDomain,
     197             :                      tmpl::list<::amr::Actions::SendAmrDiagnostics,
     198             :                                 Parallel::Actions::TerminatePhase>>>,
     199             :       LinearSolver::multigrid::ElementsAllocator<
     200             :           volume_dim, typename solver::multigrid::options_group>>;
     201             : 
     202             :   struct amr : tt::ConformsTo<::amr::protocols::AmrMetavariables> {
     203             :     using element_array = dg_element_array;
     204             :     using projectors = typename solver::amr_projectors;
     205             :     static constexpr bool keep_coarse_grids = true;
     206             :     static constexpr bool p_refine_only_in_event = false;
     207             :   };
     208             : 
     209             :   struct registration
     210             :       : tt::ConformsTo<Parallel::protocols::RegistrationMetavariables> {
     211             :     using element_registrars =
     212             :         tmpl::map<tmpl::pair<dg_element_array, register_actions>>;
     213             :   };
     214             : 
     215             :   // Specify all parallel components that will execute actions at some point.
     216             :   using component_list = tmpl::flatten<
     217             :       tmpl::list<dg_element_array, typename solver::component_list,
     218             :                  observers::Observer<Metavariables>,
     219             :                  observers::ObserverWriter<Metavariables>>>;
     220             : 
     221             :   static constexpr std::array<Parallel::Phase, 6> default_phase_order{
     222             :       {Parallel::Phase::Initialization, Parallel::Phase::Register,
     223             :        Parallel::Phase::UpdateSections, Parallel::Phase::CheckDomain,
     224             :        Parallel::Phase::Solve, Parallel::Phase::Exit}};
     225             : 
     226             :   // NOLINTNEXTLINE(google-runtime-references)
     227             :   void pup(PUP::er& /*p*/) {}
     228             : };
     229             : /// \endcond

Generated by: LCOV version 1.14