kspaceFirstOrder3D-OMP 1.0
The C++ implementation of the k-wave toolbox for the time-domain simulation of acoustic wave fields in 3D
MatrixClasses/OutputHDF5Stream.cpp
Go to the documentation of this file.
00001 
00034 #include <MatrixClasses/OutputHDF5Stream.h>
00035 
00036 
00037 using namespace std;
00038 
00039 //----------------------------------------------------------------------------//
00040 //                              Constants                                     //
00041 //----------------------------------------------------------------------------//
00042 
00043 
00044 
00045 
00046 
00047 
00048 
00049 //----------------------------------------------------------------------------//
00050 //                              Definitions                                   //
00051 //----------------------------------------------------------------------------//
00052 
00053 //----------------------------------------------------------------------------//
00054 //                              Implementation                                //
00055 //                              public methods                                //
00056 //----------------------------------------------------------------------------//
00057 
00067 void TOutputHDF5Stream::CreateStream(THDF5_File & HDF5_File, const char * DatasetName, 
00068                                      const TDimensionSizes & TotalSize, const TDimensionSizes & ChunkSize, 
00069                                      const int CompressionLevel){
00070     
00071     this->HDF5_File = &HDF5_File;
00072     
00073     HDF5_Dataset_id = HDF5_File.CreateFloatDataset(DatasetName,TotalSize,ChunkSize, CompressionLevel);
00074     HDF5_File.WriteMatrixDomainType(DatasetName,THDF5_File::hdf5_mdt_real);
00075     HDF5_File.WriteMatrixDataType(DatasetName,THDF5_File::hdf5_mdt_float);        
00076     
00077     Position = TDimensionSizes(0,0,0);
00078     
00079     
00080 }// end CreateStream
00081 //------------------------------------------------------------------------------
00082 
00087 void TOutputHDF5Stream::CloseStream(){
00088     
00089     HDF5_File->CloseDataset(HDF5_Dataset_id);
00090     HDF5_Dataset_id  = H5I_BADID;
00091     
00092 }// end of CloseStream
00093 //------------------------------------------------------------------------------
00094 
00095 
00096 
00105 void TOutputHDF5Stream::AddData(TRealMatrix& SourceMatrix, TLongMatrix& Index, float * TempBuffer){
00106      
00107 
00108   #ifndef __NO_OMP__    
00109     #pragma omp parallel for if (Index.GetTotalElementCount() > 1e6)
00110   #endif
00111     for (size_t i = 0; i < Index.GetTotalElementCount(); i++) {
00112         TempBuffer[i] = SourceMatrix[Index[i]];        
00113     }
00114     
00115     
00116     TDimensionSizes BlockSize(Index.GetTotalElementCount(),1,1);
00117     
00118     HDF5_File->WriteHyperSlab(HDF5_Dataset_id,Position,BlockSize,TempBuffer);
00119     Position.Y++;
00120     
00121 }// end of AddData
00122 //------------------------------------------------------------------------------
00123 
00124 
00125 
00130 TOutputHDF5Stream::~TOutputHDF5Stream(){
00131     
00132     if (HDF5_Dataset_id != -1) HDF5_File->CloseDataset(HDF5_Dataset_id);
00133     
00134 }// end of Destructor
00135 //------------------------------------------------------------------------------
00136 
00137 
00138 //----------------------------------------------------------------------------//
00139 //                              Implementation                                //
00140 //                             protected methods                              //
00141 //----------------------------------------------------------------------------//
00142 
00143 
00144 
00145 //----------------------------------------------------------------------------//
00146 //                              Implementation                                //
00147 //                              private methods                               //
00148 //----------------------------------------------------------------------------//
00149 
00150 
00151 
00152 
00153 
00154 
00155 
00156 
00157 
 All Classes Files Functions Variables Typedefs Enumerations