10.3. Primitives

A few useful utilities for creating primitives particularly relevant for fusion.

cherab.tools.primitives.axisymmetric_mesh.axisymmetric_mesh_from_polygon(polygon, num_toroidal_segments)

Generates an Raysect Mesh primitive from the specified 2D polygon.

Parameters:
  • polygon (object) – An object which can be converted to a numpy array with shape [N,2] specifying the wall outline polygon in the R-Z plane. The polygon should not be closed, i.e. vertex i = 0 and i = N should not be the same vertex, but neighbours.

  • num_toroidal_segments (int) – The number of repeating toroidal segments that will be used to construct the mesh.

Returns:

A Raysect Mesh primitive constructed from the R-Z polygon using symmetry.

>>> from cherab.tools.primitives import axisymmetric_mesh_from_polygon
>>>
>>> # wall_polygon is your (N, 2) ndarray describing the polygon
>>> mesh = axisymmetric_mesh_from_polygon(wall_polygon)
cherab.tools.primitives.toroidal_mesh.toroidal_mesh_from_polygon(polygon, toroidal_extent, polygon_triangles, num_toroidal_segments)

Generates a watertight Raysect Mesh primitive from the specified 2D polygon in R-Z plane by extending it in toroidal direction by a given angle and closing the poloidal faces with triangulated polygons.

Parameters:
  • polygon (object) – An object which can be converted to a numpy array with shape [N,2] specifying the wall outline polygon in the R-Z plane. The polygon should not be closed, i.e. vertex i = 0 and i = N should not be the same vertex, but neighbours.

  • polygon_triangles (object) – An object which can be converted to a numpy array with shape [M,3] specifying the triangulation of a polygon (polygon_triangles = [[v1, v2, v3],…), where v1, v2, v3 are the vertex array indices specifying the triangle’s vertices. Should be with clockwise winding. Defaults to None. If not provided, the triangulation will be performed using triangulate2d(polygon) from raysect.core.math.polygon.

  • toroidal_extent (float) – Angular extention of an element in toroidal direction (in degrees). Note that in the case of toroidal_extent=360 produces an axisymmetric mesh which has no end faces

  • num_toroidal_segments (int) – The number of repeating toroidal segments per given toroidal_extent that will be used to construct the mesh. Defaults to 500.

Returns:

A watertight Raysect Mesh primitive constructed from the R-Z polygon.

>>> from cherab.tools.primitives import toroidal_mesh_from_polygon
>>>
>>> # wall_polygon is your (N, 2) ndarray describing the polygon
>>> mesh = toroidal_mesh_from_polygon(wall_polygon, toroidal_extent = 50)