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 "Domain/Creators/AlignedLattice.hpp"
10 : #include "Domain/RadiallyCompressedCoordinates.hpp"
11 : #include "Domain/Tags.hpp"
12 : #include "Elliptic/Actions/RunEventsAndTriggers.hpp"
13 : #include "Elliptic/BoundaryConditions/BoundaryCondition.hpp"
14 : #include "Elliptic/DiscontinuousGalerkin/DgElementArray.hpp"
15 : #include "Elliptic/Executables/Solver.hpp"
16 : #include "Elliptic/Systems/SelfForce/Scalar/Actions/InitializeEffectiveSource.hpp"
17 : #include "Elliptic/Systems/SelfForce/Scalar/AmrCriteria/RefineAtPuncture.hpp"
18 : #include "Elliptic/Systems/SelfForce/Scalar/AnalyticData/CircularOrbit.hpp"
19 : #include "Elliptic/Systems/SelfForce/Scalar/BoundaryConditions/None.hpp"
20 : #include "Elliptic/Systems/SelfForce/Scalar/BoundaryConditions/Sommerfeld.hpp"
21 : #include "Elliptic/Systems/SelfForce/Scalar/Events/ObserveSelfForce.hpp"
22 : #include "Elliptic/Systems/SelfForce/Scalar/FirstOrderSystem.hpp"
23 : #include "Elliptic/Systems/SelfForce/Scalar/Tags.hpp"
24 : #include "Elliptic/Triggers/Factory.hpp"
25 : #include "IO/Observer/Actions/RegisterEvents.hpp"
26 : #include "IO/Observer/Helpers.hpp"
27 : #include "IO/Observer/ObserverComponent.hpp"
28 : #include "Options/Protocols/FactoryCreation.hpp"
29 : #include "Options/String.hpp"
30 : #include "Parallel/Phase.hpp"
31 : #include "Parallel/PhaseControl/ExecutePhaseChange.hpp"
32 : #include "Parallel/PhaseControl/VisitAndReturn.hpp"
33 : #include "Parallel/PhaseDependentActionList.hpp"
34 : #include "Parallel/Protocols/RegistrationMetavariables.hpp"
35 : #include "Parallel/Reduction.hpp"
36 : #include "ParallelAlgorithms/Actions/TerminatePhase.hpp"
37 : #include "ParallelAlgorithms/Amr/Actions/SendAmrDiagnostics.hpp"
38 : #include "ParallelAlgorithms/Amr/Criteria/Factory.hpp"
39 : #include "ParallelAlgorithms/Amr/Protocols/AmrMetavariables.hpp"
40 : #include "ParallelAlgorithms/Events/Completion.hpp"
41 : #include "ParallelAlgorithms/Events/Factory.hpp"
42 : #include "ParallelAlgorithms/Events/Tags.hpp"
43 : #include "ParallelAlgorithms/EventsAndTriggers/Event.hpp"
44 : #include "ParallelAlgorithms/EventsAndTriggers/Trigger.hpp"
45 : #include "ParallelAlgorithms/LinearSolver/Multigrid/ElementsAllocator.hpp"
46 : #include "ParallelAlgorithms/LinearSolver/Multigrid/Tags.hpp"
47 : #include "PointwiseFunctions/InitialDataUtilities/AnalyticSolution.hpp"
48 : #include "PointwiseFunctions/InitialDataUtilities/Background.hpp"
49 : #include "PointwiseFunctions/InitialDataUtilities/InitialGuess.hpp"
50 : #include "PointwiseFunctions/MathFunctions/Factory.hpp"
51 : #include "Utilities/ProtocolHelpers.hpp"
52 : #include "Utilities/TMPL.hpp"
53 :
54 : /// \cond
55 : namespace PUP {
56 : class er;
57 : } // namespace PUP
58 :
59 : struct Metavariables {
60 : static constexpr Options::String help{
61 : "Find the self-force for a scalar charge by solving a 2D elliptic "
62 : "problem."};
63 :
64 : static constexpr size_t volume_dim = 2;
65 : using system = ScalarSelfForce::FirstOrderSystem;
66 : using solver = elliptic::Solver<Metavariables, volume_dim, system>;
67 :
68 : using observe_fields = tmpl::append<
69 : typename system::primal_fields, typename system::background_fields,
70 : tmpl::list<ScalarSelfForce::Tags::SingularField,
71 : ScalarSelfForce::Tags::BoyerLindquistRadius>,
72 : typename solver::observe_fields,
73 : tmpl::list<domain::Tags::Coordinates<volume_dim, Frame::Inertial>,
74 : domain::Tags::RadiallyCompressedCoordinatesCompute<
75 : 2, Frame::Inertial, tmpl::size_t<0>>>>;
76 : using observer_compute_tags =
77 : tmpl::list<::Events::Tags::ObserverMeshCompute<volume_dim>,
78 : ::Events::Tags::ObserverDetInvJacobianCompute<
79 : Frame::ElementLogical, Frame::Inertial>>;
80 :
81 : // Collect all items to store in the cache.
82 : using const_global_cache_tags =
83 : tmpl::list<domain::Tags::RadiallyCompressedCoordinatesOptions>;
84 :
85 : struct factory_creation
86 : : tt::ConformsTo<Options::protocols::FactoryCreation> {
87 : using factory_classes = tmpl::map<
88 : tmpl::pair<DomainCreator<volume_dim>,
89 : tmpl::list<domain::creators::AlignedLattice<2>>>,
90 : tmpl::pair<elliptic::analytic_data::Background,
91 : tmpl::list<ScalarSelfForce::AnalyticData::CircularOrbit>>,
92 : tmpl::pair<elliptic::analytic_data::InitialGuess,
93 : tmpl::list<ScalarSelfForce::AnalyticData::CircularOrbit>>,
94 : tmpl::pair<elliptic::analytic_data::AnalyticSolution, tmpl::list<>>,
95 : tmpl::pair<elliptic::BoundaryConditions::BoundaryCondition<volume_dim>,
96 : tmpl::list<ScalarSelfForce::BoundaryConditions::None,
97 : ScalarSelfForce::BoundaryConditions::Sommerfeld>>,
98 : tmpl::pair<
99 : ::amr::Criterion,
100 : tmpl::push_back<::amr::Criteria::standard_criteria<
101 : volume_dim, typename system::primal_fields>,
102 : ScalarSelfForce::AmrCriteria::RefineAtPuncture>>,
103 : tmpl::pair<Event,
104 : tmpl::flatten<tmpl::list<
105 : Events::Completion,
106 : ScalarSelfForce::Events::ObserveSelfForce<
107 : amr::Tags::IsFinestGrid>,
108 : dg::Events::field_observations<
109 : volume_dim, observe_fields, observer_compute_tags,
110 : amr::Tags::IsFinestGrid>>>>,
111 : tmpl::pair<Trigger, elliptic::Triggers::all_triggers<
112 : ::amr::OptionTags::AmrGroup>>,
113 : tmpl::pair<
114 : PhaseChange,
115 : tmpl::list<
116 : // Phases for AMR
117 : PhaseControl::VisitAndReturn<
118 : Parallel::Phase::EvaluateAmrCriteria>,
119 : PhaseControl::VisitAndReturn<Parallel::Phase::AdjustDomain>,
120 : PhaseControl::VisitAndReturn<Parallel::Phase::UpdateSections>,
121 : PhaseControl::VisitAndReturn<Parallel::Phase::CheckDomain>>>>;
122 : };
123 :
124 : // Collect all reduction tags for observers
125 : using observed_reduction_data_tags =
126 : observers::collect_reduction_data_tags<tmpl::push_back<
127 : tmpl::at<typename factory_creation::factory_classes, Event>, solver>>;
128 :
129 : using initialization_actions =
130 : tmpl::push_back<typename solver::initialization_actions,
131 : Parallel::Actions::TerminatePhase>;
132 :
133 : using register_actions =
134 : tmpl::push_back<typename solver::register_actions,
135 : observers::Actions::RegisterEventsWithObservers>;
136 :
137 : using solve_actions = typename solver::template solve_actions<tmpl::list<>>;
138 :
139 : using dg_element_array = elliptic::DgElementArray<
140 : Metavariables,
141 : tmpl::list<
142 : Parallel::PhaseActions<
143 : Parallel::Phase::Initialization,
144 : tmpl::replace<initialization_actions,
145 : elliptic::Actions::InitializeFixedSources<
146 : system, typename solver::background_tag>,
147 : ScalarSelfForce::Actions::InitializeEffectiveSource<
148 : system, typename solver::background_tag>>>,
149 : Parallel::PhaseActions<
150 : Parallel::Phase::Register,
151 : tmpl::push_back<register_actions,
152 : Parallel::Actions::TerminatePhase>>,
153 : Parallel::PhaseActions<
154 : Parallel::Phase::Restart,
155 : tmpl::push_back<register_actions,
156 : Parallel::Actions::TerminatePhase>>,
157 : Parallel::PhaseActions<Parallel::Phase::Solve, solve_actions>,
158 : Parallel::PhaseActions<
159 : Parallel::Phase::CheckDomain,
160 : tmpl::list<::amr::Actions::SendAmrDiagnostics,
161 : Parallel::Actions::TerminatePhase>>>,
162 : LinearSolver::multigrid::ElementsAllocator<
163 : volume_dim, typename solver::multigrid::options_group>>;
164 :
165 : struct amr : tt::ConformsTo<::amr::protocols::AmrMetavariables> {
166 : using element_array = dg_element_array;
167 : using projectors =
168 : tmpl::replace<typename solver::amr_projectors,
169 : elliptic::Actions::InitializeFixedSources<
170 : system, typename solver::background_tag>,
171 : ScalarSelfForce::Actions::InitializeEffectiveSource<
172 : system, typename solver::background_tag>>;
173 : static constexpr bool keep_coarse_grids = true;
174 : static constexpr bool p_refine_only_in_event = false;
175 : };
176 :
177 : struct registration
178 : : tt::ConformsTo<Parallel::protocols::RegistrationMetavariables> {
179 : using element_registrars =
180 : tmpl::map<tmpl::pair<dg_element_array, register_actions>>;
181 : };
182 :
183 : // Specify all parallel components that will execute actions at some point.
184 : using component_list = tmpl::flatten<
185 : tmpl::list<dg_element_array, typename solver::component_list,
186 : observers::Observer<Metavariables>,
187 : observers::ObserverWriter<Metavariables>>>;
188 :
189 : static constexpr std::array<Parallel::Phase, 6> default_phase_order{
190 : {Parallel::Phase::Initialization, Parallel::Phase::Register,
191 : Parallel::Phase::UpdateSections, Parallel::Phase::CheckDomain,
192 : Parallel::Phase::Solve, Parallel::Phase::Exit}};
193 :
194 : // NOLINTNEXTLINE(google-runtime-references)
195 : void pup(PUP::er& /*p*/) {}
196 : };
197 : /// \endcond
|