SpECTRE
v2025.03.17
|
A volume data subfile written inside an H5 file. More...
#include <VolumeData.hpp>
Public Member Functions | |
VolumeData (bool subfile_exists, detail::OpenGroup &&group, hid_t location, const std::string &name, uint32_t version=1) | |
VolumeData (const VolumeData &)=delete | |
VolumeData & | operator= (const VolumeData &)=delete |
VolumeData (VolumeData &&)=delete | |
VolumeData & | operator= (VolumeData &&)=delete |
const std::string & | get_header () const |
uint32_t | get_version () const |
void | write_volume_data (size_t observation_id, double observation_value, const std::vector< ElementVolumeData > &elements, const std::optional< std::vector< char > > &serialized_domain=std::nullopt, const std::optional< std::vector< char > > &serialized_functions_of_time=std::nullopt) |
Insert tensor components at observation_id with floating point value observation_value . Optionally write a serialized representation of the domain and the functions of time into the subfile as well. More... | |
template<size_t SpatialDim> | |
void | extend_connectivity_data (const std::vector< size_t > &observation_ids) |
Overwrites the current connectivity dataset with a new one. This new connectivity dataset builds connectivity within each block in the domain for each observation id in a list of observation id's. | |
void | write_tensor_component (const size_t observation_id, const std::string &component_name, const DataVector &contiguous_tensor_data, bool overwrite_existing=false) |
void | write_tensor_component (const size_t observation_id, const std::string &component_name, const std::vector< float > &contiguous_tensor_data, bool overwrite_existing=false) |
std::vector< size_t > | list_observation_ids () const |
List all the integral observation ids in the subfile. More... | |
double | get_observation_value (size_t observation_id) const |
Get the observation value at the the integral observation id in the subfile. | |
size_t | find_observation_id (double observation_value, const std::optional< double > &observation_value_epsilon=std::nullopt) const |
Find the observation ID that matches the observation_value More... | |
std::vector< std::string > | list_tensor_components (size_t observation_id) const |
List all the tensor components at observation id observation_id | |
std::vector< std::string > | get_grid_names (size_t observation_id) const |
List the names of all the grids at observation id observation_id | |
TensorComponent | get_tensor_component (size_t observation_id, const std::string &tensor_component) const |
Read a tensor component with name tensor_component at observation id observation_id from all grids in the file. | |
std::vector< std::vector< size_t > > | get_extents (size_t observation_id) const |
Read the extents of all the grids stored in the file at the observation id observation_id | |
auto | get_data_by_element (std::optional< double > start_observation_value, std::optional< double > end_observation_value, const std::optional< std::vector< std::string > > &components_to_retrieve=std::nullopt) const -> std::vector< std::tuple< size_t, double, std::vector< ElementVolumeData > > > |
Retrieve volume data for IDs in [start_observation_value, end_observation_value] . More... | |
size_t | get_dimension () const |
Read the dimensionality of the grids. Note : This is the dimension of the grids as manifolds, not the dimension of the embedding space. For example, the volume data of a sphere is 2-dimensional, even though each point has an x, y, and z coordinate. | |
std::vector< std::vector< Spectral::Basis > > | get_bases (size_t observation_id) const |
Return the basis being used for each element along each axis. | |
std::vector< std::vector< Spectral::Quadrature > > | get_quadratures (size_t observation_id) const |
Return the quadrature being used for each element along each axis. | |
std::optional< std::vector< char > > | get_domain (size_t observation_id) const |
Get the serialized domain in the subfile at this observation ID, or std::nullopt if no domain was written. | |
std::optional< std::vector< char > > | get_functions_of_time (size_t observation_id) const |
Get the serialized functions of time in the subfile at this observation ID, or std::nullopt if none were written. | |
const std::string & | subfile_path () const override |
Return the path to the subfile where this object is stored. More... | |
virtual const std::string & | subfile_path () const =0 |
Return the path to the subfile where this object is stored. More... | |
Static Public Member Functions | |
static std::string | extension () |
static char | separator () |
Return the character used as a separator between grids in the subfile. | |
A volume data subfile written inside an H5 file.
The volume data inside the subfile can be of any dimensionality greater than zero. This means that in a 3D simulation, data on 2-dimensional surfaces are written as a VolumeData subfile. Data can be written using the write_volume_data()
method. An integral observation id is used to keep track of the observation instance at which the data is written, and associated with it is a floating point observation value, such as the simulation time at which the data was written. The observation id will generally be the result of hashing the temporal identifier used for the simulation.
write_volume_data()
method as a std::vector<ElementVolumeData>
. Typically the GRID_NAME
should be the output of the stream operator of the spatial ID of the parallel component element sending the data to be observed. For example, in the case of a dG evolution where the spatial IDs are ElementId
s, the grid names would be of the form [B0,(L2I3,L2I3,L2I3)]
.T_xx
which is found on all grids appears in the path H5_FILE_NAME/SUBFILE_NAME.vol/OBSERVATION_ID/GRID_NAME/T_xx
and that is where all of the T_xx
data from all of the grids resides. Note that coordinates must be written as tensors in order to visualize the data in ParaView, Visit, etc. In order to reconstruct which data came from which grid, the get_grid_names()
, and get_extents()
methods list the grids and their extents in the order which they and the data were written. For example, if the first grid has name GRID_NAME
with extents {2, 2, 2}
, it was responsible for contributing the first 2*2*2 = 8 grid points worth of data in each tensor dataset. Use the h5::offset_and_length_for_grid
function to compute the offset into the contiguous dataset that corresponds to a particular grid.std::vector<char>
, and it is up to the calling code to serialize and deserialize the data, taking into account that files may be written and read with different versions of the code.size_t h5::VolumeData::find_observation_id | ( | double | observation_value, |
const std::optional< double > & | observation_value_epsilon = std::nullopt |
||
) | const |
Find the observation ID that matches the observation_value
An epsilon can be specified and the observation id that matches within the epsilon of observation_value
will be returned. If there is more than one id that is within the epsilon, an error will occur. If no epsilon is specified, this function will do exact comparison.
auto h5::VolumeData::get_data_by_element | ( | std::optional< double > | start_observation_value, |
std::optional< double > | end_observation_value, | ||
const std::optional< std::vector< std::string > > & | components_to_retrieve = std::nullopt |
||
) | const -> std::vector< std::tuple< size_t, double, std::vector< ElementVolumeData > > > |
Retrieve volume data for IDs in [start_observation_value, end_observation_value]
.
Returns a std::vector
over times, sorted in ascending order of the observation value (the time in evolutions). The vector holds a std::tuple
that holds
ElementVolumeData
sorted by the elements' name string.start_observation_value
is std::nullopt
then return everything from the beginning of the data to end_observation_value
. If end_observation_value
is std::nullopt
then return everything from start_observation_value
to the end of the data.components_to_retrieve
is std::nullopt
then return all components.
|
inline |
Returns: the header of the VolumeData file
|
inline |
Returns: the user-specified version number of the VolumeData file
std::vector< size_t > h5::VolumeData::list_observation_ids | ( | ) | const |
List all the integral observation ids in the subfile.
The list of observation IDs is sorted by their observation value, as returned by get_observation_value(size_t).
|
inlineoverridevirtual |
Return the path to the subfile where this object is stored.
Implements h5::Object.
void h5::VolumeData::write_volume_data | ( | size_t | observation_id, |
double | observation_value, | ||
const std::vector< ElementVolumeData > & | elements, | ||
const std::optional< std::vector< char > > & | serialized_domain = std::nullopt , |
||
const std::optional< std::vector< char > > & | serialized_functions_of_time = std::nullopt |
||
) |
Insert tensor components at observation_id
with floating point value observation_value
. Optionally write a serialized representation of the domain and the functions of time into the subfile as well.
All elements
must contain the same tensor components in the same order.