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
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 
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  */
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  */
78 {
79  public:
80  /// Constructor.
82  /// Destructor.
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  */
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
144  const TMatrixIdx sampledMatrixIdx,
145  const TMatrixName& fileDatasetName,
147 
148  /// Copy constructor not allowed for public.
150  /// Operator = not allowed for public.
152 
153  /// Output stream map.
154  typedef std::map<TOutputStreamIdx, TBaseOutputHDF5Stream*> TOutputStreamMap;
155 
156  /// Map with output streams.
158 }; // end of TOutputStreamContainer
159 //--------------------------------------------------------------------------------------------------
160 
161 #endif /* OUTPUT_STREAM_CONTAINER_H */
The header file of the class saving RealMatrix data into the output HDF5 file.
bool IsEmpty() const
Is the container empty?
TOutputStreamContainer()
Constructor.
void FreeStreams()
Free all streams - destroy them.
size_t Size() const
Get size of the container.
void AddStreams(TMatrixContainer &matrixContainer)
Add all streams into the container.
const std::string TMatrixName
Datatype for matrix names.
Definition: MatrixNames.h:45
TBaseOutputHDF5Stream * CreateNewOutputStream(TMatrixContainer &matrixContainer, const TMatrixIdx sampledMatrixIdx, const TMatrixName &fileDatasetName, const TBaseOutputHDF5Stream::TReduceOperator reduceOp)
Create a new output stream.
TBaseOutputHDF5Stream & operator[](const TOutputStreamIdx outputStreamIdx)
Operator [].
void SampleStreams()
Sample all streams (only sample, no disk operations).
TReduceOperator
How to aggregate data.
The header file storing names of all variables/matrices/output streams used in the simulation...
std::map< TOutputStreamIdx, TBaseOutputHDF5Stream * > TOutputStreamMap
Output stream map.
void ReopenStreams()
Reopen streams after checkpoint file (datasets).
TOutputStreamContainer & operator=(TOutputStreamContainer &)
Operator = not allowed for public.
TMatrixIdx
Matrix identifers of all matrices in the k-space code, names based on the Matlab notation.
The header file containing the structure with 3D dimension sizes.
Abstract base class for output data streams (sampled data).
Class implementing the matrix container.
void FlushRawStreams()
Flush streams to disk - only raw streams.
TOutputStreamMap outputStreamContainer
Map with output streams.
void CheckpointStreams()
Checkpoint streams.
TOutputStreamIdx
Output streams identifiers in k-Wave.
The header file containing the matrix container and the related matrix record class.
void CreateStreams()
Create all streams - opens the datasets.
void CloseStreams()
Close all streams.
A container for output streams.
void PostProcessStreams()
Post-process all streams and flush them to the file.