cherab.imas.ggd.UnstructGrid3D¶

class cherab.imas.ggd.UnstructGrid3D(vertices: ArrayLike, cells: ArrayLike, name: str = 'Cells')Source¶

Bases: GGDGrid

Unstructured 3D grid object.

The grid cells are hexahedra (8-vertex cells). Vertices may be shared with neighbouring cells.

To use Raysect’s KDtree accelerator, each hexahedral cell is tetrahedralized.

Parameters:
vertices: ArrayLike¶

Array-like of shape (N, 3) containing vertex coordinates in (X, Y, Z).

cells: ArrayLike¶

Array-like of shape (M, 8) containing vertex indices for each hexahedral cell.

name: str = 'Cells'¶

Name of the grid, by default 'Cells'.

Methods

interpolator(grid_data[, fill_value])

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

plot_mesh([data, ax])

Plot the grid geometry to a matplotlib figure.

subset(indices[, name])

Create a subset UnstructGrid3D from this instance.

vector_interpolator(grid_vectors[, fill_vector])

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.

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 vertices : ndarray[tuple[Any, ...], dtype[float64]]Source¶

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

property cells : ndarray[tuple[Any, ...], dtype[int32]]Source¶

Mesh cells as (M, 8) array.

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(indices: Sequence[SupportsIndex] | ndarray[tuple[Any, ...], dtype[integer[Any]]], name: str | None = None) UnstructGrid3DSource¶

Create a subset UnstructGrid3D from this instance.

Parameters:
indices: Sequence[SupportsIndex] | ndarray[tuple[Any, ...], dtype[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[tuple[Any, ...], dtype[float64]], 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:
grid_data: ndarray[tuple[Any, ...], dtype[float64]]¶

Array containing data in the grid cells.

fill_value: float = 0¶

Value returned outside the grid, by default 0.

Returns:

UnstructGridFunction3D – Interpolator instance.

Raises:

TypeError – If the existing interpolator is not compatible with the provided grid data.

vector_interpolator(grid_vectors: ndarray[tuple[Any, ...], dtype[float64]], fill_vector: Vector3D = Vector3D(0.0, 0.0, 0.0)) 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[tuple[Any, ...], dtype[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.

Returns:

UnstructGridVectorFunction3D – Interpolator instance.

Raises:

TypeError – If the existing interpolator is not compatible with the provided grid vectors.

property cell_area : ndarray[tuple[Any, ...], dtype[float64]]Source¶

Cell areas as (num_cell,) array.

property cell_centre : ndarray[tuple[Any, ...], dtype[float64]]Source¶

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

property cell_volume : ndarray[tuple[Any, ...], dtype[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_mesh(data: ndarray[tuple[Any, ...], dtype[float64]] | None = None, ax: Axes | None = None, **grid_styles) AxesSource¶

Plot the grid geometry to a matplotlib figure.

Parameters:
data: ndarray[tuple[Any, ...], dtype[float64]] | None = None¶

Data array defined on the grid.

ax: Axes | None = None¶

Matplotlib axes to plot on. If None, a new figure and axes are created.

**grid_styles¶

Styles for the grid lines and faces.