AdvanceTime.hpp
Go to the documentation of this file.
1 // Distributed under the MIT License.
2 // See LICENSE.txt for details.
3 
4 /// \file
5 /// Defines action AdvanceTime
6 
7 #pragma once
8 
9 #include <tuple>
10 
13 #include "Time/Time.hpp"
14 #include "Time/TimeId.hpp"
15 #include "Utilities/Gsl.hpp"
16 #include "Utilities/TMPL.hpp"
18 
19 /// \cond
20 namespace OptionTags {
21 struct TimeStepper;
22 } // namespace OptionTags
23 namespace Tags {
24 template <typename Tag>
25 struct Next;
26 struct TimeId;
27 struct TimeStep;
28 } // namespace Tags
29 // IWYU pragma: no_forward_declare db::DataBox
30 /// \endcond
31 
32 namespace Actions {
33 /// \ingroup ActionsGroup
34 /// \ingroup TimeGroup
35 /// \brief Advance time one substep
36 ///
37 /// Uses:
38 /// - ConstGlobalCache: OptionTags::TimeStepper
39 /// - DataBox: Tags::TimeId, Tags::TimeStep
40 ///
41 /// DataBox changes:
42 /// - Adds: nothing
43 /// - Removes: nothing
44 /// - Modifies: Tags::TimeId, Tags::TimeStep
45 struct AdvanceTime {
46  template <typename DbTags, typename... InboxTags, typename Metavariables,
47  typename ArrayIndex, typename ActionList,
48  typename ParallelComponent>
52  const ArrayIndex& /*array_index*/, const ActionList /*meta*/,
53  const ParallelComponent* const /*meta*/) noexcept {
54  db::mutate<Tags::TimeId, Tags::Next<Tags::TimeId>, Tags::TimeStep>(
55  make_not_null(&box), [&cache](const gsl::not_null<TimeId*> time_id,
56  const gsl::not_null<TimeId*> next_time_id,
58  time_step) noexcept {
59  const auto& time_stepper =
60  Parallel::get<OptionTags::TimeStepper>(cache);
61  *time_id = *next_time_id;
62  *time_step = time_step->with_slab(time_id->time().slab());
63  *next_time_id = time_stepper.next_time_id(*next_time_id, *time_step);
64  });
65 
66  return std::forward_as_tuple(std::move(box));
67  }
68 };
69 } // namespace Actions
Tag for step size.
Definition: Tags.hpp:45
Defines class tuples::TaggedTuple.
Abstract base class for TimeSteppers.
Definition: TimeStepper.hpp:44
A unique identifier for the temporal state of an integrated system.
Definition: TimeId.hpp:25
Defines class TimeId.
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
Defines Time and TimeDelta.
An associative container that is indexed by structs.
Definition: TaggedTuple.hpp:272
Defines classes and functions used for manipulating DataBox&#39;s.
Definition: Strahlkorper.hpp:167
Definition: InterpolationTargetWedgeSectionTorus.hpp:24
Definition: DataBoxTag.hpp:29
A Charm++ chare that caches constant data once per Charm++ node.
Definition: ConstGlobalCache.hpp:76
Wraps the template metaprogramming library used (brigand)
Advance time one substep.
Definition: AdvanceTime.hpp:45
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 class template ConstGlobalCache.
Definition: ComputeTimeDerivative.hpp:28
Require a pointer to not be a nullptr
Definition: ConservativeFromPrimitive.hpp:12