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 : using observer_compute_tags =
75 : tmpl::list<::Events::Tags::ObserverMeshCompute<volume_dim>,
76 : ::Events::Tags::ObserverDetInvJacobianCompute<
77 : Frame::ElementLogical, Frame::Inertial>>;
78 :
79 : // Collect all items to store in the cache.
80 : using const_global_cache_tags = tmpl::list<>;
81 :
82 : struct factory_creation
83 : : tt::ConformsTo<Options::protocols::FactoryCreation> {
84 : using factory_classes = tmpl::map<
85 : tmpl::pair<DomainCreator<volume_dim>,
86 : tmpl::list<domain::creators::AlignedLattice<2>>>,
87 : tmpl::pair<elliptic::analytic_data::Background,
88 : tmpl::list<ScalarSelfForce::AnalyticData::CircularOrbit>>,
89 : tmpl::pair<elliptic::analytic_data::InitialGuess,
90 : tmpl::list<ScalarSelfForce::AnalyticData::CircularOrbit>>,
91 : tmpl::pair<elliptic::analytic_data::AnalyticSolution, tmpl::list<>>,
92 : tmpl::pair<elliptic::BoundaryConditions::BoundaryCondition<volume_dim>,
93 : tmpl::list<ScalarSelfForce::BoundaryConditions::None,
94 : ScalarSelfForce::BoundaryConditions::Sommerfeld>>,
95 : tmpl::pair<
96 : ::amr::Criterion,
97 : tmpl::push_back<::amr::Criteria::standard_criteria<
98 : volume_dim, typename system::primal_fields>,
99 : ScalarSelfForce::AmrCriteria::RefineAtPuncture>>,
100 : tmpl::pair<Event,
101 : tmpl::flatten<tmpl::list<
102 : Events::Completion,
103 : ScalarSelfForce::Events::ObserveSelfForce<
104 : amr::Tags::IsFinestGrid>,
105 : dg::Events::field_observations<
106 : volume_dim, observe_fields, observer_compute_tags,
107 : amr::Tags::IsFinestGrid>>>>,
108 : tmpl::pair<Trigger, elliptic::Triggers::all_triggers<
109 : ::amr::OptionTags::AmrGroup>>,
110 : tmpl::pair<
111 : PhaseChange,
112 : tmpl::list<
113 : // Phases for AMR
114 : PhaseControl::VisitAndReturn<
115 : Parallel::Phase::EvaluateAmrCriteria>,
116 : PhaseControl::VisitAndReturn<Parallel::Phase::AdjustDomain>,
117 : PhaseControl::VisitAndReturn<Parallel::Phase::UpdateSections>,
118 : PhaseControl::VisitAndReturn<Parallel::Phase::CheckDomain>>>>;
119 : };
120 :
121 : // Collect all reduction tags for observers
122 : using observed_reduction_data_tags =
123 : observers::collect_reduction_data_tags<tmpl::push_back<
124 : tmpl::at<typename factory_creation::factory_classes, Event>, solver>>;
125 :
126 : using initialization_actions =
127 : tmpl::push_back<typename solver::initialization_actions,
128 : Parallel::Actions::TerminatePhase>;
129 :
130 : using register_actions =
131 : tmpl::push_back<typename solver::register_actions,
132 : observers::Actions::RegisterEventsWithObservers>;
133 :
134 : using solve_actions = typename solver::template solve_actions<tmpl::list<>>;
135 :
136 : using dg_element_array = elliptic::DgElementArray<
137 : Metavariables,
138 : tmpl::list<
139 : Parallel::PhaseActions<
140 : Parallel::Phase::Initialization,
141 : tmpl::replace<initialization_actions,
142 : elliptic::Actions::InitializeFixedSources<
143 : system, typename solver::background_tag>,
144 : ScalarSelfForce::Actions::InitializeEffectiveSource<
145 : system, typename solver::background_tag>>>,
146 : Parallel::PhaseActions<
147 : Parallel::Phase::Register,
148 : tmpl::push_back<register_actions,
149 : Parallel::Actions::TerminatePhase>>,
150 : Parallel::PhaseActions<
151 : Parallel::Phase::Restart,
152 : tmpl::push_back<register_actions,
153 : Parallel::Actions::TerminatePhase>>,
154 : Parallel::PhaseActions<Parallel::Phase::Solve, solve_actions>,
155 : Parallel::PhaseActions<
156 : Parallel::Phase::CheckDomain,
157 : tmpl::list<::amr::Actions::SendAmrDiagnostics,
158 : Parallel::Actions::TerminatePhase>>>,
159 : LinearSolver::multigrid::ElementsAllocator<
160 : volume_dim, typename solver::multigrid::options_group>>;
161 :
162 : struct amr : tt::ConformsTo<::amr::protocols::AmrMetavariables> {
163 : using element_array = dg_element_array;
164 : using projectors =
165 : tmpl::replace<typename solver::amr_projectors,
166 : elliptic::Actions::InitializeFixedSources<
167 : system, typename solver::background_tag>,
168 : ScalarSelfForce::Actions::InitializeEffectiveSource<
169 : system, typename solver::background_tag>>;
170 : static constexpr bool keep_coarse_grids = true;
171 : static constexpr bool p_refine_only_in_event = false;
172 : };
173 :
174 : struct registration
175 : : tt::ConformsTo<Parallel::protocols::RegistrationMetavariables> {
176 : using element_registrars =
177 : tmpl::map<tmpl::pair<dg_element_array, register_actions>>;
178 : };
179 :
180 : // Specify all parallel components that will execute actions at some point.
181 : using component_list = tmpl::flatten<
182 : tmpl::list<dg_element_array, typename solver::component_list,
183 : observers::Observer<Metavariables>,
184 : observers::ObserverWriter<Metavariables>>>;
185 :
186 : static constexpr std::array<Parallel::Phase, 6> default_phase_order{
187 : {Parallel::Phase::Initialization, Parallel::Phase::Register,
188 : Parallel::Phase::UpdateSections, Parallel::Phase::CheckDomain,
189 : Parallel::Phase::Solve, Parallel::Phase::Exit}};
190 :
191 : // NOLINTNEXTLINE(google-runtime-references)
192 : void pup(PUP::er& /*p*/) {}
193 : };
194 : /// \endcond
|