IO

FieldAOS.h

template<typename Field, typename Buffer>
void Cubism::IO::Field2AOS(const Field &f, const typename Field::IndexRangeType &r, Buffer *buf, const size_t dface = 0)

Write field data into AoS buffer.

Copy the data from a structure of arrays (SoA) field into an array of structures (AoS) buffer for I/O operation. This is a low-level function which can be used in high-level I/O interfaces. The index range r may describe a sub-region of the index range spanned by the field f. The size of the output buffer buf is determined by the index range r and Field::NComponents.

Template Parameters
  • Field: Field type

  • Buffer: Data type of AoS buffer

Parameters
  • f: Input field

  • r: Index space for the copy (describes the memory region of buf)

  • buf: Output buffer

  • dface: Face direction (relevant for Cubism::EntityType::Face)

template<typename Field, typename Buffer>
void Cubism::IO::AOS2Field(const Buffer *buf, const typename Field::IndexRangeType &r, Field &f, const size_t dface = 0)

Read AoS buffer into field data.

Copy the data from an array of structures (AoS) buffer into a structure of arrays field. This is a low-level function which can be used in high-level I/O interfaces. The index range r may describe a sub-region of the index range spanned by the field f. The size of the input buffer buf is determined by the index range r and Field::NComponents.

Template Parameters
  • Field: Field type

  • Buffer: Data type of AoS buffer

Parameters
  • buf: Input buffer

  • r: Index space for the read (describes the memory region of buf)

  • f: Output field

  • dface: Face direction (relevant for Cubism::EntityType::Face)

FieldHDF.h

template<typename FileDataType, typename Field, typename Mesh, typename Dir = size_t>
void Cubism::IO::FieldWriteHDF(const std::string &fname, const std::string &aname, const Field &field, const Mesh &mesh, const double time, const Dir face_dir = 0, const bool create_xdmf = true)

Write field data to HDF file.

Write the data carried by field to an HDF5 container file. The data that is written to the file is specified by the index space described in mesh.

Note

The variables field and mesh are only related by the index space they span. If there is no common intersection, no data will be written to the file. If the mesh spans a larger index space and full or partially contains the index space spanned by field then the index space spanned by mesh is clipped to that spanned by field.

Example:

#include "Cubism/Block/Field.h"
#include "Cubism/Core/Index.h"
#include "Cubism/Mesh/StructuredUniform.h"
#include "Cubism/IO/FieldHDF.h"

using Mesh = Cubism::Mesh::StructuredUniform<double, 3>;
using MeshIntegrity = typename Mesh::MeshIntegrity;
using PointType = typename Mesh::PointType;
using IRange = typename Mesh::IndexRangeType;
using MIndex = typename Mesh::MultiIndex;

using CellField = Cubism::Block::CellField<double, Mesh::Dim>;

int main(void)
{
    // mesh in [0,1]^3 with 16^3 cells
    const PointType end(1);
    const MIndex cells(16);
    Mesh m(end, cells, MeshIntegrity::FullMesh);

    // cell field spans an index space [6,10)^3
    const IRange cell_range(6, 10);
    CellField cf(cell_range);

    // write field to file (since the mesh fully contains cell_range, the
    // file contains 64 doubles at the coordinates defined in m using the
    // indices in cell_range
    Cubism::IO::FieldWriteHDF<double>(
        "filename", "attributename", cf, m, 0.0);
    return 0;
}

Template Parameters
  • FileDataType: HDF file data type

  • Field: Field type

  • Mesh: Mesh type

  • Dir: Special type that defines a cast to size_t

Parameters
  • fname: Output full filename without file extension

  • aname: Name of quantity in field

  • field: Input field

  • mesh: Input mesh

  • time: Current time

  • face_dir: Face direction (relevant for Cubism::EntityType::Face)

  • create_xdmf: Flag for XDMF wrapper

template<typename FileDataType, typename Field, typename Mesh, typename Dir = size_t>
void Cubism::IO::FieldReadHDF(const std::string &fname, Field &field, const Mesh &mesh, const Dir face_dir = 0)

Read field data from HDF file.

Read the data of an HDF5 container file into field. The data that is read from the file is specified by the index space described in mesh.

Template Parameters
  • FileDataType: HDF file data type

  • Field: Field type

  • Mesh: Mesh type

  • Dir: Special type that defines a cast to size_t

Parameters
  • fname: Input full filename without file extension

  • field: Field populated with file data

  • mesh: Field (sub)mesh

  • face_dir: Face direction (relevant for Cubism::EntityType::Face)

CartesianHDF.h

template<typename FileDataType, typename Grid, typename Mesh, typename Dir = size_t>
void Cubism::IO::CartesianWriteHDF(const std::string &fname, const std::string &aname, const Grid &grid, const Mesh &mesh, const double time, const Dir face_dir = 0, const bool create_xdmf = true)

Write Cartesian grid data to HDF file.

Write the data carried by grid to an HDF5 container file. The data that is written to the file is specified by the index space described in mesh.

Template Parameters
  • FileDataType: HDF file data type

  • Grid: Grid type

  • Mesh: Mesh type

  • Dir: Special type that defines a cast to size_t

Parameters
  • fname: Output full filename without file extension

  • aname: Name of quantity in grid

  • grid: Input grid

  • mesh: Input mesh corresponding to the extracted data

  • time: Current time

  • face_dir: Face direction (relevant for Cubism::EntityType::Face)

  • create_xdmf: Flag for XDMF wrapper

template<typename FileDataType, typename Grid, typename Dir = size_t>
void Cubism::IO::CartesianWriteHDF(const std::string &fname, const std::string &aname, const Grid &grid, const double time, const Dir face_dir = 0, const bool create_xdmf = true)

Write Cartesian grid data to HDF file.

Convenience wrapper to dump a full grid to an HDF container file.

Template Parameters
  • FileDataType: HDF file data type

  • Grid: Grid type

  • Dir: Special type that defines a cast to size_t

Parameters
  • fname: Output full filename without file extension

  • aname: Name of quantity in grid

  • grid: Input grid

  • time: Current time

  • face_dir: Face direction (relevant for Cubism::EntityType::Face)

  • create_xdmf: Flag for XDMF wrapper

template<typename FileDataType, typename Grid, typename Mesh, typename Dir = size_t>
void Cubism::IO::CartesianReadHDF(const std::string &fname, Grid &grid, const Mesh &mesh, const Dir face_dir = 0)

Read Cartesian grid data from HDF file.

Read the data of an HDF5 container file into grid. The data that is read from the file is specified by the index space described in mesh.

Template Parameters
  • FileDataType: HDF file data type

  • Grid: Grid type

  • Mesh: Mesh type

  • Dir: Special type that defines a cast to size_t

Parameters
  • fname: Input full filename without file extension

  • grid: Grid populated with file data

  • mesh: Grid (sub)mesh

  • face_dir: Face direction (relevant for Cubism::EntityType::Face)

template<typename FileDataType, typename Grid, typename Dir = size_t>
void Cubism::IO::CartesianReadHDF(const std::string &fname, Grid &grid, const Dir face_dir = 0)

Read Cartesian grid data from HDF file.

Convenience wrapper to read a full grid from an HDF container file.

Template Parameters
  • FileDataType: HDF file data type

  • Grid: Grid type

  • Dir: Special type that defines a cast to size_t

Parameters
  • fname: Input full filename without file extension

  • grid: Grid populated with file data

  • face_dir: Face direction (relevant for Cubism::EntityType::Face)

CartesianMPIHDF.h

template<typename FileDataType, typename Grid, typename Mesh, typename Dir = size_t>
void Cubism::IO::CartesianMPIWriteHDF(const std::string &fname, const std::string &aname, const Grid &grid, const Mesh &mesh, const double time, const Dir face_dir = 0, const bool create_xdmf = true)

Write Cartesian MPI grid data to HDF file.

Write the data carried by the MPI grid to an HDF5 container file. The data that is written to the file is specified by the index space described in mesh.

Template Parameters
  • FileDataType: HDF file data type

  • Grid: Grid type

  • Mesh: Mesh type

  • Dir: Special type that defines a cast to size_t

Parameters
  • fname: Output full filename without file extension

  • aname: Name of quantity in grid

  • grid: Input grid

  • mesh: Input mesh corresponding to the extracted data

  • time: Current time

  • face_dir: Face direction (relevant for Cubism::EntityType::Face)

  • create_xdmf: Flag for XDMF wrapper

template<typename FileDataType, typename Grid, typename Dir = size_t>
void Cubism::IO::CartesianMPIWriteHDF(const std::string &fname, const std::string &aname, const Grid &grid, const double time, const Dir face_dir = 0, const bool create_xdmf = true)

Write Cartesian MPI grid data to HDF file.

Convenience wrapper to dump a full MPI grid to an HDF container file.

Template Parameters
  • FileDataType: HDF file data type

  • Grid: Grid type

  • Dir: Special type that defines a cast to size_t

Parameters
  • fname: Output full filename without file extension

  • aname: Name of quantity in grid

  • grid: Input grid

  • time: Current time

  • face_dir: Face direction (relevant for Cubism::EntityType::Face)

  • create_xdmf: Flag for XDMF wrapper

template<typename FileDataType, typename Grid, typename Mesh, typename Dir = size_t>
void Cubism::IO::CartesianMPIReadHDF(const std::string &fname, Grid &grid, const Mesh &mesh, const Dir face_dir = 0)

Read Cartesian MPI grid data from HDF file.

Read the data of an HDF5 container file into the MPI grid. The data that is read from the file is specified by the index space described in mesh.

Template Parameters
  • FileDataType: HDF file data type

  • Grid: Grid type

  • Mesh: Mesh type

  • Dir: Special type that defines a cast to size_t

Parameters
  • fname: Input full filename without file extension

  • grid: Grid populated with file data

  • mesh: Grid (sub)mesh

  • face_dir: Face direction (relevant for Cubism::EntityType::Face)

template<typename FileDataType, typename Grid, typename Dir = size_t>
void Cubism::IO::CartesianMPIReadHDF(const std::string &fname, Grid &grid, const Dir face_dir = 0)

Read Cartesian grid data from HDF file.

Convenience wrapper to read a full MPI grid from an HDF container file.

Template Parameters
  • FileDataType: HDF file data type

  • Grid: Grid type

  • Dir: Special type that defines a cast to size_t

Parameters
  • fname: Input full filename without file extension

  • grid: Grid populated with file data

  • face_dir: Face direction (relevant for Cubism::EntityType::Face)