walberla::geometry::VoxelFileReader< T > Class Template Reference

Detailed Description

template<typename T>
class walberla::geometry::VoxelFileReader< T >

Provides a reader for waLBerla geometry files.

Note that the data is stored in binary form. There is no correction for other binary data representations on different architectures (e.g. different Endianess)! An opened file is automatically closed upon destruction.

Template Parameters
TThe underlying datatype that is stored in binary form in the geometry file

#include <VoxelFileReader.h>

Public Member Functions

 VoxelFileReader ()
 Constructs on empty geometry file. More...
 
 VoxelFileReader (const std::string &_filename)
 Opens an existing geometry file. More...
 
 VoxelFileReader (const std::string &_filename, uint_t _xSize, uint_t _ySize, uint_t _zSize, T value=T())
 Creates a new geometry file with extends xSize x ySize x zSize. More...
 
 VoxelFileReader (const std::string &_filename, uint_t _xSize, uint_t _ySize, uint_t _zSize, const T *values)
 Creates a new geometry file with extends xSize x ySize x zSize. More...
 
void open (const std::string &_filename)
 Opens an existing geometry file. More...
 
void create (const std::string &_filename, uint_t _xSize, uint_t _ySize, uint_t _zSize, T value=T())
 Creates a new geometry file with extends xSize x ySize x zSize. More...
 
void create (const std::string &_filename, uint_t _xSize, uint_t _ySize, uint_t _zSize, const T *values)
 Creates a new geometry file with extends xSize x ySize x zSize. More...
 
void close ()
 Closes an opened geometry file. More...
 
bool isOpen () const
 Query if a geometry file is open. More...
 
const std::string & filename () const
 Gets the filename of the opened geometry file. More...
 
uint_t numCells () const
 Gets the number of cells of the currently loaded geometry file. More...
 
uint_t xSize () const
 Gets the extend of the geometry file in x direction. More...
 
uint_t ySize () const
 Gets the extend of the geometry file in y direction. More...
 
uint_t zSize () const
 Gets the extend of the geometry file in z direction. More...
 
void read (const CellInterval &cellInterval, std::vector< T > &data) const
 Reads a block of data from the opened geometry file. More...
 
void write (const CellInterval &cellInterval, const std::vector< T > &data)
 Writes a block of data to the geometry file. More...
 

Private Attributes

BasicVoxelFileReader< T > geometryFile_
 The low-level geometry file reader. More...
 

Constructor & Destructor Documentation

template<typename T >
walberla::geometry::VoxelFileReader< T >::VoxelFileReader ( )

Constructs on empty geometry file.

Postcondition
isOpen() == false
template<typename T >
walberla::geometry::VoxelFileReader< T >::VoxelFileReader ( const std::string &  _filename)

Opens an existing geometry file.

Parameters
filenameName (path) of the file.
Postcondition
isOpen() == true
template<typename T >
walberla::geometry::VoxelFileReader< T >::VoxelFileReader ( const std::string &  _filename,
uint_t  _xSize,
uint_t  _ySize,
uint_t  _zSize,
value = T() 
)

Creates a new geometry file with extends xSize x ySize x zSize.

Parameters
filenameName (path) of the file.
xSizeExtend of the geometry file in x direction.
ySizeExtend of the geometry file in y direction.
zSizeExtend of the geometry file in z direction.
valueThe value the cells are initialized with. Defaults to T().
Postcondition
isOpen() == true
template<typename T >
walberla::geometry::VoxelFileReader< T >::VoxelFileReader ( const std::string &  _filename,
uint_t  _xSize,
uint_t  _ySize,
uint_t  _zSize,
const T *  values 
)

Creates a new geometry file with extends xSize x ySize x zSize.

Parameters
filenameName (path) of the file.
xSizeExtend of the geometry file in x direction.
ySizeExtend of the geometry file in y direction.
zSizeExtend of the geometry file in z direction.
valuesAn array of size xSize * ySize * zSize with the values to initialize the geometry file with.
Precondition
values != nullptr
Postcondition
isOpen() == true

Member Function Documentation

template<typename T >
void walberla::geometry::VoxelFileReader< T >::close ( )

Closes an opened geometry file.

If no geometry file is open, this does nothing.

Postcondition
isOpen() == false
template<typename T >
void walberla::geometry::VoxelFileReader< T >::create ( const std::string &  _filename,
uint_t  _xSize,
uint_t  _ySize,
uint_t  _zSize,
value = T() 
)

Creates a new geometry file with extends xSize x ySize x zSize.

An already opened file gets closed beforehand.

Parameters
filenameName (path) of the file.
xSizeExtend of the geometry file in x direction.
ySizeExtend of the geometry file in y direction.
zSizeExtend of the geometry file in z direction.
valueThe value the cells are initialized with. Defaults to T().
Postcondition
isOpen() == true
template<typename T >
void walberla::geometry::VoxelFileReader< T >::create ( const std::string &  _filename,
uint_t  _xSize,
uint_t  _ySize,
uint_t  _zSize,
const T *  values 
)

Creates a new geometry file with extends xSize x ySize x zSize.

An already opened file gets closed beforehand.

Parameters
filenameName (path) of the file.
xSizeExtend of the geometry file in x direction.
ySizeExtend of the geometry file in y direction.
zSizeExtend of the geometry file in z direction.
valuesAn array of size xSize * ySize * zSize with the values to initialize the geometry file with.
Precondition
values != nullptr
Postcondition
isOpen() == true
template<typename T >
const std::string & walberla::geometry::VoxelFileReader< T >::filename ( ) const

Gets the filename of the opened geometry file.

Precondition
isOpen() == true
Returns
The filename of the opened geometry file.
template<typename T >
bool walberla::geometry::VoxelFileReader< T >::isOpen ( ) const

Query if a geometry file is open.

Returns
true if a file is opened, false if not.
template<typename T >
uint_t walberla::geometry::VoxelFileReader< T >::numCells ( ) const

Gets the number of cells of the currently loaded geometry file.

Precondition
isOpen() == true
Returns
xSize() * ySize() * zSize().
template<typename T >
void walberla::geometry::VoxelFileReader< T >::open ( const std::string &  _filename)

Opens an existing geometry file.

An already opened file gets closed beforehand.

Parameters
filenameName (path) of the file.
Postcondition
isOpen() == true
template<typename T >
void walberla::geometry::VoxelFileReader< T >::read ( const CellInterval &  cellInterval,
std::vector< T > &  data 
) const

Reads a block of data from the opened geometry file.

Parameters
cellIntervalThe axis-aligned bounding box of the block of data to be read.
[out]dataThe vector the read data is stored to. The Storage order is zyx. (Meaning your innermost loop should iterate over x)
Precondition
isOpen() == true
Postcondition
data.size() == cellAABB.numCells()
template<typename T >
void walberla::geometry::VoxelFileReader< T >::write ( const CellInterval &  cellInterval,
const std::vector< T > &  data 
)

Writes a block of data to the geometry file.

Parameters
cellIntervalThe axis-aligned bounding box of the block of data to be written.
dataThe vector holding the data to bw written to the geometry file. The Storage order is zyx. (Meaning your innermost loop should iterate over x)
Precondition
isOpen() == true
!cellInterval.empty()
cellInterval.positiveIndicesOnly()
data.size() >= cellAABB.numCells()
template<typename T >
uint_t walberla::geometry::VoxelFileReader< T >::xSize ( ) const

Gets the extend of the geometry file in x direction.

Precondition
isOpen() == true
Returns
The extend of the geometry file in x direction.
template<typename T >
uint_t walberla::geometry::VoxelFileReader< T >::ySize ( ) const

Gets the extend of the geometry file in y direction.

Precondition
isOpen() == true
Returns
The extend of the geometry file in y direction.
template<typename T >
uint_t walberla::geometry::VoxelFileReader< T >::zSize ( ) const

Gets the extend of the geometry file in z direction.

Precondition
isOpen() == true
Returns
The extend of the geometry file in z direction.

Member Data Documentation

template<typename T >
BasicVoxelFileReader<T> walberla::geometry::VoxelFileReader< T >::geometryFile_
private

The low-level geometry file reader.


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