Public Member Functions | Protected Types | Protected Member Functions | Protected Attributes

vtk_reader< DomainType > Class Template Reference

A VTK reader class that allows to read meshes from XML-based VTK files as defined in http://www.vtk.org/pdf/file-formats.pdf. More...

#include <vtk_reader.hpp>

Public Member Functions

int operator() (DomainType &domain, std::string const &filename)
 Triggers the read process.
std::vector< std::string > scalar_vertex_data_names (std::size_t segment_id) const
 Returns the data names of all scalar vertex data read.
std::vector< std::string > vector_vertex_data_names (std::size_t segment_id) const
 Returns the data names of all vector vertex data read.
std::vector< std::string > scalar_cell_data_names (std::size_t segment_id) const
 Returns the data names of all scalar cell data read.
std::vector< std::string > vector_cell_data_names (std::size_t segment_id) const
 Returns the data names of all vector cell data read.
template<typename T >
void add_scalar_data_on_vertices (T const &accessor, std::string name)
 Specify a special handling of scalar-valued data for vertices. Prefer the free function add_vector_data_on_vertices().
template<typename T >
void add_vector_data_on_vertices (T const &accessor, std::string name)
 Specify a special handling of vector-valued data for vertices. Prefer the free function add_vector_data_on_vertices().
template<typename T >
void add_normal_data_on_vertices (T const &accessor, std::string name)
 Specify a special handling of vector-valued (normal) data for vertices. Prefer the free function add_normal_data_on_vertices().
template<typename T >
void add_scalar_data_on_cells (T const &accessor, std::string name)
 Specify a special handling of scalar-valued data for cells. Prefer the free function add_scalar_data_on_cells().
template<typename T >
void add_vector_data_on_cells (T const &accessor, std::string name)
 Specify a special handling of vector-valued data for cells. Prefer the free function add_vector_data_on_cells().
template<typename T >
void add_normal_data_on_cells (T const &accessor, std::string name)
 Specify a special handling of vector-valued data (normals) for cells. Prefer the free function add_normal_data_on_cells().
std::vector< std::pair
< std::size_t, std::string >
> const & 
get_scalar_data_on_vertices () const
 Returns the names of all scalar-valued data read for vertices.
std::vector< std::pair
< std::size_t, std::string >
> const & 
get_vector_data_on_vertices () const
 Returns the names of all vector-valued data read for vertices.
std::vector< std::pair
< std::size_t, std::string >
> const & 
get_scalar_data_on_cells () const
 Returns the names of all scalar-valued data read for cells.
std::vector< std::pair
< std::size_t, std::string >
> const & 
get_vector_data_on_cells () const
 Returns the names of all vector-valued data read for cells.

Protected Types

typedef DomainType::config_type DomainConfiguration
typedef
DomainConfiguration::numeric_type 
CoordType
typedef
DomainConfiguration::coordinate_system_tag 
CoordinateSystemTag
typedef
DomainConfiguration::cell_tag 
CellTag
typedef result_of::point
< DomainConfiguration >::type 
PointType
typedef result_of::ncell
< DomainConfiguration, 0 >
::type 
VertexType
typedef result_of::ncell
< DomainConfiguration,
CellTag::dim >::type 
CellType
typedef
viennagrid::result_of::ncell_range
< DomainType, 0 >::type 
VertexRange
typedef
viennagrid::result_of::iterator
< VertexRange >::type 
VertexIterator
typedef
viennagrid::result_of::ncell_range
< DomainType, 1 >::type 
EdgeRange
typedef
viennagrid::result_of::iterator
< EdgeRange >::type 
EdgeIterator
typedef
viennagrid::result_of::ncell_range
< DomainType, CellTag::dim-1 >
::type 
FacetRange
typedef
viennagrid::result_of::iterator
< FacetRange >::type 
FacetIterator
typedef
viennagrid::result_of::ncell_range
< DomainType, CellTag::dim >
::type 
CellRange
typedef
viennagrid::result_of::iterator
< CellRange >::type 
CellIterator

Protected Member Functions

void openFile (std::string const &filename)
 Opens a file.
void closeFile ()
 Closes a file.
bool lowercase_compare (std::string const &s1, std::string const &s2)
 compares the lower-case representation of two strings
void checkNextToken (std::string const &expectedToken)
 Make sure that the next token is given by 'expectedToken'. Throws a bad_file_format_exception if this is not the case.
void readNodeCoordinates (long nodeNum, long numberOfComponents, std::size_t seg_id)
 Reads the coordinates of the points/vertices in the domain.
void readCellIndices (std::size_t seg_id)
 Reads the vertex indices of the cells inside the domain.
void readOffsets (std::size_t seg_id)
 Read the cell offsets for the vertex indices.
void readTypes ()
 Read the types of each cell.
void readData (std::deque< double > &container)
 Read data and push it to a container. Helper function.
template<typename ContainerType , typename NameContainerType >
void readPointCellData (size_t seg_id, ContainerType &scalar_data, ContainerType &vector_data, NameContainerType &data_names_scalar, NameContainerType &data_names_vector)
 Read point or cell data and fill the respective data containers.
void setupVertices (DomainType &domain)
 Pushes the vertices read to the domain.
void setupCells (DomainType &domain, std::size_t seg_id)
 Pushes the cells read to the domain. Preserves segment information.
template<typename ContainerType >
void setupDataVertex (DomainType &domain, std::size_t seg_id, ContainerType const &container, std::size_t num_components)
 Writes data for vertices to the ViennaGrid domain using ViennaData.
template<typename ContainerType >
void setupDataCell (DomainType &domain, std::size_t seg_id, ContainerType const &container, std::size_t num_components)
 Writes data for cells to the ViennaGrid domain using ViennaData.
void setupData (DomainType &domain, std::size_t seg_id)
 Writes all data read from files to the domain.
void parse_vtu_segment (std::string filename, std::size_t seg_id)
 Parses a .vtu file referring to a segment of the domain.
void process_vtu (std::string const &filename)
 Processes a .vtu file that represents a full domain.
void process_pvd (std::string const &filename)
 Processes a .pvd file containing the links to the segments stored in individual .vtu files.

Protected Attributes

std::ifstream reader
std::map< PointType,
std::size_t, point_less
global_points
std::map< std::size_t, PointTypeglobal_points_2
std::deque< std::deque
< std::size_t > > 
local_to_global_map
std::deque< std::deque
< std::size_t > > 
local_cell_vertices
std::deque< std::deque
< std::size_t > > 
local_cell_offsets
std::deque< std::size_t > local_cell_num
std::deque< std::deque
< std::pair< std::string,
std::deque< double > > > > 
local_scalar_vertex_data
std::deque< std::deque
< std::pair< std::string,
std::deque< double > > > > 
local_vector_vertex_data
std::deque< std::deque
< std::pair< std::string,
std::deque< double > > > > 
local_scalar_cell_data
std::deque< std::deque
< std::pair< std::string,
std::deque< double > > > > 
local_vector_cell_data

Detailed Description

template<typename DomainType>
class viennagrid::io::vtk_reader< DomainType >

A VTK reader class that allows to read meshes from XML-based VTK files as defined in http://www.vtk.org/pdf/file-formats.pdf.

Template Parameters:
DomainType The type of the domain to be read. Must not be a segment type!

Member Typedef Documentation

typedef viennagrid::result_of::iterator<CellRange>::type CellIterator [protected]
typedef viennagrid::result_of::ncell_range<DomainType, CellTag::dim>::type CellRange [protected]
typedef DomainConfiguration::cell_tag CellTag [protected]
typedef result_of::ncell<DomainConfiguration, CellTag::dim>::type CellType [protected]
typedef DomainConfiguration::coordinate_system_tag CoordinateSystemTag [protected]
typedef DomainConfiguration::numeric_type CoordType [protected]
typedef DomainType::config_type DomainConfiguration [protected]
typedef viennagrid::result_of::iterator<EdgeRange>::type EdgeIterator [protected]
typedef viennagrid::result_of::ncell_range<DomainType, 1>::type EdgeRange [protected]
typedef viennagrid::result_of::iterator<FacetRange>::type FacetIterator [protected]
typedef viennagrid::result_of::ncell_range<DomainType, CellTag::dim-1>::type FacetRange [protected]
typedef result_of::point<DomainConfiguration>::type PointType [protected]
typedef viennagrid::result_of::iterator<VertexRange>::type VertexIterator [protected]
typedef viennagrid::result_of::ncell_range<DomainType, 0>::type VertexRange [protected]
typedef result_of::ncell<DomainConfiguration, 0>::type VertexType [protected]

Member Function Documentation

void add_normal_data_on_cells ( T const &  accessor,
std::string  name 
) [inline]

Specify a special handling of vector-valued data (normals) for cells. Prefer the free function add_normal_data_on_cells().

Template Parameters:
T Anything that can be wrapped by a data_accessor_wrapper
Parameters:
accessor The quantity accessor
name The quantity name that should appear in the VTK file
void add_normal_data_on_vertices ( T const &  accessor,
std::string  name 
) [inline]

Specify a special handling of vector-valued (normal) data for vertices. Prefer the free function add_normal_data_on_vertices().

Template Parameters:
T Anything that can be wrapped by a data_accessor_wrapper
Parameters:
accessor The quantity accessor
name The quantity name that should appear in the VTK file
void add_scalar_data_on_cells ( T const &  accessor,
std::string  name 
) [inline]

Specify a special handling of scalar-valued data for cells. Prefer the free function add_scalar_data_on_cells().

Template Parameters:
T Anything that can be wrapped by a data_accessor_wrapper
Parameters:
accessor The quantity accessor
name The quantity name that should appear in the VTK file
void add_scalar_data_on_vertices ( T const &  accessor,
std::string  name 
) [inline]

Specify a special handling of scalar-valued data for vertices. Prefer the free function add_vector_data_on_vertices().

Template Parameters:
T Anything that can be wrapped by a data_accessor_wrapper
Parameters:
accessor The quantity accessor
name The quantity name that should appear in the VTK file
void add_vector_data_on_cells ( T const &  accessor,
std::string  name 
) [inline]

Specify a special handling of vector-valued data for cells. Prefer the free function add_vector_data_on_cells().

Template Parameters:
T Anything that can be wrapped by a data_accessor_wrapper
Parameters:
accessor The quantity accessor
name The quantity name that should appear in the VTK file
void add_vector_data_on_vertices ( T const &  accessor,
std::string  name 
) [inline]

Specify a special handling of vector-valued data for vertices. Prefer the free function add_vector_data_on_vertices().

Template Parameters:
T Anything that can be wrapped by a data_accessor_wrapper
Parameters:
accessor The quantity accessor
name The quantity name that should appear in the VTK file
void checkNextToken ( std::string const &  expectedToken  )  [inline, protected]

Make sure that the next token is given by 'expectedToken'. Throws a bad_file_format_exception if this is not the case.

void closeFile (  )  [inline, protected]

Closes a file.

std::vector<std::pair<std::size_t, std::string> > const& get_scalar_data_on_cells (  )  const [inline]

Returns the names of all scalar-valued data read for cells.

std::vector<std::pair<std::size_t, std::string> > const& get_scalar_data_on_vertices (  )  const [inline]

Returns the names of all scalar-valued data read for vertices.

std::vector<std::pair<std::size_t, std::string> > const& get_vector_data_on_cells (  )  const [inline]

Returns the names of all vector-valued data read for cells.

std::vector<std::pair<std::size_t, std::string> > const& get_vector_data_on_vertices (  )  const [inline]

Returns the names of all vector-valued data read for vertices.

bool lowercase_compare ( std::string const &  s1,
std::string const &  s2 
) [inline, protected]

compares the lower-case representation of two strings

void openFile ( std::string const &  filename  )  [inline, protected]

Opens a file.

int operator() ( DomainType &  domain,
std::string const &  filename 
) [inline]

Triggers the read process.

Parameters:
domain The ViennaGrid domain
filename Name of the file containing the mesh. Either .pvd (multi-segment) or .vtu (single segment)
void parse_vtu_segment ( std::string  filename,
std::size_t  seg_id 
) [inline, protected]

Parses a .vtu file referring to a segment of the domain.

void process_pvd ( std::string const &  filename  )  [inline, protected]

Processes a .pvd file containing the links to the segments stored in individual .vtu files.

void process_vtu ( std::string const &  filename  )  [inline, protected]

Processes a .vtu file that represents a full domain.

void readCellIndices ( std::size_t  seg_id  )  [inline, protected]

Reads the vertex indices of the cells inside the domain.

void readData ( std::deque< double > &  container  )  [inline, protected]

Read data and push it to a container. Helper function.

void readNodeCoordinates ( long  nodeNum,
long  numberOfComponents,
std::size_t  seg_id 
) [inline, protected]

Reads the coordinates of the points/vertices in the domain.

void readOffsets ( std::size_t  seg_id  )  [inline, protected]

Read the cell offsets for the vertex indices.

void readPointCellData ( size_t  seg_id,
ContainerType &  scalar_data,
ContainerType &  vector_data,
NameContainerType &  data_names_scalar,
NameContainerType &  data_names_vector 
) [inline, protected]

Read point or cell data and fill the respective data containers.

void readTypes (  )  [inline, protected]

Read the types of each cell.

std::vector<std::string> scalar_cell_data_names ( std::size_t  segment_id  )  const [inline]

Returns the data names of all scalar cell data read.

std::vector<std::string> scalar_vertex_data_names ( std::size_t  segment_id  )  const [inline]

Returns the data names of all scalar vertex data read.

void setupCells ( DomainType &  domain,
std::size_t  seg_id 
) [inline, protected]

Pushes the cells read to the domain. Preserves segment information.

void setupData ( DomainType &  domain,
std::size_t  seg_id 
) [inline, protected]

Writes all data read from files to the domain.

void setupDataCell ( DomainType &  domain,
std::size_t  seg_id,
ContainerType const &  container,
std::size_t  num_components 
) [inline, protected]

Writes data for cells to the ViennaGrid domain using ViennaData.

void setupDataVertex ( DomainType &  domain,
std::size_t  seg_id,
ContainerType const &  container,
std::size_t  num_components 
) [inline, protected]

Writes data for vertices to the ViennaGrid domain using ViennaData.

void setupVertices ( DomainType &  domain  )  [inline, protected]

Pushes the vertices read to the domain.

std::vector<std::string> vector_cell_data_names ( std::size_t  segment_id  )  const [inline]

Returns the data names of all vector cell data read.

std::vector<std::string> vector_vertex_data_names ( std::size_t  segment_id  )  const [inline]

Returns the data names of all vector vertex data read.


Field Documentation

std::map<PointType, std::size_t, point_less> global_points [protected]
std::map<std::size_t, PointType> global_points_2 [protected]
std::deque<std::size_t> local_cell_num [protected]
std::deque<std::deque<std::size_t> > local_cell_offsets [protected]
std::deque<std::deque<std::size_t> > local_cell_vertices [protected]
std::deque<std::deque<std::pair<std::string, std::deque<double> > > > local_scalar_cell_data [protected]
std::deque<std::deque<std::pair<std::string, std::deque<double> > > > local_scalar_vertex_data [protected]
std::deque<std::deque<std::size_t> > local_to_global_map [protected]
std::deque<std::deque<std::pair<std::string, std::deque<double> > > > local_vector_cell_data [protected]
std::deque<std::deque<std::pair<std::string, std::deque<double> > > > local_vector_vertex_data [protected]
std::ifstream reader [protected]

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