stem.geometry module

class stem.geometry.GeometricalObjectABC

Bases: ABC

An abstract base class for all geometrical objects.

abstract property id: int

Abstract property for returning the id of the object.

Raises:
  • Exception: cannot call abstract method.

class stem.geometry.Geometry(points: Dict[int, Point] = {}, lines: Dict[int, Line] = {}, surfaces: Dict[int, Surface] = {}, volumes: Dict[int, Volume] = {})

Bases: object

A class to represent a collection of geometric objects in a zero-, one-, two- or three-dimensional space.

Attributes:
  • points (Dict[int, Point]): An dictionary of Point objects representing the points in the geometry.

  • lines (Dict[int, Line]): A dictionary of Line objects representing the lines in the geometry.

  • surfaces (Dict[int, Surface]): A dictionary of Surface objects representing the surfaces in the geometry.

  • volumes (Dict[int, Volume]): A dictionary of Volume objects representing the volumes in the geometry.

calculate_area_surface(surface_id: int) float

Calculate the area of a convex or concave surface in a 3D space using the shoelace algorithm.

Args:
  • surface_id (int): The id of the surface.

Returns:
  • float: The area of the surface.

calculate_centre_of_mass_surface(surface_id: int) ndarray[tuple[Any, ...], dtype[float64]]

Calculate the centre of mass of a surface. Where mass is given to the length of the lines that make up the surface. The centre of mass is then given by the ‘O’ in the following diagram:

x—x—x—x—x | | x O x | | x—————x

Args:
  • surface_id (int): The id of the surface.

Returns:
  • npty.NDArray[np.float64]: The coordinates of the centre of mass of the surface.

calculate_centre_of_mass_volume(volume_id: int) ndarray[tuple[Any, ...], dtype[float64]]

Calculate the centre of mass of a volume. Where mass is given to the area of the surfaces that make up the volume.

Args:
  • volume_id (int): The id of the volume.

Returns:
  • npty.NDArray[np.float64]: The coordinates of the centre of mass of the volume.

calculate_centroid_of_line(line_id: int) ndarray[tuple[Any, ...], dtype[float64]]

Calculate the centroid of a line.

Args:
  • line_id (int): The id of the line.

Returns:
  • npty.NDArray[np.float64]: The coordinates of the centroid of the line.

calculate_centroid_of_surface(surface_id: int) ndarray[tuple[Any, ...], dtype[float64]]

Calculate the centroid of a surface.

Args:
  • surface_id (int): The id of the surface.

Returns:
  • npty.NDArray[np.float64]: The coordinates of the centroid of the surface.

calculate_length_line(line_id: int) float

Calculate the length of a line.

Args:
  • line_id (int): The id of the line.

Returns:
  • float: The length of the line.

classmethod create_geometry_from_geo_data(geo_data: Dict[str, Any])

Creates the geometry from gmsh geo_data

Args:
  • geo_data (Dict[str, Any]): A dictionary containing the geometry data as provided by gmsh_utils.

Returns:
classmethod create_geometry_from_gmsh_group(geo_data: Dict[str, Any], group_name: str)

Initialises the geometry by parsing the geometry data from the geo_data dictionary.

Args:
  • geo_data (Dict[str, Any]): A dictionary containing the geometry data as provided by gmsh_utils.

  • group_name (str): The name of the group to create the geometry from.

Returns:
  • Geometry: A Geometry object containing the geometric objects in the group.

get_ordered_points_from_surface(surface_id: int) List[Point]

Returns the points that make up the surface in the correct order, i.e. the order in which the points are connected by the lines that make up the surface.

Args:
  • surface_id (int): The id of the surface.

Returns:
  • List[Point]: A sequence of points that make up the surface in the correct order.

to_dict() Dict[str, Any]

Serializes the geometry object to a dictionary.

Returns:
  • Dict[str, Any]: A dictionary representation of the geometry object.

class stem.geometry.Line(id: int)

Bases: GeometricalObjectABC

A class to represent a line in space.

Inheritance:
Attributes:
  • id (int): A unique identifier for the line.

  • point_ids (Sequence[int]): A sequence of two integers representing the ids of the points that make up the line.

Constructor for the line class.

Args:

id (int): The id of the line.

classmethod create(point_ids: Sequence[int], id: int) Line

Creates a line object from a list of point ids and a line id.

Args:
  • point_ids (Sequence[int]): A sequence of two integers representing the ids of the points that make up the line.

  • id (int): The id of the line.

Returns:
  • Line: A line object.

property id: int

Getter for the id of the line.

Returns:
  • int: The id of the line.

class stem.geometry.Point(id: int)

Bases: GeometricalObjectABC

A class to represent a point in space.

Inheritance:
Attributes:
  • __id (int): A unique identifier for the point.

  • coordinates (Sequence[float]): A sequence of floats representing the x, y and z coordinates of the point.

Constructor for the point class.

Args:
  • id (int): The id of the point.

classmethod create(coordinates: Sequence[float], id: int) Point

Creates a point object from a list of coordinates and a point id.

Args:
  • coordinates (Sequence[float]): An iterable of floats representing the x, y and z coordinates of the point.

  • id (int): The id of the point.

Returns:
property id: int

Getter for the id of the point.

Returns:
  • int: The id of the point.

class stem.geometry.Surface(id: int)

Bases: GeometricalObjectABC

A class to represent a surface in space.

Inheritance:
Attributes:
  • __id (int): A unique identifier for the surface.

  • line_ids (Sequence[int]): A sequence of three or more integers representing the ids of the lines that make up the surface.

classmethod create(line_ids: Sequence[int], id: int) Surface

Creates a surface object from a list of line ids and a surface id.

Args:
  • line_ids (Sequence[int]): A sequence of three or more integers representing the ids of the lines that make up the surface.

  • id (int): The id of the surface.

Returns:
property id: int

Getter for the id of the surface.

Returns:
  • int: The id of the surface.

class stem.geometry.Volume(id: int)

Bases: GeometricalObjectABC

A class to represent a volume in a three-dimensional space.

Inheritance:
Attributes:
  • __id (int): A unique identifier for the volume.

  • surface_ids (Sequence[int]): A sequence of four or more integers representing the ids of the surfaces that make up the volume.

classmethod create(surface_ids: Sequence[int], id: int) Volume

Creates a volume object from a list of surface ids and a volume id.

Args:
  • surface_ids (Sequence[int]): A sequence of four or more integers representing the ids of the surfaces that make up the volume.

  • id (int): The id of the volume.

Returns:
property id: int

Getter for the id of the volume.

Returns:
  • int: The id of the volume.