kspaceFirstOrder3D-OMP
1.2
The C++ implementation of the k-wave toolbox for the time-domain simulation of acoustic wave fields in 3D
|
Abstract base class for output data streams (sampled data). More...
#include <BaseOutputStream.h>
Public Types | |
enum | ReduceOperator { ReduceOperator::kNone, ReduceOperator::kRms, ReduceOperator::kMax, ReduceOperator::kMin } |
How to aggregate data. More... | |
Public Member Functions | |
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... | |
BaseOutputStream & | operator= (const BaseOutputStream &src) |
Operator = not allowed (we don't want any data movements). | |
virtual void | create ()=0 |
Create a HDF5 stream and allocate data for it. | |
virtual void | reopen ()=0 |
Reopen the output stream after restart. | |
virtual void | sample ()=0 |
Sample data into buffer, apply reduction or flush to disk - based on a sensor mask. | |
virtual void | postProcess () |
Apply post-processing on the buffer and flush it to the file. More... | |
virtual void | checkpoint ()=0 |
Checkpoint the stream. | |
virtual void | close ()=0 |
Close stream (apply post-processing if necessary, flush data and close). | |
Protected Member Functions | |
virtual void | allocateMemory () |
Allocate memory using proper memory alignment. More... | |
virtual void | freeMemory () |
Free memory. More... | |
Protected Attributes | |
Hdf5File & | mFile |
Handle to HDF5 output file. | |
std::string | mRootObjectName |
HDF5 group/dataset in the output file where to store data in. | |
const RealMatrix & | mSourceMatrix |
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! | |
Static Protected Attributes | |
static constexpr size_t | kChunkSize4MB = 1048576 |
chunk size of 4MB in number of float elements. | |
Data are sampled based on the the sensor mask and the reduction operator. The sampled data is stored in the output HDF5 file.
Definition at line 47 of file BaseOutputStream.h.
|
strong |
Enumerator | |
---|---|
kNone | Store actual data (time series). |
kRms | Calculate root mean square. |
kMax | Store maximum. |
kMin | Store minimum. |
Definition at line 55 of file BaseOutputStream.h.
BaseOutputStream::BaseOutputStream | ( | Hdf5File & | file, |
MatrixName & | rootObjectName, | ||
const RealMatrix & | sourceMatrix, | ||
const ReduceOperator | reduceOp, | ||
float * | bufferToReuse = nullptr |
||
) |
There is no sensor mask by default to support both sensor mask and whole domain sampling. The constructor links the HDF5 dataset, source (sampled matrix) and the reduction operator together. The constructor DOES NOT allocate memory because the size of the sensor mask is not known at the time the instance of the class is being created.
[in] | file | - Handle to the output HDF5 file. |
[in] | rootObjectName | - The root object that stores the sample data (dataset or group). |
[in] | sourceMatrix | - The source matrix (only real matrices are supported). |
[in] | reduceOp | - Reduction operator. |
[in] | bufferToReuse | - An external buffer can be used to line up the grid points. |
Constructor - there is no sensor mask by default!
Definition at line 52 of file BaseOutputStream.cpp.
|
inlinevirtual |
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.
Definition at line 98 of file BaseOutputStream.h.
|
protectedvirtual |
std::bad_alloc | - If there's not enough memory. |
Allocate memory using a proper memory alignment.
Definition at line 117 of file BaseOutputStream.cpp.
|
protectedvirtual |
Free memory.
Definition at line 179 of file BaseOutputStream.cpp.
|
virtual |
Apply post-processing on the buffer. It supposes the elements are independent.
Reimplemented in CuboidOutputStream, IndexOutputStream, and WholeDomainOutputStream.
Definition at line 72 of file BaseOutputStream.cpp.