SpECTRE  v2024.06.18
importers::Actions::ReadAllVolumeDataAndDistribute< Dim, FieldTagsList, ReceiveComponent > Struct Template Reference

Read a volume data file and distribute the data to all registered elements, interpolating to the target points if needed. More...

#include <ReadVolumeData.hpp>

Static Public Member Functions

template<typename ParallelComponent , typename DataBox , typename Metavariables , typename ArrayIndex >
static void apply (DataBox &box, Parallel::GlobalCache< Metavariables > &cache, const ArrayIndex &, const ImporterOptions &options, const size_t volume_data_id, tuples::tagged_tuple_from_typelist< db::wrap_tags_in< Tags::Selected, FieldTagsList > > selected_fields=select_all_fields(FieldTagsList{}))

Detailed Description

template<size_t Dim, typename FieldTagsList, typename ReceiveComponent>
struct importers::Actions::ReadAllVolumeDataAndDistribute< Dim, FieldTagsList, ReceiveComponent >

Read a volume data file and distribute the data to all registered elements, interpolating to the target points if needed.

This action can be invoked on the importers::ElementDataReader component once all elements have been registered with it. It opens the data file, reads the data for each registered element and uses Parallel::receive_data to distribute the data to the elements. The elements can monitor importers::Tags::VolumeData in their inbox to wait for the data and process it once it's available. You can use importers::Actions::ReceiveVolumeData to wait for the data and move it directly into the DataBox, or implement a specialized action that might verify and post-process the data.

Note that instead of invoking this action directly on the importers::ElementDataReader component you can invoke the iterable action importers::Actions::ReadVolumeData on the elements of an array parallel component for simple use cases.

  • Pass along the following arguments to the simple action invocation:
    • options: importers::ImporterOptions that specify the H5 files with volume data to load.
    • volume_data_id: A number (or hash) that identifies this import operation. Will also be used to identify the loaded volume data in the inbox of the receiving elements.
    • selected_fields (optional): See below.
  • The FieldTagsList parameter specifies a typelist of tensor tags that can be read from the file and provided to each element. The subset of tensors that will actually be read and distributed can be selected at runtime with the selected_fields argument that is passed to this simple action. See importers::Tags::Selected for details. By default, all tensors in the FieldTagsList are selected, and read from datasets named db::tag_name<Tag>() + suffix, where the suffix is empty for scalars, or "_" followed by the Tensor::component_name for each independent tensor component.
  • Parallel::receive_data is invoked on each registered element of the ReceiveComponent to populate importers::Tags::VolumeData in the element's inbox with a tuples::tagged_tuple_from_typelist<FieldTagsList> containing the tensor data for that element. The ReceiveComponent must the the same that was encoded into the Parallel::ArrayComponentId used to register the elements. The volume_data_id passed to this action is used as key.
Memory consumption
This action runs once on every node. It reads all volume data files on the node, but doesn't keep them all in memory at once. The following items contribute primarily to memory consumption and can be reconsidered if we run into memory issues:
  • all_tensor_data: All requested tensor components in the volume data file at the specified observation ID. Only data from one volume data file is held in memory at any time. Only data from files that overlap with target elements on this node are read in.
  • target_element_data_buffer: Holds incomplete interpolated data for each (target) element that resides on this node. In the worst case, when all target elements need data from the last source element in the last volume data file, the memory consumption of this buffer can grow to hold all requested tensor components on all elements that reside on this node. However, elements are erased from this buffer once their interpolated data is complete (and sent to the target element), so the memory consumption should remain much lower in practice.
See also
Dev guide on Importing data

The documentation for this struct was generated from the following file: