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 endianness)! 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

◆ VoxelFileReader() [1/4]

Constructs on empty geometry file.

Postcondition
isOpen() == false

◆ VoxelFileReader() [2/4]

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

◆ VoxelFileReader() [3/4]

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

◆ VoxelFileReader() [4/4]

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

◆ close()

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

◆ create() [1/2]

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

◆ create() [2/2]

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

◆ filename()

template<typename T >
const std::string & walberla::geometry::VoxelFileReader< T >::filename

Gets the filename of the opened geometry file.

Precondition
isOpen() == true
Returns
The filename of the opened geometry file.

◆ isOpen()

template<typename T >
bool walberla::geometry::VoxelFileReader< T >::isOpen

Query if a geometry file is open.

Returns
true if a file is opened, false if not.

◆ numCells()

template<typename T >
uint_t walberla::geometry::VoxelFileReader< T >::numCells

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

Precondition
isOpen() == true
Returns
xSize() * ySize() * zSize().

◆ open()

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

◆ read()

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()

◆ write()

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()

◆ xSize()

template<typename T >
uint_t walberla::geometry::VoxelFileReader< T >::xSize

Gets the extend of the geometry file in x direction.

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

◆ ySize()

template<typename T >
uint_t walberla::geometry::VoxelFileReader< T >::ySize

Gets the extend of the geometry file in y direction.

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

◆ zSize()

template<typename T >
uint_t walberla::geometry::VoxelFileReader< T >::zSize

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

◆ geometryFile_

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: