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

Output stream for quantities sampled by a cuboid corner sensor mask. More...

#include <CuboidOutputStream.h>

Inheritance diagram for CuboidOutputStream:
Collaboration diagram for CuboidOutputStream:

Classes

struct  CuboidInfo
 This structure information about a HDF5 dataset (one cuboid). More...
 

Public Member Functions

 CuboidOutputStream ()=delete
 Default constructor not allowed.
 
 CuboidOutputStream (Hdf5File &file, MatrixName &groupName, const RealMatrix &sourceMatrix, const IndexMatrix &sensorMask, const ReduceOperator ReduceOp, float *bufferToReuse=nullptr)
 Constructor links the HDF5 dataset, SourceMatrix, and SensorMask together. More...
 
 CuboidOutputStream (const CuboidOutputStream &)=delete
 Copy constructor is not allowed.
 
virtual ~CuboidOutputStream ()
 Destructor. More...
 
CuboidOutputStreamoperator= (const CuboidOutputStream &)=delete
 operator= is not allowed.
 
virtual void create ()
 Create a HDF5 stream and allocate data for it. More...
 
virtual void reopen ()
 Reopen the output stream after restart and reload data. More...
 
virtual void sample ()
 Sample data into buffer and apply reduction, or flush to disk - based on a sensor mask. More...
 
virtual void postProcess ()
 Apply post-processing on the buffer and flush it to the file. More...
 
virtual void checkpoint ()
 Checkpoint the stream and close. More...
 
virtual void close ()
 Close stream (apply post-processing if necessary, flush data and close). More...
 
- Public Member Functions inherited from BaseOutputStream
 BaseOutputStream ()=delete
 Default constructor not allowed.
 
 BaseOutputStream (Hdf5File &file, MatrixName &rootObjectName, const RealMatrix &sourceMatrix, const ReduceOperator reduceOp, float *bufferToReuse=nullptr)
 Constructor. More...
 
 BaseOutputStream (const BaseOutputStream &src)
 Copy constructor not allowed.
 
virtual ~BaseOutputStream ()
 Destructor. More...
 
BaseOutputStreamoperator= (const BaseOutputStream &src)
 Operator = not allowed (we don't want any data movements).
 

Protected Member Functions

virtual hid_t createCuboidDataset (const size_t cuboidIdx)
 Create a new dataset for a given cuboid specified by index (order). More...
 
template<BaseOutputStream::ReduceOperator reduceOp>
void sampleAggregated ()
 Sample aggregated values. More...
 
virtual void flushBufferToFile ()
 Flush the buffer to the file. More...
 
- Protected Member Functions inherited from BaseOutputStream
virtual void allocateMemory ()
 Allocate memory using proper memory alignment. More...
 
virtual void freeMemory ()
 Free memory. More...
 

Protected Attributes

const IndexMatrixmSensorMask
 Sensor mask to sample data.
 
hid_t mGroup
 Handle to a HDF5 dataset.
 
std::vector< CuboidInfomCuboidsInfo
 vector keeping handles and positions of all cuboids.
 
size_t mSampledTimeStep
 Timestep to store (N/A for aggregated).
 
- Protected Attributes inherited from BaseOutputStream
Hdf5FilemFile
 Handle to HDF5 output file.
 
std::string mRootObjectName
 HDF5 group/dataset in the output file where to store data in.
 
const RealMatrixmSourceMatrix
 Source matrix to be sampled.
 
const ReduceOperator mReduceOp
 Reduction operator.
 
bool mBufferReuse
 if true, the container reuses another matrix as scratch place, e.g. Temp_1_RS3D, Temp_2_RS3D, Temp_3_RS3D.
 
size_t mBufferSize
 Buffer size.
 
float * mStoreBuffer
 Temporary buffer for store - only if Buffer Reuse = false!
 

Additional Inherited Members

- Public Types inherited from BaseOutputStream
enum  ReduceOperator { ReduceOperator::kNone, ReduceOperator::kRms, ReduceOperator::kMax, ReduceOperator::kMin }
 How to aggregate data. More...
 
- Static Protected Attributes inherited from BaseOutputStream
static constexpr size_t kChunkSize4MB = 1048576
 chunk size of 4MB in number of float elements.
 

Detailed Description

Output stream for quantities sampled by a cuboid corner sensor mask. This class writes data into separated datasets (one per cuboid) under a given dataset in the HDF5 file (time-series as well as aggregations).

Definition at line 49 of file CuboidOutputStream.h.

Constructor & Destructor Documentation

◆ CuboidOutputStream()

CuboidOutputStream::CuboidOutputStream ( Hdf5File file,
MatrixName groupName,
const RealMatrix sourceMatrix,
const IndexMatrix sensorMask,
const ReduceOperator  reduceOp,
float *  bufferToReuse = nullptr 
)
Parameters
[in]file- HDF5 file to write the output to.
[in]groupName- The name of the HDF5 group. This group contains datasets for particular cuboids.
[in]sourceMatrix- Source matrix to be sampled.
[in]sensorMask- Sensor mask with the cuboid coordinates.
[in]reduceOp- Reduction operator.
[in]bufferToReuse- If there is a memory space to be reused, provide a pointer.

Constructor - links the HDF5 dataset, SourceMatrix, and SensorMask together.

Definition at line 50 of file CuboidOutputStream.cpp.

◆ ~CuboidOutputStream()

CuboidOutputStream::~CuboidOutputStream ( )
virtual

If the file is still opened, it applies the post processing and flush the data. Then, the object memory is freed and the object destroyed.

Destructor.

Definition at line 68 of file CuboidOutputStream.cpp.

Member Function Documentation

◆ checkpoint()

void CuboidOutputStream::checkpoint ( )
virtual

Checkpoint the stream.

Implements BaseOutputStream.

Definition at line 253 of file CuboidOutputStream.cpp.

◆ close()

void CuboidOutputStream::close ( )
virtual

Close stream (apply post-processing if necessary, flush data, close datasets and the group).

Implements BaseOutputStream.

Definition at line 263 of file CuboidOutputStream.cpp.

◆ create()

void CuboidOutputStream::create ( )
virtual

Create a HDF5 stream and allocate data for it. It also creates a HDF5 group with particular datasets (one per cuboid).

Implements BaseOutputStream.

Definition at line 81 of file CuboidOutputStream.cpp.

◆ createCuboidDataset()

hid_t CuboidOutputStream::createCuboidDataset ( const size_t  cuboidIdx)
protectedvirtual
Parameters
[in]cuboidIdx- Index of the cuboid in the sensor mask.
Returns
Handle to the HDF5 dataset.

Create a new dataset for a given cuboid specified by index (order).

Definition at line 289 of file CuboidOutputStream.cpp.

◆ flushBufferToFile()

void CuboidOutputStream::flushBufferToFile ( )
protectedvirtual

Flush the buffer to the file (to multiple datasets if necessary).

Definition at line 408 of file CuboidOutputStream.cpp.

◆ postProcess()

void CuboidOutputStream::postProcess ( )
virtual

Apply post-processing on the buffer and flush it to the file.

Reimplemented from BaseOutputStream.

Definition at line 241 of file CuboidOutputStream.cpp.

◆ reopen()

void CuboidOutputStream::reopen ( )
virtual

Reopen the output stream after restart and reload data.

Implements BaseOutputStream.

Definition at line 119 of file CuboidOutputStream.cpp.

◆ sample()

void CuboidOutputStream::sample ( )
virtual

Sample data into buffer and apply reduction, or flush to disk - based on a sensor mask.

Implements BaseOutputStream.

Definition at line 186 of file CuboidOutputStream.cpp.

◆ sampleAggregated()

template<BaseOutputStream::ReduceOperator reduceOp>
void CuboidOutputStream::sampleAggregated ( )
protected
Template Parameters
reduceOp- Reduction operator

Sample aggregated values.

Definition at line 339 of file CuboidOutputStream.cpp.


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