OpenLB 1.7
Loading...
Searching...
No Matches
Public Member Functions | Protected Member Functions | List of all members
olb::BaseVTIreader3D< T, BaseType > Class Template Reference

#include <vtiReader.h>

+ Inheritance diagram for olb::BaseVTIreader3D< T, BaseType >:
+ Collaboration diagram for olb::BaseVTIreader3D< T, BaseType >:

Public Member Functions

 BaseVTIreader3D (const std::string &fName, std::string dName, const std::string class_name="BaseVTIreader3D")
 
 ~BaseVTIreader3D () override
 
- Public Member Functions inherited from olb::BaseVTIreader< T >
 BaseVTIreader (const std::string &fName, int dim, std::string dName, const std::string class_name="BaseVTIreader")
 
virtual ~BaseVTIreader ()
 
void printInfo ()
 

Protected Member Functions

void readCuboid (Cuboid3D< T > &cuboid, XMLreader *piece)
 Reads cuboid from piece node.
 
bool readBlockData (BlockData< 3, T, BaseType > &blockData, const XMLreader &pointDataTag, const std::string dName)
 Reads from pointDataTag and fills blockData.
 
- Protected Member Functions inherited from olb::BaseVTIreader< T >
std::vector< int > readExtent (const XMLreader *reader, std::string extAttrName)
 Reads Extent from extAttrName from XML Tag and returns as vector.
 
std::vector< int > getNbNodes (std::vector< int > &extents)
 Converts 4D (or 6D) extents vector into 2D (3D) nb_nodes vector.
 
int getSize (const XMLreader &tag)
 Reads size from XML tag (attribute "NumberOfComponents")
 

Additional Inherited Members

- Protected Attributes inherited from olb::BaseVTIreader< T >
OstreamManager clout
 
int _dim
 
int _size
 Size of Data Field.
 
std::vector< T > _origin
 
std::vector< int > _extent
 
_delta
 
XMLreader _xmlReader
 
int _nCuboids
 

Detailed Description

template<typename T, typename BaseType>
class olb::BaseVTIreader3D< T, BaseType >

Definition at line 109 of file vtiReader.h.

Constructor & Destructor Documentation

◆ BaseVTIreader3D()

template<typename T , typename BaseType >
olb::BaseVTIreader3D< T, BaseType >::BaseVTIreader3D ( const std::string & fName,
std::string dName,
const std::string class_name = "BaseVTIreader3D< T, BaseType >" )

Definition at line 145 of file vtiReader.hh.

147 : BaseVTIreader<T>(fName, 3, dName, class_name)
148{
149}

◆ ~BaseVTIreader3D()

template<typename T , typename BaseType >
olb::BaseVTIreader3D< T, BaseType >::~BaseVTIreader3D ( )
inlineoverride

Definition at line 113 of file vtiReader.h.

113{};

Member Function Documentation

◆ readBlockData()

template<typename T , typename BaseType >
bool olb::BaseVTIreader3D< T, BaseType >::readBlockData ( BlockData< 3, T, BaseType > & blockData,
const XMLreader & pointDataTag,
const std::string dName )
protected

Reads from pointDataTag and fills blockData.

Definition at line 169 of file vtiReader.hh.

171{
172 /*** This is the main data reader method. All other methods use this one for accessing data ***/
173
174 // Calculate number of cells in each direction
175 std::vector<int> extents = this->readExtent(&pieceTag, "Extent");
176 std::vector<int> extent = this->getNbNodes(extents);
177
178 // Iterate through all <DataArray> tags and take the one with the given Name attribute
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);
184
185 // Careful: respect ordering in VTI File
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++) {
190 BaseType tmp;
191 stream_val >> tmp;
192 // write tmp into blockData
193 blockData.get({ix, iy, iz}, iSize) = tmp;
194 }
195 }
196 }
197 }
198 }
199
200 // set correct blockData Name (GenericF)
201 // blockData.getName() = dName;
202
203 return true;
204 }
205 }
206 return false;
207}
std::vector< int > getNbNodes(std::vector< int > &extents)
Converts 4D (or 6D) extents vector into 2D (3D) nb_nodes vector.
Definition vtiReader.hh:118
std::vector< int > readExtent(const XMLreader *reader, std::string extAttrName)
Reads Extent from extAttrName from XML Tag and returns as vector.
Definition vtiReader.hh:103
unsigned getSize() const
Definition blockData.hh:118
U & get(std::size_t iCell, int iD=0)
Definition blockData.hh:94
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.
typename util::BaseTypeHelper< T >::type BaseType
Definition baseType.h:59

References olb::BlockData< D, T, U >::get(), olb::BlockStructureD< D >::getNx(), olb::BlockStructureD< D >::getNy(), olb::BlockStructureD< D >::getNz(), and olb::BlockData< D, T, U >::getSize().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ readCuboid()

template<typename T , typename BaseType >
void olb::BaseVTIreader3D< T, BaseType >::readCuboid ( Cuboid3D< T > & cuboid,
XMLreader * piece )
protected

Reads cuboid from piece node.

Definition at line 152 of file vtiReader.hh.

153{
154 if (piece->getName() == "Piece") {
155 std::vector<int> extents = this->readExtent(piece, "Extent");
156 std::vector<int> extent = this->getNbNodes(extents);
157 // int extents[i] is node number => multiply with _delta to get coordinate
158 cuboid.init(extents[0] * this->_delta,
159 extents[2] * this->_delta,
160 extents[4] * this->_delta,
161 this->_delta,
162 extent[0],
163 extent[1],
164 extent[2]);
165 }
166}

References olb::XMLreader::getName(), and olb::Cuboid3D< T >::init().

+ Here is the call graph for this function:

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