| 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
OutputStreamContainer.h
Go to the documentation of this file.
1 /**
2 * @file OutputStreamContainer.h
3 *
4 * @author Jiri Jaros & Beau Johnston \n
5 * Faculty of Information Technology \n
6 * Brno University of Technology \n
7 * jarosjir@fit.vutbr.cz
8 *
9 * @brief The header file defining the output stream container.
10 *
11 * @version kspaceFirstOrder3D 3.4
12 *
13 * @date 04 December 2014, 11:00 (created)
14 * 02 August 2016, 17:15 (revised)
15 *
16 * @section License
17 * This file is part of the C++ extension of the k-Wave Toolbox
18 * (http://www.k-wave.org).\n Copyright (C) 2016 Jiri Jaros and Bradley Treeby.
19 *
20 * This file is part of the k-Wave. k-Wave is free software: you can redistribute it and/or modify
21 * it under the terms of the GNU Lesser General Public License as published by the Free Software
22 * Foundation, either version 3 of the 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
25 * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser
26 * General Public License for 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/.
30 */
31
32 #ifndef OUTPUT_STREAM_CONTAINER_H
33 #define OUTPUT_STREAM_CONTAINER_H
34
35 #include <cstring>
36 #include <map>
37
38 #include <Containers/MatrixContainer.h>
39 #include <OutputHDF5Streams/BaseOutputHDF5Stream.h>
40
41 #include <Utils/MatrixNames.h>
42 #include <Utils/DimensionSizes.h>
43
44
45 /**
46 * @enum TOutputStreamIdx
47 * @brief Output streams identifiers in k-Wave.
48 * @details Output streams identifiers in k-Wave.
49 * @warning the order of Idxs is mandatory! it determines the order of sampling and is used for
50 * hiding the PCI-E latency
51 */
52 enum TOutputStreamIdx
53 {
54 // raw quantities are sampled first - to allow some degree of asynchronous copies
55 p_sensor_raw, ux_sensor_raw, uy_sensor_raw, uz_sensor_raw,
56 ux_shifted_sensor_raw, uy_shifted_sensor_raw, uz_shifted_sensor_raw,
57
58 // then we sample aggregated quantities
59 p_sensor_rms, p_sensor_max, p_sensor_min,
60 p_sensor_max_all, p_sensor_min_all,
61
62 ux_sensor_rms, uy_sensor_rms, uz_sensor_rms,
63 ux_sensor_max, uy_sensor_max, uz_sensor_max,
64 ux_sensor_min, uy_sensor_min, uz_sensor_min,
65
66 ux_sensor_max_all, uy_sensor_max_all, uz_sensor_max_all,
67 ux_sensor_min_all, uy_sensor_min_all, uz_sensor_min_all,
68 };// end of TOutputStreamIdx
69 //--------------------------------------------------------------------------------------------------
70
71 /**
72 * @class TOutputStreamContainer
73 * @brief A container for output streams.
74 * @details The output stream container maintains matrices used to sample data.
75 * These may or may not require some scratch place or reuse temp matrices.
76 */
77 class TOutputStreamContainer
78 {
79 public:
80 /// Constructor.
81 TOutputStreamContainer() {};
82 /// Destructor.
83 ~TOutputStreamContainer();
84
85 /**
86 * @brief Get size of the container.
87 * @details Get size of the container.
88 * @return the size of the container
89 */
90 inline size_t Size() const
91 {
92 return outputStreamContainer.size();
93 };
94
95 /**
96 * @brief Is the container empty?
97 * @details Is the container empty?
98 * @return true if the container is empty
99 */
100 inline bool IsEmpty() const
101 {
102 return outputStreamContainer.empty();
103 };
104
105 /**
106 * @brief Operator []
107 * @details Operator []
108 * @param [in] outputStreamIdx - id of the output stream
109 * @return an element of the container
110 */
111 TBaseOutputHDF5Stream& operator[] (const TOutputStreamIdx outputStreamIdx)
112 {
113 return (* (outputStreamContainer[outputStreamIdx]));
114 };
115
116 /// Add all streams into the container.
117 void AddStreams(TMatrixContainer& matrixContainer);
118
119 /// Create all streams - opens the datasets.
120 void CreateStreams();
121 /// Reopen streams after checkpoint file (datasets).
122 void ReopenStreams();
123
124 /// Sample all streams (only sample, no disk operations).
125 void SampleStreams();
126 /// Flush streams to disk - only raw streams.
127 void FlushRawStreams();
128
129 /// Post-process all streams and flush them to the file.
130 void PostProcessStreams();
131 /// Checkpoint streams.
132 void CheckpointStreams();
133
134 /// Close all streams.
135 void CloseStreams();
136 /// Free all streams - destroy them.
137 void FreeStreams();
138
139 protected:
140
141 private:
142 /// Create a new output stream
143 TBaseOutputHDF5Stream* CreateNewOutputStream(TMatrixContainer& matrixContainer,
144 const TMatrixIdx sampledMatrixIdx,
145 const TMatrixName& fileDatasetName,
146 const TBaseOutputHDF5Stream::TReduceOperator reduceOp);
147
148 /// Copy constructor not allowed for public.
149 TOutputStreamContainer(const TOutputStreamContainer&);
150 /// Operator = not allowed for public.
151 TOutputStreamContainer& operator= (TOutputStreamContainer&);
152
153 /// Output stream map.
154 typedef std::map<TOutputStreamIdx, TBaseOutputHDF5Stream*> TOutputStreamMap;
155
156 /// Map with output streams.
157 TOutputStreamMap outputStreamContainer;
158 }; // end of TOutputStreamContainer
159 //--------------------------------------------------------------------------------------------------
160
161 #endif /* OUTPUT_STREAM_CONTAINER_H */
BaseOutputHDF5Stream.h
The header file of the class saving RealMatrix data into the output HDF5 file.
TOutputStreamContainer::IsEmpty
bool IsEmpty() const
Is the container empty?
Definition: OutputStreamContainer.h:100
TOutputStreamContainer::TOutputStreamContainer
TOutputStreamContainer()
Constructor.
Definition: OutputStreamContainer.h:81
TOutputStreamContainer::FreeStreams
void FreeStreams()
Free all streams - destroy them.
Definition: OutputStreamContainer.cpp:355
TOutputStreamContainer::Size
size_t Size() const
Get size of the container.
Definition: OutputStreamContainer.h:90
TOutputStreamContainer::AddStreams
void AddStreams(TMatrixContainer &matrixContainer)
Add all streams into the container.
Definition: OutputStreamContainer.cpp:66
TMatrixName
const std::string TMatrixName
Datatype for matrix names.
Definition: MatrixNames.h:45
TOutputStreamContainer::CreateNewOutputStream
TBaseOutputHDF5Stream * CreateNewOutputStream(TMatrixContainer &matrixContainer, const TMatrixIdx sampledMatrixIdx, const TMatrixName &fileDatasetName, const TBaseOutputHDF5Stream::TReduceOperator reduceOp)
Create a new output stream.
Definition: OutputStreamContainer.cpp:385
TOutputStreamContainer::operator[]
TBaseOutputHDF5Stream & operator[](const TOutputStreamIdx outputStreamIdx)
Operator [].
Definition: OutputStreamContainer.h:111
TOutputStreamContainer::SampleStreams
void SampleStreams()
Sample all streams (only sample, no disk operations).
Definition: OutputStreamContainer.cpp:277
TBaseOutputHDF5Stream::TReduceOperator
TReduceOperator
How to aggregate data.
Definition: BaseOutputHDF5Stream.h:54
MatrixNames.h
The header file storing names of all variables/matrices/output streams used in the simulation...
TOutputStreamContainer::TOutputStreamMap
std::map< TOutputStreamIdx, TBaseOutputHDF5Stream * > TOutputStreamMap
Output stream map.
Definition: OutputStreamContainer.h:154
TOutputStreamContainer::ReopenStreams
void ReopenStreams()
Reopen streams after checkpoint file (datasets).
Definition: OutputStreamContainer.cpp:260
TOutputStreamContainer::operator=
TOutputStreamContainer & operator=(TOutputStreamContainer &)
Operator = not allowed for public.
TMatrixIdx
TMatrixIdx
Matrix identifers of all matrices in the k-space code, names based on the Matlab notation.
Definition: MatrixContainer.h:55
DimensionSizes.h
The header file containing the structure with 3D dimension sizes.
TBaseOutputHDF5Stream
Abstract base class for output data streams (sampled data).
Definition: BaseOutputHDF5Stream.h:46
TMatrixContainer
Class implementing the matrix container.
Definition: MatrixContainer.h:96
TOutputStreamContainer::FlushRawStreams
void FlushRawStreams()
Flush streams to disk - only raw streams.
Definition: OutputStreamContainer.cpp:294
TOutputStreamContainer::outputStreamContainer
TOutputStreamMap outputStreamContainer
Map with output streams.
Definition: OutputStreamContainer.h:157
TOutputStreamContainer::CheckpointStreams
void CheckpointStreams()
Checkpoint streams.
Definition: OutputStreamContainer.cpp:309
TOutputStreamIdx
TOutputStreamIdx
Output streams identifiers in k-Wave.
Definition: OutputStreamContainer.h:52
TOutputStreamContainer::~TOutputStreamContainer
~TOutputStreamContainer()
Destructor.
Definition: OutputStreamContainer.cpp:53
MatrixContainer.h
The header file containing the matrix container and the related matrix record class.
TOutputStreamContainer::CreateStreams
void CreateStreams()
Create all streams - opens the datasets.
Definition: OutputStreamContainer.cpp:245
TOutputStreamContainer::CloseStreams
void CloseStreams()
Close all streams.
Definition: OutputStreamContainer.cpp:340
TOutputStreamContainer
A container for output streams.
Definition: OutputStreamContainer.h:77
TOutputStreamContainer::PostProcessStreams
void PostProcessStreams()
Post-process all streams and flush them to the file.
Definition: OutputStreamContainer.cpp:324