pysdic.Mesh.add_vertices#

Mesh.add_vertices(new_vertices, force_inplace=False)[source]#

Add new vertices to the mesh by appending new vertex coordinates.

This method is an extension of the vertices.concatenate method that allows adding new vertices to the mesh while ensuring that the vertices structure is maintained and validated. This method will ensure that the new vertices are compatible with the existing mesh structure and will update the mesh’s vertices accordingly.

Note

The new vertices will be added to the end of the existing vertices object and store in a new vertices object (Copy of the original vertices object with the new vertices concatenated). The properties of the new vertices will be initialized with NaN values and stored in the new vertices object.

See also

Parameters:
  • new_vertices (Union[PointCloud, ArrayLike]) – An array of shape (\(Q\), \(E\)) containing the coordinates of the new vertices to add, where \(Q\) is the number of new vertices and \(E\) is the embedding dimension.

  • force_inplace (bool, optional) – If True, the new vertices will be concatenated to the existing vertices in place, modifying the original vertices object. If False, a new vertices object will be created to store the combined vertices, leaving the original vertices object unchanged. By default False.

Raises:
  • TypeError – If new_vertices is not a PointCloud instance or an array-like object. If force_inplace is not a boolean.

  • ValueError – If new_vertices does not have the correct shape.

Return type:

None

Examples

Create a simple Mesh instance.

1import numpy as np
2from pysdic import Mesh, PointCloud
3
4points = np.array([[0, 0, 0], [1, 0, 0], [0, 1, 0]])
5connectivity = np.array([[0, 1, 2]])
6mesh3d = Mesh(points, connectivity, element_type="triangle_3")

Add new vertices to the mesh.

1new_vertices = np.array([[0, 0, 1], [1, 1, 1]])
2mesh3d.add_vertices(new_vertices)
3
4print(mesh3d.vertices)
5# Output: PointCloud with 5 points [[0, 0, 0], [1, 0, 0], [0, 1, 0], [0, 0, 1], [1, 1, 1]]