|
SpECTRE
v2025.08.19
|
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... | |
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.
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).
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] .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. | 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.
| volume_files_or_glob | The list of H5 files, or a glob pattern |
| subfile_name | The name of the subfile in the H5 files containing the volume data |
| tensor_components | The tensor components to interpolate. The order of the components in the vector is the order in which they will be returned. |
| 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.
| result | the interpolated data at the target point. The vector is over the number of components. Will be resized automatically. |
| target_point | the point to interpolate to. |
| time | the time to interpolate to. Must be within the time_bounds(). |
| block_order | an 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. |
| 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.