SetData.hpp
1 // Distributed under the MIT License.
2 // See LICENSE.txt for details.
3 
4 #pragma once
5 
7 #include "Utilities/TMPL.hpp"
8 #include "Utilities/TaggedTuple.hpp"
9 
10 /// \cond
11 namespace Parallel {
12 template <typename Metavariables>
13 struct GlobalCache;
14 } // namespace Parallel
15 /// \endcond
16 
17 namespace Actions {
18 
19 /*!
20  * \ingroup ActionsGroup
21  * \brief Mutate the DataBox tags in `TagsList` according to the `data`.
22  *
23  * An example use case for this action is as the callback for the
24  * `importers::ThreadedActions::ReadVolumeData`.
25  *
26  * DataBox changes:
27  * - Modifies:
28  * - All tags in `TagsList`
29  */
30 template <typename TagsList>
31 struct SetData;
32 
33 /// \cond
34 template <typename... Tags>
35 struct SetData<tmpl::list<Tags...>> {
36  template <
37  typename ParallelComponent, typename DataBox, typename Metavariables,
38  typename ArrayIndex,
40  nullptr>
41  static void apply(DataBox& box,
42  const Parallel::GlobalCache<Metavariables>& /*cache*/,
43  const ArrayIndex& /*array_index*/,
44  tuples::TaggedTuple<Tags...> data) noexcept {
45  tmpl::for_each<tmpl::list<Tags...>>([&box, &data](auto tag_v) noexcept {
46  using tag = tmpl::type_from<decltype(tag_v)>;
47  db::mutate<tag>(
49  value) noexcept {
50  *value = std::move(tuples::get<tag>(data));
51  });
52  });
53  }
54 };
55 /// \endcond
56 
57 } // namespace Actions
Parallel::GlobalCache
Definition: ElementReceiveInterpPoints.hpp:15
DataBox.hpp
tuples::TaggedTuple< Tags... >
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
Parallel
Functionality for parallelization.
Definition: ElementReceiveInterpPoints.hpp:13
TMPL.hpp
gsl::not_null
Require a pointer to not be a nullptr
Definition: ReadSpecThirdOrderPiecewisePolynomial.hpp:13
Actions::SetData
Mutate the DataBox tags in TagsList according to the data.
Definition: SetData.hpp:31