XDMF

A set of classes and functions to write/read data to/from xdmf + hdf5 files format.

VertexChannelsData mirheo::XDMF::readVertexData(const std::string &filename, MPI_Comm comm, int chunkSize)

Read particle data from a pair of xmf+hdf5 files.

Return
The read data (on the local rank)
Parameters
  • filename: the xdmf file name (with extension)
  • comm: The communicator used in the I/O process
  • chunkSize: The smallest piece that processors can split

Grids

mirheo::XDMF::Grid objects are used to represent the geometry of the data that will be dumped.

Interface

class GridDims

Interface to represent the dimensions of the geometry data.

Subclassed by mirheo::XDMF::VertexGrid::VertexGridDims

Public Functions

virtual std::vector<hsize_t> getLocalSize() const = 0

number of elements in the current subdomain

virtual std::vector<hsize_t> getGlobalSize() const = 0

number of elements in the whole domain

virtual std::vector<hsize_t> getOffsets() const = 0

start indices in the current subdomain

bool localEmpty() const

Return
true if there is no data in the current subdomain

bool globalEmpty() const

Return
true if there is no data in the whole domain

int getDims() const

Return
The current dimension of the data (e.g. 3D for uniform grids, 1D for particles)

class Grid

Interface to represent The geometry of channels to dump.

Subclassed by mirheo::XDMF::UniformGrid, mirheo::XDMF::VertexGrid

Public Functions

virtual const GridDims *getGridDims() const = 0

Return
the GridDims that describes the data dimensions

virtual std::string getCentering() const = 0

Return
A string describing (for XDMF) data location (e.g. “Node” or “Cell”)

virtual void writeToHDF5(hid_t file_id, MPI_Comm comm) const = 0

Dump the geometry description to hdf5 file.

Parameters
  • file_id: The hdf5 file description
  • comm: MPI communicator that was used to open the file

virtual pugi::xml_node writeToXMF(pugi::xml_node node, std::string h5filename) const = 0

Dump the geometry description to xdmf file.

Parameters
  • node: The xml node that will store the geometry information
  • h5filename: name of the hdf5 file that will contain the data

virtual void readFromXMF(const pugi::xml_node &node, std::string &h5filename) = 0

read the geometry info contained in the xdmf file

Note
must be called before splitReadAccess()
Parameters
  • node: The xmf data
  • h5filename: The name of the associated hdf5 file

virtual void splitReadAccess(MPI_Comm comm, int chunkSize = 1) = 0

Set the number of elements to read for the current subdomain.

Note
must be called after readFromXMF()
Parameters
  • comm: Communicator that will be used to read the hdf5 file
  • chunkSize: For particles, this affects the number of particles to keep together on a single rank. Useful for objects.

virtual void readFromHDF5(hid_t file_id, MPI_Comm comm) = 0

Read the geometry data contained in the hdf5 file.

Note
must be called after splitReadAccess()
Parameters
  • file_id: The hdf5 file reference
  • comm: MPI communicator used in the I/O

Implementation

class UniformGrid : public mirheo::XDMF::Grid

Representation of a uniform grid geometry.

Each subdomain has the same number of grid points in every direction.

Public Functions

UniformGrid(int3 localSize, real3 h, MPI_Comm cartComm)

construct a UniformGrid object

Note
all these parameters must be the same on every rank
Parameters
  • localSize: The dimensions of the grid per rank
  • h: grid spacing
  • cartComm: The cartesian communicator that will be used for I/O

const GridDims *getGridDims() const

Return
the GridDims that describes the data dimensions

std::string getCentering() const

Return
A string describing (for XDMF) data location (e.g. “Node” or “Cell”)

void writeToHDF5(hid_t file_id, MPI_Comm comm) const

Dump the geometry description to hdf5 file.

Parameters
  • file_id: The hdf5 file description
  • comm: MPI communicator that was used to open the file

pugi::xml_node writeToXMF(pugi::xml_node node, std::string h5filename) const

Dump the geometry description to xdmf file.

Parameters
  • node: The xml node that will store the geometry information
  • h5filename: name of the hdf5 file that will contain the data

void readFromXMF(const pugi::xml_node &node, std::string &h5filename)

read the geometry info contained in the xdmf file

Note
must be called before splitReadAccess()
Parameters
  • node: The xmf data
  • h5filename: The name of the associated hdf5 file

void splitReadAccess(MPI_Comm comm, int chunkSize = 1)

Set the number of elements to read for the current subdomain.

Note
must be called after readFromXMF()
Parameters
  • comm: Communicator that will be used to read the hdf5 file
  • chunkSize: For particles, this affects the number of particles to keep together on a single rank. Useful for objects.

void readFromHDF5(hid_t file_id, MPI_Comm comm)

Read the geometry data contained in the hdf5 file.

Note
must be called after splitReadAccess()
Parameters
  • file_id: The hdf5 file reference
  • comm: MPI communicator used in the I/O

class VertexGrid : public mirheo::XDMF::Grid

Representation of particles geometry.

Each rank contains the positions of the particles in GLOBAL coordinates.

Subclassed by mirheo::XDMF::TriangleMeshGrid

Public Functions

VertexGrid(std::shared_ptr<std::vector<real3>> positions, MPI_Comm comm)

Construct a VertexGrid object.

Note
The positions are passed as a shared pointer so that this class is able to either allocate its own memory or can share it with someone else
Parameters
  • positions: The positions of the particles in the current subdomain, in global coordinates
  • comm: The communicator that will be used for I/O

const GridDims *getGridDims() const

Return
the GridDims that describes the data dimensions

std::string getCentering() const

Return
A string describing (for XDMF) data location (e.g. “Node” or “Cell”)

void writeToHDF5(hid_t file_id, MPI_Comm comm) const

Dump the geometry description to hdf5 file.

Parameters
  • file_id: The hdf5 file description
  • comm: MPI communicator that was used to open the file

pugi::xml_node writeToXMF(pugi::xml_node node, std::string h5filename) const

Dump the geometry description to xdmf file.

Parameters
  • node: The xml node that will store the geometry information
  • h5filename: name of the hdf5 file that will contain the data

void readFromXMF(const pugi::xml_node &node, std::string &h5filename)

read the geometry info contained in the xdmf file

Note
must be called before splitReadAccess()
Parameters
  • node: The xmf data
  • h5filename: The name of the associated hdf5 file

void splitReadAccess(MPI_Comm comm, int chunkSize = 1)

Set the number of elements to read for the current subdomain.

Note
must be called after readFromXMF()
Parameters
  • comm: Communicator that will be used to read the hdf5 file
  • chunkSize: For particles, this affects the number of particles to keep together on a single rank. Useful for objects.

void readFromHDF5(hid_t file_id, MPI_Comm comm)

Read the geometry data contained in the hdf5 file.

Note
must be called after splitReadAccess()
Parameters
  • file_id: The hdf5 file reference
  • comm: MPI communicator used in the I/O

class TriangleMeshGrid : public mirheo::XDMF::VertexGrid

Representation of triangle mesh geometry.

This is a VertexGrid associated with the additional connectivity (list of triangle faces). The vertices are stored in global coordinates and the connectivity also stores indices in global coordinates.

Public Functions

TriangleMeshGrid(std::shared_ptr<std::vector<real3>> positions, std::shared_ptr<std::vector<int3>> triangles, MPI_Comm comm)

Construct a TriangleMeshGrid object.

Parameters
  • positions: The positions of the particles in the current subdomain, in global coordinates
  • triangles: The list of faces in the current subdomain (global indices)
  • comm: The communicator that will be used for I/O

void writeToHDF5(hid_t file_id, MPI_Comm comm) const

Dump the geometry description to hdf5 file.

Parameters
  • file_id: The hdf5 file description
  • comm: MPI communicator that was used to open the file

Channel

namespace mirheo

Common namespace for all Mirheo code.

Copyright 1993-2013 NVIDIA Corporation.

All rights reserved.q

Please refer to the NVIDIA end user license agreement (EULA) associated with this source code for terms and conditions that govern your use of this software. Any use, reproduction, disclosure, or distribution of this software and related documentation outside the terms of the EULA is strictly prohibited.

namespace XDMF

namespace for all functions related to I/O with XDMF + hdf5

Functions

std::string dataFormToXDMFAttribute(Channel::DataForm dataForm)

Return
the xdmf-compatible string that describes the Channel::DataForm

int dataFormToNcomponents(Channel::DataForm dataForm)

Return
the number of components in the Channel::DataForm

std::string dataFormToDescription(Channel::DataForm dataForm)

Return
a unique string that describes the Channel::DataForm (two different may map to the same xdmf attribute)

Channel::DataForm descriptionToDataForm(const std::string &str)

reverse of dataFormToDescription()

decltype(H5T_NATIVE_FLOAT) numberTypeToHDF5type(Channel::NumberType nt)

Return
the HDF5-compatible description of the given Channel::NumberType data type

std::string numberTypeToString(Channel::NumberType nt)

Return
the xdmf-compatible string corresponding to the given Channel::NumberType data type

int numberTypeToPrecision(Channel::NumberType nt)

Return
the size in bytes of the type represented by the given Channel::NumberType data type

Channel::NumberType infoToNumberType(const std::string &str, int precision)

reverse of numberTypeToString() and numberTypeToPrecision()

struct Channel
#include <channel.h>

Describes one array of data to be dumped or read.

Public Types

enum DataForm

The “topology” of one element.

Values:

Scalar
Vector
Tensor6
Tensor9
Quaternion
Triangle
Vector4
RigidMotion
Other
enum NumberType

The type of the data contained in one element.

Values:

Float
Double
Int
Int64
enum NeedShift

If the data depends on the coordinates.

Values:

True
False

Public Functions

int nComponents() const

Number of component in each element (e.g. Vector has 3)

int precision() const

Number of bytes of each component in one element.

Public Members

std::string name

Name of the channel.

void *data

pointer to the data that needs to be dumped

DataForm dataForm

topology of one element

NumberType numberType

data type (enum version)

TypeDescriptor type

data type (variant version)

NeedShift needShift

wether the data depends on the coordinates or not