cherab.imas.ggd.UnstructGrid2DExtended¶
-
class cherab.imas.ggd.UnstructGrid2DExtended(vertices: ArrayLike, cells: ArrayLike, num_faces: int, num_poloidal: int, num_toroidal: int, name: str =
'Cells', coordinate_system: 'cylindrical' | 'cartesian' ='cylindrical')Source¶ Bases:
GGDGridUnstructured 2D grid with toroidal extension.
The grid cells are voxels (cubes). Vertices may be shared with neighbouring cells.
To use Raysect’s KDtree accelerator, each cell is tetrahedralized.
- Parameters:
- vertices: ArrayLike¶
Array-like of shape
(N, 3)containing coordinates of the cell vertices in the (X, Y, Z) space.- cells: ArrayLike¶
Array-like of shape
(M, 8)containing the vertex indices in clockwise or counterclockwise order for each cubic cell in the list (the starting vertex must not be included twice).- num_faces: int¶
Number of faces at the poloidal plane.
- num_poloidal: int¶
Number of poloidal points.
- num_toroidal: int¶
Number of toroidal points.
- name: str =
'Cells'¶ Name of the grid, by default
"Cells".- coordinate_system: 'cylindrical' | 'cartesian' =
'cylindrical'¶ Coordinate system of the grid, by default
"cylindrical".
Methods
interpolator(grid_data[, fill_value])Return an UnstructGridFunction3D interpolator instance for the data defined on this grid.
plot_mesh([data, ax])Plot the polygonal mesh grid geometry at the first poloidal plane to a matplotlib figure.
plot_tetra_mesh([data, ax])Plot the tetrahedral mesh grid geometry.
plot_tri_mesh(data[, ax, cmap])Plot the data defined on the triangular mesh at the poloidal plane to a matplotlib figure.
subset(indices[, name])Create a subset UnstructGrid2DExtended from this instance.
subset_faces(indices[, name])Create a subset UnstructGrid2DExtended from this instance.
vector_interpolator(grid_vectors[, fill_vector])Return an
UnstructGridVectorFunction3Dinterpolator instance for the vector data defined on this grid.Attributes
Cell areas as
(num_cell,)array.Coordinate of cell centres as
(num_cell, dimension)array.Array of shape
(M, 2)mapping every grid cell index to tetrahedral IDs.Cell volume as
(num_cell,)array.Mesh cells as
(M, 8)array.Coordinate system.
Grid dimension.
Extent of the mesh.
Grid name.
Number of grid cells.
Number of faces at the poloidal plane.
Number of poloidal grid points.
Number of toroidal grid points.
Array of shape
(5M,)mapping every tetrahedral index to a grid cell ID.Mesh tetrahedra as
(5M, 4)array.Mesh vertex coordinates as
(N, 3)array in the (X, Y, Z) space.- property vertices : ndarray[tuple[Any, ...], dtype[float64]]Source¶
Mesh vertex coordinates as
(N, 3)array in the (X, Y, Z) space.
- property tetrahedra : ndarray[tuple[Any, ...], dtype[int32]]Source¶
Mesh tetrahedra as
(5M, 4)array.
- property tetra_to_cell_map : ndarray[tuple[Any, ...], dtype[int32]]Source¶
Array of shape
(5M,)mapping every tetrahedral index to a grid cell ID.
- property cell_to_tetra_map : ndarray[tuple[Any, ...], dtype[int32]]Source¶
Array of shape
(M, 2)mapping every grid cell index to tetrahedral IDs.The first column is the index of the first tetrahedron forming the cell. The second column is the number of tetrahedra forming the cell.
>>> itet, ntet = mesh.cell_to_tetra_map[icell] >>> tet_cell = mesh.tetrahedra[itet : itet + ntet]
-
subset_faces(indices: ArrayLike, name: str | None =
None) UnstructGrid2DExtendedSource¶ Create a subset UnstructGrid2DExtended from this instance.
The subset is defined by the indices of the faces at the poloidal plane. Thus, the subset mesh is periodic in the toroidal direction.
See also
subsetFor a method that creates a subset from the original grid cells.
- Parameters:
- Returns:
Subset instance.
- Return type:
- Raises:
ValueError – If any of the indices of the faces is out of range.
-
subset(indices: ArrayLike, name: str | None =
None) UnstructGrid2DExtendedSource¶ Create a subset UnstructGrid2DExtended from this instance.
Warning
The subset loses the range of cylindrical coordinates because the extracted vertex data is not necessarily periodic in the toroidal direction.
- Parameters:
- Returns:
Subset instance.
- Return type:
-
interpolator(grid_data: ArrayLike, fill_value: float =
0) UnstructGridFunction3DSource¶ Return an UnstructGridFunction3D interpolator instance for the data defined on this grid.
On the second and subsequent calls, the interpolator is created as an instance of the previously created interpolator sharing the same KDtree structure.
- Parameters:
- Returns:
Interpolator instance.
- Return type:
-
vector_interpolator(grid_vectors: ArrayLike, fill_vector: Vector3D =
Vector3D(0.0, 0.0, 0.0)) UnstructGridVectorFunction3DSource¶ Return an
UnstructGridVectorFunction3Dinterpolator instance for the vector data defined on this grid.On the second and subsequent calls, the interpolator is created as an instance of the previously created interpolator sharing the same KDtree structure.
- Parameters:
- Returns:
Interpolator instance.
- Return type:
-
plot_tetra_mesh(data: ArrayLike | None =
None, ax: Axes | None =None) NoneSource¶ Plot the tetrahedral mesh grid geometry.
Warning
Plotting of tetrahedral mesh is not implemented yet.
-
plot_mesh(data: ArrayLike | None =
None, ax: Axes | None =None, **grid_styles: str | float) AxesSource¶ Plot the polygonal mesh grid geometry at the first poloidal plane to a matplotlib figure.
- Parameters:
- data: ArrayLike | None =
None¶ Data array defined on the polygonal mesh at the poloidal plane.
- ax: Axes | None =
None¶ Matplotlib axes to plot the mesh. If None, a new figure is created.
- **grid_styles: str | float¶
Styles for the grid lines and faces, by default
{"facecolor": "none", "edgecolor": "b", "linewidth": 0.25}.
- data: ArrayLike | None =
- Returns:
Matplotlib axes with the plotted mesh.
- Return type:
- property cell_area : ndarray[tuple[Any, ...], dtype[float64]] | NoneSource¶
Cell areas as
(num_cell,)array.
- property cell_centre : ndarray[tuple[Any, ...], dtype[float64]] | NoneSource¶
Coordinate of cell centres as
(num_cell, dimension)array.
- property cell_volume : ndarray[tuple[Any, ...], dtype[float64]] | NoneSource¶
Cell volume as
(num_cell,)array.
- property mesh_extent : dict[str, float] | NoneSource¶
Extent of the mesh.
A dictionary with xmin, xmax, ymin and ymax, … keys.
-
plot_tri_mesh(data: ArrayLike, ax: Axes | None =
None, cmap: str ='viridis') AxesSource¶ Plot the data defined on the triangular mesh at the poloidal plane to a matplotlib figure.
- Parameters:
- Returns:
Matplotlib axes with the plotted mesh.
- Return type:
- Raises:
ValueError – If the data array does not have the same number of faces as the grid.