kspaceFirstOrder3D-OMP  1.2
The C++ implementation of the k-wave toolbox for the time-domain simulation of acoustic wave fields in 3D
Hdf5FileHeader Class Reference

Class for HDF5 file header. More...

#include <Hdf5FileHeader.h>

Collaboration diagram for Hdf5FileHeader:

Public Types

enum  FileHeaderItems {
  FileHeaderItems::kCreatedBy = 0, FileHeaderItems::kCreationDate = 1, FileHeaderItems::kFileDescription = 2, FileHeaderItems::kMajorVersion = 3,
  FileHeaderItems::kMinorVersion = 4, FileHeaderItems::kFileType = 5, FileHeaderItems::kHostName = 6, FileHeaderItems::kTotalMemoryConsumption = 7,
  FileHeaderItems::kPeakMemoryConsumption = 8, FileHeaderItems::kTotalExecutionTime = 9, FileHeaderItems::kDataLoadTime = 10, FileHeaderItems::kPreProcessingTime = 11,
  FileHeaderItems::kSimulationTime = 12, FileHeaderItems::kPostProcessingTime = 13, FileHeaderItems::kNumberOfCores = 14
}
 List of all header items. More...
 
enum  FileType { FileType::kInput = 0, FileType::kOutput = 1, FileType::kCheckpoint = 2, FileType::kUnknown = 3 }
 HDF5 file type. More...
 
enum  FileVersion { FileVersion::kVersion10 = 0, FileVersion::kVersion11 = 1, FileVersion::kVersionUnknown = 2 }
 HDF5 file version. More...
 

Public Member Functions

 Hdf5FileHeader ()
 Constructor. More...
 
 Hdf5FileHeader (const Hdf5FileHeader &src)
 Copy constructor. More...
 
 ~Hdf5FileHeader ()
 Destructor. More...
 
void readHeaderFromInputFile (Hdf5File &inputFile)
 Read header from the input file. More...
 
void readHeaderFromOutputFile (Hdf5File &outputFile)
 Read header from output file (necessary for checkpoint-restart). More...
 
void readHeaderFromCheckpointFile (Hdf5File &checkpointFile)
 Read the file header form the checkpoint file. More...
 
void writeHeaderToOutputFile (Hdf5File &outputFile)
 Write header into the output file. More...
 
void writeHeaderToCheckpointFile (Hdf5File &checkpointFile)
 Write header to the output file (only a subset of all possible fields are written). More...
 
void setCodeName (const std::string &codeName)
 Set code name. More...
 
void setActualCreationTime ()
 Set creation time. More...
 
void setMajorFileVersion ()
 Set major file version.
 
void setMinorFileVersion ()
 Set minor file version.
 
FileVersion getFileVersion ()
 Get file version as an enum. More...
 
bool checkMajorFileVersion ()
 Check major file version. More...
 
bool checkMinorFileVersion ()
 Check minor file version. More...
 
Hdf5FileHeader::FileType getFileType ()
 Get File type. More...
 
void setFileType (const Hdf5FileHeader::FileType fileType)
 Set File type. More...
 
void setHostName ()
 Set host name. More...
 
void setMemoryConsumption (const size_t totalMemory)
 Set memory consumption. More...
 
void setExecutionTimes (const double totalTime, const double loadTime, const double preProcessingTime, const double simulationTime, const double postprocessingTime)
 Set execution times in file header. More...
 
void getExecutionTimes (double &totalTime, double &loadTime, double &preProcessingTime, double &simulationTime, double &postprocessingTime)
 Get execution times stored in the output file header. More...
 
void setNumberOfCores ()
 Set number of cores. More...
 

Static Public Member Functions

static std::string getFileMajorVersion ()
 Get string representing of current Major version of the file. More...
 
static std::string getFileMinorVersion ()
 Get string representing of current Minor version of the file. More...
 

Private Attributes

std::map< FileHeaderItems, std::string > mHeaderValues
 map for the header values.
 

Static Private Attributes

static std::map< FileHeaderItems, std::string > sHeaderNames
 map for the header names. More...
 
static const std::string kFileTypesNames [] = {"input", "output", "checkpoint", "unknown"}
 String representation of different file types.
 
static const std::string kMajorFileVersionsNames [] = {"1"}
 String representations of Major file versions.
 
static const std::string kMinorFileVersionsNames [] = {"0","1"}
 String representations of Major file versions.
 

Detailed Description

This class manages all information that can be stored in the input output or checkpoint file header.

Definition at line 89 of file Hdf5FileHeader.h.

Member Enumeration Documentation

◆ FileHeaderItems

List of all header items.

Todo:
In the future, we should add number of GPUs, peak GPU memory.
Enumerator
kCreatedBy 

Code that created the file.

kCreationDate 

When the file was created.

kFileDescription 

Description of the file (e.g. simulation).

kMajorVersion 

Major file version.

kMinorVersion 

Minor file version.

kFileType 

File type.

kHostName 

Machines the code were executed on.

kTotalMemoryConsumption 

Total amount of memory consumed by the code.

kPeakMemoryConsumption 

Peak memory consumption (by process).

kTotalExecutionTime 

Total execution time.

kDataLoadTime 

Time to load data in.

kPreProcessingTime 

Time to preprocess data.

kSimulationTime 

Simulation time.

kPostProcessingTime 

Time to postprocess data.

kNumberOfCores 

Number of cores the simulation was executed.

Definition at line 99 of file Hdf5FileHeader.h.

◆ FileType

HDF5 file type.

Enumerator
kInput 

Input file.

kOutput 

Output file.

kCheckpoint 

Checkpoint file.

kUnknown 

Unknown file.

Definition at line 138 of file Hdf5FileHeader.h.

◆ FileVersion

HDF5 file version.

Enumerator
kVersion10 

Version 1.0.

kVersion11 

Version 1.1.

kVersionUnknown 

Version unknown.

Definition at line 155 of file Hdf5FileHeader.h.

Constructor & Destructor Documentation

◆ Hdf5FileHeader() [1/2]

Hdf5FileHeader::Hdf5FileHeader ( )

Constructor.

Definition at line 97 of file Hdf5FileHeader.cpp.

◆ Hdf5FileHeader() [2/2]

Hdf5FileHeader::Hdf5FileHeader ( const Hdf5FileHeader src)
Parameters
[in]src- Source object.

Copy constructor.

Definition at line 107 of file Hdf5FileHeader.cpp.

◆ ~Hdf5FileHeader()

Hdf5FileHeader::~Hdf5FileHeader ( )

Destructor.

Definition at line 117 of file Hdf5FileHeader.cpp.

Member Function Documentation

◆ checkMajorFileVersion()

bool Hdf5FileHeader::checkMajorFileVersion ( )
inline
Returns
true - If the file version is supported.

Definition at line 267 of file Hdf5FileHeader.h.

◆ checkMinorFileVersion()

bool Hdf5FileHeader::checkMinorFileVersion ( )
inline
Returns
true - If the file version is supported.

Definition at line 275 of file Hdf5FileHeader.h.

◆ getExecutionTimes()

void Hdf5FileHeader::getExecutionTimes ( double &  totalTime,
double &  loadTime,
double &  preProcessingTime,
double &  simulationTime,
double &  postprocessingTime 
)
Parameters
[out]totalTime- Total time.
[out]loadTime- Time to load data.
[out]preProcessingTime- Preprocessing time.
[out]simulationTime- Simulation time.
[out]postprocessingTime- Post processing time.

Get execution times stored in the output file header.

Definition at line 406 of file Hdf5FileHeader.cpp.

◆ getFileMajorVersion()

static std::string Hdf5FileHeader::getFileMajorVersion ( )
inlinestatic
Returns
Current major file version.

Definition at line 233 of file Hdf5FileHeader.h.

◆ getFileMinorVersion()

static std::string Hdf5FileHeader::getFileMinorVersion ( )
inlinestatic
Returns
Current minor file version.

Definition at line 241 of file Hdf5FileHeader.h.

◆ getFileType()

Hdf5FileHeader::FileType Hdf5FileHeader::getFileType ( )
Returns
File type.

Get File type.

Definition at line 322 of file Hdf5FileHeader.cpp.

◆ getFileVersion()

Hdf5FileHeader::FileVersion Hdf5FileHeader::getFileVersion ( )
Returns
File version as an enum.

Get file version as an enum.

Definition at line 300 of file Hdf5FileHeader.cpp.

◆ readHeaderFromCheckpointFile()

void Hdf5FileHeader::readHeaderFromCheckpointFile ( Hdf5File checkpointFile)

We need the header to verify the file version and type.

Parameters
[in,out]checkpointFile- Checkpoint file handle.
Exceptions
ios:failure- If error happens.

Read the file header form the checkpoint file.

Definition at line 192 of file Hdf5FileHeader.cpp.

◆ readHeaderFromInputFile()

void Hdf5FileHeader::readHeaderFromInputFile ( Hdf5File inputFile)
Parameters
[in,out]inputFile- Input file handle.
Exceptions
ios:failure- If error happens.

Read header from the input file.

Definition at line 126 of file Hdf5FileHeader.cpp.

◆ readHeaderFromOutputFile()

void Hdf5FileHeader::readHeaderFromOutputFile ( Hdf5File outputFile)

Read only execution times (the others are read from the input file, or calculated based on the very last leg of the simulation). This function is called only if checkpoint-restart is enabled.

Parameters
[in,out]outputFile- Output file handle.
Exceptions
ios:failure- If error happens.

Read header from output file (necessary for checkpoint-restart).

Definition at line 160 of file Hdf5FileHeader.cpp.

◆ setActualCreationTime()

void Hdf5FileHeader::setActualCreationTime ( )

Set actual date and time.

Definition at line 284 of file Hdf5FileHeader.cpp.

◆ setCodeName()

void Hdf5FileHeader::setCodeName ( const std::string &  codeName)
inline
Parameters
[in]codeName- Code version.

Definition at line 221 of file Hdf5FileHeader.h.

◆ setExecutionTimes()

void Hdf5FileHeader::setExecutionTimes ( const double  totalTime,
const double  loadTime,
const double  preProcessingTime,
const double  simulationTime,
const double  postprocessingTime 
)
Parameters
[in]totalTime- Total time.
[in]loadTime- Time to load data.
[in]preProcessingTime- Preprocessing time.
[in]simulationTime- Simulation time.
[in]postprocessingTime- Post processing time.

Set execution times in file header.

Definition at line 389 of file Hdf5FileHeader.cpp.

◆ setFileType()

void Hdf5FileHeader::setFileType ( const Hdf5FileHeader::FileType  fileType)
Parameters
[in]fileType- File type.

Set File type.

Definition at line 340 of file Hdf5FileHeader.cpp.

◆ setHostName()

void Hdf5FileHeader::setHostName ( )

Set Host name.

Definition at line 349 of file Hdf5FileHeader.cpp.

◆ setMemoryConsumption()

void Hdf5FileHeader::setMemoryConsumption ( const size_t  totalMemory)
Parameters
[in]totalMemory- Total memory consumption.

Set memory consumption.

Definition at line 375 of file Hdf5FileHeader.cpp.

◆ setNumberOfCores()

void Hdf5FileHeader::setNumberOfCores ( )

Set Number of cores.

Definition at line 424 of file Hdf5FileHeader.cpp.

◆ writeHeaderToCheckpointFile()

void Hdf5FileHeader::writeHeaderToCheckpointFile ( Hdf5File checkpointFile)
Parameters
[in,out]checkpointFile- Checkpoint file handle.
Exceptions
ios:failure- If error happens.

Write header to the output file (only a subset of all possible fields are written).

Definition at line 241 of file Hdf5FileHeader.cpp.

◆ writeHeaderToOutputFile()

void Hdf5FileHeader::writeHeaderToOutputFile ( Hdf5File outputFile)
Parameters
[in,out]outputFile- Output file handle.
Exceptions
ios:failure- If error happens.

Write header into the output file.

Definition at line 225 of file Hdf5FileHeader.cpp.

Member Data Documentation

◆ sHeaderNames

std::map< Hdf5FileHeader::FileHeaderItems, std::string > Hdf5FileHeader::sHeaderNames
staticprivate
Initial value:

Initialisation of static map with header attribute names.

Definition at line 335 of file Hdf5FileHeader.h.


The documentation for this class was generated from the following files: