sparseSpatialSampling.export module
Interpolate CFD data for the specified fields and time steps onto the coarse grid sampled using the \(S^3\) algorithm. Export the interpolated data to HDF5 and XDMF to enable visualization in ParaView.
- class sparseSpatialSampling.export.ExportData(s_cube, write_new_file_for_each_field=False, n_jobs=None, n_neighbors=None, interpolate_at_vertices=False)[source]
Bases:
objectInitialize an Export object for interpolating original snapshots onto the grid generated by \(S^3\) and exporting them to HDF5.
- Parameters:
s_cube (SparseSpatialSampling) –
SparseSpatialSamplingobject containing the sampled gridwrite_new_file_for_each_field (bool) – If True, each field is written to a separate HDF5 file; if False, all fields are written to a single file
n_jobs (int | None) – Number of CPUs used for interpolation. If None, the same number of CPUs used for executing \(S^3\) will be used
n_neighbors (int | None) – Number of neighbors for the KNN. If None, defaults are 8 for 2D and 26 for 3D
interpolate_at_vertices (bool) – If True, interpolate a solution at cell vertices in addition to cell centers
- export(coordinates, data, field_name, n_snapshots_total=None)[source]
Interpolate the provided CFD data onto the grid generated by \(S^3\) and export it to HDF5 and XDMF files for all specified time steps.
Note
The field data from CFD must have dimensions
[N_cells, N_dimensions, N_snapshots]. For scalar fields,N_dimensions = 1.- Parameters:
coordinates (pt.Tensor) – Coordinates of the original CFD grid
data (pt.Tensor) – Original field data with dimensions
[N_cells, N_dimensions, N_snapshots]. -N_snapshotscan represent all snapshots, a batch of snapshots, or a single snapshotfield_name (str) – Name of the field to export (e.g.,
'p'for the pressure field)n_snapshots_total (int | None) – Total number of snapshots to export - If
None, it is assumed that all snapshots are included indata
- Returns:
None
- Return type:
None
- property new_file: bool
Flag indicating whether a new HDF5 file will be created for each field.
- Returns:
True if a new file is created for each field, False otherwise
- Return type:
bool
- property save_dir: str
Get the directory where output files will be saved.
- Returns:
Path of the save directory
- Return type:
str
- property save_name: str
Get the base name of the output files.
- Returns:
Name of the file used for saving the grid and data
- Return type:
str
- property write_times: list
Get the list of available write times
- Returns:
List of time steps
- Return type:
list
- class sparseSpatialSampling.export.Fields(centers=None, vertices=None)[source]
Bases:
objectInitialize a container for storing interpolated field values at cell centers and vertices.
- Parameters:
centers (pt.Tensor | None) – Interpolated field values at cell centers
vertices (pt.Tensor | None) – Interpolated field values at cell vertices