EvolveM1Grey.hpp
1 // Distributed under the MIT License.
2 // See LICENSE.txt for details.
3 
4 #pragma once
5 
6 #include <cstdint>
7 #include <vector>
8 
9 #include "Domain/Creators/RegisterDerivedWithCharm.hpp"
10 #include "Domain/Creators/TimeDependence/RegisterDerivedWithCharm.hpp"
11 #include "Domain/FunctionsOfTime/RegisterDerivedWithCharm.hpp"
12 #include "Domain/Tags.hpp"
13 #include "Evolution/Actions/ComputeTimeDerivative.hpp" // IWYU pragma: keep
14 #include "Evolution/ComputeTags.hpp"
15 #include "Evolution/DiscontinuousGalerkin/Actions/ComputeTimeDerivative.hpp"
16 #include "Evolution/DiscontinuousGalerkin/DgElementArray.hpp"
18 #include "Evolution/DiscontinuousGalerkin/Limiters/Minmod.tpp"
19 #include "Evolution/DiscontinuousGalerkin/Limiters/Tags.hpp"
20 #include "Evolution/Initialization/ConservativeSystem.hpp"
21 #include "Evolution/Initialization/DgDomain.hpp"
22 #include "Evolution/Initialization/DiscontinuousGalerkin.hpp"
23 #include "Evolution/Initialization/Evolution.hpp"
24 #include "Evolution/Initialization/GrTagsForHydro.hpp"
25 #include "Evolution/Initialization/Limiter.hpp"
26 #include "Evolution/Initialization/SetVariables.hpp"
27 #include "Evolution/Systems/RadiationTransport/M1Grey/Initialize.hpp"
30 #include "Evolution/Systems/RadiationTransport/M1Grey/System.hpp"
31 #include "Evolution/Systems/RadiationTransport/M1Grey/Tags.hpp"
32 #include "Evolution/Systems/RadiationTransport/Tags.hpp"
33 #include "Evolution/TypeTraits.hpp"
34 #include "IO/Observer/Actions/RegisterEvents.hpp"
35 #include "IO/Observer/Helpers.hpp"
36 #include "IO/Observer/ObserverComponent.hpp"
37 #include "NumericalAlgorithms/DiscontinuousGalerkin/Actions/ImposeBoundaryConditions.hpp" // IWYU pragma: keep
38 #include "NumericalAlgorithms/DiscontinuousGalerkin/BoundarySchemes/FirstOrder/FirstOrderScheme.hpp"
39 #include "NumericalAlgorithms/DiscontinuousGalerkin/BoundarySchemes/FirstOrder/FirstOrderSchemeLts.hpp"
40 #include "NumericalAlgorithms/DiscontinuousGalerkin/Formulation.hpp"
41 #include "NumericalAlgorithms/DiscontinuousGalerkin/NumericalFluxes/LocalLaxFriedrichs.hpp"
42 #include "NumericalAlgorithms/DiscontinuousGalerkin/Tags.hpp"
43 #include "Options/Options.hpp"
44 #include "Parallel/Actions/SetupDataBox.hpp"
45 #include "Parallel/Actions/TerminatePhase.hpp"
46 #include "Parallel/InitializationFunctions.hpp"
47 #include "Parallel/PhaseDependentActionList.hpp"
49 #include "ParallelAlgorithms/Actions/MutateApply.hpp"
50 #include "ParallelAlgorithms/DiscontinuousGalerkin/CollectDataForFluxes.hpp"
51 #include "ParallelAlgorithms/DiscontinuousGalerkin/FluxCommunication.hpp"
52 #include "ParallelAlgorithms/DiscontinuousGalerkin/InitializeDomain.hpp"
53 #include "ParallelAlgorithms/DiscontinuousGalerkin/InitializeInterfaces.hpp"
54 #include "ParallelAlgorithms/DiscontinuousGalerkin/InitializeMortars.hpp"
55 #include "ParallelAlgorithms/Events/ObserveErrorNorms.hpp"
56 #include "ParallelAlgorithms/Events/ObserveFields.hpp"
57 #include "ParallelAlgorithms/Events/ObserveTimeStep.hpp"
58 #include "ParallelAlgorithms/EventsAndTriggers/Actions/RunEventsAndTriggers.hpp" // IWYU pragma: keep
59 #include "ParallelAlgorithms/EventsAndTriggers/Event.hpp"
60 #include "ParallelAlgorithms/EventsAndTriggers/EventsAndTriggers.hpp" // IWYU pragma: keep
62 #include "ParallelAlgorithms/Initialization/Actions/AddComputeTags.hpp"
63 #include "ParallelAlgorithms/Initialization/Actions/RemoveOptionsAndTerminatePhase.hpp"
64 #include "PointwiseFunctions/AnalyticData/Tags.hpp"
65 #include "PointwiseFunctions/AnalyticSolutions/RadiationTransport/M1Grey/ConstantM1.hpp"
66 #include "PointwiseFunctions/AnalyticSolutions/Tags.hpp"
67 #include "PointwiseFunctions/Hydro/Tags.hpp"
69 #include "Time/Actions/ChangeSlabSize.hpp"
70 #include "Time/Actions/ChangeStepSize.hpp"
71 #include "Time/Actions/RecordTimeStepperData.hpp"
72 #include "Time/Actions/SelfStartActions.hpp" // IWYU pragma: keep
73 #include "Time/Actions/UpdateU.hpp"
74 #include "Time/StepChoosers/Cfl.hpp"
75 #include "Time/StepChoosers/Constant.hpp"
76 #include "Time/StepChoosers/Increase.hpp"
77 #include "Time/StepChoosers/PreventRapidIncrease.hpp"
78 #include "Time/StepChoosers/StepChooser.hpp"
79 #include "Time/StepChoosers/StepToTimes.hpp"
81 #include "Time/Tags.hpp"
82 #include "Time/TimeSequence.hpp"
83 #include "Time/TimeSteppers/TimeStepper.hpp"
84 #include "Time/Triggers/TimeTriggers.hpp"
85 #include "Utilities/Blas.hpp"
87 #include "Utilities/Functional.hpp"
88 #include "Utilities/TMPL.hpp"
89 
90 /// \cond
91 namespace Frame {
92 struct Inertial;
93 } // namespace Frame
94 namespace Parallel {
95 template <typename Metavariables>
96 class CProxy_GlobalCache;
97 } // namespace Parallel
98 /// \endcond
99 
100 struct EvolutionMetavars {
101  static constexpr size_t volume_dim = 3;
102  static constexpr dg::Formulation dg_formulation =
103  dg::Formulation::StrongInertial;
104 
105  // To switch which initial data is evolved you only need to change the
106  // line `using initial_data = ...;` and include the header file for the
107  // solution.
109  static_assert(
110  evolution::is_analytic_data_v<initial_data> xor
111  evolution::is_analytic_solution_v<initial_data>,
112  "initial_data must be either an analytic_data or an analytic_solution");
113 
114  // Set list of neutrino species to be used by M1 code
115  using neutrino_species = tmpl::list<neutrinos::ElectronNeutrinos<1>>;
116 
118  using temporal_id = Tags::TimeStepId;
119  static constexpr bool local_time_stepping = false;
120  using initial_data_tag =
121  tmpl::conditional_t<evolution::is_analytic_solution_v<initial_data>,
124  using boundary_condition_tag = initial_data_tag;
125  using analytic_variables_tags = typename system::variables_tag::tags_list;
126  using normal_dot_numerical_flux =
128  using limiter = Tags::Limiter<
129  Limiters::Minmod<3, typename system::variables_tag::tags_list>>;
130 
131  using step_choosers_common =
132  tmpl::list<//StepChoosers::Registrars::Cfl<volume_dim, Frame::Inertial>,
135  using step_choosers_for_step_only =
136  tmpl::list<StepChoosers::Registrars::PreventRapidIncrease>;
137  using step_choosers_for_slab_only =
138  tmpl::list<StepChoosers::Registrars::StepToTimes>;
139  using step_choosers = tmpl::conditional_t<
140  local_time_stepping,
141  tmpl::append<step_choosers_common, step_choosers_for_step_only>,
142  tmpl::list<>>;
143  using slab_choosers = tmpl::conditional_t<
144  local_time_stepping,
145  tmpl::append<step_choosers_common, step_choosers_for_slab_only>,
146  tmpl::append<step_choosers_common, step_choosers_for_step_only,
147  step_choosers_for_slab_only>>;
148 
149  using time_stepper_tag = Tags::TimeStepper<
150  tmpl::conditional_t<local_time_stepping, LtsTimeStepper, TimeStepper>>;
151  using boundary_scheme = tmpl::conditional_t<
152  local_time_stepping,
154  volume_dim, typename system::variables_tag,
156  normal_dot_numerical_flux, Tags::TimeStepId, time_stepper_tag>,
158  volume_dim, typename system::variables_tag,
160  normal_dot_numerical_flux, Tags::TimeStepId>>;
161 
162  // public for use by the Charm++ registration code
163  using events = tmpl::flatten<tmpl::list<
164  tmpl::conditional_t<evolution::is_analytic_solution_v<initial_data>,
166  Tags::Time, analytic_variables_tags>,
167  tmpl::list<>>,
169  3, Tags::Time,
170  tmpl::append<typename system::variables_tag::tags_list,
171  typename system::primitive_variables_tag::tags_list>,
172  tmpl::conditional_t<evolution::is_analytic_solution_v<initial_data>,
173  analytic_variables_tags, tmpl::list<>>>,
176  using triggers = Triggers::time_triggers;
177 
178  using observed_reduction_data_tags = observers::collect_reduction_data_tags<
179  typename Event<events>::creatable_classes>;
180 
181  using step_actions = tmpl::flatten<tmpl::list<
183  tmpl::conditional_t<
184  evolution::is_analytic_solution_v<initial_data>,
186  tmpl::list<>>,
188  boundary_scheme,
191  tmpl::conditional_t<local_time_stepping,
192  tmpl::list<Actions::RecordTimeStepperData<>,
194  tmpl::list<Actions::MutateApply<boundary_scheme>,
198  Actions::MutateApply<typename RadiationTransport::M1Grey::
199  ComputeM1Closure<neutrino_species>>,
200  Actions::MutateApply<typename RadiationTransport::M1Grey::
201  ComputeM1HydroCoupling<neutrino_species>>>>;
202 
203  enum class Phase {
204  Initialization,
205  InitializeTimeStepperHistory,
206  RegisterWithObserver,
207  Evolve,
208  Exit
209  };
210 
211  using initialization_actions = tmpl::list<
221  Actions::MutateApply<typename RadiationTransport::M1Grey::
222  ComputeM1Closure<neutrino_species>>,
223  Actions::MutateApply<typename RadiationTransport::M1Grey::
224  ComputeM1HydroCoupling<neutrino_species>>,
226  system,
228  typename system::variables_tag,
229  typename system::spacetime_variables_tag,
230  typename system::primitive_variables_tag>,
232  typename system::spacetime_variables_tag,
233  typename system::primitive_variables_tag>,
236  tmpl::conditional_t<
237  evolution::is_analytic_solution_v<initial_data>,
240  3, initial_data_tag, analytic_variables_tags>>>,
241  tmpl::list<>>,
246 
247  using component_list = tmpl::list<
252  tmpl::list<
253  Parallel::PhaseActions<Phase, Phase::Initialization,
254  initialization_actions>,
255 
257  Phase, Phase::InitializeTimeStepperHistory,
259 
261  Phase, Phase::RegisterWithObserver,
264 
266  Phase, Phase::Evolve,
267  tmpl::list<
269  tmpl::conditional_t<
270  local_time_stepping,
272  step_actions, Actions::AdvanceTime>>>>>;
273 
274  using const_global_cache_tags =
275  tmpl::list<initial_data_tag, normal_dot_numerical_flux, time_stepper_tag,
277 
278  static constexpr Options::String help{
279  "Evolve the M1Grey system (without coupling to hydro).\n\n"};
280 
281  static Phase determine_next_phase(
282  const Phase& current_phase,
283  const Parallel::CProxy_GlobalCache<
284  EvolutionMetavars>& /*cache_proxy*/) noexcept {
285  switch (current_phase) {
286  case Phase::Initialization:
287  return Phase::InitializeTimeStepperHistory;
288  case Phase::InitializeTimeStepperHistory:
289  return Phase::RegisterWithObserver;
290  case Phase::RegisterWithObserver:
291  return Phase::Evolve;
292  case Phase::Evolve:
293  return Phase::Exit;
294  case Phase::Exit:
295  ERROR(
296  "Should never call determine_next_phase with the current phase "
297  "being 'Exit'");
298  default:
299  ERROR(
300  "Unknown type of phase. Did you static_cast<Phase> an integral "
301  "value?");
302  }
303  }
304 };
305 
306 static const std::vector<void (*)()> charm_init_node_funcs{
307  &setup_error_handling, &disable_openblas_multithreading,
308  &domain::creators::register_derived_with_charm,
309  &domain::creators::time_dependence::register_derived_with_charm,
310  &domain::FunctionsOfTime::register_derived_with_charm,
317  &Parallel::register_derived_classes_with_charm<StepController>,
318  &Parallel::register_derived_classes_with_charm<TimeSequence<double>>,
319  &Parallel::register_derived_classes_with_charm<TimeSequence<std::uint64_t>>,
320  &Parallel::register_derived_classes_with_charm<TimeStepper>,
323 
324 static const std::vector<void (*)()> charm_init_proc_funcs{
FloatingPointExceptions.hpp
RegisterDerivedClassesWithCharm.hpp
Actions::SetupDataBox
Add into the DataBox default constructed items for the collection of tags requested by any of the act...
Definition: SetupDataBox.hpp:81
Tags::Limiter
The global cache tag for the limiter.
Definition: Tags.hpp:42
Tags::TimeStepId
Tag for TimeStepId for the algorithm state.
Definition: Tags.hpp:33
observers::Actions::RegisterEventsWithObservers
Registers this element of a parallel component with the local Observer parallel component for each tr...
Definition: RegisterEvents.hpp:97
Limiters::Actions::SendData
Send local data needed for limiting.
Definition: LimiterActions.hpp:157
domain::Tags::Coordinates
Definition: Tags.hpp:130
Tags.hpp
LimiterActions.hpp
M1Closure.hpp
Options.hpp
Initialization::Actions::AddComputeTags
Initialize the list of compute tags in ComputeTagsList
Definition: AddComputeTags.hpp:42
Tags.hpp
vector
evolution::Tags::AnalyticCompute
Use the AnalyticSolutionTag to compute the analytic solution of the tags in AnalyticFieldsTagList.
Definition: ComputeTags.hpp:24
Triggers::time_triggers
tmpl::list< Registrars::NearTimes, Registrars::PastTime, Registrars::Slabs, Registrars::Times > time_triggers
Definition: TimeTriggers.hpp:17
db::add_tag_prefix
typename detail::add_tag_prefix_impl< Prefix, Tag, Args... >::type add_tag_prefix
Definition: PrefixHelpers.hpp:51
Initialization::Actions::RemoveOptionsAndTerminatePhase
Definition: RemoveOptionsAndTerminatePhase.hpp:27
Initialization::Actions::Minmod
Allocate items for minmod limiter.
Definition: Limiter.hpp:38
Actions::AdvanceTime
Advance time one substep.
Definition: AdvanceTime.hpp:50
dg::Initialization::face_compute_tags
tmpl::list< Tags... > face_compute_tags
Definition: InitializeInterfaces.hpp:41
Parallel::Actions::TerminatePhase
Terminate the algorithm to proceed to the next phase.
Definition: TerminatePhase.hpp:26
Tags::NumericalFlux
The global cache tag for the numerical flux.
Definition: Tags.hpp:84
M1HydroCoupling.hpp
dg::Initialization::slice_tags_to_face
tmpl::list< Tags... > slice_tags_to_face
Definition: InitializeInterfaces.hpp:31
disable_openblas_multithreading
void disable_openblas_multithreading() noexcept
Disable OpenBLAS multithreading since it conflicts with Charm++ parallelism.
Definition: Blas.cpp:15
domain::Tags::BoundaryDirectionsInterior
Definition: Tags.hpp:296
DgElementArray
The parallel component responsible for managing the DG elements that compose the computational domain...
Definition: DgElementArray.hpp:30
Registration::Registrar
A template for defining a registrar.
Definition: Registration.hpp:42
EvolutionMetavars
Definition: EvolveBurgers.hpp:95
Initialization::Actions::ConservativeSystem
Allocate variables needed for evolution of conservative systems.
Definition: ConservativeSystem.hpp:72
enable_floating_point_exceptions
void enable_floating_point_exceptions()
Definition: FloatingPointExceptions.cpp:27
ERROR
#define ERROR(m)
prints an error message to the standard error stream and aborts the program.
Definition: Error.hpp:36
Actions::ChangeSlabSize
Definition: ChangeSlabSize.hpp:107
dg::FirstOrderScheme::FirstOrderSchemeLts
Boundary contributions for a first-order DG scheme with local time-stepping.
Definition: FirstOrderSchemeLts.hpp:80
Parallel::PhaseActions
List of all the actions to be executed in the specified phase.
Definition: PhaseDependentActionList.hpp:16
observers::ObserverWriter
The nodegroup parallel component that is responsible for writing data to disk.
Definition: ObserverComponent.hpp:51
dg::Actions::InitializeInterfaces
Initialize items related to the interfaces between Elements and on external boundaries.
Definition: InitializeInterfaces.hpp:120
Event
Definition: Event.hpp:30
Initialization::Actions::GrTagsForHydro
Allocate and set general relativity quantities needed for evolution of some hydro systems.
Definition: GrTagsForHydro.hpp:65
evolution::dg::Actions::ComputeTimeDerivative
Computes the time derivative for a DG time step.
Definition: ComputeTimeDerivative.hpp:353
Actions::RunEventsAndTriggers
Run the events and triggers.
Definition: RunEventsAndTriggers.hpp:27
Actions::MutateApply
Apply the function Mutator::apply to the DataBox.
Definition: MutateApply.hpp:40
evolution::dg::Initialization::Domain
Initialize items related to the basic structure of the element.
Definition: DgDomain.hpp:85
Initialization::Actions::TimeStepperHistory
Initialize time-stepper items.
Definition: Evolution.hpp:192
Tags::AnalyticSolution
Definition: Tags.hpp:58
cstdint
observers::Observer
The group parallel component that is responsible for reducing data to be observed.
Definition: ObserverComponent.hpp:29
Limiters::Actions::Limit
Receive limiter data from neighbors, then apply limiter.
Definition: LimiterActions.hpp:70
Trigger
Definition: Trigger.hpp:34
StepController.hpp
dg::Actions::InitializeMortars
Initialize mortars between elements for exchanging fluxes.
Definition: InitializeMortars.hpp:78
Tags::Time
Tag for the current time as a double.
Definition: Tags.hpp:73
Actions::ChangeStepSize
Adjust the step size for local time stepping.
Definition: ChangeStepSize.hpp:48
dg::Actions::CollectDataForFluxes
Collect data that is needed to compute numerical fluxes and store it on mortars, projecting it if nec...
Definition: CollectDataForFluxes.hpp:68
dg::Events::Registrars::ObserveFields
Definition: ObserveFields.hpp:68
AdvanceTime.hpp
Tags::AnalyticData
The analytic data, with the type of the analytic data set as the template parameter.
Definition: Tags.hpp:43
Actions::RecordTimeStepperData
Records the variables and their time derivatives in the time stepper history.
Definition: RecordTimeStepperData.hpp:49
RadiationTransport::M1Grey::Actions::InitializeM1Tags
Definition: Initialize.hpp:46
dg::Actions::ImposeDirichletBoundaryConditions
Packages data on external boundaries for calculating numerical flux. Computes contributions on the in...
Definition: ImposeBoundaryConditions.hpp:60
Tags::EventsAndTriggers
Definition: Tags.hpp:57
RadiationTransport::M1Grey::Solutions::ConstantM1
Constant solution to M1 equations in Minkowski spacetime.
Definition: ConstantM1.hpp:39
dg::Initialization::exterior_compute_tags
tmpl::list< Tags... > exterior_compute_tags
Definition: InitializeInterfaces.hpp:46
evolution::Initialization::Actions::SetVariables
Sets variables needed for evolution of hyperbolic systems.
Definition: SetVariables.hpp:54
Tags::TimeStepper
Tag for a TimeStepper of type StepperType.
Definition: Tags.hpp:187
Options::String
const char *const String
The string used in option structs.
Definition: Options.hpp:32
dg::FirstOrderScheme::FirstOrderScheme
Boundary contributions for a first-order DG scheme.
Definition: FirstOrderScheme.hpp:66
Frame
Definition: IndexType.hpp:36
Actions::UpdateU
Perform variable updates for one substep.
Definition: UpdateU.hpp:49
Initialization::Actions::TimeAndTimeStep
Initialize items related to time, such as the time step.
Definition: Evolution.hpp:80
SelfStart::self_start_procedure
typename detail::self_start_procedure_impl< StepActions >::type self_start_procedure
Definition: SelfStartActions.hpp:467
Parallel::register_derived_classes_with_charm
void register_derived_classes_with_charm() noexcept
Register derived classes of the Base class.
Definition: RegisterDerivedClassesWithCharm.hpp:31
UpdateU.hpp
Blas.hpp
dg::Actions::ReceiveDataForFluxes
Receive boundary data needed for fluxes from neighbors.
Definition: FluxCommunication.hpp:175
dg::Formulation
Formulation
The DG formulation to use.
Definition: Formulation.hpp:34
RadiationTransport::M1Grey::System
Definition: System.hpp:30
StepChooser
Definition: StepChooser.hpp:43
Initialization::Actions::DiscontinuousGalerkin
Initialize items related to the discontinuous Galerkin method.
Definition: DiscontinuousGalerkin.hpp:70
TMPL.hpp
dg::Initialization::slice_tags_to_exterior
tmpl::list< Tags... > slice_tags_to_exterior
Definition: InitializeInterfaces.hpp:36