Vulpes  0.1.0
Versatile and parallel compUtational Library for high-order discontinuous Polytopal Element Simulations
Loading...
Searching...
No Matches
vulpes::geometry::MeshExporter< MeshDerived > Class Template Reference

Exports a single mesh as a single VTK grid. More...

#include <mesh_exporter.hpp>

Inheritance diagram for vulpes::geometry::MeshExporter< MeshDerived >:
[legend]
Collaboration diagram for vulpes::geometry::MeshExporter< MeshDerived >:
[legend]

Public Types

using float_t = MeshDerived::float_t
 The float type used by the mesh.
using index_t = MeshDerived::index_t
 The index type used by the mesh.

Public Member Functions

 MeshExporter (const MeshDerived &mesh, const VtuOptions &options={})
 Constructs a MeshExporter for a given mesh.
void attachVertexData (const std::string &label, const Eigen::Map< const Eigen::Matrix< float_t, -1, -1 > > data_view) const
 Attaches a list of vertex data to the VTK grid.
void attachVertexData (const std::string &label, const Eigen::Matrix< float_t, -1, -1 > &data) const
 Attaches a list of vertex data to the VTK grid.
void attachVertexData (const std::string &label, const std::vector< float_t > &data) const
 Attaches an instance of vertex data to the VTK grid.
void attachVertexData (const std::string &label, const std::vector< index_t > &data) const
 Attaches an instance of integer vertex data to the VTK grid.
template<typename DataType>
void attachCellData (const std::string &label, const Eigen::Map< const Eigen::Vector< DataType, -1 > > data_view) const
 Attaches a vector of cell data to the VTK grid.
template<typename DataType>
void attachCellData (const std::string &label, const std::vector< DataType > &data) const
 Attaches a vector of cell data to the VTK grid.
void attachMetadata (const MeshDerived &mesh) const
 Attaches metadata (field data) to the VTK grid.
void save (const std::string &filename, const std::optional< VtuOptions > &options=std::nullopt) const
 Saves the mesh data to a file.
const auto & getMesh () const
 Gets a constant reference to the mesh.
const auto & getVtkGrids () const
 Gets a constant reference to the generated VTK grids.

Protected Member Functions

void buildVtkMesh2D ()
 Builds a 2D VTK mesh from the internal mesh data.
void buildVtkMesh3D ()
 Builds a 3D VTK mesh from the internal mesh data.
void savePvtu (const std::string &filename, const VtuOptions &write_options) const
 Saves the mesh data to a parallel VTU file.
void initializeMeshForExport () const
 Initializes the mesh for export, modifying if necessary.
const MeshDerived & getMeshRef () const
 Gets a reference to the mesh for export (original/modified).

Protected Attributes

const MeshDerived & m_mesh
VtuOptions m_export_options
std::vector< vtkSmartPointer< vtkUnstructuredGrid > > m_vtk_grids
std::optional< MeshDerived > m_modified_mesh

Detailed Description

template<typename MeshDerived>
class vulpes::geometry::MeshExporter< MeshDerived >

Exports a single mesh as a single VTK grid.

This class extends MeshExporterBase to handle a single mesh and convert it into a single VTK unstructured grid. It provides methods to attach both vertex and cell data to this grid. The constructor automatically builds the grid based on the mesh's dimensionality.

Template Parameters
MeshDerivedThe derived mesh class.

Member Typedef Documentation

◆ float_t

template<typename MeshDerived>
using vulpes::geometry::MeshExporter< MeshDerived >::float_t = MeshDerived::float_t

The float type used by the mesh.

◆ index_t

template<typename MeshDerived>
using vulpes::geometry::MeshExporter< MeshDerived >::index_t = MeshDerived::index_t

The index type used by the mesh.

Constructor & Destructor Documentation

◆ MeshExporter()

template<typename MeshDerived>
vulpes::geometry::MeshExporter< MeshDerived >::MeshExporter ( const MeshDerived & mesh,
const VtuOptions & options = {} )
inlineexplicit

Constructs a MeshExporter for a given mesh.

This constructor builds the VTK mesh and attaches any tags found in the mesh's metadata.

Parameters
meshThe mesh to be exported.
optionsExport options including precision settings.

Member Function Documentation

◆ attachCellData() [1/2]

template<typename MeshDerived>
template<typename DataType>
void vulpes::geometry::MeshExporter< MeshDerived >::attachCellData ( const std::string & label,
const Eigen::Map< const Eigen::Vector< DataType, -1 > > data_view ) const

Attaches a vector of cell data to the VTK grid.

Template Parameters
DataTypeThe type of the data (e.g., double, int).
Parameters
labelThe name for the data array.
data_viewA view of the vector containing the cell data.

◆ attachCellData() [2/2]

template<typename MeshDerived>
template<typename DataType>
void vulpes::geometry::MeshExporter< MeshDerived >::attachCellData ( const std::string & label,
const std::vector< DataType > & data ) const
inline

Attaches a vector of cell data to the VTK grid.

Template Parameters
DataTypeThe type of the data (e.g., double, int).
Parameters
labelThe name for the data array.
dataThe vector containing the cell data.

◆ attachMetadata()

template<typename MeshDerived>
void vulpes::geometry::MeshExporter< MeshDerived >::attachMetadata ( const MeshDerived & mesh) const

Attaches metadata (field data) to the VTK grid.

This method writes both double and integer metadata from the mesh to the VTK grid's field data, preserving information like periodic dimensions and other mesh-level attributes.

◆ attachVertexData() [1/4]

template<typename MeshDerived>
void vulpes::geometry::MeshExporter< MeshDerived >::attachVertexData ( const std::string & label,
const Eigen::Map< const Eigen::Matrix< float_t, -1, -1 > > data_view ) const

Attaches a list of vertex data to the VTK grid.

The data is attached to the points (vertices) of the grid, with each row of the matrix being a separate data array (in column major format). That is, data is contiguous across the same vertex list.

Parameters
labelThe base name for the data arrays. An index will be appended for each row.
data_viewA view of the matrix containing the vertex data.

◆ attachVertexData() [2/4]

template<typename MeshDerived>
void vulpes::geometry::MeshExporter< MeshDerived >::attachVertexData ( const std::string & label,
const Eigen::Matrix< float_t, -1, -1 > & data ) const
inline

Attaches a list of vertex data to the VTK grid.

The data is attached to the points (vertices) of the grid, with each row of the matrix being a separate data array (in column major format). That is, data is contiguous across the same vertex list.

Parameters
labelThe base name for the data arrays. An index will be appended for each row.
dataThe matrix containing the vertex data.

◆ attachVertexData() [3/4]

template<typename MeshDerived>
void vulpes::geometry::MeshExporter< MeshDerived >::attachVertexData ( const std::string & label,
const std::vector< float_t > & data ) const
inline

Attaches an instance of vertex data to the VTK grid.

The data is attached to the points (vertices) of the grid, with each row of the matrix being a separate data array (in column major format). That is, data is contiguous across the same vertex list.

Parameters
labelThe base name for the data arrays. An index will be appended for each row.
dataThe vector containing the vertex data.

◆ attachVertexData() [4/4]

template<typename MeshDerived>
void vulpes::geometry::MeshExporter< MeshDerived >::attachVertexData ( const std::string & label,
const std::vector< index_t > & data ) const

Attaches an instance of integer vertex data to the VTK grid.

This is used for vertex tags which are typically stored as integers.

Parameters
labelThe name for the data array.
dataThe vector containing the integer vertex data.

◆ buildVtkMesh2D()

template<typename MeshDerived>
void vulpes::geometry::MeshExporter< MeshDerived >::buildVtkMesh2D ( )
protected

Builds a 2D VTK mesh from the internal mesh data.

This method creates a single vtkUnstructuredGrid representing the 2D mesh, using vtkPolygon cells. Uses getMeshRef() to access the appropriate mesh (original or modified).

◆ buildVtkMesh3D()

template<typename MeshDerived>
void vulpes::geometry::MeshExporter< MeshDerived >::buildVtkMesh3D ( )
protected

Builds a 3D VTK mesh from the internal mesh data.

This method creates a single vtkUnstructuredGrid representing the 3D mesh, using vtkPolyhedron cells. Uses getMeshRef() to access the appropriate mesh (original or modified).

◆ getMesh()

template<typename MeshDerived>
const auto & vulpes::geometry::MeshExporterBase< MeshDerived >::getMesh ( ) const
inlineinherited

Gets a constant reference to the mesh.

Returns
A constant reference to the stored mesh.

◆ getMeshRef()

template<typename MeshDerived>
const MeshDerived & vulpes::geometry::MeshExporterBase< MeshDerived >::getMeshRef ( ) const
inlineprotectedinherited

Gets a reference to the mesh for export (original/modified).

Returns
A const reference to either the original mesh or the modified copy.

◆ getVtkGrids()

template<typename MeshDerived>
const auto & vulpes::geometry::MeshExporterBase< MeshDerived >::getVtkGrids ( ) const
inlineinherited

Gets a constant reference to the generated VTK grids.

Returns
A constant reference to the vector of VTK unstructured grids.

◆ initializeMeshForExport()

template<typename MeshDerived>
void vulpes::geometry::MeshExporterBase< MeshDerived >::initializeMeshForExport ( ) const
inlineprotectedinherited

Initializes the mesh for export, modifying if necessary.

If the mesh requires modification (e.g., closed periodic 2D mesh), this creates a modified copy stored in m_modified_mesh for use during export.

◆ save()

template<typename MeshDerived>
void vulpes::geometry::MeshExporterBase< MeshDerived >::save ( const std::string & filename,
const std::optional< VtuOptions > & options = std::nullopt ) const
inherited

Saves the mesh data to a file.

This method writes the internal VTK grid data to the specified filename. It supports .vtu (VTK Unstructured Grid XML) and .vtk (legacy VTK) file formats.

Parameters
filenameThe name of the output file.
optionsOptional override for writer options (compressor_type and data_mode). If not provided, uses the options passed to the constructor. Note: coordinate_precision cannot be changed here as it affects point data already built in the VTK grids.

◆ savePvtu()

template<typename MeshDerived>
void vulpes::geometry::MeshExporterBase< MeshDerived >::savePvtu ( const std::string & filename,
const VtuOptions & write_options ) const
protectedinherited

Saves the mesh data to a parallel VTU file.

This method writes the internal VTK grid data using the parallel .pvtu XML format. It is intended for ParallelMesh exporters.

Parameters
filenameThe name of the output .pvtu file.
write_optionsWriter options used for the output files.

Member Data Documentation

◆ m_export_options

template<typename MeshDerived>
VtuOptions vulpes::geometry::MeshExporterBase< MeshDerived >::m_export_options
protectedinherited

◆ m_mesh

template<typename MeshDerived>
const MeshDerived& vulpes::geometry::MeshExporterBase< MeshDerived >::m_mesh
protectedinherited

◆ m_modified_mesh

template<typename MeshDerived>
std::optional<MeshDerived> vulpes::geometry::MeshExporterBase< MeshDerived >::m_modified_mesh
mutableprotectedinherited

◆ m_vtk_grids

template<typename MeshDerived>
std::vector<vtkSmartPointer<vtkUnstructuredGrid> > vulpes::geometry::MeshExporterBase< MeshDerived >::m_vtk_grids
protectedinherited

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