![]() |
SemiDiscreteOT 1.0
Semi-Discrete Optimal Transport Library
|
A handler class for reading and interpolating data from VTK files. More...
#include <VtkHandler.h>
Public Types | |
enum class | DataLocation { PointData , CellData } |
Enum to specify whether the data is associated with points or cells. More... | |
Public Member Functions | |
VTKHandler (const std::string &filename, const bool is_binary=false, const double scaling_factor=1.0) | |
Constructor for the VTKHandler. | |
void | read_file () |
Reads the VTK file and initializes the internal data structures. | |
void | setup_field (const std::string &field_name, const DataLocation data_location=DataLocation::PointData, const unsigned int component=0) |
Sets up the field to be used for interpolation. | |
virtual double | value (const Point< spacedim > &p, const unsigned int component=0) const override |
Interpolates the value of the selected field at a given point. | |
vtkSmartPointer< vtkUnstructuredGrid > | get_grid () const |
Returns the underlying VTK unstructured grid. | |
vtkSmartPointer< vtkDataArray > | get_field_data () const |
Returns the data array for the selected field. | |
int | get_num_components () const |
Returns the number of components in the selected field data. | |
Private Attributes | |
std::string | filename |
bool | is_binary |
double | scaling_factor |
vtkSmartPointer< vtkUnstructuredGrid > | vtk_grid |
vtkSmartPointer< vtkDataArray > | field_data |
vtkSmartPointer< vtkPointLocator > | point_locator |
vtkSmartPointer< vtkCellLocator > | cell_locator |
DataLocation | data_location |
std::string | field_name |
unsigned int | selected_component |
A handler class for reading and interpolating data from VTK files.
This class inherits from dealii::Function
and provides functionality to read VTK unstructured grids, extract scalar or vector fields from point or cell data, and interpolate these fields at arbitrary points in space.
dim | The dimension of the mesh. |
spacedim | The dimension of the space the mesh is embedded in. |
Definition at line 33 of file VtkHandler.h.
|
strong |
Enum to specify whether the data is associated with points or cells.
Enumerator | |
---|---|
PointData | Data is associated with the vertices of the grid. |
CellData | Data is associated with the cells of the grid. |
Definition at line 39 of file VtkHandler.h.
VTKHandler< dim, spacedim >::VTKHandler | ( | const std::string & | filename, |
const bool | is_binary = false , |
||
const double | scaling_factor = 1.0 |
||
) |
Constructor for the VTKHandler.
filename | The path to the VTK file. |
is_binary | Whether the VTK file is in binary format. |
scaling_factor | A factor to scale the data by upon reading. |
Definition at line 15 of file VtkHandler.cc.
void VTKHandler< dim, spacedim >::read_file | ( | ) |
Reads the VTK file and initializes the internal data structures.
std::runtime_error | if the file cannot be opened or is invalid. |
Definition at line 33 of file VtkHandler.cc.
void VTKHandler< dim, spacedim >::setup_field | ( | const std::string & | field_name, |
const DataLocation | data_location = DataLocation::PointData , |
||
const unsigned int | component = 0 |
||
) |
Sets up the field to be used for interpolation.
field_name | The name of the data array in the VTK file. |
data_location | Whether the data is point or cell data. |
component | The component of the data array to use (for vector fields). |
Definition at line 94 of file VtkHandler.cc.
|
overridevirtual |
Interpolates the value of the selected field at a given point.
This method overrides the value
method of the dealii::Function
base class.
p | The point at which to interpolate the value. |
component | The component of the function to evaluate (unused, as the component is pre-selected in setup_field). |
Definition at line 134 of file VtkHandler.cc.
|
inline |
Returns the underlying VTK unstructured grid.
vtkSmartPointer
to the vtkUnstructuredGrid
. Definition at line 88 of file VtkHandler.h.
|
inline |
Returns the data array for the selected field.
vtkSmartPointer
to the vtkDataArray
. Definition at line 94 of file VtkHandler.h.
|
inline |
Returns the number of components in the selected field data.
Definition at line 100 of file VtkHandler.h.
|
private |
Definition at line 103 of file VtkHandler.h.
|
private |
Definition at line 104 of file VtkHandler.h.
|
private |
Definition at line 105 of file VtkHandler.h.
|
private |
Definition at line 107 of file VtkHandler.h.
|
private |
Definition at line 108 of file VtkHandler.h.
|
private |
Definition at line 109 of file VtkHandler.h.
|
private |
Definition at line 110 of file VtkHandler.h.
|
private |
Definition at line 112 of file VtkHandler.h.
|
private |
Definition at line 113 of file VtkHandler.h.
|
private |
Definition at line 114 of file VtkHandler.h.