SetData.hpp
1 // Distributed under the MIT License.
2 // See LICENSE.txt for details.
3 
4 #pragma once
5 
8 #include "Utilities/TMPL.hpp"
9 #include "Utilities/TaggedTuple.hpp"
10 
11 /// \cond
12 namespace Parallel {
13 template <typename Metavariables>
14 struct ConstGlobalCache;
15 } // namespace Parallel
16 /// \endcond
17 
18 namespace Actions {
19 
20 /*!
21  * \ingroup ActionsGroup
22  * \brief Mutate the DataBox tags in `TagsList` according to the `data`.
23  *
24  * An example use case for this action is as the callback for the
25  * `importers::ThreadedActions::ReadVolumeData`.
26  *
27  * DataBox changes:
28  * - Modifies:
29  * - All tags in `TagsList`
30  */
31 template <typename TagsList>
32 struct SetData;
33 
34 /// \cond
35 template <typename... Tags>
36 struct SetData<tmpl::list<Tags...>> {
37  template <
38  typename ParallelComponent, typename DataBox, typename Metavariables,
39  typename ArrayIndex,
41  nullptr>
42  static void apply(DataBox& box,
44  const ArrayIndex& /*array_index*/,
45  tuples::TaggedTuple<Tags...> data) noexcept {
46  tmpl::for_each<tmpl::list<Tags...>>([&box, &data](auto tag_v) noexcept {
47  using tag = tmpl::type_from<decltype(tag_v)>;
48  db::mutate<tag>(
49  make_not_null(&box),
50  [&data](const gsl::not_null<db::item_type<tag>*> value) noexcept {
51  *value = std::move(tuples::get<tag>(data));
52  });
53  });
54  }
55 };
56 /// \endcond
57 
58 } // namespace Actions
Parallel::ConstGlobalCache
Definition: ElementReceiveInterpPoints.hpp:16
DataBoxTag.hpp
db::apply
constexpr auto apply(F &&f, const DataBox< BoxTags > &box, Args &&... args) noexcept
Apply the invokable f with argument Tags TagsList from DataBox box
Definition: DataBox.hpp:1443
DataBox.hpp
db::item_type
typename DataBox_detail::item_type_impl< TagList, Tag >::type item_type
Get the type that can be written to the Tag. If it is a base tag then a TagList must be passed as a s...
Definition: DataBoxTag.hpp:246
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
Contains functions that forward to Charm++ parallel functions.
Definition: ElementReceiveInterpPoints.hpp:14
TMPL.hpp
gsl::not_null
Require a pointer to not be a nullptr
Definition: Gsl.hpp:183
Actions::SetData
Mutate the DataBox tags in TagsList according to the data.
Definition: SetData.hpp:32