EvolveM1Grey.hpp
1 // Distributed under the MIT License.
2 // See LICENSE.txt for details.
3 
4 #pragma once
5 
6 #include <vector>
7 
8 #include "Domain/Creators/RegisterDerivedWithCharm.hpp"
9 #include "Domain/Creators/TimeDependence/RegisterDerivedWithCharm.hpp"
10 #include "Domain/FunctionsOfTime/RegisterDerivedWithCharm.hpp"
11 #include "Domain/Tags.hpp"
13 #include "Evolution/Actions/AddMeshVelocitySourceTerms.hpp"
14 #include "Evolution/Actions/ComputeTimeDerivative.hpp" // IWYU pragma: keep
15 #include "Evolution/Actions/ComputeVolumeFluxes.hpp"
16 #include "Evolution/Actions/ComputeVolumeSources.hpp"
17 #include "Evolution/ComputeTags.hpp"
18 #include "Evolution/Conservative/ConservativeDuDt.hpp"
19 #include "Evolution/DiscontinuousGalerkin/DgElementArray.hpp"
21 #include "Evolution/DiscontinuousGalerkin/Limiters/Minmod.tpp"
22 #include "Evolution/DiscontinuousGalerkin/Limiters/Tags.hpp"
23 #include "Evolution/Initialization/ConservativeSystem.hpp"
24 #include "Evolution/Initialization/DgDomain.hpp"
25 #include "Evolution/Initialization/DiscontinuousGalerkin.hpp"
26 #include "Evolution/Initialization/Evolution.hpp"
27 #include "Evolution/Initialization/GrTagsForHydro.hpp"
28 #include "Evolution/Initialization/Limiter.hpp"
29 #include "Evolution/Initialization/SetVariables.hpp"
30 #include "Evolution/Systems/RadiationTransport/M1Grey/Initialize.hpp"
33 #include "Evolution/Systems/RadiationTransport/M1Grey/System.hpp"
34 #include "Evolution/Systems/RadiationTransport/M1Grey/Tags.hpp"
35 #include "Evolution/Systems/RadiationTransport/Tags.hpp"
36 #include "Evolution/TypeTraits.hpp"
37 #include "IO/Observer/Actions/RegisterEvents.hpp"
38 #include "IO/Observer/Helpers.hpp"
39 #include "IO/Observer/ObserverComponent.hpp"
40 #include "NumericalAlgorithms/DiscontinuousGalerkin/Actions/ImposeBoundaryConditions.hpp" // IWYU pragma: keep
41 #include "NumericalAlgorithms/DiscontinuousGalerkin/BoundarySchemes/FirstOrder/FirstOrderScheme.hpp"
42 #include "NumericalAlgorithms/DiscontinuousGalerkin/BoundarySchemes/FirstOrder/FirstOrderSchemeLts.hpp"
43 #include "NumericalAlgorithms/DiscontinuousGalerkin/Formulation.hpp"
44 #include "NumericalAlgorithms/DiscontinuousGalerkin/NumericalFluxes/LocalLaxFriedrichs.hpp"
45 #include "NumericalAlgorithms/DiscontinuousGalerkin/Tags.hpp"
46 #include "Options/Options.hpp"
47 #include "Parallel/Actions/TerminatePhase.hpp"
48 #include "Parallel/InitializationFunctions.hpp"
49 #include "Parallel/PhaseDependentActionList.hpp"
51 #include "ParallelAlgorithms/Actions/MutateApply.hpp"
52 #include "ParallelAlgorithms/DiscontinuousGalerkin/CollectDataForFluxes.hpp"
53 #include "ParallelAlgorithms/DiscontinuousGalerkin/FluxCommunication.hpp"
54 #include "ParallelAlgorithms/DiscontinuousGalerkin/InitializeDomain.hpp"
55 #include "ParallelAlgorithms/DiscontinuousGalerkin/InitializeInterfaces.hpp"
56 #include "ParallelAlgorithms/DiscontinuousGalerkin/InitializeMortars.hpp"
57 #include "ParallelAlgorithms/Events/ObserveErrorNorms.hpp"
58 #include "ParallelAlgorithms/Events/ObserveFields.hpp"
59 #include "ParallelAlgorithms/EventsAndTriggers/Actions/RunEventsAndTriggers.hpp" // IWYU pragma: keep
60 #include "ParallelAlgorithms/EventsAndTriggers/Event.hpp"
61 #include "ParallelAlgorithms/EventsAndTriggers/EventsAndTriggers.hpp" // IWYU pragma: keep
63 #include "ParallelAlgorithms/Initialization/Actions/AddComputeTags.hpp"
64 #include "ParallelAlgorithms/Initialization/Actions/RemoveOptionsAndTerminatePhase.hpp"
65 #include "PointwiseFunctions/AnalyticData/Tags.hpp"
66 #include "PointwiseFunctions/AnalyticSolutions/RadiationTransport/M1Grey/ConstantM1.hpp"
67 #include "PointwiseFunctions/AnalyticSolutions/Tags.hpp"
68 #include "PointwiseFunctions/Hydro/Tags.hpp"
70 #include "Time/Actions/ChangeSlabSize.hpp"
71 #include "Time/Actions/ChangeStepSize.hpp"
72 #include "Time/Actions/RecordTimeStepperData.hpp"
73 #include "Time/Actions/SelfStartActions.hpp" // IWYU pragma: keep
74 #include "Time/Actions/UpdateU.hpp"
75 #include "Time/StepChoosers/Cfl.hpp"
76 #include "Time/StepChoosers/Constant.hpp"
77 #include "Time/StepChoosers/Increase.hpp"
78 #include "Time/StepChoosers/PreventRapidIncrease.hpp"
79 #include "Time/StepChoosers/StepChooser.hpp"
80 #include "Time/StepChoosers/StepToTimes.hpp"
82 #include "Time/Tags.hpp"
83 #include "Time/TimeSteppers/TimeStepper.hpp"
84 #include "Time/Triggers/TimeTriggers.hpp"
85 #include "Utilities/Blas.hpp"
86 #include "Utilities/Functional.hpp"
87 #include "Utilities/TMPL.hpp"
88 
89 /// \cond
90 namespace Frame {
91 struct Inertial;
92 } // namespace Frame
93 namespace Parallel {
94 template <typename Metavariables>
95 class CProxy_GlobalCache;
96 } // namespace Parallel
97 /// \endcond
98 
99 struct EvolutionMetavars {
100  static constexpr size_t volume_dim = 3;
101  static constexpr dg::Formulation dg_formulation =
102  dg::Formulation::StrongInertial;
103 
104  // To switch which initial data is evolved you only need to change the
105  // line `using initial_data = ...;` and include the header file for the
106  // solution.
108  static_assert(
109  evolution::is_analytic_data_v<initial_data> xor
110  evolution::is_analytic_solution_v<initial_data>,
111  "initial_data must be either an analytic_data or an analytic_solution");
112 
113  // Set list of neutrino species to be used by M1 code
114  using neutrino_species = tmpl::list<neutrinos::ElectronNeutrinos<1>>;
115 
117  using temporal_id = Tags::TimeStepId;
118  static constexpr bool local_time_stepping = false;
119  using initial_data_tag =
120  tmpl::conditional_t<evolution::is_analytic_solution_v<initial_data>,
123  using boundary_condition_tag = initial_data_tag;
124  using analytic_variables_tags = typename system::variables_tag::tags_list;
125  using normal_dot_numerical_flux =
127  using limiter = Tags::Limiter<
128  Limiters::Minmod<3, typename system::variables_tag::tags_list>>;
129 
130  using step_choosers_common =
131  tmpl::list<//StepChoosers::Registrars::Cfl<volume_dim, Frame::Inertial>,
134  using step_choosers_for_step_only =
135  tmpl::list<StepChoosers::Registrars::PreventRapidIncrease>;
136  using step_choosers_for_slab_only =
137  tmpl::list<StepChoosers::Registrars::StepToTimes>;
138  using step_choosers = tmpl::conditional_t<
139  local_time_stepping,
140  tmpl::append<step_choosers_common, step_choosers_for_step_only>,
141  tmpl::list<>>;
142  using slab_choosers = tmpl::conditional_t<
143  local_time_stepping,
144  tmpl::append<step_choosers_common, step_choosers_for_slab_only>,
145  tmpl::append<step_choosers_common, step_choosers_for_step_only,
146  step_choosers_for_slab_only>>;
147 
148  using time_stepper_tag = Tags::TimeStepper<
149  tmpl::conditional_t<local_time_stepping, LtsTimeStepper, TimeStepper>>;
150  using boundary_scheme = tmpl::conditional_t<
151  local_time_stepping,
153  volume_dim, typename system::variables_tag, normal_dot_numerical_flux,
154  Tags::TimeStepId, time_stepper_tag>,
156  volume_dim, typename system::variables_tag, normal_dot_numerical_flux,
158 
159  // public for use by the Charm++ registration code
160  using events = tmpl::flatten<tmpl::list<
161  tmpl::conditional_t<evolution::is_analytic_solution_v<initial_data>,
163  Tags::Time, analytic_variables_tags>,
164  tmpl::list<>>,
166  3, Tags::Time,
167  tmpl::append<typename system::variables_tag::tags_list,
168  typename system::primitive_variables_tag::tags_list>,
169  tmpl::conditional_t<evolution::is_analytic_solution_v<initial_data>,
170  analytic_variables_tags, tmpl::list<>>>,
172  using triggers = Triggers::time_triggers;
173 
174  using observed_reduction_data_tags = observers::collect_reduction_data_tags<
175  typename Event<events>::creatable_classes>;
176 
177  using step_actions = tmpl::flatten<tmpl::list<
186  tmpl::conditional_t<
187  evolution::is_analytic_solution_v<initial_data>,
189  tmpl::list<>>,
191  boundary_scheme,
194  tmpl::conditional_t<local_time_stepping,
195  tmpl::list<Actions::RecordTimeStepperData<>,
197  tmpl::list<Actions::MutateApply<boundary_scheme>,
201  Actions::MutateApply<typename RadiationTransport::M1Grey::
202  ComputeM1Closure<neutrino_species>>,
203  Actions::MutateApply<typename RadiationTransport::M1Grey::
204  ComputeM1HydroCoupling<neutrino_species>>>>;
205 
206  enum class Phase {
207  Initialization,
208  InitializeTimeStepperHistory,
209  RegisterWithObserver,
210  Evolve,
211  Exit
212  };
213 
214  using initialization_actions = tmpl::list<
223  Actions::MutateApply<typename RadiationTransport::M1Grey::
224  ComputeM1Closure<neutrino_species>>,
225  Actions::MutateApply<typename RadiationTransport::M1Grey::
226  ComputeM1HydroCoupling<neutrino_species>>,
228  system,
230  typename system::variables_tag,
231  typename system::spacetime_variables_tag,
232  typename system::primitive_variables_tag>,
234  typename system::spacetime_variables_tag,
235  typename system::primitive_variables_tag>,
238  tmpl::conditional_t<
239  evolution::is_analytic_solution_v<initial_data>,
242  3, initial_data_tag, analytic_variables_tags>>>,
243  tmpl::list<>>,
248 
249  using component_list = tmpl::list<
254  tmpl::list<
255  Parallel::PhaseActions<Phase, Phase::Initialization,
256  initialization_actions>,
257 
259  Phase, Phase::InitializeTimeStepperHistory,
261 
263  Phase, Phase::RegisterWithObserver,
266 
268  Phase, Phase::Evolve,
269  tmpl::list<
271  tmpl::conditional_t<
272  local_time_stepping,
274  step_actions, Actions::AdvanceTime>>>>>;
275 
276  using const_global_cache_tags =
277  tmpl::list<initial_data_tag, normal_dot_numerical_flux, time_stepper_tag,
279 
280  static constexpr Options::String help{
281  "Evolve the M1Grey system (without coupling to hydro).\n\n"};
282 
283  static Phase determine_next_phase(
284  const Phase& current_phase,
285  const Parallel::CProxy_GlobalCache<
286  EvolutionMetavars>& /*cache_proxy*/) noexcept {
287  switch (current_phase) {
288  case Phase::Initialization:
289  return Phase::InitializeTimeStepperHistory;
290  case Phase::InitializeTimeStepperHistory:
291  return Phase::RegisterWithObserver;
292  case Phase::RegisterWithObserver:
293  return Phase::Evolve;
294  case Phase::Evolve:
295  return Phase::Exit;
296  case Phase::Exit:
297  ERROR(
298  "Should never call determine_next_phase with the current phase "
299  "being 'Exit'");
300  default:
301  ERROR(
302  "Unknown type of phase. Did you static_cast<Phase> an integral "
303  "value?");
304  }
305  }
306 };
307 
308 static const std::vector<void (*)()> charm_init_node_funcs{
309  &setup_error_handling, &disable_openblas_multithreading,
310  &domain::creators::register_derived_with_charm,
311  &domain::creators::time_dependence::register_derived_with_charm,
312  &domain::FunctionsOfTime::register_derived_with_charm,
319  &Parallel::register_derived_classes_with_charm<StepController>,
320  &Parallel::register_derived_classes_with_charm<TimeStepper>,
323 
324 static const std::vector<void (*)()> charm_init_proc_funcs{
FloatingPointExceptions.hpp
RegisterDerivedClassesWithCharm.hpp
Tags::Limiter
The global cache tag for the limiter.
Definition: Tags.hpp:42
evolution::dg::ConservativeDuDt
Calculate for a conservative system.
Definition: ConservativeDuDt.hpp:34
Tags::TimeStepId
Tag for TimeStepId for the algorithm state.
Definition: Tags.hpp:34
observers::Actions::RegisterEventsWithObservers
Registers this element of a parallel component with the local Observer parallel component for each tr...
Definition: RegisterEvents.hpp:98
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:38
Tags.hpp
vector
evolution::Tags::AnalyticCompute
Use the AnalyticSolutionTag to compute the analytic solution of the tags in AnalyticFieldsTagList.
Definition: ComputeTags.hpp:24
dg::Actions::SendDataForFluxes
Send local boundary data needed for fluxes to neighbors.
Definition: FluxCommunication.hpp:79
Initialization::Actions::RemoveOptionsAndTerminatePhase
Definition: RemoveOptionsAndTerminatePhase.hpp:27
Initialization::Actions::Minmod
Allocate items for minmod limiter.
Definition: Limiter.hpp:35
Actions::AdvanceTime
Advance time one substep.
Definition: AdvanceTime.hpp:50
dg::Initialization::face_compute_tags
tmpl::list< Tags... > face_compute_tags
Definition: InitializeInterfaces.hpp:42
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:85
M1HydroCoupling.hpp
dg::Initialization::slice_tags_to_face
tmpl::list< Tags... > slice_tags_to_face
Definition: InitializeInterfaces.hpp:32
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:262
DgElementArray
The parallel component responsible for managing the DG elements that compose the computational domain...
Definition: DgElementArray.hpp:94
Registration::Registrar
A template for defining a registrar.
Definition: Registration.hpp:42
EvolutionMetavars
Definition: EvolveBurgers.hpp:92
Initialization::Actions::ConservativeSystem
Allocate variables needed for evolution of conservative systems.
Definition: ConservativeSystem.hpp:66
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
evolution::Actions::AddMeshVelocitySourceTerms
Compute and add the source term modification for moving meshes.
Definition: AddMeshVelocitySourceTerms.hpp:55
dg::FirstOrderScheme::FirstOrderSchemeLts
Boundary contributions for a first-order DG scheme with local time-stepping.
Definition: FirstOrderSchemeLts.hpp:79
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:48
dg::Actions::InitializeInterfaces
Initialize items related to the interfaces between Elements and on external boundaries.
Definition: InitializeInterfaces.hpp:106
Event
Definition: Event.hpp:30
Initialization::Actions::GrTagsForHydro
Allocate and set general relativity quantities needed for evolution of some hydro systems.
Definition: GrTagsForHydro.hpp:60
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:80
Initialization::Actions::TimeStepperHistory
Initialize time-stepper items.
Definition: Evolution.hpp:186
Tags::AnalyticSolution
Definition: Tags.hpp:54
observers::Observer
The group parallel component that is responsible for reducing data to be observed.
Definition: ObserverComponent.hpp:27
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:75
Tags::Time
Tag for the current time as a double.
Definition: Tags.hpp:74
Actions::ComputeTimeDerivative
Compute the time derivative of the system variables.
Definition: ComputeTimeDerivative.hpp:46
Actions::ChangeStepSize
Adjust the step size for local time stepping.
Definition: ChangeStepSize.hpp:48
Triggers::time_triggers
tmpl::list< Registrars::EveryNSlabs, Registrars::NearTimes, Registrars::PastTime, Registrars::SpecifiedSlabs, Registrars::SpecifiedTimes > time_triggers
Definition: TimeTriggers.hpp:19
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:62
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:50
RadiationTransport::M1Grey::Actions::InitializeM1Tags
Definition: Initialize.hpp:44
dg::Actions::ImposeDirichletBoundaryConditions
Packages data on external boundaries for calculating numerical flux. Computes contributions on the in...
Definition: ImposeBoundaryConditions.hpp:61
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:47
evolution::Initialization::Actions::SetVariables
Sets variables needed for evolution of hyperbolic systems.
Definition: SetVariables.hpp:55
Tags::TimeStepper
Tag for a TimeStepper of type StepperType.
Definition: Tags.hpp:188
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:67
Frame
Definition: IndexType.hpp:36
Actions::UpdateU
Perform variable updates for one substep.
Definition: UpdateU.hpp:50
domain::Tags::InternalDirections
Definition: Tags.hpp:235
Initialization::Actions::TimeAndTimeStep
Initialize items related to time, such as the time step.
Definition: Evolution.hpp:76
SelfStart::self_start_procedure
typename detail::self_start_procedure_impl< StepActions >::type self_start_procedure
Definition: SelfStartActions.hpp:468
UpdateU.hpp
Parallel::register_derived_classes_with_charm
void register_derived_classes_with_charm() noexcept
Register derived classes of the Base class.
Definition: RegisterDerivedClassesWithCharm.hpp:31
Blas.hpp
dg::Actions::ReceiveDataForFluxes
Receive boundary data needed for fluxes from neighbors.
Definition: FluxCommunication.hpp:177
Actions::ComputeVolumeFluxes
Compute the volume fluxes of the evolved variables.
Definition: ComputeVolumeFluxes.hpp:57
dg::Formulation
Formulation
The DG formulation to use.
Definition: Formulation.hpp:26
RadiationTransport::M1Grey::System
Definition: System.hpp:29
StepChooser
Definition: StepChooser.hpp:43
Actions::ComputeVolumeSources
Compute the volume sources of the evolved variables.
Definition: ComputeVolumeSources.hpp:35
Parallel
Contains functions that forward to Charm++ parallel functions.
Definition: ElementReceiveInterpPoints.hpp:14
Initialization::Actions::DiscontinuousGalerkin
Initialize items related to the discontinuous Galerkin method.
Definition: DiscontinuousGalerkin.hpp:66
TMPL.hpp
dg::Initialization::slice_tags_to_exterior
tmpl::list< Tags... > slice_tags_to_exterior
Definition: InitializeInterfaces.hpp:37