SpECTRE Documentation Coverage Report
Current view: top level - IO/Importers/Actions - ReceiveVolumeData.hpp Hit Total Coverage
Commit: 9ddc33268b29014a4956c8f0c24ca90b397463e1 Lines: 1 4 25.0 %
Date: 2024-04-26 20:00:04
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 <cstddef>
       7             : #include <optional>
       8             : #include <tuple>
       9             : 
      10             : #include "DataStructures/DataBox/DataBox.hpp"
      11             : #include "IO/Importers/Tags.hpp"
      12             : #include "Parallel/AlgorithmExecution.hpp"
      13             : #include "Parallel/GlobalCache.hpp"
      14             : #include "Utilities/Gsl.hpp"
      15             : #include "Utilities/Literals.hpp"
      16             : #include "Utilities/TMPL.hpp"
      17             : #include "Utilities/TaggedTuple.hpp"
      18             : 
      19             : namespace importers::Actions {
      20             : 
      21             : /*!
      22             :  * \brief Wait for data from a volume data file to arrive and directly move it
      23             :  * into the DataBox
      24             :  *
      25             :  * Monitors `importers::Tags::VolumeData` in the element's inbox and moves the
      26             :  * received data directly into the `FieldTagsList` in the DataBox.
      27             :  *
      28             :  * \see Dev guide on \ref dev_guide_importing
      29             :  */
      30             : template <typename FieldTagsList>
      31           1 : struct ReceiveVolumeData {
      32           0 :   using inbox_tags = tmpl::list<Tags::VolumeData<FieldTagsList>>;
      33             : 
      34             :   template <typename DbTagsList, typename... InboxTags, typename Metavariables,
      35             :             typename ArrayIndex, typename ActionList,
      36             :             typename ParallelComponent>
      37           0 :   static Parallel::iterable_action_return_t apply(
      38             :       db::DataBox<DbTagsList>& box, tuples::TaggedTuple<InboxTags...>& inboxes,
      39             :       const Parallel::GlobalCache<Metavariables>& /*cache*/,
      40             :       const ArrayIndex& /*array_index*/, const ActionList /*meta*/,
      41             :       const ParallelComponent* const /*meta*/) {
      42             :     auto& inbox = tuples::get<Tags::VolumeData<FieldTagsList>>(inboxes);
      43             :     // Using `0` for the temporal ID since we only read the volume data once, so
      44             :     // there's no need to keep track of the temporal ID.
      45             :     const auto received_data = inbox.find(0_st);
      46             :     if (received_data == inbox.end()) {
      47             :       return {Parallel::AlgorithmExecution::Retry, std::nullopt};
      48             :     }
      49             : 
      50             :     auto& element_data = received_data->second;
      51             :     tmpl::for_each<FieldTagsList>([&box, &element_data](auto tag_v) {
      52             :       using tag = tmpl::type_from<decltype(tag_v)>;
      53             :       db::mutate<tag>(
      54             :           [&element_data](const gsl::not_null<typename tag::type*> value) {
      55             :             *value = std::move(tuples::get<tag>(element_data));
      56             :           },
      57             :           make_not_null(&box));
      58             :     });
      59             :     inbox.erase(received_data);
      60             :     return {Parallel::AlgorithmExecution::Continue, std::nullopt};
      61             :   }
      62             : };
      63             : 
      64             : }  // namespace importers::Actions

Generated by: LCOV version 1.14