IoManager

Enums

enum io_attribute_type_t

The four types of supported attribute types.

Values:

enumerator IO_CELL_SCALAR

A cell-centered scalar.

enumerator IO_CELL_VECTOR

A cell-centered vector.

enumerator IO_NODE_SCALAR

A node-centered scalar.

enumerator IO_NODE_VECTOR

A node-centered vector.

class IoManager
#include “IoManager.h”

Io manager to handle data input/output.

The writer has no opened files by default except a main xmf file that contains a collection of all the files that are to be written next as a Temporal Collection.

nodes info

store information about nodes for writing node data

p4est_gloidx_t m_global_num_nodes
p4est_locidx_t m_local_num_nodes
p4est_locidx_t m_start_nodes

Public Functions

IoManager(SettingManager *stg_mgr, MPI_Comm mpicomm)
Parameters:
  • stg_mgr[in] a SettingManager object (to parse input setting file)

  • mpicomm[in] MPI communicator

~IoManager()
template<typename cons_t>
void write_h5_file(double time, QdataManager<cons_t> *qdata_mgr)

write h5 file

qdata_mgr is needed to here to retrieve the quad_get_field method for outputs.

Template Parameters:

cons_t – A type containing a set of conservative variables

Parameters:
  • time[in] Current time of the simulation

  • qdata_mgr[in] Pointer to the Qdata Manager

void write_p4est_file()

write restart file using p4est native format

void open(const std::string &basename)

Open the HDF5 and XMF files for writing.

Also includes this file inside the main xmf file, if needed.

void close()

Close the HDF5 and XMF files.

Also closes the main xmf file, if it was opened.

void destroy()

Free the writer struct.

This also closes the main xmf file

int write_header(double time)

Write the header for the XMF and HDF5 files.

The header includes the node information, connectivity information and the treeid, level or mpirank for each quadrant, if required.

In the case of the XMF file, this will defined the topology and geometry of the mesh and point to the relevant fields in the HDF5 file.

int write_attribute(const std::string &name, void *data, size_t dim, io_attribute_type_t ftype, hid_t dtype, hid_t wtype)

Write a node-centered or cell-centered attribute.

Parameters:
  • w[in] The writer.

  • name[in] The name of the attribute.

  • data[in] The data to be written.

  • dim[in] In the case of a vector, this is the dimension of each element in the vector field.

  • ftype[in] The type of the attribute. See supported types in the io_attribute_type_t enum.

  • dtype[in] The type of the data we are writing. This is given as a native HDF5 type. See the types defined in the H5Tpublic.h header.

  • wtype[in] The type of the data written to the file. The conversion between the data type and the written data is handled by HDF5.

int write_lnode_attribute(const std::string &name, p4est_lnodes_t *lnodes, double *lnode_data, hid_t type_id)

Write a lnode-centered attribute. Only works for degree 1 lnodes.

Parameters:
  • name[in] The name of the attribute.

  • lnodes[in] The p4est_lnodes_t pointer describing the lnodes

  • lnode_data[in] The actual data, in lnode order

  • type_id[in] The HDF5 type id of the data to be written.

int write_footer()

Write the XMF footer.

Closes all the XML tags.

Public Members

p4est_t *m_p4est

not owned, pointer to p4est struct

p4est_geometry_t *m_geom

nullptr canoP hadles only cartesian geometry

p4est_nodes_t *m_nodes

nullptr or owned if nodes are needed

std::string m_basename

the base name of the two files

hid_t m_hdff

HDF file descriptor.

FILE *m_xmff

XMF file descriptor.

FILE *m_main_xmff

XMF main file descriptor.

int m_times_saved

current ouput number

double m_scale

scale of a quad (forced to 1)

std::string m_output_prefix

the output prefix for the filenames (default output)

std::string m_restart_filename

filename of data from a previous run (default data.p4est)

int m_restart_enabled

is this a restart run ? (default 0, options 0 or 1)

int m_mesh_info

write treeid/level/mpirank to file (default 0, options 0 or 1)

int m_single_precision

write data in single precision (default 1, options 0 or 1)

int m_save_count

requested number of outputs (default 1)

std::vector<std::string> m_write_variables

names of variables to save (default NULL)

int m_statistics_level

verbose level for the timers (default 0)

int m_num_write_variables

Number of variables to save.

Private Functions

void io_xmf_write_main_header()

Write the header of the main XMF file.

void io_xmf_write_header(double time)

Write the XMF header information: topology and geometry.

void io_xmf_write_main_include(const std::string &name)

Write the include for the current file.

void io_xmf_write_attribute(const std::string &name, const std::string &number_type, io_attribute_type_t type, hsize_t dims[2])

Write information about an attribute.

Parameters:
  • fd[in] file descriptor for xmf file

  • basename[in] The basename.

  • name[in] The name of the attribute.

  • tyep[in] The type.

  • dims[in] The dimensions of the attribute. If it is a scalar, dims[1] will be ignored.

void io_xmf_write_main_footer()

Close the remaining tags for the main file.

void io_xmf_write_footer()

Close all remaining tags.

Parameters:

fd[in] xmff file descriptor

void io_hdf_writev(hid_t fd, const std::string &name, void *data, hid_t dtype_id, hid_t wtype_id, hid_t rank, hsize_t dims[], hsize_t count[], hsize_t start[])

Write a given dataset into the HDF5 file.

See also

H5TPublic.h

Parameters:
  • fd[in] An open file descriptor to a HDF5 file.

  • name[in] The name of the dataset we are writing.

  • data[in] The data to write.

  • dtype_id[in] The native HDF5 type of the given data.

  • wtype_id[in] The native HDF5 type of the written data.

  • rank[in] The rank of the dataset. 1 if it is a vector, 2 for a matrix.

  • dims[in] The global dimensions of the dataset.

  • count[in] The local dimensions of the dataset.

  • start[in] The offset of the local data with respect to the global positioning.

void io_hdf_write_coordinates(p4est_nodes_t *nodes)

Compute and write the coordinates of all the mesh nodes.

void io_hdf_write_connectivity(p4est_nodes_t *nodes)

Compute and write the connectivity information for each quadrant.

void io_hdf_write_tree()

Compute and write the treeid for each quadrant.

void io_hdf_write_level()

Compute and write the level for each quadrant.

void io_hdf_write_rank()

Compute and write the MPI rank for each quadrant.

The rank is wrapped with IO_MPIRANK_WRAP.