kspaceFirstOrder3D-OMP  1.2
The C++ implementation of the k-wave toolbox for the time-domain simulation of acoustic wave fields in 3D
OutputStreamContainer.h
Go to the documentation of this file.
1 /**
2  * @file OutputStreamContainer.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 defining the output stream container.
10  *
11  * @version kspaceFirstOrder3D 2.16
12  *
13  * @date 27 August 2017, 08:58 (created) \n
14  * 04 September 2017, 10:54 (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 OUTPUT_STREAM_CONTAINER_H
33 #define OUTPUT_STREAM_CONTAINER_H
34 
35 #include <map>
36 
39 
40 #include <Utils/MatrixNames.h>
41 #include <Utils/DimensionSizes.h>
42 
43 
44 /**
45  * @class OutputStreamContainer
46  * @brief A container for output streams.
47  * @details The output stream container maintains matrices used to sample data.
48  * These may or may not require some scratch place or reuse temp matrices.
49  */
51 {
52  public:
53  /**
54  * @enum OutputStreamIdx
55  * @brief Output streams identifiers in k-Wave.
56  * @details Output streams identifiers in k-Wave.
57  */
58  enum class OutputStreamIdx
59  {
60  /// Pressure time series.
62  /// RMS of pressure over sensor mask.
64  /// Max of pressure over sensor mask.
66  /// Min of pressure over sensor mask.
68  /// Max of pressure over all domain.
70  /// Min of pressure over all domain.
72 
73  /// Velocity x time series.
75  /// Velocity y time series.
77  /// Velocity z time series.
79  /// Non staggered velocity x time series.
81  /// Non staggered velocity y time series.
83  /// Non staggered velocity z time series.
85 
86  /// RMS of velocity x over sensor mask.
88  /// RMS of velocity y over sensor mask.
90  /// RMS of velocity z over sensor mask.
92  /// Max of velocity x over sensor mask.
94  /// Max of velocity y over sensor mask.
96  /// Max of velocity z over sensor mask.
98  /// Min of velocity x over sensor mask.
100  /// Min of velocity y over sensor mask.
102  /// Min of velocity z over sensor mask.
104 
105  /// Max of velocity x over all domain.
107  /// Max of velocity y over all domain.
109  /// Max of velocity z over all domain.
111  /// Min of velocity x over all domain.
113  /// Min of velocity y over all domain.
115  /// Min of velocity z over all domain.
117  };// end of OutputStreamIdx
118 
119 
120  /// Constructor.
122  /// Copy constructor not allowed.
124  /// Destructor.
126 
127  /// Operator = not allowed.
129 
130  /**
131  * @brief Get size of the container.
132  * @return the size of the container
133  */
134  size_t size() const
135  {
136  return mContainer.size();
137  };
138 
139  /**
140  * @brief Is the container empty?
141  * @return true - If the container is empty.
142  */
143  bool empty() const
144  {
145  return mContainer.empty();
146  };
147 
148  /**
149  * @brief operator []
150  * @param [in] outputStreamIdx - Id of the output stream.
151  * @return An element of the container.
152  */
154  {
155  return (* (mContainer[outputStreamIdx]));
156  };
157 
158  /**
159  * @brief Add all streams in simulation in the container, set all streams records here!
160  *
161  * Please note, the matrix container has to be populated before calling this routine.
162  *
163  * @param [in] matrixContainer - matrix container to link the steams with sampled matrices and sensor masks.
164  */
165  void addStreams(MatrixContainer& matrixContainer);
166 
167  /// Create all streams - opens the datasets.
168  void createStreams();
169  /// Reopen streams after checkpoint file (datasets).
170  void reopenStreams();
171 
172  /// Sample all streams.
173  void sampleStreams();
174  /// Post-process all streams and flush them to the file.
175  void postProcessStreams();
176  /// Checkpoint streams.
177  void checkpointStreams();
178 
179  /// Close all streams.
180  void closeStreams();
181 
182  /// Free all streams - destroy them.
183  void freeStreams();
184 
185  protected:
186  /**
187  * @brief Create a new output stream.
188  * @param [in] matrixContainer - name of the HDF5 dataset or group
189  * @param [in] sampledMatrixIdx - code id of the matrix
190  * @param [in] fileObjectName - name of the HDF5 dataset or group
191  * @param [in] reduceOp - reduction operator
192  * @param [in] bufferToReuse - buffer to reuse
193  * @return New output stream with defined links.
194  */
196  const MatrixContainer::MatrixIdx sampledMatrixIdx,
197  const MatrixName& fileObjectName,
198  const BaseOutputStream::ReduceOperator reduceOp,
199  float* bufferToReuse = nullptr);
200 
201  private:
202  /// Map with output streams.
203  std::map<OutputStreamIdx, BaseOutputStream*> mContainer;
204 
205 }; // end of OutputStreamContainer
206 //----------------------------------------------------------------------------------------------------------------------
207 
208 #endif /* OUTPUT_STREAM_CONTAINER_H */
void postProcessStreams()
Post-process all streams and flush them to the file.
OutputStreamContainer & operator=(OutputStreamContainer &)=delete
Operator = not allowed.
Class implementing the matrix container.
OutputStreamIdx
Output streams identifiers in k-Wave.
Max of velocity y over sensor mask.
BaseOutputStream & operator[](const OutputStreamIdx outputStreamIdx)
operator []
bool empty() const
Is the container empty?
RMS of velocity x over sensor mask.
RMS of velocity y over sensor mask.
Max of velocity z over sensor mask.
void reopenStreams()
Reopen streams after checkpoint file (datasets).
Max of velocity x over sensor mask.
Min of velocity x over sensor mask.
void addStreams(MatrixContainer &matrixContainer)
Add all streams in simulation in the container, set all streams records here!
void freeStreams()
Free all streams - destroy them.
OutputStreamContainer()
Constructor.
void sampleStreams()
Sample all streams.
Min of velocity y over sensor mask.
void createStreams()
Create all streams - opens the datasets.
const std::string MatrixName
Datatype for matrix names.
Definition: MatrixNames.h:39
MatrixIdx
Matrix identifers of all matrices in the k-space code.
The header file storing names of all variables.
The header file containing the structure with 3D dimension sizes.
A container for output streams.
ReduceOperator
How to aggregate data.
size_t size() const
Get size of the container.
std::map< OutputStreamIdx, BaseOutputStream * > mContainer
Map with output streams.
The header file containing the matrix container.
The header file of the class saving RealMatrix data into the output HDF5 file.
void closeStreams()
Close all streams.
void checkpointStreams()
Checkpoint streams.
RMS of velocity z over sensor mask.
Abstract base class for output data streams (sampled data).
BaseOutputStream * createOutputStream(MatrixContainer &matrixContainer, const MatrixContainer::MatrixIdx sampledMatrixIdx, const MatrixName &fileObjectName, const BaseOutputStream::ReduceOperator reduceOp, float *bufferToReuse=nullptr)
Create a new output stream.
Min of velocity z over sensor mask.