SetData.hpp
1 // Distributed under the MIT License.
2 // See LICENSE.txt for details.
3 
4 #pragma once
5 
8 #include "Utilities/TMPL.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
Defines class tuples::TaggedTuple.
Definition: Digraph.hpp:11
Contains functions that forward to Charm++ parallel functions.
Definition: Abort.hpp:13
Mutate the DataBox tags in TagsList according to the data.
Definition: SetData.hpp:32
Defines classes and functions used for manipulating DataBox&#39;s.
Definition: DataBoxTag.hpp:29
A Charm++ chare that caches constant data once per Charm++ node.
Definition: ConstGlobalCache.hpp:135
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:1628
Wraps the template metaprogramming library used (brigand)
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:879
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
Defines classes SimpleTag, PrefixTag, ComputeTag and several functions for retrieving tag info...
Definition: ComputeTimeDerivative.hpp:28
Require a pointer to not be a nullptr
Definition: Gsl.hpp:182