kspaceFirstOrder3D-OMP  1.2
The C++ implementation of the k-wave toolbox for the time-domain simulation of acoustic wave fields in 3D
IndexMatrix Class Reference

The class for 64b unsigned integers (indices). It is used for linear and cuboid corners masks to get the address of sampled voxels. More...

#include <IndexMatrix.h>

Inheritance diagram for IndexMatrix:
Collaboration diagram for IndexMatrix:

Public Member Functions

 IndexMatrix ()=delete
 Default constructor not allowed.
 
 IndexMatrix (const DimensionSizes &dimensionSizes)
 Constructor. More...
 
 IndexMatrix (const IndexMatrix &)=delete
 Copy constructor not allowed.
 
virtual ~IndexMatrix ()
 Destructor. More...
 
IndexMatrixoperator= (const IndexMatrix &)
 Operator= is not allowed.
 
virtual void readData (Hdf5File &file, MatrixName &matrixName)
 Read matrix from HDF5 file. More...
 
virtual void writeData (Hdf5File &file, MatrixName &matrixName, const size_t compressionLevel)
 Write data into HDF5 file. More...
 
size_t & operator[] (const size_t &index)
 operator []. More...
 
const size_t & operator[] (const size_t &index) const
 operator [], constant version. More...
 
DimensionSizes getTopLeftCorner (const size_t &index) const
 Get the top left corner of the index-th cuboid. More...
 
DimensionSizes getBottomRightCorner (const size_t &index) const
 Get the top bottom right of the index-th cuboid. More...
 
void recomputeIndicesToCPP ()
 Recompute indices MATALAB->C++. More...
 
void recomputeIndicesToMatlab ()
 Recompute indices C++ -> MATLAB. More...
 
size_t getSizeOfAllCuboids () const
 Get total number of elements in all cuboids to be able to allocate output file. More...
 
- Public Member Functions inherited from BaseIndexMatrix
 BaseIndexMatrix ()
 Default constructor. More...
 
 BaseIndexMatrix (const BaseIndexMatrix &)=delete
 Copy constructor is not allowed.
 
virtual ~BaseIndexMatrix ()
 Destructor.
 
BaseIndexMatrixoperator= (const BaseIndexMatrix &)=delete
 operator= is not allowed.
 
virtual const DimensionSizesgetDimensionSizes () const
 Get dimension sizes of the matrix. More...
 
virtual size_t size () const
 Size of the matrix. More...
 
virtual size_t capacity () const
 The capacity of the matrix (this may differ from size due to padding, etc.). More...
 
virtual void zeroMatrix ()
 Zero all elements of the matrix (NUMA first touch). More...
 
virtual size_t * getData ()
 Get raw data out of the class (for direct kernel access). More...
 
virtual const size_t * getData () const
 Get raw data out of the class (for direct kernel access), const version. More...
 
- Public Member Functions inherited from BaseMatrix
 BaseMatrix ()
 Default constructor.
 
 BaseMatrix (const BaseMatrix &)=delete
 Copy constructor is not allowed.
 
virtual ~BaseMatrix ()
 Destructor.
 
BaseMatrixoperator= (const BaseMatrix &)=delete
 Operator= is not allowed.
 

Private Member Functions

void initDimensions (const DimensionSizes &dimensionSizes)
 Init dimension. More...
 

Static Private Attributes

static constexpr size_t kChunkSize1D4MB = 1048576
 Number of elements to get 4MB block of data.
 
static constexpr size_t kChunkSize1D1MB = 262144
 Number of elements to get 1MB block of data.
 
static constexpr size_t kChunkSize1D256kB = 65536
 Number of elements to get 256KB block of data.
 

Additional Inherited Members

- Protected Member Functions inherited from BaseIndexMatrix
virtual void allocateMemory ()
 Aligned memory allocation (both on CPU and GPU). More...
 
virtual void freeMemory ()
 Memory deallocation (both on CPU and GPU) More...
 
- Protected Attributes inherited from BaseIndexMatrix
size_t mSize
 Total number of elements.
 
size_t mCapacity
 Total number of allocated elements (in terms of size_t).
 
DimensionSizes mDimensionSizes
 Dimension sizes.
 
size_t mRowSize
 Size of 1D row in X dimension.
 
size_t mSlabSize
 Size of a XY slab.
 
size_t * mData
 Raw matrix data.
 

Detailed Description

The class for 64b unsigned integers (indices). It is used for linear and cuboid corners masks to get the get the address of sampled voxels.

Definition at line 47 of file IndexMatrix.h.

Constructor & Destructor Documentation

◆ IndexMatrix()

IndexMatrix::IndexMatrix ( const DimensionSizes dimensionSizes)
Parameters
[in]dimensionSizes- Dimension sizes of the matrix.

Constructor allocating memory.

Definition at line 50 of file IndexMatrix.cpp.

◆ ~IndexMatrix()

IndexMatrix::~IndexMatrix ( )
virtual

Destructor.

Definition at line 61 of file IndexMatrix.cpp.

Member Function Documentation

◆ getBottomRightCorner()

DimensionSizes IndexMatrix::getBottomRightCorner ( const size_t &  index) const
Parameters
[in]index- Index of the cuboid
Returns
The bottom right corner

Get the top bottom right of the index-th cuboid. Cuboids are stored as 6-tuples (two 3D coordinates). This gives the first three coordinates. This routine works only on the CPU side.

Definition at line 156 of file IndexMatrix.cpp.

◆ getSizeOfAllCuboids()

size_t IndexMatrix::getSizeOfAllCuboids ( ) const
Returns
Total sampled grid points

Get total number of elements in all cuboids to be able to allocate output file.

Definition at line 195 of file IndexMatrix.cpp.

◆ getTopLeftCorner()

DimensionSizes IndexMatrix::getTopLeftCorner ( const size_t &  index) const
Parameters
[in]index- Index of the cuboid
Returns
The top left corner

Get the top left corner of the index-th cuboid. Cuboids are stored as 6-tuples (two 3D coordinates). This gives the first three coordinates.

Definition at line 142 of file IndexMatrix.cpp.

◆ initDimensions()

void IndexMatrix::initDimensions ( const DimensionSizes dimensionSizes)
private

Set necessary dimensions and auxiliary variables.

Definition at line 218 of file IndexMatrix.cpp.

◆ operator[]() [1/2]

size_t& IndexMatrix::operator[] ( const size_t &  index)
inline
Parameters
[in]index- 1D index into the matrix.
Returns
An element of the matrix.

Definition at line 92 of file IndexMatrix.h.

◆ operator[]() [2/2]

const size_t& IndexMatrix::operator[] ( const size_t &  index) const
inline
Parameters
[in]index- 1D index into the matrix.
Returns
An element of the matrix.

Definition at line 98 of file IndexMatrix.h.

◆ readData()

void IndexMatrix::readData ( Hdf5File file,
MatrixName matrixName 
)
virtual

Read matrix from HDF5 file.

Parameters
[in]file- Handle to the HDF5 file
[in]matrixName- HDF5 dataset name to read from
Exceptions
ios::failure- If error occurred.

Read data from HDF5 file (only from the root group).

Implements BaseMatrix.

Definition at line 70 of file IndexMatrix.cpp.

◆ recomputeIndicesToCPP()

void IndexMatrix::recomputeIndicesToCPP ( )

Recompute indeces, MATLAB -> C++.

Definition at line 169 of file IndexMatrix.cpp.

◆ recomputeIndicesToMatlab()

void IndexMatrix::recomputeIndicesToMatlab ( )

Recompute indeces, C++ -> MATLAB.

Definition at line 182 of file IndexMatrix.cpp.

◆ writeData()

void IndexMatrix::writeData ( Hdf5File file,
MatrixName matrixName,
const size_t  compressionLevel 
)
virtual

Write data into HDF5 file.

Parameters
[in]file- Handle to the HDF5 file
[in]matrixName- HDF5 dataset name to write to
[in]compressionLevel- Compression level for the HDF5 dataset
Exceptions
ios::failure- If an error occurred.

Write data to HDF5 file.

Implements BaseMatrix.

Definition at line 94 of file IndexMatrix.cpp.


The documentation for this class was generated from the following files: