48 std::string dName,
const std::string class_name )
49 : clout(class_name), _dim(dim), _size(0), _origin(_dim, 0), _extent(_dim, 0),
50 _delta(0), _xmlReader(fName), _nCuboids(0)
57 std::stringstream stream_val_1(
_xmlReader[
"ImageData"].getAttribute(
"Spacing"));
61 std::stringstream stream_val_2(
_xmlReader[
"ImageData"].getAttribute(
"Origin"));
62 for (
auto& origin_i :
_origin) {
63 stream_val_2 >> origin_i;
67 for (
auto& piece :
_xmlReader[
"ImageData"] ) {
68 if (piece->getName() ==
"Piece") {
71 for (
auto &dataArray : (*piece)[
"PointData"]) {
72 if (dataArray->getAttribute(
"Name") == dName && dataArray->getName() ==
"DataArray") {
86 clout <<
"Information on VTIreader Data:" << std::endl;
88 for (
auto& origin_i : _origin) {
89 clout << origin_i <<
" ";
94 for (
auto& extend_i : _extent) {
95 clout << extend_i <<
" ";
99 clout <<
"Spacing: " << _delta << std::endl;
107 std::stringstream extstr(reader->
getAttribute(extAttrName));
108 std::vector<int> extents;
110 for (
int i = 0; i < 2 * _dim; ++i) {
112 extents.push_back(tmp);
121 std::vector<int> nNodes;
122 for (
int i = 0; i < _dim; i++ ) {
123 nNodes.push_back(extents[ 2*i + 1 ] - extents[ 2* i ] + 1);
132 int size = std::atoi((tag.
getAttribute(
"NumberOfComponents")).c_str());
134 clout <<
"VTI READER: NumberOfComponents zero or not given!" << std::endl;
135 clout <<
"EXAMPLE: <DataArray Name='physVelocity' NumberOfComponents='3'" << std::endl;
144template<
typename T,
typename BaseType>
146 const std::string class_name)
151template<
typename T,
typename BaseType>
154 if (piece->
getName() ==
"Piece") {
155 std::vector<int> extents = this->readExtent(piece,
"Extent");
156 std::vector<int> extent = this->getNbNodes(extents);
158 cuboid.
init(extents[0] * this->_delta,
159 extents[2] * this->_delta,
160 extents[4] * this->_delta,
168template<
typename T,
typename BaseType>
170 const XMLreader& pieceTag,
const std::string dName)
175 std::vector<int> extents = this->readExtent(&pieceTag,
"Extent");
176 std::vector<int> extent = this->getNbNodes(extents);
179 for (
auto & dataArray : pieceTag[
"PointData"]) {
180 if (dataArray->getAttribute(
"Name") == dName && dataArray->getName() ==
"DataArray") {
181 std::string data_str;
182 if (dataArray->read(data_str)) {
183 std::stringstream stream_val(data_str);
186 for (
int iz = 0; iz < blockData.
getNz(); iz++) {
187 for (
int iy = 0; iy < blockData.
getNy(); iy++) {
188 for (
int ix = 0; ix < blockData.
getNx(); ix++) {
189 for (
unsigned iSize=0; iSize < blockData.
getSize(); iSize++) {
193 blockData.
get({ix, iy, iz}, iSize) = tmp;
212template<
typename T,
typename BaseType>
215 _cuboid(this->_origin, this->_delta, this->_extent),
216 _blockData(_cuboid, 0, this->_size)
223template<
typename T,
typename BaseType>
229template<
typename T,
typename BaseType>
238template<
typename T,
typename BaseType>
241 delete _loadBalancer;
246template<
typename T,
typename BaseType>
250 this->
clout <<
"Start reading \"" << fName <<
"\"... "
251 <<
"(" << this->
_nCuboids <<
" cuboids)" << std::endl;
256 this->
clout <<
"* Reading Cuboid Geometry..." << std::endl;
259 readCuboidGeometry();
261 _cGeometry->printExtended();
269 this->
clout <<
"* Reading BlockData..." << std::endl;
272 readSuperData(dName);
274 this->
clout <<
"VTI Reader finished." << std::endl;
277template<
typename T,
typename BaseType>
281 for (
auto& piece : this->_xmlReader[
"ImageData"] ) {
282 if (piece->getName() ==
"Piece") {
283 std::vector<int> extents = this->readExtent(piece,
"Extent");
284 std::vector<int> extent = this->getNbNodes(extents);
287 extents[2] * this->_delta,
288 extents[4] * this->_delta,
293 _cGeometry->add(cuboid);
298template<
typename T,
typename BaseType>
299void SuperVTIreader3D<T,BaseType>::readSuperData(
const std::string dName)
303 for (
auto & piece : this->_xmlReader[
"ImageData"]) {
304 if (piece->getName() ==
"Piece") {
305 this->readBlockData(_superData->getBlock(counter), *piece, dName);
311template<
typename T,
typename BaseType>
317template<
typename T,
typename BaseType>
323template<
typename T,
typename BaseType>
326 return *_loadBalancer;
BaseVTIreader3D(const std::string &fName, std::string dName, const std::string class_name="BaseVTIreader3D")
bool readBlockData(BlockData< 3, T, BaseType > &blockData, const XMLreader &pointDataTag, const std::string dName)
Reads from pointDataTag and fills blockData.
void readCuboid(Cuboid3D< T > &cuboid, XMLreader *piece)
Reads cuboid from piece node.
std::vector< int > getNbNodes(std::vector< int > &extents)
Converts 4D (or 6D) extents vector into 2D (3D) nb_nodes vector.
int _size
Size of Data Field.
std::vector< int > readExtent(const XMLreader *reader, std::string extAttrName)
Reads Extent from extAttrName from XML Tag and returns as vector.
std::vector< int > _extent
BaseVTIreader(const std::string &fName, int dim, std::string dName, const std::string class_name="BaseVTIreader")
int getSize(const XMLreader &tag)
Reads size from XML tag (attribute "NumberOfComponents")
U & get(std::size_t iCell, int iD=0)
int getNy() const
Read only access to block height.
int getNx() const
Read only access to block width.
int getNz() const
Read only access to block height.
Cuboid3D< T > & getCuboid()
BlockVTIreader3D(const std::string &fName, const std::string &dName)
BlockData< 3, T, BaseType > _blockData
BlockData< 3, T, BaseType > & getBlockData()
A regular single 3D cuboid is the basic component of a 3D cuboid structure which defines the grid.
void init(T globPosX, T globPosY, T globPosZ, T delta, int nX, int nY, int nZ)
Initializes the cuboid.
A cuboid geometry represents a voxel mesh.
Constructs a load balancer from a given cuboid geometry using a heurist.
Base class for all LoadBalancer.
~SuperVTIreader3D() override
LoadBalancer< T > & getLoadBalancer()
SuperData< 3, T, BaseType > & getSuperData()
SuperVTIreader3D(const std::string &fName, const std::string dName)
CuboidGeometry3D< T > & getCuboidGeometry()
std::string getAttribute(const std::string &aName) const
std::string getName() const
return the name of the element
The description of a single 2D cuboid – header file.
Top level namespace for all of OpenLB.
typename util::BaseTypeHelper< T >::type BaseType
The VTI reader is able to read from VTI files and create and fill corresponding data structures.