Loading...
Searching...
No Matches
terra::io Namespace Reference

Namespaces

namespace  detail
 

Classes

struct  CheckpointMetadata
 
struct  GridLayout2D
 Describes the 2D grid layout for a linearized data column. More...
 
struct  ScalarLookupTable2D
 Device-capable 2D scalar lookup table with bilinear interpolation. More...
 
class  VTKOutput
 
class  XDMFOutput
 XDMF output that simultaneously serves for visualization with software like Paraview and as a simulation checkpoint. More...
 

Enumerations

enum class  VtkElementType { LINEAR_QUAD , QUADRATIC_QUAD }
 
enum class  DiagonalSplitType { FORWARD_SLASH , BACKWARD_SLASH }
 

Functions

template<typename ScalarType = double>
std::vector< ScalarLookupTable2D< ScalarType > > read_lookup_tables_2d (const std::string &filename, const std::vector< int > &column_indices, const GridLayout2D &layout, const std::string &label="lookup_table")
 Read selected columns from a delimited data file into 2D lookup tables.
 
template<typename ScalarType = double>
ScalarLookupTable2D< ScalarType > read_lookup_table_2d (const std::string &filename, int column_index, const GridLayout2D &layout, const std::string &label="lookup_table")
 Convenience overload: read a single column from a data file.
 
void write_vtk_xml_quad_mesh (const std::string &filename, const Kokkos::View< double **[3] > &vertices, VtkElementType elementType=VtkElementType::LINEAR_QUAD)
 Writes a 2D grid of vertices stored in a Kokkos View to a VTK XML Unstructured Grid file (.vtu) representing a quadrilateral mesh (linear or quadratic).
 
template<typename T >
std::string get_vtk_type_string ()
 
template<typename ScalarType >
void write_rectilinear_to_triangular_vtu (Kokkos::View< ScalarType **[3] > points_device_view, const std::string &filename, DiagonalSplitType split_type)
 
template<typename PointRealT , typename AttachedDataType >
void write_surface_radial_extruded_to_wedge_vtu (grid::Grid2DDataVec< PointRealT, 3 > surface_points_device_view, grid::Grid1DDataScalar< PointRealT > radii_device_view, std::optional< AttachedDataType > optional_attached_data_device_view, const std::string &vector_data_name, const std::string &filename, DiagonalSplitType split_type)
 
util::Result< CheckpointMetadataread_xdmf_checkpoint_metadata (const std::string &checkpoint_directory)
 Reads metadata from an XDMF/checkpoint directory. See XDMFOutput for details.
 
template<typename GridDataType >
util::Result read_xdmf_checkpoint_grid (const std::string &checkpoint_directory, const std::string &data_label, const int step, const grid::shell::DistributedDomain &distributed_domain, GridDataType &grid_data_device)
 Reads a single grid at a single write step from an XDMF checkpoint.
 

Variables

constexpr int VTK_QUAD = 9
 
constexpr int VTK_QUADRATIC_QUAD = 23
 

Enumeration Type Documentation

◆ DiagonalSplitType

enum class terra::io::DiagonalSplitType
strong
Enumerator
FORWARD_SLASH 
BACKWARD_SLASH 

◆ VtkElementType

enum class terra::io::VtkElementType
strong
Enumerator
LINEAR_QUAD 
QUADRATIC_QUAD 

Function Documentation

◆ get_vtk_type_string()

template<typename T >
std::string terra::io::get_vtk_type_string ( )

◆ read_lookup_table_2d()

template<typename ScalarType = double>
ScalarLookupTable2D< ScalarType > terra::io::read_lookup_table_2d ( const std::string &  filename,
int  column_index,
const GridLayout2D layout,
const std::string &  label = "lookup_table" 
)

Convenience overload: read a single column from a data file.

Equivalent to calling read_lookup_tables_2d with a one-element column-index vector and returning the first (and only) result.

Parameters
filenamePath to the data file
column_index0-based index of the column to read
layoutGrid dimensions, physical coordinates, and strides
labelOptional label for the Kokkos view
Returns
A ScalarLookupTable2D for the requested column
Exceptions
std::runtime_error(same conditions as read_lookup_tables_2d)

◆ read_lookup_tables_2d()

template<typename ScalarType = double>
std::vector< ScalarLookupTable2D< ScalarType > > terra::io::read_lookup_tables_2d ( const std::string &  filename,
const std::vector< int > &  column_indices,
const GridLayout2D layout,
const std::string &  label = "lookup_table" 
)

Read selected columns from a delimited data file into 2D lookup tables.

File format
  • Lines starting with # (after optional leading whitespace) are treated as comments and ignored.
  • Empty or whitespace-only lines are also skipped.
  • All other lines are data rows. Values may be separated by spaces, tabs, commas, or any mixture thereof.
  • The file must contain at least layout.nx * layout.ny data rows; additional rows after that are silently ignored.
  • Columns are 0-indexed. Each requested column index must be present on every data row.
Flat-to-grid mapping
Data row k (0-based, among non-comment rows) maps to grid index (ix, iy) via the strides stored in layout (see GridLayout2D for details). The resulting Kokkos view is indexed as view(ix, iy).
Parameters
filenamePath to the data file
column_indices0-based column indices to extract (order is preserved)
layoutGrid dimensions, physical coordinates, and strides
labelOptional label prefix for the Kokkos views
Returns
One ScalarLookupTable2D per requested column, in the same order as column_indices.
Exceptions
std::runtime_errorif the file cannot be opened, if a data row has fewer columns than the largest requested index, or if fewer than nx * ny data rows are found.

◆ read_xdmf_checkpoint_grid()

template<typename GridDataType >
util::Result terra::io::read_xdmf_checkpoint_grid ( const std::string &  checkpoint_directory,
const std::string &  data_label,
const int  step,
const grid::shell::DistributedDomain distributed_domain,
GridDataType &  grid_data_device 
)

Reads a single grid at a single write step from an XDMF checkpoint.

See XDMFOutput for details.

Parameters
checkpoint_directorypath to the directory containing the XDMF data
data_labelthe Kokkos::View label of the grid data that shall be read in
stepthe "timestep" to read
distributed_domainDistributedDomain instance that has the same topology as the one used when writing the checkpoint
grid_data_device[out] properly sized Kokkos::View (can live on a device) to write the checkpoint to

◆ read_xdmf_checkpoint_metadata()

util::Result< CheckpointMetadata > terra::io::read_xdmf_checkpoint_metadata ( const std::string &  checkpoint_directory)
inline

Reads metadata from an XDMF/checkpoint directory. See XDMFOutput for details.

Parameters
checkpoint_directorypath to the directory containing the XDMF data
Returns
Populated CheckpointMetadata struct.

◆ write_rectilinear_to_triangular_vtu()

template<typename ScalarType >
void terra::io::write_rectilinear_to_triangular_vtu ( Kokkos::View< ScalarType **[3] >  points_device_view,
const std::string &  filename,
DiagonalSplitType  split_type 
)

◆ write_surface_radial_extruded_to_wedge_vtu()

template<typename PointRealT , typename AttachedDataType >
void terra::io::write_surface_radial_extruded_to_wedge_vtu ( grid::Grid2DDataVec< PointRealT, 3 >  surface_points_device_view,
grid::Grid1DDataScalar< PointRealT >  radii_device_view,
std::optional< AttachedDataType >  optional_attached_data_device_view,
const std::string &  vector_data_name,
const std::string &  filename,
DiagonalSplitType  split_type 
)

◆ write_vtk_xml_quad_mesh()

void terra::io::write_vtk_xml_quad_mesh ( const std::string &  filename,
const Kokkos::View< double **[3] > &  vertices,
VtkElementType  elementType = VtkElementType::LINEAR_QUAD 
)

Writes a 2D grid of vertices stored in a Kokkos View to a VTK XML Unstructured Grid file (.vtu) representing a quadrilateral mesh (linear or quadratic).

Parameters
filenameThe path to the output VTK file (.vtu).
verticesA Kokkos View containing the vertex coordinates. Assumed dimensions: (Nx, Ny, 3). vertices(i, j, 0) = X coordinate of point (i, j) vertices(i, j, 1) = Y coordinate of point (i, j) vertices(i, j, 2) = Z coordinate of point (i, j) Nx = vertices.extent(0), Ny = vertices.extent(1) For QUADRATIC_QUAD, Nx and Ny must be odd and >= 3.
elementTypeSpecifies whether to write linear or quadratic elements.

Variable Documentation

◆ VTK_QUAD

constexpr int terra::io::VTK_QUAD = 9
constexpr

◆ VTK_QUADRATIC_QUAD

constexpr int terra::io::VTK_QUADRATIC_QUAD = 23
constexpr