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

Exports a mesh as multiple VTK grids, one for each cell. More...

#include <mesh_exporter.hpp>

Inheritance diagram for vulpes::geometry::MeshExporterSubmesh< MeshDerived >:
[legend]
Collaboration diagram for vulpes::geometry::MeshExporterSubmesh< 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

 MeshExporterSubmesh (const MeshDerived &mesh, std::size_t min_n_submesh_elem, const VtuOptions &options={})
 Constructs a MeshExporterSubmesh for a given mesh.
void attachVertexData (const std::string &label, const datastructure::CrsMap< float_t, index_t > &data) const
 Attaches vertex data to the sub-meshes.
template<typename DataType>
void attachCellData (const std::string &label, const Eigen::Map< const Eigen::Vector< DataType, -1 > > data_view) const
 Attaches cell data to the sub-meshes.
template<typename DataType>
void attachCellData (const std::string &label, const std::vector< DataType > &data) const
 Attaches cell data to the sub-meshes.
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 (std::size_t min_n_submesh_elem)
 Builds 2D sub-meshes from each cell.
void buildVtkMesh3D (std::size_t min_n_submesh_elem)
 Builds 3D sub-meshes from each cell.
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::MeshExporterSubmesh< MeshDerived >

Exports a mesh as multiple VTK grids, one for each cell.

This class extends MeshExporterBase to create a separate vtkUnstructuredGrid for each cell (or element) of the original mesh. This is useful for visualizing results that are defined on a per-cell basis, especially when solving problems with discontinuous methods.

Template Parameters
MeshDerivedThe derived mesh class.

Member Typedef Documentation

◆ float_t

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

The float type used by the mesh.

◆ index_t

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

The index type used by the mesh.

Constructor & Destructor Documentation

◆ MeshExporterSubmesh()

template<typename MeshDerived>
vulpes::geometry::MeshExporterSubmesh< MeshDerived >::MeshExporterSubmesh ( const MeshDerived & mesh,
std::size_t min_n_submesh_elem,
const VtuOptions & options = {} )
inline

Constructs a MeshExporterSubmesh for a given mesh.

This constructor builds a separate sub-mesh (triangulation or tetrahedralization) for each cell of the input mesh, ensuring that each sub-mesh has at least a specified number of elements.

Parameters
meshThe mesh to be exported.
min_n_submesh_elemThe minimum number of elements (triangles or tetrahedra) to create for each sub-mesh.
optionsExport options including precision settings.

Member Function Documentation

◆ attachCellData() [1/2]

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

Attaches cell data to the sub-meshes.

This method adds a single value to the cell data of each sub-mesh, based on the data_view index. The value from the data_view at index i is assigned to all cells of the i-th 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::MeshExporterSubmesh< MeshDerived >::attachCellData ( const std::string & label,
const std::vector< DataType > & data ) const
inline

Attaches cell data to the sub-meshes.

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

◆ attachVertexData()

template<typename MeshDerived>
void vulpes::geometry::MeshExporterSubmesh< MeshDerived >::attachVertexData ( const std::string & label,
const datastructure::CrsMap< float_t, index_t > & data ) const

Attaches vertex data to the sub-meshes.

This method handles vertex data that is structured per sub-mesh. The data is added to each individual vtkUnstructuredGrid in the exporter.

Parameters
labelThe base name for the data arrays.
dataThe CrsMap containing the vertex data for each sub-mesh.

◆ buildVtkMesh2D()

template<typename MeshDerived>
void vulpes::geometry::MeshExporterSubmesh< MeshDerived >::buildVtkMesh2D ( std::size_t min_n_submesh_elem)
protected

Builds 2D sub-meshes from each cell.

Each cell of the original mesh is triangulated into a separate VTK grid, ensuring a minimum number of elements.

Parameters
min_n_submesh_elemThe minimum number of triangles for each sub-mesh.

◆ buildVtkMesh3D()

template<typename MeshDerived>
void vulpes::geometry::MeshExporterSubmesh< MeshDerived >::buildVtkMesh3D ( std::size_t min_n_submesh_elem)
protected

Builds 3D sub-meshes from each cell.

Each cell of the original mesh is tetrahedralized into a separate VTK grid, ensuring a minimum number of elements.

Parameters
min_n_submesh_elemThe minimum number of tetrahedra for each sub-mesh.

◆ 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: