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 : #include <vector>
8 :
9 : #include "ApparentHorizons/ComputeItems.hpp"
10 : #include "ApparentHorizons/Tags.hpp"
11 : #include "DataStructures/DataBox/PrefixHelpers.hpp"
12 : #include "DataStructures/DataBox/Tag.hpp"
13 : #include "DataStructures/Tensor/IndexType.hpp"
14 : #include "Domain/Creators/Factory3D.hpp"
15 : #include "Domain/Creators/RegisterDerivedWithCharm.hpp"
16 : #include "Domain/Creators/TimeDependence/RegisterDerivedWithCharm.hpp"
17 : #include "Domain/FunctionsOfTime/RegisterDerivedWithCharm.hpp"
18 : #include "Domain/Tags.hpp"
19 : #include "Evolution/Actions/RunEventsAndDenseTriggers.hpp"
20 : #include "Evolution/ComputeTags.hpp"
21 : #include "Evolution/Conservative/UpdateConservatives.hpp"
22 : #include "Evolution/Conservative/UpdatePrimitives.hpp"
23 : #include "Evolution/DgSubcell/Actions/Initialize.hpp"
24 : #include "Evolution/DgSubcell/Actions/Labels.hpp"
25 : #include "Evolution/DgSubcell/Actions/ReconstructionCommunication.hpp"
26 : #include "Evolution/DgSubcell/Actions/SelectNumericalMethod.hpp"
27 : #include "Evolution/DgSubcell/Actions/TakeTimeStep.hpp"
28 : #include "Evolution/DgSubcell/Actions/TciAndRollback.hpp"
29 : #include "Evolution/DgSubcell/Actions/TciAndSwitchToDg.hpp"
30 : #include "Evolution/DgSubcell/CartesianFluxDivergence.hpp"
31 : #include "Evolution/DgSubcell/ComputeBoundaryTerms.hpp"
32 : #include "Evolution/DgSubcell/CorrectPackagedData.hpp"
33 : #include "Evolution/DgSubcell/NeighborReconstructedFaceSolution.hpp"
34 : #include "Evolution/DgSubcell/PerssonTci.hpp"
35 : #include "Evolution/DgSubcell/PrepareNeighborData.hpp"
36 : #include "Evolution/DgSubcell/Tags/ObserverCoordinates.hpp"
37 : #include "Evolution/DgSubcell/Tags/ObserverMesh.hpp"
38 : #include "Evolution/DgSubcell/Tags/TciStatus.hpp"
39 : #include "Evolution/DgSubcell/TwoMeshRdmpTci.hpp"
40 : #include "Evolution/DiscontinuousGalerkin/Actions/ApplyBoundaryCorrections.hpp"
41 : #include "Evolution/DiscontinuousGalerkin/Actions/ComputeTimeDerivative.hpp"
42 : #include "Evolution/DiscontinuousGalerkin/DgElementArray.hpp"
43 : #include "Evolution/DiscontinuousGalerkin/Initialization/Mortars.hpp"
44 : #include "Evolution/DiscontinuousGalerkin/Initialization/QuadratureTag.hpp"
45 : #include "Evolution/DiscontinuousGalerkin/Limiters/LimiterActions.hpp"
46 : #include "Evolution/DiscontinuousGalerkin/Limiters/Minmod.hpp"
47 : #include "Evolution/DiscontinuousGalerkin/Limiters/Tags.hpp"
48 : #include "Evolution/DiscontinuousGalerkin/Limiters/Weno.hpp"
49 : #include "Evolution/EventsAndDenseTriggers/DenseTrigger.hpp"
50 : #include "Evolution/EventsAndDenseTriggers/DenseTriggers/Factory.hpp"
51 : #include "Evolution/Initialization/ConservativeSystem.hpp"
52 : #include "Evolution/Initialization/DgDomain.hpp"
53 : #include "Evolution/Initialization/Evolution.hpp"
54 : #include "Evolution/Initialization/Limiter.hpp"
55 : #include "Evolution/Initialization/NonconservativeSystem.hpp"
56 : #include "Evolution/Initialization/SetVariables.hpp"
57 : #include "Evolution/NumericInitialData.hpp"
58 : #include "Evolution/Systems/GeneralizedHarmonic/AllSolutions.hpp"
59 : #include "Evolution/Systems/GeneralizedHarmonic/BoundaryConditions/Factory.hpp"
60 : #include "Evolution/Systems/GeneralizedHarmonic/BoundaryCorrections/Factory.hpp"
61 : #include "Evolution/Systems/GeneralizedHarmonic/Equations.hpp"
62 : #include "Evolution/Systems/GeneralizedHarmonic/GaugeSourceFunctions/Factory.hpp"
63 : #include "Evolution/Systems/GeneralizedHarmonic/GaugeSourceFunctions/Gauges.hpp"
64 : #include "Evolution/Systems/GeneralizedHarmonic/GaugeSourceFunctions/SetPiFromGauge.hpp"
65 : #include "Evolution/Systems/GeneralizedHarmonic/GaugeSourceFunctions/Tags/GaugeCondition.hpp"
66 : #include "Evolution/Systems/GeneralizedHarmonic/Initialize.hpp"
67 : #include "Evolution/Systems/GeneralizedHarmonic/System.hpp"
68 : #include "Evolution/Systems/GeneralizedHarmonic/Tags.hpp"
69 : #include "Evolution/Systems/GrMhd/GhValenciaDivClean/Actions/SetInitialData.hpp"
70 : #include "Evolution/Systems/GrMhd/GhValenciaDivClean/BoundaryConditions/Factory.hpp"
71 : #include "Evolution/Systems/GrMhd/GhValenciaDivClean/BoundaryCorrections/ProductOfCorrections.hpp"
72 : #include "Evolution/Systems/GrMhd/GhValenciaDivClean/FiniteDifference/Tag.hpp"
73 : #include "Evolution/Systems/GrMhd/GhValenciaDivClean/SetPiFromGauge.hpp"
74 : #include "Evolution/Systems/GrMhd/GhValenciaDivClean/Subcell/FixConservativesAndComputePrims.hpp"
75 : #include "Evolution/Systems/GrMhd/GhValenciaDivClean/Subcell/InitialDataTci.hpp"
76 : #include "Evolution/Systems/GrMhd/GhValenciaDivClean/Subcell/NeighborPackagedData.hpp"
77 : #include "Evolution/Systems/GrMhd/GhValenciaDivClean/Subcell/PrimitiveGhostData.hpp"
78 : #include "Evolution/Systems/GrMhd/GhValenciaDivClean/Subcell/PrimsAfterRollback.hpp"
79 : #include "Evolution/Systems/GrMhd/GhValenciaDivClean/Subcell/ResizeAndComputePrimitives.hpp"
80 : #include "Evolution/Systems/GrMhd/GhValenciaDivClean/Subcell/TciOnDgGrid.hpp"
81 : #include "Evolution/Systems/GrMhd/GhValenciaDivClean/Subcell/TciOnFdGrid.hpp"
82 : #include "Evolution/Systems/GrMhd/GhValenciaDivClean/Subcell/TimeDerivative.hpp"
83 : #include "Evolution/Systems/GrMhd/GhValenciaDivClean/System.hpp"
84 : #include "Evolution/Systems/GrMhd/GhValenciaDivClean/TimeDerivativeTerms.hpp"
85 : #include "Evolution/Systems/GrMhd/ValenciaDivClean/BoundaryConditions/Factory.hpp"
86 : #include "Evolution/Systems/GrMhd/ValenciaDivClean/BoundaryCorrections/Factory.hpp"
87 : #include "Evolution/Systems/GrMhd/ValenciaDivClean/BoundaryCorrections/RegisterDerived.hpp"
88 : #include "Evolution/Systems/GrMhd/ValenciaDivClean/FixConservatives.hpp"
89 : #include "Evolution/Systems/GrMhd/ValenciaDivClean/KastaunEtAl.hpp"
90 : #include "Evolution/Systems/GrMhd/ValenciaDivClean/NewmanHamlin.hpp"
91 : #include "Evolution/Systems/GrMhd/ValenciaDivClean/PalenzuelaEtAl.hpp"
92 : #include "Evolution/Systems/GrMhd/ValenciaDivClean/SetVariablesNeededFixingToFalse.hpp"
93 : #include "Evolution/Systems/GrMhd/ValenciaDivClean/Subcell/InitialDataTci.hpp"
94 : #include "Evolution/Systems/GrMhd/ValenciaDivClean/System.hpp"
95 : #include "Evolution/Systems/GrMhd/ValenciaDivClean/Tags.hpp"
96 : #include "Evolution/Tags/Filter.hpp"
97 : #include "Evolution/TypeTraits.hpp"
98 : #include "Evolution/VariableFixing/Actions.hpp"
99 : #include "Evolution/VariableFixing/FixToAtmosphere.hpp"
100 : #include "Evolution/VariableFixing/Tags.hpp"
101 : #include "IO/Importers/Actions/ReadVolumeData.hpp"
102 : #include "IO/Importers/Actions/ReceiveVolumeData.hpp"
103 : #include "IO/Importers/Actions/RegisterWithElementDataReader.hpp"
104 : #include "IO/Importers/ElementDataReader.hpp"
105 : #include "IO/Observer/Actions/ObserverRegistration.hpp"
106 : #include "IO/Observer/Actions/RegisterEvents.hpp"
107 : #include "IO/Observer/Helpers.hpp"
108 : #include "IO/Observer/ObserverComponent.hpp"
109 : #include "IO/Observer/Tags.hpp"
110 : #include "NumericalAlgorithms/DiscontinuousGalerkin/Formulation.hpp"
111 : #include "NumericalAlgorithms/DiscontinuousGalerkin/Tags.hpp"
112 : #include "NumericalAlgorithms/LinearOperators/ExponentialFilter.hpp"
113 : #include "NumericalAlgorithms/LinearOperators/FilterAction.hpp"
114 : #include "Options/Protocols/FactoryCreation.hpp"
115 : #include "Options/String.hpp"
116 : #include "Parallel/Algorithms/AlgorithmSingleton.hpp"
117 : #include "Parallel/InitializationFunctions.hpp"
118 : #include "Parallel/Local.hpp"
119 : #include "Parallel/Phase.hpp"
120 : #include "Parallel/PhaseControl/ExecutePhaseChange.hpp"
121 : #include "Parallel/PhaseControl/Factory.hpp"
122 : #include "Parallel/PhaseControl/VisitAndReturn.hpp"
123 : #include "Parallel/PhaseDependentActionList.hpp"
124 : #include "Parallel/Reduction.hpp"
125 : #include "ParallelAlgorithms/Actions/AddComputeTags.hpp"
126 : #include "ParallelAlgorithms/Actions/AddSimpleTags.hpp"
127 : #include "ParallelAlgorithms/Actions/InitializeItems.hpp"
128 : #include "ParallelAlgorithms/Actions/MutateApply.hpp"
129 : #include "ParallelAlgorithms/Actions/TerminatePhase.hpp"
130 : #include "ParallelAlgorithms/Events/Factory.hpp"
131 : #include "ParallelAlgorithms/Events/ObserveAtExtremum.hpp"
132 : #include "ParallelAlgorithms/Events/ObserveVolumeIntegrals.hpp"
133 : #include "ParallelAlgorithms/EventsAndTriggers/Actions/RunEventsAndTriggers.hpp"
134 : #include "ParallelAlgorithms/EventsAndTriggers/Actions/RunEventsOnFailure.hpp"
135 : #include "ParallelAlgorithms/EventsAndTriggers/Completion.hpp"
136 : #include "ParallelAlgorithms/EventsAndTriggers/Event.hpp"
137 : #include "ParallelAlgorithms/EventsAndTriggers/EventsAndTriggers.hpp"
138 : #include "ParallelAlgorithms/EventsAndTriggers/LogicalTriggers.hpp"
139 : #include "ParallelAlgorithms/EventsAndTriggers/Trigger.hpp"
140 : #include "ParallelAlgorithms/Interpolation/Actions/CleanUpInterpolator.hpp"
141 : #include "ParallelAlgorithms/Interpolation/Actions/ElementInitInterpPoints.hpp"
142 : #include "ParallelAlgorithms/Interpolation/Actions/InitializeInterpolationTarget.hpp"
143 : #include "ParallelAlgorithms/Interpolation/Actions/InterpolationTargetReceiveVars.hpp"
144 : #include "ParallelAlgorithms/Interpolation/Actions/InterpolatorReceivePoints.hpp"
145 : #include "ParallelAlgorithms/Interpolation/Actions/InterpolatorReceiveVolumeData.hpp"
146 : #include "ParallelAlgorithms/Interpolation/Actions/InterpolatorRegisterElement.hpp"
147 : #include "ParallelAlgorithms/Interpolation/Actions/TryToInterpolate.hpp"
148 : #include "ParallelAlgorithms/Interpolation/Callbacks/FindApparentHorizon.hpp"
149 : #include "ParallelAlgorithms/Interpolation/Callbacks/ObserveTimeSeriesOnSurface.hpp"
150 : #include "ParallelAlgorithms/Interpolation/Events/Interpolate.hpp"
151 : #include "ParallelAlgorithms/Interpolation/InterpolationTarget.hpp"
152 : #include "ParallelAlgorithms/Interpolation/Interpolator.hpp"
153 : #include "ParallelAlgorithms/Interpolation/Tags.hpp"
154 : #include "ParallelAlgorithms/Interpolation/Targets/ApparentHorizon.hpp"
155 : #include "ParallelAlgorithms/Interpolation/Targets/KerrHorizon.hpp"
156 : #include "PointwiseFunctions/AnalyticData/AnalyticData.hpp"
157 : #include "PointwiseFunctions/AnalyticData/GhGrMhd/Factory.hpp"
158 : #include "PointwiseFunctions/AnalyticData/GrMhd/BlastWave.hpp"
159 : #include "PointwiseFunctions/AnalyticData/GrMhd/BondiHoyleAccretion.hpp"
160 : #include "PointwiseFunctions/AnalyticData/GrMhd/MagneticFieldLoop.hpp"
161 : #include "PointwiseFunctions/AnalyticData/GrMhd/MagneticRotor.hpp"
162 : #include "PointwiseFunctions/AnalyticData/GrMhd/MagnetizedFmDisk.hpp"
163 : #include "PointwiseFunctions/AnalyticData/GrMhd/OrszagTangVortex.hpp"
164 : #include "PointwiseFunctions/AnalyticData/Tags.hpp"
165 : #include "PointwiseFunctions/AnalyticSolutions/AnalyticSolution.hpp"
166 : #include "PointwiseFunctions/AnalyticSolutions/GeneralRelativity/Factory.hpp"
167 : #include "PointwiseFunctions/AnalyticSolutions/GeneralRelativity/KerrSchild.hpp"
168 : #include "PointwiseFunctions/AnalyticSolutions/GeneralRelativity/WrappedGr.hpp"
169 : #include "PointwiseFunctions/AnalyticSolutions/GhGrMhd/Factory.hpp"
170 : #include "PointwiseFunctions/AnalyticSolutions/GhRelativisticEuler/Factory.hpp"
171 : #include "PointwiseFunctions/AnalyticSolutions/GrMhd/AlfvenWave.hpp"
172 : #include "PointwiseFunctions/AnalyticSolutions/GrMhd/BondiMichel.hpp"
173 : #include "PointwiseFunctions/AnalyticSolutions/GrMhd/KomissarovShock.hpp"
174 : #include "PointwiseFunctions/AnalyticSolutions/GrMhd/SmoothFlow.hpp"
175 : #include "PointwiseFunctions/AnalyticSolutions/RelativisticEuler/FishboneMoncriefDisk.hpp"
176 : #include "PointwiseFunctions/AnalyticSolutions/RelativisticEuler/SmoothFlow.hpp"
177 : #include "PointwiseFunctions/AnalyticSolutions/RelativisticEuler/TovStar.hpp"
178 : #include "PointwiseFunctions/AnalyticSolutions/Tags.hpp"
179 : #include "PointwiseFunctions/GeneralRelativity/Christoffel.hpp"
180 : #include "PointwiseFunctions/GeneralRelativity/DetAndInverseSpatialMetric.hpp"
181 : #include "PointwiseFunctions/GeneralRelativity/GeneralizedHarmonic/ConstraintGammas.hpp"
182 : #include "PointwiseFunctions/GeneralRelativity/IndexManipulation.hpp"
183 : #include "PointwiseFunctions/GeneralRelativity/Ricci.hpp"
184 : #include "PointwiseFunctions/GeneralRelativity/Tags.hpp"
185 : #include "PointwiseFunctions/Hydro/EquationsOfState/Factory.hpp"
186 : #include "PointwiseFunctions/Hydro/MassFlux.hpp"
187 : #include "PointwiseFunctions/Hydro/MassWeightedFluidItems.hpp"
188 : #include "PointwiseFunctions/Hydro/Tags.hpp"
189 : #include "Time/Actions/AdvanceTime.hpp"
190 : #include "Time/Actions/ChangeSlabSize.hpp"
191 : #include "Time/Actions/RecordTimeStepperData.hpp"
192 : #include "Time/Actions/SelfStartActions.hpp"
193 : #include "Time/Actions/SelfStartActions.hpp" // IWYU pragma: keep
194 : #include "Time/Actions/UpdateU.hpp"
195 : #include "Time/StepChoosers/Cfl.hpp"
196 : #include "Time/StepChoosers/Constant.hpp"
197 : #include "Time/StepChoosers/Factory.hpp"
198 : #include "Time/StepChoosers/Increase.hpp"
199 : #include "Time/StepChoosers/PreventRapidIncrease.hpp"
200 : #include "Time/StepChoosers/StepChooser.hpp"
201 : #include "Time/StepChoosers/StepToTimes.hpp"
202 : #include "Time/Tags.hpp"
203 : #include "Time/TimeSequence.hpp"
204 : #include "Time/TimeSteppers/Factory.hpp"
205 : #include "Time/TimeSteppers/LtsTimeStepper.hpp"
206 : #include "Time/TimeSteppers/TimeStepper.hpp"
207 : #include "Time/Triggers/TimeTriggers.hpp"
208 : #include "Utilities/Blas.hpp"
209 : #include "Utilities/ErrorHandling/Error.hpp"
210 : #include "Utilities/ErrorHandling/FloatingPointExceptions.hpp"
211 : #include "Utilities/Functional.hpp"
212 : #include "Utilities/NoSuchType.hpp"
213 : #include "Utilities/ProtocolHelpers.hpp"
214 : #include "Utilities/Serialization/RegisterDerivedClassesWithCharm.hpp"
215 : #include "Utilities/TMPL.hpp"
216 :
217 : // Check if SpEC is linked and therefore we can load SpEC initial data
218 : #ifdef HAS_SPEC_EXPORTER
219 : #include "PointwiseFunctions/AnalyticData/GrMhd/SpecInitialData.hpp"
220 : using SpecInitialData = grmhd::AnalyticData::SpecInitialData;
221 : #else
222 0 : using SpecInitialData = NoSuchType;
223 : #endif
224 :
225 : /// \cond
226 : namespace Frame {
227 : // IWYU pragma: no_forward_declare MathFunction
228 : struct Inertial;
229 : } // namespace Frame
230 : namespace PUP {
231 : class er;
232 : } // namespace PUP
233 : namespace Parallel {
234 : template <typename Metavariables>
235 : class CProxy_GlobalCache;
236 : } // namespace Parallel
237 : /// \endcond
238 :
239 : namespace detail {
240 : template <typename InitialData,
241 : bool IsNumericInitialData =
242 : evolution::is_numeric_initial_data_v<InitialData>>
243 : struct get_thermodynamic_dim;
244 :
245 : template <typename InitialData>
246 : struct get_thermodynamic_dim<InitialData, true> {
247 : // Use a relativistic 1D EOS for numeric initial data for now. This assumption
248 : // can be removed once we have an EOS base class that's agnostic to the
249 : // thermodynamic dimension (alternatively the thermodynamic dimension could be
250 : // specified as a template parameter to the metavariables, but that's not
251 : // great because we have to compile separate executables for 1D and 2D EOS).
252 : static constexpr size_t value = 1;
253 : };
254 :
255 : template <typename InitialData>
256 : struct get_thermodynamic_dim<InitialData, false> {
257 : static constexpr size_t value =
258 : InitialData::equation_of_state_type::thermodynamic_dim;
259 : };
260 : } // namespace detail
261 :
262 : template <bool UseDgSubcell>
263 0 : struct GhValenciaDivCleanDefaults {
264 : public:
265 0 : static constexpr size_t volume_dim = 3;
266 0 : using domain_frame = Frame::Inertial;
267 0 : static constexpr bool use_damped_harmonic_rollon = true;
268 0 : using temporal_id = Tags::TimeStepId;
269 0 : static constexpr bool local_time_stepping = false;
270 :
271 0 : using system = grmhd::GhValenciaDivClean::System;
272 0 : using analytic_variables_tags =
273 : typename system::primitive_variables_tag::tags_list;
274 0 : using analytic_solution_fields =
275 : tmpl::append<typename system::primitive_variables_tag::tags_list,
276 : typename system::gh_system::variables_tag::tags_list>;
277 0 : using ordered_list_of_primitive_recovery_schemes = tmpl::list<
278 : grmhd::ValenciaDivClean::PrimitiveRecoverySchemes::KastaunEtAl,
279 : grmhd::ValenciaDivClean::PrimitiveRecoverySchemes::NewmanHamlin,
280 : grmhd::ValenciaDivClean::PrimitiveRecoverySchemes::PalenzuelaEtAl>;
281 :
282 : // Do not limit the divergence-cleaning field Phi or the GH fields
283 0 : using limiter = Tags::Limiter<
284 : Limiters::Minmod<3, tmpl::list<grmhd::ValenciaDivClean::Tags::TildeD,
285 : grmhd::ValenciaDivClean::Tags::TildeTau,
286 : grmhd::ValenciaDivClean::Tags::TildeS<>,
287 : grmhd::ValenciaDivClean::Tags::TildeB<>>>>;
288 :
289 0 : using initialize_initial_data_dependent_quantities_actions = tmpl::list<
290 : gh::Actions::InitializeGhAnd3Plus1Variables<volume_dim>,
291 : Actions::MutateApply<tmpl::conditional_t<
292 : UseDgSubcell, grmhd::GhValenciaDivClean::SetPiFromGauge,
293 : gh::gauges::SetPiFromGauge<3>>>,
294 : Initialization::Actions::AddComputeTags<
295 : tmpl::list<gr::Tags::SqrtDetSpatialMetricCompute<
296 : DataVector, volume_dim, domain_frame>>>,
297 : VariableFixing::Actions::FixVariables<
298 : VariableFixing::FixToAtmosphere<volume_dim>>,
299 : Actions::UpdateConservatives,
300 : tmpl::conditional_t<
301 : UseDgSubcell,
302 : tmpl::list<
303 : evolution::dg::subcell::Actions::Initialize<
304 : volume_dim, system,
305 : grmhd::GhValenciaDivClean::subcell::DgInitialDataTci>,
306 : Initialization::Actions::AddSimpleTags<
307 : grmhd::ValenciaDivClean::SetVariablesNeededFixingToFalse>,
308 : VariableFixing::Actions::FixVariables<
309 : VariableFixing::FixToAtmosphere<volume_dim>>,
310 : Actions::UpdateConservatives,
311 : Actions::MutateApply<
312 : grmhd::ValenciaDivClean::subcell::SetInitialRdmpData>>,
313 : tmpl::list<>>,
314 : Parallel::Actions::TerminatePhase>;
315 :
316 : // NOLINTNEXTLINE(google-runtime-references)
317 0 : void pup(PUP::er& /*p*/) {}
318 : };
319 :
320 : template <typename EvolutionMetavarsDerived, bool UseDgSubcell>
321 0 : struct GhValenciaDivCleanTemplateBase;
322 :
323 : namespace detail {
324 : template <typename InitialData>
325 : constexpr auto make_default_phase_order() {
326 : if constexpr (evolution::is_numeric_initial_data_v<InitialData>) {
327 : return std::array<Parallel::Phase, 8>{
328 : {Parallel::Phase::Initialization,
329 : Parallel::Phase::RegisterWithElementDataReader,
330 : Parallel::Phase::ImportInitialData,
331 : Parallel::Phase::InitializeInitialDataDependentQuantities,
332 : Parallel::Phase::InitializeTimeStepperHistory,
333 : Parallel::Phase::Register, Parallel::Phase::Evolve,
334 : Parallel::Phase::Exit}};
335 : } else {
336 : return std::array<Parallel::Phase, 6>{
337 : {Parallel::Phase::Initialization,
338 : Parallel::Phase::InitializeInitialDataDependentQuantities,
339 : Parallel::Phase::InitializeTimeStepperHistory,
340 : Parallel::Phase::Register, Parallel::Phase::Evolve,
341 : Parallel::Phase::Exit}};
342 : }
343 : }
344 : } // namespace detail
345 :
346 : template <bool UseDgSubcell,
347 : template <typename, typename...> class EvolutionMetavarsDerived,
348 : typename InitialData, typename... InterpolationTargetTags>
349 0 : struct GhValenciaDivCleanTemplateBase<
350 : EvolutionMetavarsDerived<InitialData, InterpolationTargetTags...>,
351 : UseDgSubcell> : public virtual GhValenciaDivCleanDefaults<UseDgSubcell> {
352 0 : using derived_metavars =
353 : EvolutionMetavarsDerived<InitialData, InterpolationTargetTags...>;
354 0 : using defaults = GhValenciaDivCleanDefaults<UseDgSubcell>;
355 0 : static constexpr size_t volume_dim = defaults::volume_dim;
356 0 : using domain_frame = typename defaults::domain_frame;
357 0 : static constexpr bool use_damped_harmonic_rollon =
358 : defaults::use_damped_harmonic_rollon;
359 0 : using temporal_id = typename defaults::temporal_id;
360 0 : static constexpr bool local_time_stepping = defaults::local_time_stepping;
361 0 : using system = typename defaults::system;
362 0 : using analytic_variables_tags = typename defaults::analytic_variables_tags;
363 0 : using analytic_solution_fields = typename defaults::analytic_solution_fields;
364 0 : using ordered_list_of_primitive_recovery_schemes =
365 : typename defaults::ordered_list_of_primitive_recovery_schemes;
366 0 : using limiter = typename defaults::limiter;
367 0 : using initialize_initial_data_dependent_quantities_actions =
368 : typename defaults::initialize_initial_data_dependent_quantities_actions;
369 :
370 0 : static constexpr bool use_dg_subcell = UseDgSubcell;
371 :
372 0 : using initial_data = InitialData;
373 0 : static constexpr bool use_numeric_initial_data =
374 : evolution::is_numeric_initial_data_v<initial_data>;
375 : static_assert(
376 : is_analytic_data_v<initial_data> xor
377 : is_analytic_solution_v<initial_data> xor use_numeric_initial_data,
378 : "initial_data must be either an analytic_data, an "
379 : "analytic_solution, or externally provided numerical initial data");
380 :
381 0 : static constexpr size_t thermodynamic_dim =
382 : detail::get_thermodynamic_dim<initial_data>::value;
383 : // Get the EOS from options for numeric ID, or else from the analytic
384 : // solution/data.
385 0 : using equation_of_state_tag = std::conditional_t<
386 : use_numeric_initial_data,
387 : hydro::Tags::EquationOfStateFromOptions<true, thermodynamic_dim>,
388 : hydro::Tags::EquationOfState<std::unique_ptr<
389 : EquationsOfState::EquationOfState<true, thermodynamic_dim>>>>;
390 :
391 0 : using initial_data_list = gh::solutions_including_matter<3>;
392 :
393 0 : using initial_data_tag =
394 : tmpl::conditional_t<is_analytic_solution_v<initial_data>,
395 : Tags::AnalyticSolution<initial_data>,
396 : Tags::AnalyticData<initial_data>>;
397 :
398 0 : using interpolator_source_vars =
399 : tmpl::remove_duplicates<tmpl::flatten<tmpl::list<
400 : typename InterpolationTargetTags::vars_to_interpolate_to_target...>>>;
401 :
402 0 : using analytic_compute = evolution::Tags::AnalyticSolutionsCompute<
403 : volume_dim, analytic_solution_fields, use_dg_subcell>;
404 0 : using error_compute = Tags::ErrorsCompute<analytic_solution_fields>;
405 0 : using error_tags = db::wrap_tags_in<Tags::Error, analytic_solution_fields>;
406 0 : using observe_fields = tmpl::push_back<
407 : tmpl::append<
408 : typename system::variables_tag::tags_list,
409 : typename system::primitive_variables_tag::tags_list,
410 : tmpl::conditional_t<use_numeric_initial_data, tmpl::list<>,
411 : error_tags>,
412 : tmpl::list<hydro::Tags::MassWeightedInternalEnergyCompute<DataVector>,
413 : hydro::Tags::MassWeightedKineticEnergyCompute<DataVector>,
414 : hydro::Tags::TildeDUnboundUtCriterionCompute<
415 : DataVector, volume_dim, domain_frame>,
416 : hydro::Tags::MassWeightedCoordsCompute<
417 : DataVector, volume_dim, ::domain::ObjectLabel::None,
418 : Events::Tags::ObserverCoordinates<3, Frame::Grid>,
419 : Events::Tags::ObserverCoordinates<3, Frame::Inertial>,
420 : Frame::Inertial>,
421 : gr::Tags::SpacetimeNormalOneFormCompute<
422 : DataVector, volume_dim, domain_frame>,
423 : gr::Tags::SpacetimeNormalVectorCompute<
424 : DataVector, volume_dim, domain_frame>,
425 : gr::Tags::InverseSpacetimeMetricCompute<
426 : DataVector, volume_dim, domain_frame>,
427 : gh::Tags::GaugeConstraintCompute<volume_dim, domain_frame>,
428 : ::Tags::PointwiseL2NormCompute<gh::Tags::GaugeConstraint<
429 : DataVector, volume_dim, domain_frame>>>,
430 : tmpl::conditional_t<use_dg_subcell,
431 : tmpl::list<evolution::dg::subcell::Tags::
432 : TciStatusCompute<volume_dim>>,
433 : tmpl::list<>>>,
434 : tmpl::conditional_t<
435 : use_dg_subcell,
436 : evolution::dg::subcell::Tags::ObserverCoordinatesCompute<
437 : volume_dim, Frame::ElementLogical>,
438 : ::Events::Tags::ObserverCoordinatesCompute<volume_dim,
439 : Frame::ElementLogical>>,
440 : tmpl::conditional_t<
441 : use_dg_subcell,
442 : evolution::dg::subcell::Tags::ObserverCoordinatesCompute<volume_dim,
443 : Frame::Grid>,
444 : ::Events::Tags::ObserverCoordinatesCompute<volume_dim, Frame::Grid>>,
445 : tmpl::conditional_t<
446 : use_dg_subcell,
447 : evolution::dg::subcell::Tags::ObserverCoordinatesCompute<
448 : volume_dim, Frame::Inertial>,
449 : ::Events::Tags::ObserverCoordinatesCompute<volume_dim,
450 : Frame::Inertial>>>;
451 0 : using integrand_fields = tmpl::append<
452 : typename system::variables_tag::tags_list,
453 : tmpl::list<hydro::Tags::MassWeightedInternalEnergyCompute<DataVector>,
454 : hydro::Tags::MassWeightedKineticEnergyCompute<DataVector>,
455 : hydro::Tags::TildeDUnboundUtCriterionCompute<
456 : DataVector, volume_dim, domain_frame>,
457 : hydro::Tags::MassWeightedCoordsCompute<
458 : DataVector, volume_dim, ::domain::ObjectLabel::None,
459 : Events::Tags::ObserverCoordinates<3, Frame::Grid>,
460 : Events::Tags::ObserverCoordinates<3, Frame::Inertial>,
461 : Frame::Inertial>>>;
462 :
463 0 : using non_tensor_compute_tags = tmpl::append<
464 : tmpl::conditional_t<
465 : use_dg_subcell,
466 : tmpl::list<
467 : evolution::dg::subcell::Tags::ObserverMeshCompute<volume_dim>,
468 : evolution::dg::subcell::Tags::ObserverInverseJacobianCompute<
469 : volume_dim, Frame::ElementLogical, Frame::Inertial>,
470 : evolution::dg::subcell::Tags::ObserverJacobianAndDetInvJacobian<
471 : volume_dim, Frame::ElementLogical, Frame::Inertial>>,
472 : tmpl::list<::Events::Tags::ObserverMeshCompute<volume_dim>,
473 : ::Events::Tags::ObserverInverseJacobianCompute<
474 : volume_dim, Frame::ElementLogical, Frame::Inertial>,
475 : ::Events::Tags::ObserverJacobianCompute<
476 : volume_dim, Frame::ElementLogical, Frame::Inertial>,
477 : ::Events::Tags::ObserverDetInvJacobianCompute<
478 : Frame::ElementLogical, Frame::Inertial>>>,
479 : tmpl::conditional_t<use_numeric_initial_data, tmpl::list<>,
480 : tmpl::list<analytic_compute, error_compute>>,
481 : tmpl::list<gh::gauges::Tags::GaugeAndDerivativeCompute<volume_dim>>>;
482 :
483 0 : struct factory_creation
484 : : tt::ConformsTo<Options::protocols::FactoryCreation> {
485 : private:
486 0 : using boundary_conditions = tmpl::conditional_t<
487 : use_dg_subcell,
488 : tmpl::append<
489 : grmhd::GhValenciaDivClean::BoundaryConditions::
490 : standard_fd_boundary_conditions,
491 : tmpl::conditional_t<
492 : use_numeric_initial_data, tmpl::list<>,
493 : tmpl::list<grmhd::GhValenciaDivClean::BoundaryConditions::
494 : DirichletAnalytic,
495 : grmhd::GhValenciaDivClean::BoundaryConditions::
496 : DirichletFreeOutflow>>>,
497 : grmhd::GhValenciaDivClean::BoundaryConditions::
498 : standard_boundary_conditions>;
499 :
500 : public:
501 0 : using factory_classes = tmpl::map<
502 : tmpl::pair<DenseTrigger, DenseTriggers::standard_dense_triggers>,
503 : tmpl::pair<DomainCreator<volume_dim>, domain_creators<volume_dim>>,
504 : tmpl::pair<
505 : Event,
506 : tmpl::flatten<tmpl::list<
507 : Events::Completion,
508 : dg::Events::field_observations<volume_dim, Tags::Time,
509 : observe_fields,
510 : non_tensor_compute_tags>,
511 : dg::Events::ObserveVolumeIntegrals<volume_dim, Tags::Time,
512 : integrand_fields,
513 : non_tensor_compute_tags>,
514 : Events::ObserveAtExtremum<Tags::Time, observe_fields,
515 : non_tensor_compute_tags>,
516 : Events::time_events<system>,
517 : intrp::Events::Interpolate<3, InterpolationTargetTags,
518 : interpolator_source_vars>...>>>,
519 : tmpl::pair<
520 : grmhd::GhValenciaDivClean::BoundaryConditions::BoundaryCondition,
521 : boundary_conditions>,
522 : tmpl::pair<gh::gauges::GaugeCondition, gh::gauges::all_gauges>,
523 : tmpl::pair<evolution::initial_data::InitialData,
524 : tmpl::conditional_t<
525 : use_numeric_initial_data,
526 : tmpl::flatten<tmpl::list<
527 : grmhd::GhValenciaDivClean::NumericInitialData,
528 : tmpl::conditional_t<
529 : std::is_same_v<SpecInitialData, NoSuchType>,
530 : tmpl::list<>, SpecInitialData>>>,
531 : initial_data_list>>,
532 : tmpl::pair<LtsTimeStepper, TimeSteppers::lts_time_steppers>,
533 : tmpl::pair<PhaseChange, PhaseControl::factory_creatable_classes>,
534 : tmpl::pair<StepChooser<StepChooserUse::LtsStep>,
535 : StepChoosers::standard_step_choosers<system>>,
536 : tmpl::pair<
537 : StepChooser<StepChooserUse::Slab>,
538 : StepChoosers::standard_slab_choosers<system, local_time_stepping>>,
539 : tmpl::pair<TimeSequence<double>,
540 : TimeSequences::all_time_sequences<double>>,
541 : tmpl::pair<TimeSequence<std::uint64_t>,
542 : TimeSequences::all_time_sequences<std::uint64_t>>,
543 : tmpl::pair<TimeStepper, TimeSteppers::time_steppers>,
544 : tmpl::pair<Trigger, tmpl::append<Triggers::logical_triggers,
545 : Triggers::time_triggers>>>;
546 : };
547 :
548 0 : using interpolation_target_tags = tmpl::list<InterpolationTargetTags...>;
549 :
550 0 : using observed_reduction_data_tags = observers::collect_reduction_data_tags<
551 : tmpl::at<typename factory_creation::factory_classes, Event>>;
552 :
553 0 : using const_global_cache_tags = tmpl::flatten<tmpl::list<
554 : tmpl::conditional_t<
555 : use_dg_subcell,
556 : tmpl::list<
557 : grmhd::GhValenciaDivClean::fd::Tags::Reconstructor,
558 : grmhd::GhValenciaDivClean::fd::Tags::FilterOptions,
559 : ::Tags::VariableFixer<grmhd::ValenciaDivClean::FixConservatives>,
560 : grmhd::ValenciaDivClean::subcell::Tags::TciOptions>,
561 : tmpl::list<>>,
562 : gh::gauges::Tags::GaugeCondition,
563 : tmpl::conditional_t<use_numeric_initial_data, tmpl::list<>,
564 : initial_data_tag>,
565 : grmhd::ValenciaDivClean::Tags::ConstraintDampingParameter,
566 : equation_of_state_tag,
567 : gh::ConstraintDamping::Tags::DampingFunctionGamma0<volume_dim,
568 : Frame::Grid>,
569 : gh::ConstraintDamping::Tags::DampingFunctionGamma1<volume_dim,
570 : Frame::Grid>,
571 : gh::ConstraintDamping::Tags::DampingFunctionGamma2<volume_dim,
572 : Frame::Grid>>>;
573 :
574 0 : using dg_registration_list =
575 : tmpl::list<intrp::Actions::RegisterElementWithInterpolator,
576 : observers::Actions::RegisterEventsWithObservers>;
577 :
578 0 : static constexpr auto default_phase_order =
579 : detail::make_default_phase_order<initial_data>();
580 :
581 0 : struct SubcellOptions {
582 0 : using evolved_vars_tags = typename system::variables_tag::tags_list;
583 0 : using prim_tags = typename system::primitive_variables_tag::tags_list;
584 :
585 0 : static constexpr bool subcell_enabled = use_dg_subcell;
586 0 : static constexpr bool subcell_enabled_at_external_boundary = true;
587 :
588 : // We send `ghost_zone_size` cell-centered grid points for variable
589 : // reconstruction, of which we need `ghost_zone_size-1` for reconstruction
590 : // to the internal side of the element face, and `ghost_zone_size` for
591 : // reconstruction to the external side of the element face.
592 : template <typename DbTagsList>
593 0 : static constexpr size_t ghost_zone_size(
594 : const db::DataBox<DbTagsList>& box) {
595 : return db::get<grmhd::GhValenciaDivClean::fd::Tags::Reconstructor>(box)
596 : .ghost_zone_size();
597 : }
598 :
599 0 : using DgComputeSubcellNeighborPackagedData =
600 : grmhd::GhValenciaDivClean::subcell::NeighborPackagedData;
601 :
602 0 : using GhostVariables =
603 : grmhd::GhValenciaDivClean::subcell::PrimitiveGhostVariables;
604 : };
605 :
606 0 : using events_and_dense_triggers_subcell_postprocessors =
607 : tmpl::list<AlwaysReadyPostprocessor<
608 : grmhd::GhValenciaDivClean::subcell::FixConservativesAndComputePrims<
609 : ordered_list_of_primitive_recovery_schemes>>>;
610 :
611 0 : using dg_step_actions = tmpl::flatten<tmpl::list<
612 : evolution::dg::Actions::ComputeTimeDerivative<
613 : volume_dim, system, AllStepChoosers, local_time_stepping>,
614 : tmpl::conditional_t<
615 : local_time_stepping,
616 : tmpl::list<evolution::dg::Actions::ApplyLtsBoundaryCorrections<
617 : system, volume_dim, false>>,
618 : tmpl::list<
619 : evolution::dg::Actions::ApplyBoundaryCorrectionsToTimeDerivative<
620 : system, volume_dim, false>,
621 : Actions::RecordTimeStepperData<system>,
622 : Actions::UpdateU<system>>>,
623 : Limiters::Actions::SendData<derived_metavars>,
624 : Limiters::Actions::Limit<derived_metavars>,
625 : VariableFixing::Actions::FixVariables<
626 : grmhd::ValenciaDivClean::FixConservatives>,
627 : Actions::UpdatePrimitives>>;
628 :
629 0 : using dg_subcell_step_actions = tmpl::flatten<tmpl::list<
630 : evolution::dg::subcell::Actions::SelectNumericalMethod,
631 :
632 : Actions::Label<evolution::dg::subcell::Actions::Labels::BeginDg>,
633 : dg::Actions::Filter<::Filters::Exponential<0>,
634 : tmpl::list<gr::Tags::SpacetimeMetric<DataVector, 3>,
635 : gh::Tags::Pi<DataVector, 3>,
636 : gh::Tags::Phi<DataVector, 3>>>,
637 : evolution::dg::Actions::ComputeTimeDerivative<
638 : volume_dim, system, AllStepChoosers, local_time_stepping>,
639 : evolution::dg::Actions::ApplyBoundaryCorrectionsToTimeDerivative<
640 : system, volume_dim, false>,
641 : tmpl::conditional_t<
642 : local_time_stepping, tmpl::list<>,
643 : tmpl::list<Actions::RecordTimeStepperData<system>,
644 : evolution::Actions::RunEventsAndDenseTriggers<
645 : events_and_dense_triggers_subcell_postprocessors>,
646 : Actions::UpdateU<system>>>,
647 : // Note: The primitive variables are computed as part of the TCI.
648 : evolution::dg::subcell::Actions::TciAndRollback<
649 : grmhd::GhValenciaDivClean::subcell::TciOnDgGrid<
650 : tmpl::front<ordered_list_of_primitive_recovery_schemes>>>,
651 : VariableFixing::Actions::FixVariables<
652 : VariableFixing::FixToAtmosphere<volume_dim>>,
653 : Actions::UpdateConservatives,
654 : Actions::Goto<evolution::dg::subcell::Actions::Labels::EndOfSolvers>,
655 :
656 : Actions::Label<evolution::dg::subcell::Actions::Labels::BeginSubcell>,
657 : evolution::dg::subcell::Actions::SendDataForReconstruction<
658 : volume_dim,
659 : grmhd::GhValenciaDivClean::subcell::PrimitiveGhostVariables,
660 : local_time_stepping>,
661 : evolution::dg::subcell::Actions::ReceiveDataForReconstruction<volume_dim>,
662 : Actions::Label<
663 : evolution::dg::subcell::Actions::Labels::BeginSubcellAfterDgRollback>,
664 : Actions::MutateApply<
665 : grmhd::GhValenciaDivClean::subcell::PrimsAfterRollback<
666 : ordered_list_of_primitive_recovery_schemes>>,
667 : evolution::dg::subcell::fd::Actions::TakeTimeStep<
668 : grmhd::GhValenciaDivClean::subcell::TimeDerivative>,
669 : Actions::RecordTimeStepperData<system>,
670 : evolution::Actions::RunEventsAndDenseTriggers<
671 : events_and_dense_triggers_subcell_postprocessors>,
672 : Actions::UpdateU<system>,
673 : Actions::MutateApply<
674 : grmhd::GhValenciaDivClean::subcell::FixConservativesAndComputePrims<
675 : ordered_list_of_primitive_recovery_schemes>>,
676 : evolution::dg::subcell::Actions::TciAndSwitchToDg<
677 : grmhd::GhValenciaDivClean::subcell::TciOnFdGrid>,
678 : Actions::MutateApply<
679 : grmhd::GhValenciaDivClean::subcell::ResizeAndComputePrims<
680 : ordered_list_of_primitive_recovery_schemes>>,
681 : VariableFixing::Actions::FixVariables<
682 : VariableFixing::FixToAtmosphere<volume_dim>>,
683 : Actions::UpdateConservatives,
684 :
685 : Actions::Label<evolution::dg::subcell::Actions::Labels::EndOfSolvers>>>;
686 :
687 0 : using step_actions =
688 : tmpl::conditional_t<use_dg_subcell, dg_subcell_step_actions,
689 : dg_step_actions>;
690 :
691 0 : using initialization_actions = tmpl::list<
692 : Initialization::Actions::InitializeItems<
693 : Initialization::TimeStepping<derived_metavars, local_time_stepping>,
694 : evolution::dg::Initialization::Domain<3>,
695 : Initialization::TimeStepperHistory<derived_metavars>>,
696 : Initialization::Actions::ConservativeSystem<system>,
697 : std::conditional_t<
698 : use_numeric_initial_data, tmpl::list<>,
699 : evolution::Initialization::Actions::SetVariables<
700 : domain::Tags::Coordinates<volume_dim, Frame::ElementLogical>>>,
701 : Initialization::Actions::AddComputeTags<
702 : StepChoosers::step_chooser_compute_tags<
703 : GhValenciaDivCleanTemplateBase, local_time_stepping>>,
704 : ::evolution::dg::Initialization::Mortars<volume_dim, system>,
705 : Initialization::Actions::Minmod<3>,
706 : evolution::Actions::InitializeRunEventsAndDenseTriggers,
707 : intrp::Actions::ElementInitInterpPoints<
708 : intrp::Tags::InterpPointInfo<derived_metavars>>,
709 : Parallel::Actions::TerminatePhase>;
710 :
711 0 : using import_initial_data_action_lists = tmpl::list<
712 : Parallel::PhaseActions<
713 : Parallel::Phase::RegisterWithElementDataReader,
714 : tmpl::list<importers::Actions::RegisterWithElementDataReader,
715 : Parallel::Actions::TerminatePhase>>,
716 : Parallel::PhaseActions<
717 : Parallel::Phase::ImportInitialData,
718 : tmpl::list<
719 : grmhd::GhValenciaDivClean::Actions::SetInitialData,
720 : grmhd::GhValenciaDivClean::Actions::ReceiveNumericInitialData,
721 : Parallel::Actions::TerminatePhase>>>;
722 :
723 0 : using dg_element_array_component = DgElementArray<
724 : derived_metavars,
725 : tmpl::flatten<tmpl::list<
726 : Parallel::PhaseActions<Parallel::Phase::Initialization,
727 : initialization_actions>,
728 : tmpl::conditional_t<use_numeric_initial_data,
729 : import_initial_data_action_lists, tmpl::list<>>,
730 : Parallel::PhaseActions<
731 : Parallel::Phase::InitializeInitialDataDependentQuantities,
732 : initialize_initial_data_dependent_quantities_actions>,
733 : Parallel::PhaseActions<
734 : Parallel::Phase::InitializeTimeStepperHistory,
735 : SelfStart::self_start_procedure<step_actions, system>>,
736 : Parallel::PhaseActions<Parallel::Phase::Register,
737 : tmpl::list<dg_registration_list,
738 : Parallel::Actions::TerminatePhase>>,
739 : Parallel::PhaseActions<
740 : Parallel::Phase::Evolve,
741 : tmpl::list<VariableFixing::Actions::FixVariables<
742 : VariableFixing::FixToAtmosphere<volume_dim>>,
743 : Actions::UpdateConservatives,
744 : Actions::RunEventsAndTriggers, Actions::ChangeSlabSize,
745 : step_actions, Actions::AdvanceTime,
746 : PhaseControl::Actions::ExecutePhaseChange>>,
747 : Parallel::PhaseActions<
748 : Parallel::Phase::PostFailureCleanup,
749 : tmpl::list<Actions::RunEventsOnFailure,
750 : Parallel::Actions::TerminatePhase>>>>>;
751 :
752 : template <typename ParallelComponent>
753 0 : struct registration_list {
754 0 : using type = std::conditional_t<
755 : std::is_same_v<ParallelComponent, dg_element_array_component>,
756 : dg_registration_list, tmpl::list<>>;
757 : };
758 :
759 0 : using component_list = tmpl::flatten<tmpl::list<
760 : observers::Observer<derived_metavars>,
761 : observers::ObserverWriter<derived_metavars>,
762 : std::conditional_t<use_numeric_initial_data,
763 : importers::ElementDataReader<derived_metavars>,
764 : tmpl::list<>>,
765 : intrp::Interpolator<derived_metavars>,
766 : intrp::InterpolationTarget<derived_metavars, InterpolationTargetTags>...,
767 : dg_element_array_component>>;
768 : };
|