InitializeCharacteristicEvolutionTime.hpp
1 // Distributed under the MIT License.
2 // See LICENSE.txt for details.
3 
4 #pragma once
5 
6 #include <cstddef>
7 #include <tuple>
8 #include <utility>
9 
12 #include "DataStructures/VariablesTag.hpp"
13 #include "Evolution/Systems/Cce/OptionTags.hpp"
14 #include "ParallelAlgorithms/Initialization/MergeIntoDataBox.hpp"
15 #include "Time/Tags.hpp"
16 #include "Time/TimeSteppers/TimeStepper.hpp"
17 #include "Utilities/Rational.hpp"
18 #include "Utilities/Requires.hpp"
19 #include "Utilities/TMPL.hpp"
20 #include "Utilities/TaggedTuple.hpp"
21 
22 namespace Cce {
23 namespace Actions {
24 
25 /*!
26  * \ingroup ActionsGroup
27  * \brief Initializes the contents of the `CharacteristicEvolution` component
28  * for performing the time evolution of the system, which is the singleton that
29  * handles the main evolution system for CCE computations.
30  *
31  * \details Sets up the \ref DataBoxGroup to be ready to perform the
32  * time-stepping associated with the CCE system.
33  *
34  * \ref DataBoxGroup changes:
35  * - Modifies: nothing
36  * - Adds:
37  * - `Tags::TimeStepId`
38  * - `Tags::Next<Tags::TimeStepId>`
39  * - `Tags::TimeStep`
40  * - `Tags::Time`
41  * -
42  * ```
43  * Tags::HistoryEvolvedVariables<
44  * metavariables::evolved_coordinates_variables_tag,
45  * db::add_tag_prefix<Tags::dt,
46  * metavariables::evolved_coordinates_variables_tag>>
47  * ```
48  * -
49  * ```
50  * Tags::HistoryEvolvedVariables<
51  * ::Tags::Variables<metavariables::evolved_swsh_tag>,
52  * ::Tags::Variables<metavariables::evolved_swsh_dt_tag>>
53  * ```
54  * - Removes: nothing
55  */
57  using initialization_tags = tmpl::list<InitializationTags::TargetStepSize>;
58  using const_global_cache_tags = tmpl::list<::Tags::TimeStepper<TimeStepper>,
60 
61  template <typename DbTags, typename... InboxTags, typename Metavariables,
62  typename ArrayIndex, typename ActionList,
63  typename ParallelComponent,
64  Requires<tmpl::list_contains_v<
65  DbTags, InitializationTags::TargetStepSize>> = nullptr>
66  static auto apply(db::DataBox<DbTags>& box,
67  const tuples::TaggedTuple<InboxTags...>& /*inboxes*/,
69  const ArrayIndex& /*array_index*/,
70  const ActionList /*meta*/,
71  const ParallelComponent* const /*meta*/) noexcept {
72  using coordinate_variables_tag =
73  typename Metavariables::evolved_coordinates_variables_tag;
74  using evolved_swsh_variables_tag =
76  using evolution_simple_tags = db::AddSimpleTags<
80  using evolution_compute_tags =
82 
83  const double initial_time_value = db::get<Tags::StartTime>(box);
84  const double step_size = db::get<InitializationTags::TargetStepSize>(box);
85 
86  const Slab single_step_slab{initial_time_value,
87  initial_time_value + step_size};
88  const Time initial_time = single_step_slab.start();
89  const TimeDelta fixed_time_step =
90  TimeDelta{single_step_slab, Rational{1, 1}};
91  TimeStepId initial_time_id{true, 0, initial_time};
92  const auto& time_stepper = db::get<::Tags::TimeStepper<TimeStepper>>(box);
93  TimeStepId second_time_id =
94  time_stepper.next_time_id(initial_time_id, fixed_time_step);
95 
97  coordinate_history;
98 
100  swsh_history;
101  return std::make_tuple(
103  InitializeCharacteristicEvolutionTime, evolution_simple_tags,
104  evolution_compute_tags, Initialization::MergePolicy::Overwrite>(
105  std::move(box), std::move(initial_time_id), // NOLINT
106  std::move(second_time_id), fixed_time_step, // NOLINT
107  initial_time_value, std::move(coordinate_history),
108  std::move(swsh_history)));
109  }
110 
111  template <typename DbTags, typename... InboxTags, typename Metavariables,
112  typename ArrayIndex, typename ActionList,
113  typename ParallelComponent,
114  Requires<not tmpl::list_contains_v<
115  DbTags, InitializationTags::TargetStepSize>> = nullptr>
116  static std::tuple<db::DataBox<DbTags>&&> apply(
117  const db::DataBox<DbTags>& /*box*/,
118  const tuples::TaggedTuple<InboxTags...>& /*inboxes*/,
120  const ArrayIndex& /*array_index*/, const ActionList /*meta*/,
121  const ParallelComponent* const /*meta*/) noexcept {
122  ERROR(
123  "The DataBox is missing required dependency "
124  "`Cce::InitializationTags::TargetStepSize.`");
125  }
126 };
127 
128 } // namespace Actions
129 } // namespace Cce
Parallel::ConstGlobalCache
Definition: ElementReceiveInterpPoints.hpp:16
DataBoxTag.hpp
utility
Slab
Definition: Slab.hpp:27
Tags::TimeStepId
Tag for TimeStepId for the algorithm state.
Definition: Tags.hpp:34
Cce::Actions::InitializeCharacteristicEvolutionTime
Initializes the contents of the CharacteristicEvolution component for performing the time evolution o...
Definition: InitializeCharacteristicEvolutionTime.hpp:56
Tags::TimeStep
Tag for step size.
Definition: Tags.hpp:43
Tags::Variables
Definition: VariablesTag.hpp:21
db::AddComputeTags
tmpl::flatten< tmpl::list< Tags... > > AddComputeTags
List of Compute Item Tags to add to the DataBox.
Definition: DataBox.hpp:1171
tuple
Tags::Next
Prefix indicating the value a quantity will take on the next iteration of the algorithm.
Definition: Prefixes.hpp:152
Cce::Tags::EndTime
Represents the final time of a bounded CCE evolution, determined either from option specification or ...
Definition: OptionTags.hpp:305
ERROR
#define ERROR(m)
prints an error message to the standard error stream and aborts the program.
Definition: Error.hpp:36
DataBox.hpp
cstddef
Cce::InitializationTags::TargetStepSize
Definition: OptionTags.hpp:186
db::item_type
typename DataBox_detail::item_type_impl< TagList, Tag >::type item_type
Get the type that can be written to the Tag. If it is a base tag then a TagList must be passed as a s...
Definition: DataBoxTag.hpp:246
TimeDelta
Definition: Time.hpp:88
tuples::TaggedTuple
An associative container that is indexed by structs.
Definition: TaggedTuple.hpp:272
Tags::Time
Tag for the current time as a double.
Definition: Tags.hpp:72
TimeStepId
Definition: TimeStepId.hpp:25
db::AddSimpleTags
tmpl::flatten< tmpl::list< Tags... > > AddSimpleTags
List of Tags to add to the DataBox.
Definition: DataBox.hpp:1150
Cce
The set of utilities for performing Cauchy characteristic evolution and Cauchy characteristic matchin...
Definition: BoundaryComputeAndSendToEvolution.hpp:28
Time
Definition: Time.hpp:29
Requires.hpp
Initialization::merge_into_databox
auto merge_into_databox(db::DataBox< DbTagsList > &&box, Args &&... args) noexcept
Add tags that are not yet in the DataBox.
Definition: MergeIntoDataBox.hpp:133
Requires
typename Requires_detail::requires_impl< B >::template_error_type_failed_to_meet_requirements_on_template_parameters Requires
Express requirements on the template parameters of a function or class, replaces std::enable_if_t
Definition: Requires.hpp:67
Tags::HistoryEvolvedVariables
Definition: Tags.hpp:84
db::DataBox
Definition: InterpolationTargetWedgeSectionTorus.hpp:24
Cce::Tags::StartTime
Definition: OptionTags.hpp:281
TMPL.hpp
Rational
Definition: Rational.hpp:24