57 mSensorMask(sensorMask),
90 size_t actualPositionInBuffer = 0;
92 for (
size_t cuboidIdx = 0; cuboidIdx < nCuboids; cuboidIdx++)
141 size_t actualPositionInBuffer = 0;
146 for (
size_t cuboidIdx = 0; cuboidIdx < nCuboids; cuboidIdx++)
151 const std::string datasetName = std::to_string(cuboidIdx + 1);
199 for (
size_t cuboidIdx = 0; cuboidIdx <
mCuboidsInfo.size(); cuboidIdx++)
221 sampleAggregated<ReduceOperator::kRms>();
226 sampleAggregated<ReduceOperator::kMax>();
231 sampleAggregated<ReduceOperator::kMin>();
269 for (
size_t cuboidIdx = 0; cuboidIdx <
mCuboidsInfo.size(); cuboidIdx++)
314 cuboidChunkSize.
nz = nSlabs;
318 const std::string datasetName = std::to_string(cuboidIdx + 1);
338 template<BaseOutputStream::ReduceOperator reduceOp>
346 size_t cuboidInBufferStart = 0;
355 size_t cuboidSlabSize = (bottomRightCorner.
ny - topLeftCorner.
ny + 1) *
356 (bottomRightCorner.
nx - topLeftCorner.
nx + 1);
357 size_t cuboidRowSize = (bottomRightCorner.
nx - topLeftCorner.
nx + 1);
359 #pragma omp for collapse(3) 360 for (
size_t z = topLeftCorner.
nz; z <= bottomRightCorner.
nz; z++)
361 for (
size_t y = topLeftCorner.
ny; y <= bottomRightCorner.
ny; y++)
362 for (
size_t x = topLeftCorner.
nx; x <= bottomRightCorner.
nx; x++)
364 const size_t storeBufferIndex = cuboidInBufferStart +
365 (z - topLeftCorner.
nz) * cuboidSlabSize +
366 (y - topLeftCorner.
ny) * cuboidRowSize +
367 (x - topLeftCorner.
nx);
369 const size_t sourceIndex = z * slabSize + y * rowSize + x;
376 mStoreBuffer[storeBufferIndex] = sourceData[sourceIndex];
381 mStoreBuffer[storeBufferIndex] += (sourceData[sourceIndex] * sourceData[sourceIndex]);
399 cuboidInBufferStart += (bottomRightCorner - topLeftCorner).nElements();
415 for (
size_t cuboidIdx = 0; cuboidIdx <
mCuboidsInfo.size(); cuboidIdx++)
hid_t openDataset(const hid_t parentGroup, MatrixName &datasetName)
Open a dataset at a specified place in the file tree.
Calculate root mean square.
The class for real matrices.
virtual void freeMemory()
Free memory.
std::vector< CuboidInfo > mCuboidsInfo
vector keeping handles and positions of all cuboids.
virtual ~CuboidOutputStream()
Destructor.
virtual void flushBufferToFile()
Flush the buffer to the file.
size_t getCompressionLevel() const
Get compression level.
std::string mRootObjectName
HDF5 group/dataset in the output file where to store data in.
hid_t getRootGroup() const
Get handle to the root group of the file.
CuboidOutputStream()=delete
Default constructor not allowed.
size_t nz
Number of elements in the z direction.
size_t getNt() const
Get total number of time steps.
hid_t openGroup(const hid_t parentGroup, MatrixName &groupName)
Open a HDF5 group at a specified place in the file tree.
const IndexMatrix & mSensorMask
Sensor mask to sample data.
const ReduceOperator mReduceOp
Reduction operator.
void writeCuboidToHyperSlab(const hid_t dataset, const DimensionSizes &hyperslabPosition, const DimensionSizes &cuboidPosition, const DimensionSizes &cuboidSize, const DimensionSizes &matrixDimensions, const float *matrixData)
Write a cuboid selected within the matrixData into a hyperslab.
virtual void sample()
Sample data into buffer and apply reduction, or flush to disk - based on a sensor mask...
Class storing all parameters of the simulation.
virtual void allocateMemory()
Allocate memory using proper memory alignment.
virtual void postProcess()
Apply post-processing on the buffer and flush it to the file.
Store actual data (time series).
void sampleAggregated()
Sample aggregated values.
virtual void close()
Close stream (apply post-processing if necessary, flush data and close).
The header file containing the parameters of the simulation.
void writeMatrixDomainType(const hid_t parentGroup, MatrixName &datasetName, const MatrixDomainType &matrixDomainType)
Write matrix data type into the dataset at a specified place in the file tree.
void closeDataset(const hid_t dataset)
Close dataset.
size_t nt
Number of time steps (for time series datasets).
void writeMatrixDataType(const hid_t parentGroup, MatrixName &datasetName, const MatrixDataType &matrixDataType)
Write matrix data type into the dataset at a specified place in the file tree.
DimensionSizes getTopLeftCorner(const size_t &index) const
Get the top left corner of the index-th cuboid.
hid_t mGroup
Handle to a HDF5 dataset.
size_t getSamplingStartTimeIndex() const
Get start time index when sensor data collection begins.
hid_t createGroup(const hid_t parentGroup, MatrixName &groupName)
Create a HDF5 group at a specified place in the file tree.
The header file of classes responsible for storing output quantities based on the cuboid sensor mask ...
virtual const DimensionSizes & getDimensionSizes() const
Get dimension sizes of the matrix.
Class wrapping the HDF5 routines.
hid_t cuboidId
Id of the dataset storing the given cuboid.
size_t mBufferSize
Buffer size.
void writeHyperSlab(const hid_t dataset, const DimensionSizes &position, const DimensionSizes &size, const T *data)
Write a hyperslab into the dataset.
const std::string MatrixName
Datatype for matrix names.
Structure with 4D dimension sizes (3 in space and 1 in time).
size_t mSampledTimeStep
Timestep to store (N/A for aggregated).
virtual void checkpoint()
Checkpoint the stream and close.
The matrix is stored in floating point 32b wide format.
Hdf5File & mFile
Handle to HDF5 output file.
size_t ny
Number of elements in the y direction.
size_t getTimeIndex() const
Get actual simulation time step.
virtual void postProcess()
Apply post-processing on the buffer and flush it to the file.
void closeGroup(const hid_t group)
Close a group.
virtual void create()
Create a HDF5 stream and allocate data for it.
const RealMatrix & mSourceMatrix
Source matrix to be sampled.
size_t startingPossitionInBuffer
Having a single buffer for all cuboids, where this one starts.
DimensionSizes getBottomRightCorner(const size_t &index) const
Get the top bottom right of the index-th cuboid.
size_t nElements() const
Get the number of elements, in 3D only spatial domain, in 4D with time.
float * mStoreBuffer
Temporary buffer for store - only if Buffer Reuse = false!
ReduceOperator
How to aggregate data.
virtual float * getData()
Get raw data out of the class (for direct kernel access).
void readCompleteDataset(const hid_t parentGroup, MatrixName &datasetName, const DimensionSizes &dimensionSizes, T *data)
Read data from the dataset at a specified place in the file tree.
virtual hid_t createCuboidDataset(const size_t cuboidIdx)
Create a new dataset for a given cuboid specified by index (order).
virtual void reopen()
Reopen the output stream after restart and reload data.
size_t nx
Number of elements in the x direction.
static Parameters & getInstance()
Get instance of the singleton class.
virtual const DimensionSizes & getDimensionSizes() const
Get dimension sizes of the matrix.
This structure information about a HDF5 dataset (one cuboid).
The class for 64b unsigned integers (indices). It is used for linear and cuboid corners masks to get ...
hid_t createDataset(const hid_t parentGroup, MatrixName &datasetName, const DimensionSizes &dimensionSizes, const DimensionSizes &chunkSizes, const MatrixDataType matrixDataType, const size_t compressionLevel)
Create a float HDF5 dataset at a specified place in the file tree (3D/4D).
static constexpr size_t kChunkSize4MB
chunk size of 4MB in number of float elements.
Abstract base class for output data streams (sampled data).
The matrix is defined on real domain.
bool mBufferReuse
if true, the container reuses another matrix as scratch place, e.g. Temp_1_RS3D, Temp_2_RS3D, Temp_3_RS3D.
size_t getSizeOfAllCuboids() const
Get total number of elements in all cuboids to be able to allocate output file.