AddSimpleTags.hpp
1 // Distributed under the MIT License.
2 // See LICENSE.txt for details.
3 
4 #pragma once
5 
6 #include <tuple>
7 #include <utility>
8 
10 #include "Utilities/TMPL.hpp"
11 #include "Utilities/TaggedTuple.hpp"
12 
13 /// \cond
14 namespace Parallel {
15 template <typename Metavariables>
16 class GlobalCache;
17 } // namespace Parallel
18 /// \endcond
19 
20 namespace Initialization {
21 namespace Actions {
22 /*!
23  * \ingroup ActionsGroup
24  * \brief Initialize the list of simple tags in `Mutators::return_tags` by
25  * calling each mutator in the order they are specified
26  *
27  * There's a specialization for `AddSimpleTags<tmpl::list<Mutators...>>` that
28  * can also be used if a `tmpl::list` is available.
29  *
30  * Uses: nothing
31  *
32  * DataBox changes:
33  * - Adds:
34  * - Each simple tag in the list `Mutators::return_tags`
35  * - Removes:
36  * - nothing
37  * - Modifies:
38  * - Each simple tag in the list `Mutators::return_tags`
39  *
40  * \note This action relies on the `SetupDataBox` aggregated initialization
41  * mechanism, so `Actions::SetupDataBox` must be present in the `Initialization`
42  * phase action list prior to this action.
43  */
44 template <typename... Mutators>
45 struct AddSimpleTags {
46  using simple_tags =
47  tmpl::flatten<tmpl::append<typename Mutators::return_tags...>>;
48  using compute_tags = tmpl::list<>;
49 
50  template <typename DbTagsList, typename... InboxTags, typename Metavariables,
51  typename ArrayIndex, typename ActionList,
52  typename ParallelComponent>
53  static auto apply(db::DataBox<DbTagsList>& box,
54  const tuples::TaggedTuple<InboxTags...>& /*inboxes*/,
55  const Parallel::GlobalCache<Metavariables>& /*cache*/,
56  const ArrayIndex& /*array_index*/, ActionList /*meta*/,
57  const ParallelComponent* const /*meta*/) noexcept {
58  EXPAND_PACK_LEFT_TO_RIGHT(db::mutate_apply<Mutators>(make_not_null(&box)));
59  return std::make_tuple(std::move(box));
60  }
61 };
62 
63 /// \cond
64 template <typename... Mutators>
65 struct AddSimpleTags<tmpl::list<Mutators...>>
66  : public AddSimpleTags<Mutators...> {};
67 /// \endcond
68 } // namespace Actions
69 } // namespace Initialization
EXPAND_PACK_LEFT_TO_RIGHT
#define EXPAND_PACK_LEFT_TO_RIGHT(...)
Expand a parameter pack evaluating the terms from left to right.
Definition: TMPL.hpp:601
utility
Initialization::Actions::AddSimpleTags
Initialize the list of simple tags in Mutators::return_tags by calling each mutator in the order they...
Definition: AddSimpleTags.hpp:45
Parallel::GlobalCache
Definition: ElementReceiveInterpPoints.hpp:15
tuple
DataBox.hpp
tuples::TaggedTuple
An associative container that is indexed by structs.
Definition: TaggedTuple.hpp:271
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
Parallel
Functionality for parallelization.
Definition: ElementReceiveInterpPoints.hpp:13
TMPL.hpp