SpECTRE  v2025.08.19
spectre::Exporter::SpacetimeInterpolator< Dim, Frame > Struct Template Reference

Interpolates data in volume files in both space and time. More...

#include <SpacetimeInterpolator.hpp>

Public Member Functions

 SpacetimeInterpolator (std::variant< std::vector< std::string >, std::string > volume_files_or_glob, std::string subfile_name, std::vector< std::string > tensor_components)
 Construct the interpolator without loading any volume data. More...
 
std::array< double, 2 > max_time_bounds () const
 The maximum time bounds available in the volume data files (taking into account the number of ghost slices needed for interpolation). Only time bounds in this (inclusive) range can be requested with the load_time_bounds() function.
 
void load_time_bounds (std::array< double, 2 > time_bounds)
 Load volume data into memory such that the given time bounds are covered. More...
 
std::array< double, 2 > time_bounds () const
 The time bounds of the loaded data (inclusive). It is an error to call the interpolation routines outside these bounds.
 
size_t num_loaded_slices () const
 The number of loaded time slices.
 
void interpolate_to_point (gsl::not_null< std::vector< double > * > result, const tnsr::I< double, Dim, Frame > &target_point, double time, std::optional< gsl::not_null< std::vector< size_t > * > > block_order=std::nullopt) const
 Interpolate to a single point. More...
 

Detailed Description

template<size_t Dim, typename Frame = ::Frame::Inertial>
struct spectre::Exporter::SpacetimeInterpolator< Dim, Frame >

Interpolates data in volume files in both space and time.

This class reads the volume data at multiple time steps into memory and can then interpolate it to any number of target points at any time within the time bounds of the loaded data.

Details

The interpolation is first done in space and then in time. For the interpolation in space, the PointwiseInterpolator class is used, which does spectral interpolation within the elements. For the interpolation in time, a polynomial interpolation with fixed order is used (currently third order, meaning four time slices are used).

Coordinate frames
The target points are given in the Frame specified as template parameter (defaults to Frame::Inertial). However, the interpolation is done in the grid frame, which is time-independent and therefore best suitable for interpolation in time. Details of this idea can be found in [26] .
Thread safety
Loading volume data from H5 files on multiple threads at once is not generally thread safe, so load_time_bounds may only be called on a single thread. However, once the data is loaded, the interpolate_to_point function is thread safe. This means the volume data can be loaded once in a single thread and then used by multiple threads to interpolate to different points in parallel. Also, load_time_bounds can be called again to load new data while other threads are still accessing the old data, as long as they only request data within both the old and the new time bounds.

Constructor & Destructor Documentation

◆ SpacetimeInterpolator()

template<size_t Dim, typename Frame = ::Frame::Inertial>
spectre::Exporter::SpacetimeInterpolator< Dim, Frame >::SpacetimeInterpolator ( std::variant< std::vector< std::string >, std::string volume_files_or_glob,
std::string  subfile_name,
std::vector< std::string tensor_components 
)

Construct the interpolator without loading any volume data.

Parameters
volume_files_or_globThe list of H5 files, or a glob pattern
subfile_nameThe name of the subfile in the H5 files containing the volume data
tensor_componentsThe tensor components to interpolate. The order of the components in the vector is the order in which they will be returned.

Member Function Documentation

◆ interpolate_to_point()

template<size_t Dim, typename Frame = ::Frame::Inertial>
void spectre::Exporter::SpacetimeInterpolator< Dim, Frame >::interpolate_to_point ( gsl::not_null< std::vector< double > * >  result,
const tnsr::I< double, Dim, Frame > &  target_point,
double  time,
std::optional< gsl::not_null< std::vector< size_t > * > >  block_order = std::nullopt 
) const

Interpolate to a single point.

This function is thread safe, so the interpolator can be constructed to load the volume data once and then used by multiple threads to interpolate to different points in parallel. Note that updating the block_order (if provided) is not thread safe, so each thread should manage a separate block_order.

Parameters
resultthe interpolated data at the target point. The vector is over the number of components. Will be resized automatically.
target_pointthe point to interpolate to.
timethe time to interpolate to. Must be within the time_bounds().
block_orderan optional priority order to search for the block containing the target point. Will be updated when the point is found. See block_logical_coordinates_single_point for more details.

◆ load_time_bounds()

template<size_t Dim, typename Frame = ::Frame::Inertial>
void spectre::Exporter::SpacetimeInterpolator< Dim, Frame >::load_time_bounds ( std::array< double, 2 >  time_bounds)

Load volume data into memory such that the given time bounds are covered.

The given time bounds must be within the max_time_bounds() (inclusive).

Previously loaded volume data slices outside the given time bounds will be dropped and new ones loaded.

Thread safety
This function is not generally thread safe, as it loads data from H5 files. It should be called from a single thread only. It is safe to keep calling interpolation routines from other threads while this function is running, as long as they are requesting data within both the old and the new time bounds.

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