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

Interpolates data in volume files to target points by reading the volume data into memory. More...

#include <PointwiseInterpolator.hpp>

Public Member Functions

 PointwiseInterpolator (const std::variant< std::vector< std::string >, std::string > &volume_files_or_glob, const std::string &subfile_name, const ObservationVariant &observation, const std::vector< std::string > &tensor_components)
 
void interpolate_to_points (gsl::not_null< std::vector< DataVector > * > result, const tnsr::I< DataVector, Dim, Frame > &target_points, bool extrapolate_into_excisions=false, bool error_on_missing_points=false, std::optional< size_t > num_threads=std::nullopt) const
 Interpolate to many points. More...
 
void interpolate_to_point (gsl::not_null< std::vector< double > * > result, const tnsr::I< double, Dim, Frame > &target_point, std::optional< gsl::not_null< std::vector< size_t > * > > block_order=std::nullopt) const
 Interpolate to a single point. More...
 
void interpolate_to_point (gsl::not_null< std::vector< double > * > result, const IdPair< domain::BlockId, tnsr::I< double, Dim, ::Frame::BlockLogical > > &target_point) const
 Interpolate to a single point in block-logical coordinates. More...
 
size_t obs_id () const
 
double time () const
 
const Domain< Dim > & domain () const
 
const domain::FunctionsOfTimeMapfunctions_of_time () const
 

Detailed Description

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

Interpolates data in volume files to target points by reading the volume data into memory.

This class reads the volume data at the requested time into memory and can then interpolate it to any number of target points.

Thread safety
Constructing the PointwiseInterpolator on multiple threads at once is not thread safe (unless HDF5 was built with thread-safety support) because the constructor opens the H5 files and reads in the data. However, once the data is loaded, the interpolate_to_points and interpolate_to_point functions are 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.

Member Function Documentation

◆ interpolate_to_point() [1/2]

template<size_t Dim, typename Frame = ::Frame::Inertial>
void spectre::Exporter::PointwiseInterpolator< Dim, Frame >::interpolate_to_point ( gsl::not_null< std::vector< double > * >  result,
const IdPair< domain::BlockId, tnsr::I< double, Dim, ::Frame::BlockLogical > > &  target_point 
) const

Interpolate to a single point in block-logical coordinates.

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 in block-logical coordinates.

◆ interpolate_to_point() [2/2]

template<size_t Dim, typename Frame = ::Frame::Inertial>
void spectre::Exporter::PointwiseInterpolator< Dim, Frame >::interpolate_to_point ( gsl::not_null< std::vector< double > * >  result,
const tnsr::I< double, Dim, Frame > &  target_point,
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
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.

◆ interpolate_to_points()

template<size_t Dim, typename Frame = ::Frame::Inertial>
void spectre::Exporter::PointwiseInterpolator< Dim, Frame >::interpolate_to_points ( gsl::not_null< std::vector< DataVector > * >  result,
const tnsr::I< DataVector, Dim, Frame > &  target_points,
bool  extrapolate_into_excisions = false,
bool  error_on_missing_points = false,
std::optional< size_t >  num_threads = std::nullopt 
) const

Interpolate to many points.

Parameters
resultthe interpolated data at the target points. The outer vector is the number of components and the inner vector is the number of target points. Will be resized automatically.
target_pointsthe points to interpolate to
extrapolate_into_excisionswhether to extrapolate into excised regions
error_on_missing_pointswhether to throw an error if any of the target points are outside the domain
num_threadsthe number of OpenMP threads to use to parallelize the interpolation over the target points. If not provided, the default number of threads will be used.

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