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/InitialDataUtilities/NumericData.hpp"
47 : #include "PointwiseFunctions/Punctures/AdmIntegrals.hpp"
48 : #include "Utilities/ProtocolHelpers.hpp"
49 : #include "Utilities/TMPL.hpp"
50 :
51 : /// \cond
52 : struct Metavariables {
53 : static constexpr Options::String help{"Solve for puncture initial data"};
54 :
55 : static constexpr size_t volume_dim = 3;
56 : using system = Punctures::FirstOrderSystem;
57 : using solver = elliptic::Solver<Metavariables, volume_dim, system>;
58 :
59 : using observe_integral_fields =
60 : tmpl::list<Punctures::Tags::AdmMassIntegrandCompute>;
61 : using observe_fields = tmpl::append<
62 : typename system::primal_fields, typename system::background_fields,
63 : typename solver::observe_fields, observe_integral_fields,
64 : tmpl::list<domain::Tags::Coordinates<volume_dim, Frame::Inertial>,
65 : domain::Tags::RadiallyCompressedCoordinatesCompute<
66 : volume_dim, Frame::Inertial>>>;
67 : using observer_compute_tags =
68 : tmpl::list<::Events::Tags::ObserverMeshCompute<volume_dim>,
69 : ::Events::Tags::ObserverDetInvJacobianCompute<
70 : Frame::ElementLogical, Frame::Inertial>>;
71 :
72 : struct factory_creation
73 : : tt::ConformsTo<Options::protocols::FactoryCreation> {
74 : using factory_classes = tmpl::map<
75 : tmpl::pair<DomainCreator<volume_dim>, domain_creators<volume_dim>>,
76 : tmpl::pair<elliptic::analytic_data::Background,
77 : tmpl::list<Punctures::AnalyticData::MultiplePunctures,
78 : elliptic::analytic_data::NumericData>>,
79 : tmpl::pair<elliptic::analytic_data::InitialGuess,
80 : tmpl::list<Punctures::Solutions::Flatness,
81 : elliptic::analytic_data::NumericData>>,
82 : tmpl::pair<elliptic::analytic_data::AnalyticSolution, tmpl::list<>>,
83 : tmpl::pair<elliptic::BoundaryConditions::BoundaryCondition<volume_dim>,
84 : tmpl::list<Punctures::BoundaryConditions::Flatness>>,
85 : tmpl::pair<
86 : ::amr::Criterion,
87 : tmpl::push_back<::amr::Criteria::standard_criteria<
88 : volume_dim, tmpl::list<Punctures::Tags::Field>>,
89 : Punctures::AmrCriteria::RefineAtPunctures>>,
90 : tmpl::pair<Event,
91 : tmpl::flatten<tmpl::list<
92 : Events::Completion,
93 : dg::Events::field_observations<
94 : volume_dim, observe_fields, observer_compute_tags,
95 : ::amr::Tags::IsFinestGrid>>>>,
96 : tmpl::pair<Trigger, elliptic::Triggers::all_triggers<
97 : ::amr::OptionTags::AmrGroup>>,
98 : tmpl::pair<
99 : PhaseChange,
100 : tmpl::list<
101 : PhaseControl::VisitAndReturn<
102 : Parallel::Phase::EvaluateAmrCriteria>,
103 : PhaseControl::VisitAndReturn<Parallel::Phase::AdjustDomain>,
104 : PhaseControl::VisitAndReturn<Parallel::Phase::UpdateSections>,
105 : PhaseControl::VisitAndReturn<Parallel::Phase::CheckDomain>>>>;
106 : };
107 :
108 : // Additional items to store in the global cache
109 : using const_global_cache_tags =
110 : tmpl::list<domain::Tags::RadiallyCompressedCoordinatesOptions>;
111 :
112 : // Collect all reduction tags for observers
113 : using observed_reduction_data_tags =
114 : observers::collect_reduction_data_tags<tmpl::push_back<
115 : tmpl::at<factory_creation::factory_classes, Event>, solver>>;
116 :
117 : using initialization_actions =
118 : tmpl::push_back<typename solver::initialization_actions,
119 : Parallel::Actions::TerminatePhase>;
120 :
121 : using register_actions =
122 : tmpl::push_back<typename solver::register_actions,
123 : observers::Actions::RegisterEventsWithObservers>;
124 :
125 : using solve_actions = typename solver::template solve_actions<tmpl::list<>>;
126 :
127 : using dg_element_array = elliptic::DgElementArray<
128 : Metavariables,
129 : tmpl::list<Parallel::PhaseActions<Parallel::Phase::Initialization,
130 : initialization_actions>,
131 : Parallel::PhaseActions<
132 : Parallel::Phase::Register,
133 : tmpl::push_back<register_actions,
134 : Parallel::Actions::TerminatePhase>>,
135 : Parallel::PhaseActions<
136 : Parallel::Phase::Restart,
137 : tmpl::push_back<register_actions,
138 : Parallel::Actions::TerminatePhase>>,
139 : Parallel::PhaseActions<Parallel::Phase::Solve, solve_actions>,
140 : Parallel::PhaseActions<
141 : Parallel::Phase::CheckDomain,
142 : tmpl::list<::amr::Actions::SendAmrDiagnostics,
143 : Parallel::Actions::TerminatePhase>>>,
144 : LinearSolver::multigrid::ElementsAllocator<
145 : volume_dim, typename solver::multigrid::options_group>>;
146 :
147 : struct amr : tt::ConformsTo<::amr::protocols::AmrMetavariables> {
148 : using element_array = dg_element_array;
149 : using projectors = typename solver::amr_projectors;
150 : static constexpr bool keep_coarse_grids = true;
151 : static constexpr bool p_refine_only_in_event = false;
152 : };
153 :
154 : struct registration
155 : : tt::ConformsTo<Parallel::protocols::RegistrationMetavariables> {
156 : using element_registrars =
157 : tmpl::map<tmpl::pair<dg_element_array, register_actions>>;
158 : };
159 :
160 : // Specify all parallel components that will execute actions at some point.
161 : using component_list = tmpl::flatten<
162 : tmpl::list<dg_element_array, typename solver::component_list,
163 : observers::Observer<Metavariables>,
164 : observers::ObserverWriter<Metavariables>>>;
165 :
166 : static constexpr std::array<Parallel::Phase, 6> default_phase_order{
167 : {Parallel::Phase::Initialization, Parallel::Phase::Register,
168 : Parallel::Phase::UpdateSections, Parallel::Phase::CheckDomain,
169 : Parallel::Phase::Solve, Parallel::Phase::Exit}};
170 :
171 : // NOLINTNEXTLINE(google-runtime-references)
172 : void pup(PUP::er& /*p*/) {}
173 : };
174 : /// \endcond
|