cherab.imas.ggd.UnstructGrid3D¶
-
class cherab.imas.ggd.UnstructGrid3D(vertices: ArrayLike, cells: ArrayLike, name: str =
'Cells')Source¶ Bases:
GGDGridUnstructured 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:
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[, ...])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.
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[float64]Source¶
Mesh vertex coordinates as
(N, 3)array in the (X, Y, Z) space.
- 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(indices: Sequence[SupportsIndex] | NDArray[integer[Any]], name: str | None =
None) UnstructGrid3DSource¶ Create a subset UnstructGrid3D from this instance.
- Parameters:
- Returns:
UnstructGrid3D– Subset instance.
-
interpolator(grid_data: NDArray[float64], 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[float64]¶
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 theInterpolatorCacheModetype 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
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:
- 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 theInterpolatorCacheModetype 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.
- property cell_centre : NDArray[float64]Source¶
Coordinate of cell centres as
(num_cell, dimension)array.
- property mesh_extent : dict[str, float]Source¶
Extent of the mesh.
A dictionary with xmin, xmax, ymin and ymax, … keys.