| kspaceFirstOrder3D-CUDA 1.1 The CUDA/C++ implementation of the k-wave toolbox for the time-domain simulation of acoustic wave fields in 3D

- Main Page
- Related Pages
- Namespaces
- Classes
- Files

- File List
- File Members

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
39 #include <OutputHDF5Streams/BaseOutputHDF5Stream.h>
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 */
49 class TCuboidOutputHDF5Stream : public TBaseOutputHDF5Stream
50 {
51 public:
52
53 /// Constructor.
54 TCuboidOutputHDF5Stream(THDF5_File& file,
55 TMatrixName& groupName,
56 const TRealMatrix& sourceMatrix,
57 const TIndexMatrix& sensorMask,
58 const TReduceOperator reduceOp);
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.
97 size_t startingPossitionInBuffer;
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.
107 const TIndexMatrix& sensorMask;
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).
116 size_t sampledTimeStep;
117
118 /// Has the sampling finished?
119 cudaEvent_t eventSamplingFinished;
120 };// end of TCuboidOutputHDF5Stream
121 //--------------------------------------------------------------------------------------------------
122
123 #endif /* CUBOID_OUTPUT_HDF5_STREAM_H */
124
TBaseOutputHDF5Stream::file
THDF5_File & file
HDF5 file handle.
Definition: BaseOutputHDF5Stream.h:115
TCuboidOutputHDF5Stream::group
hid_t group
Handle to a HDF5 dataset.
Definition: CuboidOutputHDF5Stream.h:110
TCuboidOutputHDF5Stream::TCuboidInfo::startingPossitionInBuffer
size_t startingPossitionInBuffer
Having a single buffer for all cuboids, where this one starts.
Definition: CuboidOutputHDF5Stream.h:97
BaseOutputHDF5Stream.h
The header file of the class saving RealMatrix data into the output HDF5 file.
TCuboidOutputHDF5Stream
Output stream for quantities sampled by a cuboid corner sensor mask.
Definition: CuboidOutputHDF5Stream.h:49
TBaseOutputHDF5Stream::reduceOp
const TReduceOperator reduceOp
Reduce operator.
Definition: BaseOutputHDF5Stream.h:126
TMatrixName
const std::string TMatrixName
Datatype for matrix names.
Definition: MatrixNames.h:45
TCuboidOutputHDF5Stream::CreateCuboidDataset
virtual hid_t CreateCuboidDataset(const size_t cuboidIdx)
Create a new dataset for a given cuboid specified by index (order).
Definition: CuboidOutputHDF5Stream.cpp:378
TBaseOutputHDF5Stream::sourceMatrix
const TRealMatrix & sourceMatrix
Source matrix to be sampled.
Definition: BaseOutputHDF5Stream.h:121
TCuboidOutputHDF5Stream::PostProcess
virtual void PostProcess()
Apply post-processing on the buffer and flush it to the file.
Definition: CuboidOutputHDF5Stream.cpp:311
TCuboidOutputHDF5Stream::FlushRaw
virtual void FlushRaw()
Flush data to disk (from raw streams only).
Definition: CuboidOutputHDF5Stream.cpp:294
TCuboidOutputHDF5Stream::cuboidsInfo
std::vector< TCuboidInfo > cuboidsInfo
vector keeping handles and positions of all cuboids
Definition: CuboidOutputHDF5Stream.h:113
TCuboidOutputHDF5Stream::Create
virtual void Create()
Create a HDF5 stream and allocate data for it.
Definition: CuboidOutputHDF5Stream.cpp:97
TBaseOutputHDF5Stream::TReduceOperator
TReduceOperator
How to aggregate data.
Definition: BaseOutputHDF5Stream.h:54
TCuboidOutputHDF5Stream::eventSamplingFinished
cudaEvent_t eventSamplingFinished
Has the sampling finished?
Definition: CuboidOutputHDF5Stream.h:119
TBaseOutputHDF5Stream
Abstract base class for output data streams (sampled data).
Definition: BaseOutputHDF5Stream.h:46
TCuboidOutputHDF5Stream::Checkpoint
virtual void Checkpoint()
Checkpoint the stream and close.
Definition: CuboidOutputHDF5Stream.cpp:332
TCuboidOutputHDF5Stream::sampledTimeStep
size_t sampledTimeStep
Timestep to store (N/A for aggregated).
Definition: CuboidOutputHDF5Stream.h:116
TRealMatrix
The class for real matrices.
Definition: RealMatrix.h:45
TCuboidOutputHDF5Stream::TCuboidInfo
This structure information about one cuboid. Namely, its HDF5_ID, starting position in a lineup buffe...
Definition: CuboidOutputHDF5Stream.h:92
TCuboidOutputHDF5Stream::sensorMask
const TIndexMatrix & sensorMask
Sensor mask to sample data.
Definition: CuboidOutputHDF5Stream.h:107
TIndexMatrix
The class for 64b unsigned integers (indices). It is used for sensor_mask_index or sensor_corners_mas...
Definition: IndexMatrix.h:46
TCuboidOutputHDF5Stream::Sample
virtual void Sample()
Sample data into buffer, apply reduce or copy to the CPU side.
Definition: CuboidOutputHDF5Stream.cpp:207
TCuboidOutputHDF5Stream::Close
virtual void Close()
Close stream (apply post-processing if necessary, flush data and close).
Definition: CuboidOutputHDF5Stream.cpp:349
TCuboidOutputHDF5Stream::Reopen
virtual void Reopen()
Reopen the output stream after restart and reload data.
Definition: CuboidOutputHDF5Stream.cpp:136
TCuboidOutputHDF5Stream::FlushBufferToFile
virtual void FlushBufferToFile()
Flush the buffer to the file.
Definition: CuboidOutputHDF5Stream.cpp:423
TCuboidOutputHDF5Stream::TCuboidOutputHDF5Stream
TCuboidOutputHDF5Stream(THDF5_File &file, TMatrixName &groupName, const TRealMatrix &sourceMatrix, const TIndexMatrix &sensorMask, const TReduceOperator reduceOp)
Constructor.
Definition: CuboidOutputHDF5Stream.cpp:61
TCuboidOutputHDF5Stream::TCuboidInfo::cuboidIdx
hid_t cuboidIdx
Idx of the dataset storing the given cuboid.
Definition: CuboidOutputHDF5Stream.h:95
THDF5_File
Class wrapping the HDF5 routines.
Definition: HDF5_File.h:500
TCuboidOutputHDF5Stream::~TCuboidOutputHDF5Stream
virtual ~TCuboidOutputHDF5Stream()
Destructor.
Definition: CuboidOutputHDF5Stream.cpp:82