GridFormat 0.2.1
I/O-Library for grid-like data structures
Loading...
Searching...
No Matches
API

The high-level API and recommended way of using GridFormat More...

Detailed Description

The high-level API exposes all available File Formats and the generic GridFormat::Writer (and GridFormat::Reader, see below), which takes an instance of one of the formats and a grid that is to be written. It is recommended to use the provided Format Selectors for construction of a GridFormat::Writer. As an example, to construct a writer for the .vtu file format for your grid, you may write

GridFormat::Writer writer{GridFormat::vtu, grid};
Interface to the writers for all supported file formats. Depending on the chosen format,...
Definition: writer.hpp:90

You can also let GridFormat select a default for you:

constexpr auto default_for()
Selects a default format suitable to write the given grid.
Definition: gridformat.hpp:1126

Some file formats take configuration options. For instance, the .vtu file format allows you to specify (among other options) an encoder to be used:

GridFormat::vtu({.encoder = GridFormat::Encoding::base64}),
grid
};
constexpr Base64 base64
Instance of the base64 encoder.
Definition: base64.hpp:262

For more information on these options, see GridFormat::FileFormat::VTU. Note that all writers take the given grid by reference, and thus, their validity is bound to the lifetime of the grid.

The GridFormat::Reader can be constructed without any format argument, in which case the format will be deduced from the extension of the given file. For example, with the following code you can read both a .vtu and a .vti file with the same reader:

reader.open("my_vti_file.vti");
std::cout << "Number of cells in vti file: " << reader.number_of_cells() << std::endl;
reader.open("my_vtu_file.vtu");
std::cout << "Number of cells in vtu file: " << reader.number_of_cells() << std::endl;
void open(const std::string &filename)
Open the given grid file.
Definition: reader.hpp:78
std::size_t number_of_cells() const
Return the number of cells in the grid read from the file.
Definition: reader.hpp:97
Interface to the readers for all supported file formats.
Definition: reader.hpp:94

To create a reader for a specific file format, pass a format specifier to the constructor:

GridFormat::Reader vti_reader{GridFormat::vti};
reader.open("my_vti_file.vti");
reader.open("my_vti_file_without_extension");
// reader.open("my_vtu_file"); // this would not work

Modules

 File Formats
 Classes representing the available file formats. For predefined selectors, see Format Selectors.
 
 Format Selectors
 Selector classes for all available file formats. For more details on the formats, see the File Formats classes. For examples on how to use them, see API.
 

Files

file  gridformat.hpp
 This file is the entrypoint to the high-level API exposing all provided readers/writers through a unified interface.
 
file  writer.hpp
 A generic writer providing access to the writers for all supported formats.
 
file  reader.hpp
 A generic reader providing access to the readers for all supported formats.
 

Classes

struct  GridFormat::FileFormat::Any
 Selector for an unspecified file format. When using this format, GridFormat will automatically select a format or deduce from a file being read, for instance. More...
 
struct  GridFormat::FileFormat::AnyTimeSeries
 Time series variant of the Any format selector. More...
 
struct  GridFormat::FileFormat::VTI
 Selector for the .vti/.pvti image grid file format to be passed to the Writer. More...
 
struct  GridFormat::FileFormat::VTR
 Selector for the .vtr/.pvtr rectilinear grid file format to be passed to the Writer. More...
 
struct  GridFormat::FileFormat::VTS
 Selector for the .vts/.pvts structured grid file format to be passed to the Writer. More...
 
struct  GridFormat::FileFormat::VTP
 Selector for the .vtp/.pvtp file format for two-dimensional unstructured grids. More...
 
struct  GridFormat::FileFormat::VTU
 Selector for the .vtu/.pvtu file format for general unstructured grids. More...
 
struct  GridFormat::FileFormat::VTKXMLTimeSeries< VTX >
 Selector for a time series of any VTK-XML format. More...
 
struct  GridFormat::FileFormat::VTKHDFImage
 Selector for the vtk-hdf file format for image grids. For more information, see here. More...
 
struct  GridFormat::FileFormat::VTKHDFImageTransient
 Transient variant of the vtk-hdf image data format. More...
 
struct  GridFormat::FileFormat::VTKHDFUnstructured
 Selector for the vtk-hdf file format for unstructured grids. For more information, see here. More...
 
struct  GridFormat::FileFormat::VTKHDFUnstructuredTransient
 Transient variant of the vtk-hdf unstructured grid format. More...
 
struct  GridFormat::FileFormat::VTKHDFTransient
 Selector for the transient vtk-hdf file format with automatic deduction of the flavour. If the grid for which a writer is constructed is an image grid, it selects the image-grid flavour, otherwise it selects the flavour for unstructured grids (which requires the respective traits to be specialized). More...
 
struct  GridFormat::FileFormat::VTKHDF
 Selector for the vtk-hdf file format with automatic deduction of the flavour. If the grid for which a writer is constructed is an image grid, it selects the image-grid flavour, otherwise it selects the flavour for unstructured grids (which requires the respective traits to be specialized). More...
 
struct  GridFormat::FileFormat::PVD< PieceFormat >
 Selector for the .pvd file format for a time series. For more information, see here. More...
 
struct  GridFormat::FileFormat::PVDClosure
 Closure for selecting the .pvd file format. Takes a VTK-XML format and returns an instance of PVD. More...
 
struct  GridFormat::FileFormat::TimeSeriesClosure
 Closure for time series format selection. Takes a sequential format and returns a time series variant. More...
 
class  GridFormat::Writer< G >
 Interface to the writers for all supported file formats. Depending on the chosen format, this exposes the interface of grid file or time series writers. More...
 
class  GridFormat::Reader
 Interface to the readers for all supported file formats. More...
 

Functions

template<typename OutFormat , typename InFormat , typename Communicator = None>
std::string GridFormat::convert (const std::string &in, const std::string &out, const ConversionOptions< OutFormat, InFormat > &opts, const Communicator &communicator={})
 Convert between parallel grid file formats.
 
template<Concepts::Grid G>
constexpr auto GridFormat::Formats::default_for ()
 Selects a default format suitable to write the given grid.
 
template<Concepts::Grid G>
constexpr auto GridFormat::Formats::default_for (const G &)
 Selects a default format suitable to write the given grid.
 

Function Documentation

◆ convert()

template<typename OutFormat , typename InFormat , typename Communicator = None>
std::string GridFormat::convert ( const std::string &  in,
const std::string &  out,
const ConversionOptions< OutFormat, InFormat > &  opts,
const Communicator &  communicator = {} 
)
Parameters
inThe input filename.
outThe output filename.
optsConversion options.
communicatorThe communicator (for parallel I/O).
Note
Converting into .vtp file format does not work yet.

◆ default_for() [1/2]

template<Concepts::Grid G>
constexpr auto GridFormat::Formats::default_for ( )
constexpr
Template Parameters
GThe grid type for which to select a file format.

◆ default_for() [2/2]

template<Concepts::Grid G>
constexpr auto GridFormat::Formats::default_for ( const G &  )
constexpr
Template Parameters
GThe grid type for which to select a file format.