15#include <vtkPointSet.h>
16#include <vtkPolyData.h>
17#include <vtkSmartPointer.h>
18#include <vtkUnstructuredGrid.h>
53 virtual void read_file(
const std::string &file_name);
119 const Array<double> &data);
130 void set_element_data(
const std::string &data_name,
const Array<int> &data);
154 const Array<double> &data);
165 void set_point_data(
const std::string &data_name,
const Array<int> &data);
248 Array<double> &mesh_data)
const;
291 Array<double> &mesh_data)
const;
419 vtkSmartPointer<vtkIdList> elem_nodes) = 0;
465 VtkVtpData(
const std::string &file_name,
bool reader =
true);
475 virtual void write()
const override;
486 virtual int cell_type(
int nsd,
int np_elem)
const override;
492 vtkSmartPointer<vtkIdList> elem_nodes)
override;
523 VtkVtuData(
const std::string &file_name,
bool reader =
true);
533 virtual void write()
const override;
544 virtual int cell_type(
int nsd,
int np_elem)
const override;
550 vtkSmartPointer<vtkIdList> elem_nodes)
override;
The Vector template class is used for storing int and double data.
Definition Vector.h:26
A mesh stored in one of the VTK XML file formats.
Definition VtkData.h:35
Array< double > get_point_data(const std::string &data_name) const
Get an array of point data from the mesh.
Definition VtkData.cpp:504
int num_points_
Number of points.
Definition VtkData.h:439
virtual void read_file(const std::string &file_name)
Read the mesh data from a VTK file.
Definition VtkData.cpp:27
int num_points_per_elem() const
Get the number of points per element.
Definition VtkData.cpp:90
int num_elems() const
Get the number of elements in the mesh.
Definition VtkData.cpp:86
Array< int > get_connectivity() const
Get the connectivity of the mesh elements.
Definition VtkData.cpp:52
int elem_type() const
Get the element type.
Definition VtkData.cpp:88
int num_elems_
Number of elements.
Definition VtkData.h:433
bool has_point_data(const std::string &data_name) const
Check if a given point data array exists.
Definition VtkData.cpp:317
int num_points_per_elem_
Number of points per element.
Definition VtkData.h:436
virtual void create_grid()=0
Create an empty grid.
void set_time_value(const double time)
Store a time value as field data.
Definition VtkData.cpp:293
int elem_type_
Type of elements in the mesh.
Definition VtkData.h:430
virtual ~VtkData()=default
Virtual destructor.
void set_point_data(const std::string &data_name, const Array< double > &data)
Set a double-valued point data array.
Definition VtkData.cpp:166
static VtkData * create_reader(const std::string &file_name)
Create an object to read a mesh from a VTK file.
Definition VtkData.cpp:549
static VtkData * create_writer(const std::string &file_name)
Create an object to write a mesh to a VTK file.
Definition VtkData.cpp:562
int num_points() const
Get the number of points in the mesh.
Definition VtkData.cpp:92
bool has_cell_data(const std::string &data_name) const
Check if a given cell data array exists.
Definition VtkData.cpp:304
void set_points(const Array< double > &points)
Set the point coordinates of the mesh.
Definition VtkData.cpp:240
virtual void write() const =0
Write the mesh data to a VTK file.
vtkSmartPointer< vtkPointSet > vtk_data
Definition VtkData.h:424
virtual void insert_cell(int vtk_cell_type, vtkSmartPointer< vtkIdList > elem_nodes)=0
Insert a new cell into the VTK data object.
void copy_points(Array< double > &points) const
Copy the mesh points to an Array.
Definition VtkData.cpp:330
virtual void read_file_internal(const std::string &file_name)=0
Read the mesh data from a file.
void set_connectivity(const int nsd, const Array< int > &conn)
Set the mesh connectivity to define the elements.
Definition VtkData.cpp:262
std::string file_name_
Filename that the mesh is read from, or written to.
Definition VtkData.h:427
void copy_cell_data(const std::string &data_name, Array< double > &mesh_data) const
Copy an array of cell data from the mesh into the given Array.
Definition VtkData.cpp:427
virtual int cell_type(int nsd, int np_elem) const =0
Get the VTK cell type for a given number of spatial dimensions and number of points per element.
VtkData()=default
Default constructor.
void copy_point_data(const std::string &data_name, Array< double > &mesh_data) const
Copy an array of point data from the mesh into the given Array.
Definition VtkData.cpp:350
std::pair< int, int > get_cell_data_dimensions(const std::string &data_name) const
Get the dimensions of a cell data array.
Definition VtkData.cpp:539
Array< double > get_points() const
Get the points of the mesh.
Definition VtkData.cpp:69
void set_element_data(const std::string &data_name, const Array< double > &data)
Set a double-valued element data array.
Definition VtkData.cpp:94
std::vector< std::string > get_point_data_names() const
Get a list of point data names.
Definition VtkData.cpp:527
A mesh stored in the VTK XML polygonal data format ('.vtp' files).
Definition VtkData.h:449
vtkSmartPointer< vtkPolyData > vtk_polydata
Definition VtkData.h:497
virtual void create_grid() override
Create an empty grid.
Definition VtkData.cpp:588
virtual void read_file_internal(const std::string &file_name) override
Read the mesh data from a file.
Definition VtkData.cpp:611
virtual void write() const override
Write the mesh data to a file.
Definition VtkData.cpp:598
virtual int cell_type(int nsd, int np_elem) const override
Get the VTK cell type of a surface element.
Definition VtkData.cpp:625
VtkVtpData()
Default constructor.
Definition VtkData.cpp:576
virtual void insert_cell(int vtk_cell_type, vtkSmartPointer< vtkIdList > elem_nodes) override
Insert a new cell into the vtkPolyData object.
Definition VtkData.cpp:652
A mesh stored in the VTK XML unstructured grid format ('.vtu' files).
Definition VtkData.h:507
vtkSmartPointer< vtkUnstructuredGrid > vtk_ugrid
Definition VtkData.h:555
VtkVtuData()
Default constructor.
Definition VtkData.cpp:659
virtual void write() const override
Write the mesh data to a file.
Definition VtkData.cpp:681
virtual void read_file_internal(const std::string &file_name) override
Read the mesh data from a file.
Definition VtkData.cpp:694
virtual void insert_cell(int vtk_cell_type, vtkSmartPointer< vtkIdList > elem_nodes) override
Insert a new cell into the vtkUnstructuredGrid object.
Definition VtkData.cpp:751
virtual void create_grid() override
Create an empty grid.
Definition VtkData.cpp:671
virtual int cell_type(int nsd, int np_elem) const override
Get the VTK cell type of a volume element.
Definition VtkData.cpp:708