pylbo.visualisation.modes.vtk_export
Classes
Main class to prepare data for export to VTK files. |
|
Main class to prepare data for export to VTK files. |
|
Main class to prepare data for export to VTK files. |
Module Contents
- class pylbo.visualisation.modes.vtk_export.VTKDataExporter(data: pylbo.visualisation.modes.mode_data.ModeVisualisationData, u1: numpy.ndarray, u2: numpy.ndarray, u3: numpy.ndarray)[source]
Main class to prepare data for export to VTK files.
- Parameters:
data (ModeVisualisationData) – The data for the visualisation
u1 (np.ndarray) – The 1D \(u_1\) coordinate array.
u2 (np.ndarray) – The 1D \(u_2\) coordinate array.
u3 (np.ndarray) – The 1D \(u_3\) coordinate array.
- _u1
The 1D \(u_1\) coordinates.
- Type:
ndarray
- _u2
The 1D \(u_2\) coordinates.
- Type:
ndarray
- _u3
The 1D \(u_3\) coordinates.
- Type:
ndarray
- u1_data
The 3D \(u_1\) coordinate data.
- Type:
ndarray
- u2_data
The 3D \(u_2\) coordinate data.
- Type:
ndarray
- u3_data
The 3D \(u_3\) coordinate data.
- Type:
ndarray
- _set_coordinate_data(u1: numpy.ndarray, u2: numpy.ndarray, u3: numpy.ndarray)[source]
Sets the coordinate data.
- Parameters:
u1 (np.ndarray) – The 1D \(u_1\) coordinate array.
u2 (np.ndarray) – The 1D \(u_2\) coordinate array.
u3 (np.ndarray) – The 1D \(u_3\) coordinate array.
- abstract get_coordinate_data() tuple[numpy.ndarray, numpy.ndarray, numpy.ndarray] [source]
Returns the coordinate data. This should always return the data in a Cartesian reference frame (u1, u2, u3), so coordinate transformations should be implemented in subclassed if necessary.
- Returns:
u1_data (ndarray) – The 3D \(u_1\) coordinate data.
u2_data (ndarray) – The 3D \(u_2\) coordinate data.
u3_data (ndarray) – The 3D \(u_3\) coordinate data.
- broadcast_to_3d(array: numpy.ndarray) numpy.ndarray [source]
Broadcasts a 1D array to a 3D array with the same shape as the coordinate data.
- Parameters:
array (np.ndarray) – The 1D array to broadcast.
- Returns:
The broadcasted array.
- Return type:
np.ndarray
- get_solution(name: str, time: float) numpy.ndarray [source]
Returns the eigenmode solution for a given time.
- _validate_and_set_dtype(dtype: str) None [source]
Validates and sets the VTK data type.
- Parameters:
dtype (str) – The VTK data type. Valid values are “float32” and “float64”.
- Raises:
ValueError – If the VTK data type is not valid.
- _write_vtk_header(vtkfile)[source]
Writes the VTK file header. This includes the VTK file version, the data type, the grid dimensions and the number of points.
- Parameters:
vtkfile (str) – The name of the VTK file to write to.
- _write_vtk_coordinate_data(vtkfile)[source]
Writes the VTK grid coordinates.
- Parameters:
vtkfile (str) – The name of the VTK file to write to.
- _write_vtk_point_data_start(vtkfile)[source]
Writes the VTK point data start marker, i.e. the ‘POINT_DATA’ statement and the number of points.
- Parameters:
vtkfile (str) – The name of the VTK file to write to.
- _write_vtk_scalar_field(vtkfile, fieldname, fielddata)[source]
Writes a 3D VTK scalar field with a given fieldname. If fielddata is smaller than 1e-12 everywhere the field is not written to the VTK file.
- _write_vtk_auxiliary_coordinates(vtkfile)[source]
Writes auxiliary coordinate data to the VTK file, for example the theta values in cylindrical geometry. These are needed for appropriate transformations to draw vector fields in e.g. ParaView.
- Parameters:
vtkfile (str) – The name of the VTK file to write to.
- export_to_vtk(filename: str, time: float | numpy.ndarray, names: str | list[str] = None, bg_names: str | list[str] = None, dtype: str = 'float32', starting_index: int = 0) None [source]
Exports the mode solution to a VTK file.
- Parameters:
filename (str) – The name of the VTK file to write to.
time (Union[float, np.ndarray]) – The time(s) at which to export the mode solution.
names (Union[str, list[str]], optional) – The name(s) of the mode(s) to export.
bg_names (Union[str, list[str]], optional) – The name(s) of the equilibrium background(s) to export.
dtype (str, optional) – The VTK data type, defaults to “float32” (32 bit floating point). Can be set to “float64” (64 bit floating point) but uses more memory.
starting_index (int, optional) – The starting index for filenames, defaults to 0.
- class pylbo.visualisation.modes.vtk_export.VTKCartesianData(data: pylbo.visualisation.modes.mode_data.ModeVisualisationData, u2: numpy.ndarray, u3: numpy.ndarray)[source]
Bases:
VTKDataExporter
Main class to prepare data for export to VTK files.
- Parameters:
data (ModeVisualisationData) – The data for the visualisation
u1 (np.ndarray) – The 1D \(u_1\) coordinate array.
u2 (np.ndarray) – The 1D \(u_2\) coordinate array.
u3 (np.ndarray) – The 1D \(u_3\) coordinate array.
- _u1
The 1D \(u_1\) coordinates.
- Type:
ndarray
- _u2
The 1D \(u_2\) coordinates.
- Type:
ndarray
- _u3
The 1D \(u_3\) coordinates.
- Type:
ndarray
- u1_data
The 3D \(u_1\) coordinate data.
- Type:
ndarray
- u2_data
The 3D \(u_2\) coordinate data.
- Type:
ndarray
- u3_data
The 3D \(u_3\) coordinate data.
- Type:
ndarray
- get_coordinate_data() tuple[numpy.ndarray, numpy.ndarray, numpy.ndarray] [source]
Returns the coordinate data. This should always return the data in a Cartesian reference frame (u1, u2, u3), so coordinate transformations should be implemented in subclassed if necessary.
- Returns:
u1_data (ndarray) – The 3D \(u_1\) coordinate data.
u2_data (ndarray) – The 3D \(u_2\) coordinate data.
u3_data (ndarray) – The 3D \(u_3\) coordinate data.
- class pylbo.visualisation.modes.vtk_export.VTKCylindricalData(data: pylbo.visualisation.modes.mode_data.ModeVisualisationData, u2: numpy.ndarray, u3: numpy.ndarray)[source]
Bases:
VTKDataExporter
Main class to prepare data for export to VTK files.
- Parameters:
data (ModeVisualisationData) – The data for the visualisation
u1 (np.ndarray) – The 1D \(u_1\) coordinate array.
u2 (np.ndarray) – The 1D \(u_2\) coordinate array.
u3 (np.ndarray) – The 1D \(u_3\) coordinate array.
- _u1
The 1D \(u_1\) coordinates.
- Type:
ndarray
- _u2
The 1D \(u_2\) coordinates.
- Type:
ndarray
- _u3
The 1D \(u_3\) coordinates.
- Type:
ndarray
- u1_data
The 3D \(u_1\) coordinate data.
- Type:
ndarray
- u2_data
The 3D \(u_2\) coordinate data.
- Type:
ndarray
- u3_data
The 3D \(u_3\) coordinate data.
- Type:
ndarray
- get_coordinate_data() tuple[numpy.ndarray, numpy.ndarray, numpy.ndarray] [source]
Returns the coordinate data. This should always return the data in a Cartesian reference frame (u1, u2, u3), so coordinate transformations should be implemented in subclassed if necessary.
- Returns:
u1_data (ndarray) – The 3D \(u_1\) coordinate data.
u2_data (ndarray) – The 3D \(u_2\) coordinate data.
u3_data (ndarray) – The 3D \(u_3\) coordinate data.
- _write_vtk_auxiliary_coordinates(vtkfile)[source]
Writes auxiliary coordinate data to the VTK file, for example the theta values in cylindrical geometry. These are needed for appropriate transformations to draw vector fields in e.g. ParaView.
- Parameters:
vtkfile (str) – The name of the VTK file to write to.