SpECTRE Documentation Coverage Report
Current view: top level - ParallelAlgorithms/Actions - SetData.hpp Hit Total Coverage
Commit: 9a905b0737f373631c1b8e8389b8f26e67fa5313 Lines: 1 2 50.0 %
Date: 2024-03-28 09:03:18
Legend: Lines: hit not hit

          Line data    Source code
       1           0 : // Distributed under the MIT License.
       2             : // See LICENSE.txt for details.
       3             : 
       4             : #pragma once
       5             : 
       6             : #include "DataStructures/DataBox/DataBox.hpp"
       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           1 : struct SetData;
      32             : 
      33             : /// \cond
      34             : template <typename... Tags>
      35             : struct SetData<tmpl::list<Tags...>> {
      36             :   template <typename ParallelComponent, typename DataBox,
      37             :             typename Metavariables, typename ArrayIndex>
      38             :   static void apply(DataBox& box,
      39             :                     const Parallel::GlobalCache<Metavariables>& /*cache*/,
      40             :                     const ArrayIndex& /*array_index*/,
      41             :                     tuples::TaggedTuple<Tags...> data) {
      42             :     tmpl::for_each<tmpl::list<Tags...>>([&box, &data](auto tag_v) {
      43             :       using tag = tmpl::type_from<decltype(tag_v)>;
      44             :       db::mutate<tag>(
      45             :           [&data](const gsl::not_null<typename tag::type*> value) {
      46             :             *value = std::move(tuples::get<tag>(data));
      47             :           },
      48             :           make_not_null(&box));
      49             :     });
      50             :   }
      51             : };
      52             : /// \endcond
      53             : 
      54             : }  // namespace Actions

Generated by: LCOV version 1.14