ComputeTimeDerivative.hpp
1 // Distributed under the MIT License.
2 // See LICENSE.txt for details.
3 
4 #pragma once
5 
6 #include <tuple>
7 
9 #include "Utilities/Gsl.hpp"
10 #include "Utilities/Requires.hpp"
11 #include "Utilities/TMPL.hpp"
12 
13 /// \cond
14 // IWYU pragma: no_forward_declare db::DataBox
15 namespace tuples {
16 template <typename...>
17 class TaggedTuple; // IWYU pragma: keep
18 } // namespace tuples
19 
20 namespace Parallel {
21 template <typename Metavariables>
22 class GlobalCache;
23 } // namespace Parallel
24 /// \endcond
25 
26 namespace Actions {
27 /*!
28  * \ingroup ActionsGroup
29  * \ingroup DiscontinuousGalerkinGroup
30  * \brief Compute the time derivative of the system variables
31  *
32  * Uses:
33  * - Metavariables:
34  * - `temporal_id::step_prefix`
35  * - DataBox:
36  * - `TimeDerivativeComputer::argument_tags<step_prefix>`
37  *
38  * DataBox changes:
39  * - Modifies:
40  * - `TimeDerivativeComputer::return_tags<step_prefix>`
41  */
42 template <typename TimeDerivativeComputer>
44  template <typename DbTagsList, typename... InboxTags, typename Metavariables,
45  typename ArrayIndex, typename ActionList,
46  typename ParallelComponent,
48  static std::tuple<db::DataBox<DbTagsList>&&> apply(
49  db::DataBox<DbTagsList>& box,
51  const Parallel::GlobalCache<Metavariables>& /*cache*/,
52  const ArrayIndex& /*array_index*/, ActionList /*meta*/,
53  const ParallelComponent* const /*meta*/) noexcept { // NOLINT const
54  // Notes:
55  // - dt_variables is not zeroed and the operator cannot assume this.
56  // - We retrieve the `step_prefix` from the `Metavariables` (as opposed to
57  // hard-coding `Tags::dt`) to retain consistency with other actions that do
58  // the same (for instance `dg::Actions::ApplyFluxes` that is not specific to
59  // evolution systems)
60  db::mutate_apply<typename TimeDerivativeComputer::template return_tags<
61  Metavariables::temporal_id::template step_prefix>,
62  typename TimeDerivativeComputer::argument_tags>(
63  TimeDerivativeComputer{}, make_not_null(&box));
64  return std::forward_as_tuple(std::move(box));
65  }
66 };
67 } // namespace Actions
db::mutate_apply
constexpr void mutate_apply(F &&f, const gsl::not_null< DataBox< BoxTags > * > box, Args &&... args) noexcept
Apply the invokable f mutating items MutateTags and taking as additional arguments ArgumentTags and a...
Definition: DataBox.hpp:1417
Parallel::GlobalCache
Definition: ElementReceiveInterpPoints.hpp:15
tuple
DataBox.hpp
tuples::TaggedTuple
An associative container that is indexed by structs.
Definition: TaggedTuple.hpp:271
Actions::ComputeTimeDerivative
Compute the time derivative of the system variables.
Definition: ComputeTimeDerivative.hpp:43
Gsl.hpp
Requires.hpp
make_not_null
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,...
Definition: Gsl.hpp:880
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
TMPL.hpp