Caribou
Public Types | Public Member Functions | Static Public Member Functions | List of all members
caribou::topology::io::VTKReader< Dimension > Class Template Reference

Public Types

using ElementsIndices = Eigen::Matrix< UNSIGNED_INTEGER_TYPE, Eigen::Dynamic, Eigen::Dynamic, Eigen::RowMajor >
 
using DomainBuilder = std::function< BaseDomain *(Mesh< Dimension > &, const ElementsIndices &)>
 
using MeshType = Mesh< Dimension >
 

Public Member Functions

void print (std::ostream &out) const
 Print information about the current vtk file.
 
auto mesh () const -> MeshType
 Build the actual unstructured mesh from the vtk file.
 
template<typename Element >
auto register_element_type (const VTKCellType &vtkCellType) -> VTKReader &
 Register an element type to the given VTK cell type.
 
auto register_element_type (const VTKCellType &vtkCellType, DomainBuilder builder) -> VTKReader &
 Register an element type to the given VTK cell type and give it a domain builder callback function. More...
 

Static Public Member Functions

static auto Read (const std::string &filepath) -> VTKReader
 Build a new VTKReader instance by reading a vtk file.
 

Member Function Documentation

◆ register_element_type()

template<UNSIGNED_INTEGER_TYPE Dimension>
auto caribou::topology::io::VTKReader< Dimension >::register_element_type ( const VTKCellType &  vtkCellType,
DomainBuilder  builder 
) -> VTKReader &
inline

Register an element type to the given VTK cell type and give it a domain builder callback function.

Parameters
vtkCellTypeThe type of VTK cell for which we want the builder to be use
builderA callback function that will be called with the mesh being created and the list of element node indices. The builder is responsible to create the Domain and add it to the mesh. The list of element node indices is given as a NxM matrix where N is the number of elements, and M is the number of nodes per elements. Domain created domain should be returned by the callback, or nullptr if the creation failed.

DomainBuilder Signature:

builder(Mesh<Dimension> & mesh, const ElementsIndices & indices) -> BaseDomain *;

Where mesh is the current mesh being created and ElementsIndices is an array of the following form:

*                      // Node 1   Node 2   Node 3    ...    Node M
*                    [[   e1n1,    e1n2,    e1n3,    ...,    e1nM   ], // Element 1
*                     [   e2n1,    e2n2,    e2n3,    ...,    e2nM   ], // Element 2
*                                                    ...
*                     [   eNn1,    eNn2,    eNn3,    ...,    eNnM]  ] // Element N
*                     

Here, for example, e2n4 means the indice of the second node of the fourth element of the mesh.

Example:

auto reader = io::VTKReader<_3D>::Read("meshes/3D_hexahedron_linear.vtk");
reader.register_element_type(VTK_HEXAHEDRON, [](Mesh<_3D> & mesh, const Mesh<_3D>::ElementsIndices &indices)) {
// ElementsIndices is a matrix Nx8 : N hexahedral elements of 8 node indices.
return m.add_domain<Hexahedron>("my_hexahdral_domain", indices);
});
auto mesh = reader.mesh();

The documentation for this class was generated from the following files:
caribou::topology::io::VTKReader::mesh
auto mesh() const -> MeshType
Build the actual unstructured mesh from the vtk file.
Definition: VTKReader.cpp:95
caribou::topology::io::VTKReader::Read
static auto Read(const std::string &filepath) -> VTKReader
Build a new VTKReader instance by reading a vtk file.
Definition: VTKReader.cpp:75