kspaceFirstOrder3D-OMP  1.2
The C++ implementation of the k-wave toolbox for the time-domain simulation of acoustic wave fields in 3D
IndexOutputStream.h
Go to the documentation of this file.
1 /**
2  * @file IndexOutputStream.h
3  *
4  * @author Jiri Jaros \n
5  * Faculty of Information Technology \n
6  * Brno University of Technology \n
7  * jarosjir@fit.vutbr.cz
8  *
9  * @brief The header file of the class saving data based on the index senor mask into the output HDF5 file.
10  *
11  * @version kspaceFirstOrder3D 2.16
12  *
13  * @date 26 August 2017, 16:55 (created) \n
14  * 04 September 2017, 11:10 (revised)
15  *
16  * @copyright Copyright (C) 2017 Jiri Jaros and Bradley Treeby.
17  *
18  * This file is part of the C++ extension of the [k-Wave Toolbox](http://www.k-wave.org).
19  *
20  * This file is part of the k-Wave. k-Wave is free software: you can redistribute it and/or modify it under the terms
21  * of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the
22  * License, or (at your option) any later version.
23  *
24  * k-Wave is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied
25  * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for
26  * more details.
27  *
28  * You should have received a copy of the GNU Lesser General Public License along with k-Wave.
29  * If not, see [http://www.gnu.org/licenses/](http://www.gnu.org/licenses/).
30  */
31 
32 #ifndef INDEX_OUTPUT_STREAM_H
33 #define INDEX_OUTPUT_STREAM_H
34 
36 
37 /**
38  * @class IndexOutputStream.
39  * @brief Output stream for quantities sampled by an index sensor mask.
40  *
41  * Output stream for quantities sampled by an index sensor mask. This class writes data to a single dataset in a
42  * root group of the HDF5 file (time-series as well as aggregations).
43  */
45 {
46  public:
47  /// Default constructor not allowed.
48  IndexOutputStream() = delete;
49 
50  /**
51  * @brief Constructor links the HDF5 dataset, SourceMatrix, and SensorMask together.
52  *
53  * Constructor - links the HDF5 dataset, source (sampled matrix), Sensor mask and the reduction operator together.
54  * The constructor DOES NOT allocate memory because the size of the sensor mask is not known at the time the
55  * instance of the class is being created.
56  *
57  * @param [in] file - Handle to the HDF5 (output) file.
58  * @param [in] datasetName - The dataset's name (index based sensor data is store in a single dataset).
59  * @param [in] sourceMatrix - The source matrix (only real matrices are supported).
60  * @param [in] sensorMask - Index based sensor mask.
61  * @param [in] reduceOp - Reduction operator.
62  * @param [in] bufferToReuse - An external buffer can be used to line up the grid points.
63  */
65  MatrixName& datasetName,
66  const RealMatrix& sourceMatrix,
67  const IndexMatrix& sensorMask,
68  const ReduceOperator reduceOp,
69  float* bufferToReuse = nullptr);
70 
71  /// Copy constructor not allowed.
72  IndexOutputStream(const IndexOutputStream&) = delete;
73 
74  /**
75  * @brief Destructor.
76  *
77  * If the file is still opened, it applies the post processing and flush the data.
78  * Then, the object memory is freed and the object destroyed.
79  */
80  virtual ~IndexOutputStream();
81 
82  /// Create a HDF5 stream and allocate data for it.
83  virtual void create();
84 
85  /// Reopen the output stream after restart and reload data.
86  virtual void reopen();
87 
88  /// Sample data into buffer, apply reduction or flush to disk - based on a sensor mask.
89  virtual void sample();
90 
91  /// Apply post-processing on the buffer and flush it to the file.
92  virtual void postProcess();
93 
94  /// Checkpoint the stream.
95  virtual void checkpoint();
96 
97  /// Close stream (apply post-processing if necessary, flush data and close).
98  virtual void close();
99 
100  protected:
101 
102  /// Flush the buffer to the file.
103  virtual void flushBufferToFile();
104 
105  /// Sensor mask to sample data.
107  /// Handle to a HDF5 dataset.
108  hid_t mDataset;
109 
110  /// Time step to store (N/A for aggregated).
112 }; // end of IndexOutputStream
113 //----------------------------------------------------------------------------------------------------------------------
114 
115 #endif /* INDEX_OUTPUT_STREAM_H */
virtual void reopen()
Reopen the output stream after restart and reload data.
Output stream for quantities sampled by an index sensor mask.
The class for real matrices.
Definition: RealMatrix.h:47
virtual void create()
Create a HDF5 stream and allocate data for it.
const IndexMatrix & sensorMask
Sensor mask to sample data.
hid_t mDataset
Handle to a HDF5 dataset.
size_t mSampledTimeStep
Time step to store (N/A for aggregated).
virtual ~IndexOutputStream()
Destructor.
virtual void close()
Close stream (apply post-processing if necessary, flush data and close).
virtual void postProcess()
Apply post-processing on the buffer and flush it to the file.
virtual void sample()
Sample data into buffer, apply reduction or flush to disk - based on a sensor mask.
Class wrapping the HDF5 routines.
Definition: Hdf5File.h:490
IndexOutputStream()=delete
Default constructor not allowed.
const std::string MatrixName
Datatype for matrix names.
Definition: MatrixNames.h:39
ReduceOperator
How to aggregate data.
The header file of the class saving RealMatrix data into the output HDF5 file.
virtual void checkpoint()
Checkpoint the stream.
The class for 64b unsigned integers (indices). It is used for linear and cuboid corners masks to get ...
Definition: IndexMatrix.h:47
Abstract base class for output data streams (sampled data).
virtual void flushBufferToFile()
Flush the buffer to the file.