| kspaceFirstOrder3D-OMP 1.0 The C++ implementation of the k-wave toolbox for the time-domain simulation of acoustic wave fields in 3D

- Main Page
- Classes
- Files

- File List
- File Members

HDF5/HDF5_File.h
Go to the documentation of this file.

    00001
    00336 #ifndef THDF5_FILE_H
    00337 #define  THDF5_FILE_H
    00338
    00339
    00340 #include <hdf5.h>
    00341 #include <hdf5_hl.h>
    00342 #include <string>
    00343 #include <map>
    00344
    00345 #include <Utils/DimensionSizes.h>
    00346
    00347 using namespace std;
    00348
    00349 // Class with File header
    00350 class THDF5_FileHeader;
    00351
    00352
    00357 class THDF5_File {
    00358 public:
    00359
    00364     enum THDF5_MatrixDataType   {hdf5_mdt_float = 0, hdf5_mdt_long    = 1};
    00365
    00370     enum THDF5_MatrixDomainType {hdf5_mdt_real  = 0, hdf5_mdt_complex = 1};
    00371
    00372
    00374     THDF5_File();
    00375
    00376
    00378     void Create(const char * FileName, unsigned int Flags = H5F_ACC_TRUNC );
    00380     void Open (const char * FileName, unsigned int Flags  = H5F_ACC_RDONLY);
    00385     bool IsOpened() const {return HDF5_FileId >=0; };
    00387     void Close();
    00388
    00390     hid_t OpenDataset  (const char * DatasetName);
    00392     hid_t CreateFloatDataset(const char * DatasetName, const TDimensionSizes & DimensionSizes, const TDimensionSizes & ChunkSizes, const int CompressionLevel);
    00394     void  CloseDataset (const hid_t& HDF5_Dataset_id);
    00395
    00396
    00397
    00399     void WriteCompleteDataset(const char * DatasetName, const TDimensionSizes & DimensionSizes, const float * Data);
    00401     void WriteCompleteDataset(const char * DatasetName, const TDimensionSizes & DimensionSizes, const long  * Data);
    00402
    00404     void WriteHyperSlab(const hid_t HDF5_Dataset_id, const TDimensionSizes & Position , const TDimensionSizes & Size, const float * Data);
    00406     void WriteHyperSlab(const hid_t HDF5_Dataset_id, const TDimensionSizes & Position , const TDimensionSizes & Size, const long * Data);
    00407
    00409     void WriteScalarValue(const char * DatasetName, const float Value);
    00411     void WriteScalarValue(const char * DatasetName, const long  Value);
    00412
    00413
    00415     void ReadCompleteDataset (const char * DatasetName, const TDimensionSizes & DimensionSizes, float * Data);
    00417     void ReadCompleteDataset (const char * DatasetName, const TDimensionSizes & DimensionSizes, long  * Data);
    00418
    00420     TDimensionSizes GetDatasetDimensionSizes(const char * DatasetName);
    00422     size_t          GetDatasetElementCount(const char * DatasetName);
    00423
    00425     void WriteMatrixDataType  (const char * DatasetName, const THDF5_MatrixDataType   & MatrixDataType);
    00427     void WriteMatrixDomainType(const char * DatasetName, const THDF5_MatrixDomainType & MatrixDomainType);
    00428
    00430     THDF5_File::THDF5_MatrixDataType   ReadMatrixDataType  (const char * DatasetName);
    00432     THDF5_File::THDF5_MatrixDomainType ReadMatrixDomainType(const char * DatasetName);
    00433
    00435     void   WriteStringAttribute (const char * DatasetName, const char * AttributeName, const string &  Value);
    00437     string ReadStringAttribute  (const char * DatasetName, const char * AttributeName);
    00438
    00440     virtual ~THDF5_File();
    00441 protected:
    00442
    00444     THDF5_File(const THDF5_File& src);
    00446     THDF5_File & operator = (const THDF5_File& src);
    00447
    00448
    00449 private:
    00451     static const char * HDF5_MatrixDomainTypeName;
    00453     static const char * HDF5_MatrixDataTypeName;
    00454
    00456     static const string HDF5_MatrixDomainTypeNames[];
    00458     static const string HDF5_MatrixDataTypeNames[];
    00459
    00460
    00462     hid_t       HDF5_FileId;
    00464     string      FileName;
    00465
    00466
    00467
    00468 }; // THDF5_File
    00469 //------------------------------------------------------------------------------
    00470
    00471
    00472
    00478 class THDF5_FileHeader{
    00479
    00480 public:
    00481
    00486     enum THDF5_FileHeaderItems { hdf5_fhi_created_by                   =  0,
    00487                                  hdf5_fhi_creation_date                =  1,
    00488                                  hdf5_fhi_file_description             =  2,
    00489                                  hdf5_fhi_major_version                =  3,
    00490                                  hdf5_fhi_minor_version                =  4,
    00491                                  hdf5_fhi_file_type                    =  5,
    00492                                  hdf5_fhi_host_name                    =  6,
    00493                                  hdf5_fhi_total_memory_consumption     =  7,
    00494                                  hdf5_fhi_peak_core_memory_consumption =  8,
    00495                                  hdf5_fhi_total_execution_time         =  9,
    00496                                  hdf5_fhi_data_load_time               = 10,
    00497                                  hdf5_fhi_preprocessing_time           = 11,
    00498                                  hdf5_fhi_simulation_time              = 12,
    00499                                  hdf5_fhi_postprocessing_time          = 13,
    00500                                  hdf5_fhi_number_of_cores              = 14
    00501                                 };
    00502
    00507     enum THDF5_FileType         {hdf5_ft_input  = 0, hdf5_ft_output = 1, hdf5_ft_checkpoint = 2, hdf5_ft_unknown = 3};
    00508
    00509
    00510
    00512     THDF5_FileHeader();
    00514     THDF5_FileHeader(const THDF5_FileHeader & other);
    00516     ~THDF5_FileHeader();
    00517
    00519     void ReadHeaderFromInputFile(THDF5_File & InputFile);
    00521     void WriteHeaderToOutputFile(THDF5_File & OutputFile);
    00522
    00527     void SetCodeName(string CodeName) {HDF5_FileHeaderValues[hdf5_fhi_created_by] = CodeName;};
    00529     void SetActualCreationTime();
    00530
    00535     static string GetSupportedHDF5_MajorVersion() {return "1"; };
    00536
    00541     static string GetSupportedHDF5_MinorVersion() {return "0"; };
    00542
    00544     void SetMajorFileVersion() { HDF5_FileHeaderValues[hdf5_fhi_major_version] = GetSupportedHDF5_MajorVersion(); };
    00546     void SetMinorFileVersion() { HDF5_FileHeaderValues[hdf5_fhi_minor_version] = GetSupportedHDF5_MinorVersion(); };
    00547
    00552     bool CheckMajorFileVersion() {return (HDF5_FileHeaderValues[hdf5_fhi_major_version] == GetSupportedHDF5_MajorVersion()); };
    00557     bool CheckMinorFileVersion() {return (HDF5_FileHeaderValues[hdf5_fhi_minor_version] == GetSupportedHDF5_MinorVersion()); };
    00558
    00560     THDF5_FileHeader::THDF5_FileType GetFileType();
    00562     void SetFileType(const THDF5_FileHeader::THDF5_FileType FileType);
    00563
    00565     void SetHostName();
    00567     void SetMemoryConsumption(size_t TotalMemory);
    00569     void SetExecutionTimes(const double TotalTime, const double LoadTime,
    00570                            const double PreProcessingTime, const double SimulationTime,
    00571                            const double PostprocessingTime);
    00573     void SetNumberOfCores();
    00574
    00575 private:
    00577     void PopulateHeaderFileMap();
    00578
    00580     map<THDF5_FileHeaderItems, string> HDF5_FileHeaderValues;
    00582     map<THDF5_FileHeaderItems, string> HDF5_FileHeaderNames;
    00583
    00585     static const string HDF5_FileTypesNames[];
    00586 };// THDF5_FileHeader
    00587 //------------------------------------------------------------------------------
    00588
    00589
    00590 #endif   /* THDF5_FILE_H */
    00591

All Classes Files Functions Variables Typedefs Enumerations