cherab.imas.ggd.UnstructGrid2DExtendedยถ

class cherab.imas.ggd.UnstructGrid2DExtended(vertices: ArrayLike, cells: NDArray[integer[Any]] | Sequence[Sequence[SupportsIndex] | NDArray[integer[Any]]], num_faces: int, num_poloidal: int, num_toroidal: int, name: str = 'Cells', coordinate_system: 'cylindrical' | 'cartesian' = 'cylindrical')Sourceยถ

Bases: GGDGrid

Unstructured 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: NDArray[integer[Any]] | Sequence[Sequence[SupportsIndex] | NDArray[integer[Any]]]ยถ

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 UnstructGrid3D from this instance.

subset_faces(indices[,ย name])

Create a subset UnstructGrid2DExtended from this instance.

vector_interpolator(grid_vectors[,ย ...])

Return an UnstructGridVectorFunction3D interpolator instance for the vector data defined on this grid.

Attributes

cell_area

Cell areas as (num_cell,) array.

cell_centre

Coordinate of cell centres as (num_cell, dimension) array.

cell_to_tetra_map

Array of shape (M, 2) mapping every grid cell index to tetrahedral IDs.

cell_volume

Cell volume as (num_cell,) array.

cells

Mesh cells as (M, 8) array.

coordinate_system

Coordinate system.

dimension

Grid dimension.

mesh_extent

Extent of the mesh.

name

Grid name.

num_cell

Number of grid cells.

num_faces

Number of faces at the poloidal plane.

num_poloidal

Number of poloidal grid points.

num_toroidal

Number of toroidal grid points.

tetra_to_cell_map

Array of shape (5M,) mapping every tetrahedral index to a grid cell ID.

tetrahedra

Mesh tetrahedra as (5M, 4) array.

vertices

Mesh vertex coordinates as (N, 3) array in the (X, Y, Z) space.

property num_poloidal : intSourceยถ

Number of poloidal grid points.

property num_toroidal : intSourceยถ

Number of toroidal grid points.

property num_faces : intSourceยถ

Number of faces at the poloidal plane.

property vertices : NDArray[float64]Sourceยถ

Mesh vertex coordinates as (N, 3) array in the (X, Y, Z) space.

property cells : NDArray[int32]Sourceยถ

Mesh cells as (M, 8) array.

property tetrahedra : NDArray[int32]Sourceยถ

Mesh tetrahedra as (5M, 4) array.

property tetra_to_cell_map : NDArray[int32]Sourceยถ

Array of shape (5M,) mapping every tetrahedral index to a grid cell ID.

property cell_to_tetra_map : NDArray[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: Sequence[SupportsIndex] | NDArray[integer[Any]], 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.

Parameters:
indices: Sequence[SupportsIndex] | NDArray[integer[Any]]ยถ

Indices of the faces of the original grid in the subset.

name: str | None = Noneยถ

Name of the grid subset. Default is instance.name + " subset".

Returns:

UnstructGrid2DExtended โ€“ Subset instance.

Raises:

ValueError โ€“ If any of the indices of the faces is out of range. If the number of faces at the poloidal plane, the number of poloidal points, or the number of toroidal points is not defined for this grid.

See also

subset

For a method that creates a subset from the original grid cells.

subset(indices: Sequence[SupportsIndex] | NDArray[integer[Any]], name: str | None = None) UnstructGrid3DSourceยถ

Create a subset UnstructGrid3D 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:
indices: Sequence[SupportsIndex] | NDArray[integer[Any]]ยถ

Indices of the cells of the original grid in the subset.

name: str | None = Noneยถ

Name of the grid subset. Default is instance.name + " subset".

Returns:

UnstructGrid3D โ€“ Subset instance.

interpolator(grid_data: NDArray[floating[Any]] | Sequence[float], fill_value: float = 0, *, interpolator_cache: 'none' | 'memory' | 'disk' = 'memory', interpolator_cache_dir: str | Path | None = None, interpolator_cache_namespace: str = 'ggd') 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:
grid_data: NDArray[floating[Any]] | Sequence[float]ยถ

Array containing data in the grid cells.

fill_value: float = 0ยถ

Value returned outside the grid, by default 0.0.

interpolator_cache: 'none' | 'memory' | 'disk' = 'memory'ยถ

Cache mode for the interpolator, by default "memory". The cache mode is described in the InterpolatorCacheMode type alias.

interpolator_cache_dir: str | Path | None = Noneยถ

Directory used when interpolator_cache="disk", by default None (uses the system cache directory, e.g., ~/.cache/cherab/imas/interpolators).

interpolator_cache_namespace: str = 'ggd'ยถ

Namespace prefix to avoid cache-key collisions, by default "ggd".

Returns:

UnstructGridFunction3D โ€“ Interpolator instance.

vector_interpolator(grid_vectors: NDArray[float64], fill_vector: Vector3D = Vector3D(0.0, 0.0, 0.0), *, interpolator_cache: 'none' | 'memory' | 'disk' = 'memory', interpolator_cache_dir: str | Path | None = None, interpolator_cache_namespace: str = 'ggd') UnstructGridVectorFunction3DSourceยถ

Return an UnstructGridVectorFunction3D interpolator 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:
grid_vectors: NDArray[float64]ยถ

(3, L) Array containing 3D vectors in the grid cells.

fill_vector: Vector3D = Vector3D(0.0, 0.0, 0.0)ยถ

3D vector returned outside the grid, by default Vector3D(0, 0, 0).

interpolator_cache: 'none' | 'memory' | 'disk' = 'memory'ยถ

Cache mode for the interpolator, by default "memory". The cache mode is described in the InterpolatorCacheMode type alias.

interpolator_cache_dir: str | Path | None = Noneยถ

Directory used when interpolator_cache="disk", by default None (uses the system cache directory, e.g., ~/.cache/cherab/imas/interpolators).

interpolator_cache_namespace: str = 'ggd'ยถ

Namespace prefix to avoid cache-key collisions, by default "ggd".

Returns:

UnstructGridVectorFunction3D โ€“ Interpolator instance.

plot_tetra_mesh(data: NDArray[floating[Any]] | Sequence[float] | None = None, ax: Axes | None = None) NoneSourceยถ

Plot the tetrahedral mesh grid geometry.

Warning

Plotting of tetrahedral mesh is not implemented yet.

Parameters:
data: NDArray[floating[Any]] | Sequence[float] | None = Noneยถ

Data array defined on the tetrahedral mesh.

ax: Axes | None = Noneยถ

Matplotlib axes to plot the mesh. If None, a new figure is created.

Raises:

NotImplementedError โ€“ Plotting of tetrahedral mesh is not implemented yet.

plot_mesh(data: NDArray[floating[Any]] | Sequence[float] | None = None, ax: Axes | None = None, **grid_styles) AxesSourceยถ

Plot the polygonal mesh grid geometry at the first poloidal plane to a matplotlib figure.

Parameters:
data: NDArray[floating[Any]] | Sequence[float] | 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ยถ

Styles for the grid lines and faces, by default {"facecolor": "none", "edgecolor": "b", "linewidth": 0.25}.

Returns:

Axes โ€“ Matplotlib axes with the plotted mesh.

property cell_area : NDArray[float64]Sourceยถ

Cell areas as (num_cell,) array.

property cell_centre : NDArray[float64]Sourceยถ

Coordinate of cell centres as (num_cell, dimension) array.

property cell_volume : NDArray[float64]Sourceยถ

Cell volume as (num_cell,) array.

property coordinate_system : strSourceยถ

Coordinate system.

property dimension : intSourceยถ

Grid dimension.

property mesh_extent : dict[str, float]Sourceยถ

Extent of the mesh.

A dictionary with xmin, xmax, ymin and ymax, โ€ฆ keys.

property name : strSourceยถ

Grid name.

property num_cell : intSourceยถ

Number of grid cells.

plot_tri_mesh(data: NDArray[floating[Any]] | Sequence[float], ax: Axes | None = None, cmap: str = 'viridis', **kwargs) AxesSourceยถ

Plot the data defined on the triangular mesh at the poloidal plane to a matplotlib figure.

Parameters:
data: NDArray[floating[Any]] | Sequence[float]ยถ

Data array defined on the triangular mesh at the poloidal plane.

ax: Axes | None = Noneยถ

Matplotlib axes to plot the mesh. If None, a new figure is created.

cmap: str = 'viridis'ยถ

Colormap to use for the data, by default โ€˜viridisโ€™.

**kwargsยถ

Additional keyword arguments passed to tripcolor.

Returns:

Axes โ€“ Matplotlib axes with the plotted mesh.

Raises:

ValueError โ€“ If the data array does not have the same number of faces as the grid. If the number of faces at the poloidal plane or the number of poloidal points is not defined for this grid.