Line data Source code
1 0 : // Distributed under the MIT License. 2 : // See LICENSE.txt for details. 3 : 4 : #pragma once 5 : 6 : #include <array> 7 : #include <cstddef> 8 : 9 : #include "Domain/Creators/Factory3D.hpp" 10 : #include "Domain/RadiallyCompressedCoordinates.hpp" 11 : #include "Domain/Tags.hpp" 12 : #include "Elliptic/Actions/RunEventsAndTriggers.hpp" 13 : #include "Elliptic/DiscontinuousGalerkin/DgElementArray.hpp" 14 : #include "Elliptic/Executables/Solver.hpp" 15 : #include "Elliptic/Systems/Punctures/AmrCriteria/RefineAtPunctures.hpp" 16 : #include "Elliptic/Systems/Punctures/BoundaryConditions/Flatness.hpp" 17 : #include "Elliptic/Systems/Punctures/FirstOrderSystem.hpp" 18 : #include "Elliptic/Triggers/Factory.hpp" 19 : #include "IO/Observer/Actions/RegisterEvents.hpp" 20 : #include "IO/Observer/Helpers.hpp" 21 : #include "IO/Observer/ObserverComponent.hpp" 22 : #include "Options/Protocols/FactoryCreation.hpp" 23 : #include "Options/String.hpp" 24 : #include "Parallel/GlobalCache.hpp" 25 : #include "Parallel/Phase.hpp" 26 : #include "Parallel/PhaseControl/VisitAndReturn.hpp" 27 : #include "Parallel/PhaseDependentActionList.hpp" 28 : #include "Parallel/Protocols/RegistrationMetavariables.hpp" 29 : #include "ParallelAlgorithms/Actions/TerminatePhase.hpp" 30 : #include "ParallelAlgorithms/Amr/Actions/SendAmrDiagnostics.hpp" 31 : #include "ParallelAlgorithms/Amr/Criteria/Factory.hpp" 32 : #include "ParallelAlgorithms/Amr/Protocols/AmrMetavariables.hpp" 33 : #include "ParallelAlgorithms/Amr/Tags.hpp" 34 : #include "ParallelAlgorithms/Events/Factory.hpp" 35 : #include "ParallelAlgorithms/Events/Tags.hpp" 36 : #include "ParallelAlgorithms/EventsAndTriggers/Completion.hpp" 37 : #include "ParallelAlgorithms/EventsAndTriggers/Event.hpp" 38 : #include "ParallelAlgorithms/EventsAndTriggers/Trigger.hpp" 39 : #include "ParallelAlgorithms/LinearSolver/Multigrid/ElementsAllocator.hpp" 40 : #include "ParallelAlgorithms/LinearSolver/Multigrid/Tags.hpp" 41 : #include "PointwiseFunctions/AnalyticData/Punctures/MultiplePunctures.hpp" 42 : #include "PointwiseFunctions/AnalyticSolutions/Punctures/Flatness.hpp" 43 : #include "PointwiseFunctions/InitialDataUtilities/AnalyticSolution.hpp" 44 : #include "PointwiseFunctions/InitialDataUtilities/Background.hpp" 45 : #include "PointwiseFunctions/InitialDataUtilities/InitialGuess.hpp" 46 : #include "PointwiseFunctions/Punctures/AdmIntegrals.hpp" 47 : #include "Utilities/ProtocolHelpers.hpp" 48 : #include "Utilities/TMPL.hpp" 49 : 50 : /// \cond 51 : struct Metavariables { 52 : static constexpr Options::String help{"Solve for puncture initial data"}; 53 : 54 : static constexpr size_t volume_dim = 3; 55 : using system = Punctures::FirstOrderSystem; 56 : using solver = elliptic::Solver<Metavariables>; 57 : 58 : using observe_integral_fields = 59 : tmpl::list<Punctures::Tags::AdmMassIntegrandCompute>; 60 : using observe_fields = tmpl::append< 61 : typename system::primal_fields, typename system::background_fields, 62 : typename solver::observe_fields, observe_integral_fields, 63 : tmpl::list<domain::Tags::Coordinates<volume_dim, Frame::Inertial>, 64 : domain::Tags::RadiallyCompressedCoordinatesCompute< 65 : volume_dim, Frame::Inertial>>>; 66 : using observer_compute_tags = 67 : tmpl::list<::Events::Tags::ObserverMeshCompute<volume_dim>, 68 : ::Events::Tags::ObserverDetInvJacobianCompute< 69 : Frame::ElementLogical, Frame::Inertial>>; 70 : 71 : struct factory_creation 72 : : tt::ConformsTo<Options::protocols::FactoryCreation> { 73 : using factory_classes = tmpl::map< 74 : tmpl::pair<DomainCreator<volume_dim>, domain_creators<volume_dim>>, 75 : tmpl::pair<elliptic::analytic_data::Background, 76 : tmpl::list<Punctures::AnalyticData::MultiplePunctures>>, 77 : tmpl::pair<elliptic::analytic_data::InitialGuess, 78 : tmpl::list<Punctures::Solutions::Flatness>>, 79 : tmpl::pair<elliptic::analytic_data::AnalyticSolution, tmpl::list<>>, 80 : tmpl::pair<elliptic::BoundaryConditions::BoundaryCondition<volume_dim>, 81 : tmpl::list<Punctures::BoundaryConditions::Flatness>>, 82 : tmpl::pair< 83 : ::amr::Criterion, 84 : tmpl::push_back<::amr::Criteria::standard_criteria< 85 : volume_dim, tmpl::list<Punctures::Tags::Field>>, 86 : Punctures::AmrCriteria::RefineAtPunctures>>, 87 : tmpl::pair<Event, 88 : tmpl::flatten<tmpl::list< 89 : Events::Completion, 90 : dg::Events::field_observations< 91 : volume_dim, observe_fields, observer_compute_tags, 92 : LinearSolver::multigrid::Tags::IsFinestGrid>>>>, 93 : tmpl::pair<Trigger, elliptic::Triggers::all_triggers< 94 : ::amr::OptionTags::AmrGroup>>, 95 : tmpl::pair< 96 : PhaseChange, 97 : tmpl::list< 98 : PhaseControl::VisitAndReturn< 99 : Parallel::Phase::EvaluateAmrCriteria>, 100 : PhaseControl::VisitAndReturn<Parallel::Phase::AdjustDomain>, 101 : PhaseControl::VisitAndReturn<Parallel::Phase::CheckDomain>>>>; 102 : }; 103 : 104 : // Additional items to store in the global cache 105 : using const_global_cache_tags = 106 : tmpl::list<domain::Tags::RadiallyCompressedCoordinatesOptions>; 107 : 108 : // Collect all reduction tags for observers 109 : using observed_reduction_data_tags = 110 : observers::collect_reduction_data_tags<tmpl::push_back< 111 : tmpl::at<factory_creation::factory_classes, Event>, solver>>; 112 : 113 : using initialization_actions = 114 : tmpl::push_back<typename solver::initialization_actions, 115 : Parallel::Actions::TerminatePhase>; 116 : 117 : using register_actions = 118 : tmpl::push_back<typename solver::register_actions, 119 : observers::Actions::RegisterEventsWithObservers>; 120 : 121 : using solve_actions = typename solver::template solve_actions<tmpl::list<>>; 122 : 123 : using dg_element_array = elliptic::DgElementArray< 124 : Metavariables, 125 : tmpl::list<Parallel::PhaseActions<Parallel::Phase::Initialization, 126 : initialization_actions>, 127 : Parallel::PhaseActions< 128 : Parallel::Phase::Register, 129 : tmpl::push_back<register_actions, 130 : Parallel::Actions::TerminatePhase>>, 131 : Parallel::PhaseActions<Parallel::Phase::Solve, solve_actions>, 132 : Parallel::PhaseActions< 133 : Parallel::Phase::CheckDomain, 134 : tmpl::list<::amr::Actions::SendAmrDiagnostics, 135 : Parallel::Actions::TerminatePhase>>>, 136 : LinearSolver::multigrid::ElementsAllocator< 137 : volume_dim, typename solver::multigrid::options_group>>; 138 : 139 : struct amr : tt::ConformsTo<::amr::protocols::AmrMetavariables> { 140 : using element_array = dg_element_array; 141 : using projectors = typename solver::amr_projectors; 142 : }; 143 : 144 : struct registration 145 : : tt::ConformsTo<Parallel::protocols::RegistrationMetavariables> { 146 : using element_registrars = 147 : tmpl::map<tmpl::pair<dg_element_array, register_actions>>; 148 : }; 149 : 150 : // Specify all parallel components that will execute actions at some point. 151 : using component_list = tmpl::flatten< 152 : tmpl::list<dg_element_array, typename solver::component_list, 153 : observers::Observer<Metavariables>, 154 : observers::ObserverWriter<Metavariables>>>; 155 : 156 : static constexpr std::array<Parallel::Phase, 4> default_phase_order{ 157 : {Parallel::Phase::Initialization, Parallel::Phase::Register, 158 : Parallel::Phase::Solve, Parallel::Phase::Exit}}; 159 : 160 : // NOLINTNEXTLINE(google-runtime-references) 161 : void pup(PUP::er& /*p*/) {} 162 : }; 163 : /// \endcond