stem.mesh module

class stem.mesh.Element(id: int, element_type: str, node_ids: List[int])

Bases: object

Class containing information about an element

Attributes:
  • id (int): element id

  • element_type (str): Gmsh element type

  • node_ids (Sequence[int]): node ids

Initialize the element.

Args:
  • id (int): Element id

  • element_type (str): Gmsh-element type

  • node_ids (List[int]): Node connectivities

class stem.mesh.ElementShape(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)

Bases: Enum

Enum class for the element shape. TRIANGLE for triangular elements and tetrahedral elements, QUADRILATERAL for quadrilateral elements and hexahedral elements.

QUADRILATERAL = 'quadrilateral'
TRIANGLE = 'triangle'
class stem.mesh.Mesh(ndim: int)

Bases: object

Class containing information about the mesh

Args:
  • ndim (int): number of dimensions of the mesh

Attributes:
  • ndim (int): number of dimensions of the mesh

  • nodes (Dict[int, Node]): dictionary of node ids followed by the node object

  • elements (Dict[int, Element]): dictionary of element ids followed by the element object

Initialize the mesh.

Args:
  • ndim (int): number of dimensions of the mesh

calculate_centroids() ndarray[tuple[Any, ...], dtype[float64]]

Calculate the centroids of all elements

Returns:
  • npty.NDArray[np.float64]: centroids of all elements

classmethod create_mesh_from_gmsh_group(mesh_data: Dict[str, Any], group_name: str) Mesh

Creates a mesh object from gmsh group

Args:
  • mesh_data (Dict[str, Any]): dictionary of mesh data

  • group_name (str): name of the group

Raises:
  • ValueError: If the group name is not found in the mesh data

Returns:
find_elements_connected_to_nodes() Dict[int, List[int]]

Creates a dictionary of node ids as keys and a list of element ids which are connected to the node as values.

Returns:
  • Dict[int, List[int]]: dictionary containing node ids as keys and a list of element ids which are

connected to the node as values.

class stem.mesh.MeshSettings(element_size: float = -1, element_order: int = 1, element_shape: ElementShape = ElementShape.TRIANGLE)

Bases: object

A class to represent the mesh settings.

Attributes:
  • element_size (float): The element size (default -1, which means that gmsh determines the size).

  • element_shape (ElementShape): The element shape. TRIANGLE for triangular elements and tetrahedral elements, QUADRILATERAL for quadrilateral elements and hexahedral elements. (default TRIANGLE)

  • __element_order (int): The element order. 1 for linear elements, 2 for quadratic elements. (default 1)

Initialize the mesh settings.

Args:
  • element_size (float): The element size (default -1, which means that gmsh determines the size).

  • element_order (int): The element order. 1 for linear elements, 2 for quadratic elements. (default 1)

  • element_shape (ElementShape): The element shape. TRIANGLE for triangular elements and tetrahedral elements, QUADRILATERAL for quadrilateral elements and hexahedral elements. (default TRIANGLE)

property constraints: Dict[str, Any]

Get the constraints.

Returns:
  • Dict[str, Any]: The constraints.

property element_order: int

Get the element order.

Returns:
  • int: element order

set_structured_mesh_constraint_line(line_id: int, n_points: int)

Set the structured mesh constraint for a line.

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

  • n_points (int): The number of points.

set_structured_mesh_constraint_surface(surface_id: int, n_points: List[int])

Set the structured mesh constraint for a surface.

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

  • n_points (List[int]): The number of points in x,y,z direction.

set_structured_mesh_constraint_volume(volume_id: int, n_points: List[int])

Set the structured mesh constraint for a volume.

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

  • n_points (int): The number of points in x,y,z direction.

class stem.mesh.Node(id: int, coordinates: Sequence[float])

Bases: object

Class containing information about a node

Attributes:
  • id (int): node id

  • coordinates (Sequence[float]): node coordinates

Initialize the node.

Args:
  • id (int): Node id

  • coordinates (Sequence[float]): Node coordinates