SpECTRE  v2026.09.05
Loading...
Searching...
No Matches
spectre::Exporter::ModalTimeSeriesReader< Dim > Class Template Reference

Reads time series of modal coefficients from volume data files. More...

#include <ModalTimeSeriesReader.hpp>

Public Types

using Series = std::vector<std::vector<std::vector<double>>>
 Modal coefficient time series of a single element, indexed as series[component][mode][observation]. Modes are ordered by the collapsed index of the element's mesh.

Public Member Functions

 ModalTimeSeriesReader (const std::variant< std::vector< std::string >, std::string > &volume_files_or_glob, std::string subfile_name, std::vector< std::string > tensor_components, std::optional< double > start_time=std::nullopt, std::optional< double > end_time=std::nullopt)
 Construct from one or more volume files.
 ModalTimeSeriesReader (ModalTimeSeriesReader &&)
ModalTimeSeriesReaderoperator= (ModalTimeSeriesReader &&)
 ModalTimeSeriesReader (const ModalTimeSeriesReader &)=delete
ModalTimeSeriesReaderoperator= (const ModalTimeSeriesReader &)=delete
double start_time () const
 Time of the first observation (after filtering by start_time and end_time)
double time_step () const
 Uniform spacing between observation times.
size_t num_observations () const
 Number of observations (after filtering by start_time and end_time)
const std::vector< std::string > & tensor_components () const
 The tensor components that will be read.
const std::vector< std::pair< ElementId< Dim >, Mesh< Dim > > > & elements () const
 All elements in the volume files and their meshes.
Series modal_time_series (const ElementId< Dim > &element_id)
 The time series of all modal coefficients of all tensor components of the given element.

Detailed Description

template<size_t Dim>
class spectre::Exporter::ModalTimeSeriesReader< Dim >

Reads time series of modal coefficients from volume data files.

This class reads tensor components written by multiple observations of a volume data subfile, transforms the nodal data of each element to modal coefficients, and returns the time series of every modal coefficient one element at a time. Reading element-by-element keeps memory usage low: only a single element's time series is held in memory at once, so the volume data never has to be loaded into memory as a whole.

Request the time series with modal_time_series(), e.g.:

for (const auto& [element_id, element_mesh] : reader.elements()) {
const auto series = reader.modal_time_series(element_id);
// ... process the time series of this element ...

The observation times must be uniformly spaced. Multiple files can be used when the elements of each observation are distributed across files, such as files written by different nodes. All files must contain the same observations in the requested time interval, and each element must reside in the same file with the same mesh for all observations. Files from different simulation segments must be joined first, with overlapping observations removed. Adaptive mesh refinement and element migration between files (e.g. by load balancing) are not supported yet and raise errors.

Only the Legendre basis is supported for now.

Note
When observing fields on a smaller mesh, use the ProjectToMesh option of the ObserveFields event to ensure the data is truncated cleanly in modal space. Do not use InterpolateToMesh as this creates a catastrophic aliasing error.

Constructor & Destructor Documentation

◆ ModalTimeSeriesReader()

template<size_t Dim>
spectre::Exporter::ModalTimeSeriesReader< Dim >::ModalTimeSeriesReader ( const std::variant< std::vector< std::string >, std::string > & volume_files_or_glob,
std::string subfile_name,
std::vector< std::string > tensor_components,
std::optional< double > start_time = std::nullopt,
std::optional< double > end_time = std::nullopt )

Construct from one or more volume files.

Reads and validates metadata from all files. The volume data itself is only read when calling modal_time_series().

Parameters
volume_files_or_globA list of volume H5 files, or a glob string that resolves to volume files. The files can distribute elements of the same observations across nodes, but files from different simulation segments must be joined first.
subfile_nameThe name of the volume data subfile in the H5 files.
tensor_componentsTensor component names to read. Each component must exist in every file at every observation.
start_timeOptional lower bound to restrict observations.
end_timeOptional upper bound to restrict observations.

Member Function Documentation

◆ elements()

template<size_t Dim>
const std::vector< std::pair< ElementId< Dim >, Mesh< Dim > > > & spectre::Exporter::ModalTimeSeriesReader< Dim >::elements ( ) const
inline

All elements in the volume files and their meshes.

The elements are grouped by the volume file they reside in. Requesting the modal_time_series() in this order avoids re-reading per-file metadata.

◆ modal_time_series()

template<size_t Dim>
Series spectre::Exporter::ModalTimeSeriesReader< Dim >::modal_time_series ( const ElementId< Dim > & element_id)

The time series of all modal coefficients of all tensor components of the given element.

Metadata of the file in which the element resides is cached between calls, so requesting elements in the order of elements() is most efficient (this is also why this function is not const).

Reading the volume data is currently not optimized: every observation of a tensor component is read from disk once per element residing in the file. Reading only the element's subset of the data would avoid this amplification without changing this interface.


The documentation for this class was generated from the following file:
  • src/IO/Exporter/ModalTimeSeriesReader.hpp