RecordTimeStepperData.hpp
1 // Distributed under the MIT License.
2 // See LICENSE.txt for details.
3 
4 #pragma once
5 
6 #include <tuple>
7 #include <utility> // IWYU pragma: keep // for std::move
8 
12 #include "Time/Tags.hpp"
13 // IWYU pragma: no_include "Time/Time.hpp" // for Time
14 #include "Utilities/Gsl.hpp"
16 
17 /// \cond
18 // IWYU pragma: no_forward_declare Time
19 namespace Parallel {
20 template <typename Metavariables>
21 class ConstGlobalCache;
22 } // namespace Parallel
23 // IWYU pragma: no_forward_declare db::DataBox
24 /// \endcond
25 
26 namespace Actions {
27 /// \ingroup ActionsGroup
28 /// \ingroup TimeGroup
29 /// \brief Records the variables and their time derivatives in the
30 /// time stepper history.
31 ///
32 /// With `dt_variables_tag = db::add_tag_prefix<Tags::dt, variables_tag>`:
33 ///
34 /// Uses:
35 /// - ConstGlobalCache: nothing
36 /// - DataBox:
37 /// - variables_tag
38 /// - dt_variables_tag
39 /// - Tags::HistoryEvolvedVariables<system::variables_tag, dt_variables_tag>
40 /// - Tags::Time
41 ///
42 /// DataBox changes:
43 /// - Adds: nothing
44 /// - Removes: nothing
45 /// - Modifies:
46 /// - dt_variables_tag,
47 /// - Tags::HistoryEvolvedVariables<variables_tag, dt_variables_tag>
49  template <typename DbTags, typename... InboxTags, typename Metavariables,
50  typename ArrayIndex, typename ActionList,
51  typename ParallelComponent>
55  const ArrayIndex& /*array_index*/, const ActionList /*meta*/,
56  const ParallelComponent* const /*meta*/) noexcept {
57  using variables_tag = typename Metavariables::system::variables_tag;
58  using dt_variables_tag = db::add_tag_prefix<Tags::dt, variables_tag>;
59  using history_tag =
61 
62  db::mutate<dt_variables_tag, history_tag>(
63  make_not_null(&box),
66  const db::item_type<variables_tag>& vars,
67  const db::item_type<Tags::Time>& time) noexcept {
68  history->insert(time, vars, std::move(*dt_vars));
69  },
70  db::get<variables_tag>(box), db::get<Tags::Time>(box));
71 
72  return std::forward_as_tuple(std::move(box));
73  }
74 };
75 } // namespace Actions
Prefix< DataBox_detail::dispatch_add_tag_prefix_impl< Prefix, Tag, Args... >, Args... > add_tag_prefix
Wrap Tag in Prefix<_, Args...>, also wrapping variables tags if Tag is a Tags::Variables.
Definition: DataBoxTag.hpp:533
Defines class tuples::TaggedTuple.
Define prefixes for DataBox tags.
Contains functions that forward to Charm++ parallel functions.
Definition: Abort.hpp:13
constexpr auto apply(F &&f, const DataBox< BoxTags > &box, Args &&... args)
Apply the function f with argument Tags TagsList from DataBox box
Definition: DataBox.hpp:1595
Prefix for TimeStepper history.
Definition: Tags.hpp:75
An associative container that is indexed by structs.
Definition: TaggedTuple.hpp:272
Defines classes and functions used for manipulating DataBox&#39;s.
Definition: InterpolationTargetWedgeSectionTorus.hpp:24
A Charm++ chare that caches constant data once per Charm++ node.
Definition: ConstGlobalCache.hpp:76
Records the variables and their time derivatives in the time stepper history.
Definition: RecordTimeStepperData.hpp:48
typename DataBox_detail::item_type_impl< TagList, Tag >::type item_type
Get the type that is returned by the Tag. If it is a base tag then a TagList must be passed as a seco...
Definition: DataBoxTag.hpp:410
Defines functions and classes from the GSL.
gsl::not_null< T * > make_not_null(T *ptr) noexcept
Construct a not_null from a pointer. Often this will be done as an implicit conversion, but it may be necessary to perform the conversion explicitly when type deduction is desired.
Definition: Gsl.hpp:863
Definition: SolvePoissonProblem.hpp:38
Defines classes SimpleTag, PrefixTag, ComputeTag and several functions for retrieving tag info...
Defines tags related to Time quantities.
Definition: ComputeTimeDerivative.hpp:28
Require a pointer to not be a nullptr
Definition: ConservativeFromPrimitive.hpp:12