cherab.imas.ggd.UnstructGrid2D¶
-
class cherab.imas.ggd.UnstructGrid2D(vertices: ArrayLike, cells: list[ArrayLike], name: str =
'Cells', coordinate_system: 'cylindrical' | 'cartesian' ='cylindrical')Source¶ Bases:
GGDGridUnstructured 2D grid object.
The grid cells are polygons. Vertices may be shared with neighbouring cells.
To use Raysect’s KDtree accelerator, each polygonal cell is triangulated.
- Parameters:
- vertices: ArrayLike¶
Array-like of shape
(N, 2)containing coordinates of the polygon vertices.- cells: list[ArrayLike]¶
List of
(N,)-shaped arrays containing the vertex indices in clockwise or counterclockwise order for each polygonal cell in the list (the starting vertex must not be included twice).- 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
UnstructGridFunction2Dinterpolator instance for the data defined on this grid.plot_mesh([data, ax])Plot the polygonal mesh grid geometry to a matplotlib figure.
plot_triangle_mesh([data, ax])Plot the triangle mesh grid geometry to a matplotlib figure.
subset(indices[, name])Create a subset UnstructGrid2D from this instance.
vector_interpolator(grid_vectors[, fill_vector])Return an
UnstructGridVectorFunction2Dinterpolator 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
(K, 2)mapping every grid cell index to triangle IDs.Cell volume as
(num_cell,)array.List of
Kpolygonal cells.Coordinate system.
Grid dimension.
Extent of the mesh.
Grid name.
Number of grid cells.
Array of shape
(M,)mapping every triangle index to a grid cell ID.Mesh triangles as
(M, 3)array.Mesh vertex coordinates as
(N, 2)array.- property vertices : ndarray[tuple[Any, ...], dtype[float64]]Source¶
Mesh vertex coordinates as
(N, 2)array.
- property triangle_to_cell_map : ndarray[tuple[Any, ...], dtype[int32]]Source¶
Array of shape
(M,)mapping every triangle index to a grid cell ID.
- property cell_to_triangle_map : ndarray[tuple[Any, ...], dtype[int32]]Source¶
Array of shape
(K, 2)mapping every grid cell index to triangle IDs.The first column is the index of the first triangle forming the cell. The second column is the number of triangles forming the cell.
>>> itri, ntri = mesh.cell_to_triangle_map[icell] >>> tri_cell = mesh.triangles[itri : itri + ntri]
-
subset(indices: ArrayLike, name: str | None =
None) UnstructGrid2DSource¶ Create a subset UnstructGrid2D from this instance.
- Parameters:
- Returns:
Subset instance.
- Return type:
-
interpolator(grid_data: ArrayLike, fill_value: float =
0) UnstructGridFunction2DSource¶ Return an
UnstructGridFunction2Dinterpolator 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)) UnstructGridVectorFunction2DSource¶ Return an
UnstructGridVectorFunction2Dinterpolator 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_triangle_mesh(data: ArrayLike | None =
None, ax: Axes | None =None) AxesSource¶ Plot the triangle mesh grid geometry to a matplotlib figure.
- 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.