kspaceFirstOrder3D-CUDA  1.1
The CUDA/C++ implementation of the k-wave toolbox for the time-domain simulation of acoustic wave fields in 3D
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
CuboidOutputHDF5Stream.h
Go to the documentation of this file.
1 /**
2  * @file CuboidOutputHDF5Stream.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 classes responsible for storing output quantities based on the
10  * cuboid sensor mask into the output HDF5 file.
11  *
12  * @version kspaceFirstOrder3D 3.4
13  *
14  * @date 13 February 2015, 12:51 (created)
15  * 26 July 2016, 13:54 (revised)
16  *
17  * @section License
18  * This file is part of the C++ extension of the k-Wave Toolbox
19  * (http://www.k-wave.org).\n Copyright (C) 2016 Jiri Jaros and Bradley Treeby.
20  *
21  * This file is part of the k-Wave. k-Wave is free software: you can redistribute it and/or modify
22  * it under the terms of the GNU Lesser General Public License as published by the Free Software
23  * Foundation, either version 3 of the License, or (at your option) any later version.
24  *
25  * k-Wave is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even
26  * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser
27  * General Public License for more details.
28  *
29  * You should have received a copy of the GNU Lesser General Public License along with k-Wave.
30  * If not, see http://www.gnu.org/licenses/.
31  */
32 
33 #ifndef CUBOID_OUTPUT_HDF5_STREAM_H
34 #define CUBOID_OUTPUT_HDF5_STREAM_H
35 
36 #include <vector>
37 #include <cuda_runtime.h>
38 
40 
41 /**
42  * @class TCuboidOutputHDF5Stream
43  * @brief Output stream for quantities sampled by a cuboid corner sensor mask.
44  * @details Output stream for quantities sampled by a cuboid corner sensor mask.
45  * This class writes data into separated datasets (one per cuboid) under a given dataset
46  * in the HDF5 file (time-series as well as aggregations).
47  *
48  */
50 {
51  public:
52 
53  /// Constructor.
55  TMatrixName& groupName,
57  const TIndexMatrix& sensorMask,
59 
60  /// Destructor.
61  virtual ~TCuboidOutputHDF5Stream();
62 
63  /// Create a HDF5 stream and allocate data for it.
64  virtual void Create();
65 
66  /// Reopen the output stream after restart and reload data.
67  virtual void Reopen();
68 
69  /// Sample data into buffer, apply reduce or copy to the CPU side
70  virtual void Sample();
71 
72  /// Flush data to disk (from raw streams only).
73  virtual void FlushRaw();
74 
75  /// Apply post-processing on the buffer and flush it to the file.
76  virtual void PostProcess();
77 
78  /// Checkpoint the stream and close.
79  virtual void Checkpoint();
80 
81  /// Close stream (apply post-processing if necessary, flush data and close).
82  virtual void Close();
83 
84  protected:
85  /**
86  * @struct TCuboidInfo
87  * @brief This structure information about one cuboid. Namely, its HDF5_ID,
88  * starting position in a lineup buffer.
89  * @details This structure information about one cuboid. Namely, its HDF5_ID,
90  * starting position in a lineup buffer.
91  */
92  struct TCuboidInfo
93  {
94  /// Idx of the dataset storing the given cuboid.
95  hid_t cuboidIdx;
96  /// Having a single buffer for all cuboids, where this one starts.
98  };
99 
100  /// Create a new dataset for a given cuboid specified by index (order).
101  virtual hid_t CreateCuboidDataset(const size_t cuboidIdx);
102 
103  /// Flush the buffer to the file.
104  virtual void FlushBufferToFile();
105 
106  /// Sensor mask to sample data.
108 
109  /// Handle to a HDF5 dataset.
110  hid_t group;
111 
112  /// vector keeping handles and positions of all cuboids
113  std::vector<TCuboidInfo> cuboidsInfo;
114 
115  /// Timestep to store (N/A for aggregated).
117 
118  /// Has the sampling finished?
120 };// end of TCuboidOutputHDF5Stream
121 //--------------------------------------------------------------------------------------------------
122 
123 #endif /* CUBOID_OUTPUT_HDF5_STREAM_H */
124 
THDF5_File & file
HDF5 file handle.
hid_t group
Handle to a HDF5 dataset.
size_t startingPossitionInBuffer
Having a single buffer for all cuboids, where this one starts.
The header file of the class saving RealMatrix data into the output HDF5 file.
Output stream for quantities sampled by a cuboid corner sensor mask.
const TReduceOperator reduceOp
Reduce operator.
const std::string TMatrixName
Datatype for matrix names.
Definition: MatrixNames.h:45
virtual hid_t CreateCuboidDataset(const size_t cuboidIdx)
Create a new dataset for a given cuboid specified by index (order).
const TRealMatrix & sourceMatrix
Source matrix to be sampled.
virtual void PostProcess()
Apply post-processing on the buffer and flush it to the file.
virtual void FlushRaw()
Flush data to disk (from raw streams only).
std::vector< TCuboidInfo > cuboidsInfo
vector keeping handles and positions of all cuboids
virtual void Create()
Create a HDF5 stream and allocate data for it.
TReduceOperator
How to aggregate data.
cudaEvent_t eventSamplingFinished
Has the sampling finished?
Abstract base class for output data streams (sampled data).
virtual void Checkpoint()
Checkpoint the stream and close.
size_t sampledTimeStep
Timestep to store (N/A for aggregated).
The class for real matrices.
Definition: RealMatrix.h:45
This structure information about one cuboid. Namely, its HDF5_ID, starting position in a lineup buffe...
const TIndexMatrix & sensorMask
Sensor mask to sample data.
The class for 64b unsigned integers (indices). It is used for sensor_mask_index or sensor_corners_mas...
Definition: IndexMatrix.h:46
virtual void Sample()
Sample data into buffer, apply reduce or copy to the CPU side.
virtual void Close()
Close stream (apply post-processing if necessary, flush data and close).
virtual void Reopen()
Reopen the output stream after restart and reload data.
virtual void FlushBufferToFile()
Flush the buffer to the file.
TCuboidOutputHDF5Stream(THDF5_File &file, TMatrixName &groupName, const TRealMatrix &sourceMatrix, const TIndexMatrix &sensorMask, const TReduceOperator reduceOp)
Constructor.
hid_t cuboidIdx
Idx of the dataset storing the given cuboid.
Class wrapping the HDF5 routines.
Definition: HDF5_File.h:500
virtual ~TCuboidOutputHDF5Stream()
Destructor.