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

Generated by: LCOV version 1.14