NLMech  0.1.0
rw::reader::VtkReader Class Reference

A class to read VTK (.vtu) mesh files. More...

#include <vtkReader.h>

Collaboration diagram for rw::reader::VtkReader:
Collaboration graph

Public Member Functions

void close ()
 Close the file.
 
bool readCellData (const std::string &name, std::vector< double > *data)
 reads cell data from .vtu file More...
 
bool readCellData (const std::string &name, std::vector< float > *data)
 reads cell data from .vtu file More...
 
bool readCellData (const std::string &name, std::vector< util::Matrix33 > *data)
 reads cell data from .vtu file More...
 
bool readCellData (const std::string &name, std::vector< util::Point3 > *data)
 reads cell data from .vtu file More...
 
bool readCellData (const std::string &name, std::vector< util::SymMatrix3 > *data)
 reads cell data from .vtu file More...
 
void readCells (size_t dim, size_t &element_type, size_t &num_elem, std::vector< size_t > *enc, std::vector< std::vector< size_t >> *nec)
 Reads cell data, i.e. element-node connectivity and node-element connectivity. More...
 
void readMesh (size_t dim, std::vector< util::Point3 > *nodes, size_t &element_type, size_t &num_elem, std::vector< size_t > *enc, std::vector< std::vector< size_t >> *nec, std::vector< double > *volumes, bool is_fd=false)
 Reads mesh data into node file and element file. More...
 
void readNodes (std::vector< util::Point3 > *nodes)
 Reads nodal position. More...
 
bool readPointData (const std::string &name, std::vector< double > *data)
 reads point data from .vtu file More...
 
bool readPointData (const std::string &name, std::vector< float > *data)
 reads point data from .vtu file More...
 
bool readPointData (const std::string &name, std::vector< int > *data)
 reads point data from .vtu file More...
 
bool readPointData (const std::string &name, std::vector< size_t > *data)
 reads point data from .vtu file More...
 
bool readPointData (const std::string &name, std::vector< uint8_t > *data)
 reads point data from .vtu file More...
 
bool readPointData (const std::string &name, std::vector< util::Matrix33 > *data)
 reads point data from .vtu file More...
 
bool readPointData (const std::string &name, std::vector< util::Point3 > *data)
 reads point data from .vtu file More...
 
bool readPointData (const std::string &name, std::vector< util::SymMatrix3 > *data)
 reads point data from .vtu file More...
 
std::vector< std::string > readVtuFileCellTags ()
 Reads all cell data tags. More...
 
std::vector< std::string > readVtuFilePointTags ()
 Reads all point data tags. More...
 
 VtkReader (const std::string &filename)
 Constructor. More...
 
bool vtuHasCellData (const std::string &data_tag)
 Checks if file has needed data. More...
 
bool vtuHasPointData (const std::string &data_tag)
 Checks if file has needed data. More...
 

Private Attributes

vtkSmartPointer< vtkUnstructuredGrid > d_grid_p
 Unstructured grid.
 
vtkSmartPointer< vtkXMLUnstructuredGridReader > d_reader_p
 XML unstructured grid writer.
 

Static Private Attributes

static size_t d_count = 0
 Counter.
 

Detailed Description

A class to read VTK (.vtu) mesh files.

Note
Depends on VTK library.

Constructor & Destructor Documentation

◆ VtkReader()

rw::reader::VtkReader::VtkReader ( const std::string &  filename)
explicit

Constructor.

Parameters
filenameName of mesh file
Note
filename is expected to have .vtu extension

Member Function Documentation

◆ readCellData() [1/5]

bool rw::reader::VtkReader::readCellData ( const std::string &  name,
std::vector< double > *  data 
)

reads cell data from .vtu file

Parameters
nameName of data
dataPointer to the vector of data
Returns
status True if data is found otherwise false

◆ readCellData() [2/5]

bool rw::reader::VtkReader::readCellData ( const std::string &  name,
std::vector< float > *  data 
)

reads cell data from .vtu file

Parameters
nameName of data
dataPointer to the vector of data
Returns
status True if data is found otherwise false

◆ readCellData() [3/5]

bool rw::reader::VtkReader::readCellData ( const std::string &  name,
std::vector< util::Matrix33 > *  data 
)

reads cell data from .vtu file

Parameters
nameName of data
dataPointer to the vector of data
Returns
status True if data is found otherwise false

◆ readCellData() [4/5]

bool rw::reader::VtkReader::readCellData ( const std::string &  name,
std::vector< util::Point3 > *  data 
)

reads cell data from .vtu file

Parameters
nameName of data
dataPointer to the vector of data
Returns
status True if data is found otherwise false

◆ readCellData() [5/5]

bool rw::reader::VtkReader::readCellData ( const std::string &  name,
std::vector< util::SymMatrix3 > *  data 
)

reads cell data from .vtu file

Parameters
nameName of data
dataPointer to the vector of data
Returns
status True if data is found otherwise false

◆ readCells()

void rw::reader::VtkReader::readCells ( size_t  dim,
size_t &  element_type,
size_t &  num_elem,
std::vector< size_t > *  enc,
std::vector< std::vector< size_t >> *  nec 
)

Reads cell data, i.e. element-node connectivity and node-element connectivity.

Parameters
dimDimension
element_typeType of element
num_elemNumber of elements
encElement-node connectivity
necNode-element connectivity

◆ readMesh()

void rw::reader::VtkReader::readMesh ( size_t  dim,
std::vector< util::Point3 > *  nodes,
size_t &  element_type,
size_t &  num_elem,
std::vector< size_t > *  enc,
std::vector< std::vector< size_t >> *  nec,
std::vector< double > *  volumes,
bool  is_fd = false 
)

Reads mesh data into node file and element file.

Parameters
dimDimension
nodesVector of nodes data
element_typeType of element
num_elemNumber of elements
encVector holding element-node connectivity
necVector holding node-element connectivity
volumesVector holding volume of the nodes
is_fdFlag indicating if this mesh is for finite_difference simulation

◆ readNodes()

void rw::reader::VtkReader::readNodes ( std::vector< util::Point3 > *  nodes)

Reads nodal position.

Parameters
nodesVector of nodal coordinates

◆ readPointData() [1/8]

bool rw::reader::VtkReader::readPointData ( const std::string &  name,
std::vector< double > *  data 
)

reads point data from .vtu file

Parameters
nameName of data
dataPointer to the vector of data
Returns
status True if data is found otherwise false

◆ readPointData() [2/8]

bool rw::reader::VtkReader::readPointData ( const std::string &  name,
std::vector< float > *  data 
)

reads point data from .vtu file

Parameters
nameName of data
dataPointer to the vector of data
Returns
status True if data is found otherwise false

◆ readPointData() [3/8]

bool rw::reader::VtkReader::readPointData ( const std::string &  name,
std::vector< int > *  data 
)

reads point data from .vtu file

Parameters
nameName of data
dataPointer to the vector of data
Returns
status True if data is found otherwise false

◆ readPointData() [4/8]

bool rw::reader::VtkReader::readPointData ( const std::string &  name,
std::vector< size_t > *  data 
)

reads point data from .vtu file

Parameters
nameName of data
dataPointer to the vector of data
Returns
status True if data is found otherwise false

◆ readPointData() [5/8]

bool rw::reader::VtkReader::readPointData ( const std::string &  name,
std::vector< uint8_t > *  data 
)

reads point data from .vtu file

Parameters
nameName of data
dataPointer to the vector of data
Returns
status True if data is found otherwise false

◆ readPointData() [6/8]

bool rw::reader::VtkReader::readPointData ( const std::string &  name,
std::vector< util::Matrix33 > *  data 
)

reads point data from .vtu file

Parameters
nameName of data
dataPointer to the vector of data
Returns
status True if data is found otherwise false

◆ readPointData() [7/8]

bool rw::reader::VtkReader::readPointData ( const std::string &  name,
std::vector< util::Point3 > *  data 
)

reads point data from .vtu file

Parameters
nameName of data
dataPointer to the vector of data
Returns
status True if data is found otherwise false

◆ readPointData() [8/8]

bool rw::reader::VtkReader::readPointData ( const std::string &  name,
std::vector< util::SymMatrix3 > *  data 
)

reads point data from .vtu file

Parameters
nameName of data
dataPointer to the vector of data
Returns
status True if data is found otherwise false

◆ readVtuFileCellTags()

std::vector< std::string > rw::reader::VtkReader::readVtuFileCellTags ( )

Reads all cell data tags.

Returns
List List of point data tags

◆ readVtuFilePointTags()

std::vector< std::string > rw::reader::VtkReader::readVtuFilePointTags ( )

Reads all point data tags.

Returns
List List of point data tags

◆ vtuHasCellData()

bool rw::reader::VtkReader::vtuHasCellData ( const std::string &  data_tag)

Checks if file has needed data.

Parameters
data_tagTag name of data
Returns
True If file has data otherwise false

◆ vtuHasPointData()

bool rw::reader::VtkReader::vtuHasPointData ( const std::string &  data_tag)

Checks if file has needed data.

Parameters
data_tagTag name of data
Returns
True If file has data otherwise false

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