pysdic.fem.compute_vertices_normals#

compute_vertices_normals(vertices_coordinates, connectivity_array, element_type)[source]#

Compute the unit normal at each vertex of a 3D surface mesh (\(K = 2\), \(E = 3\)).

The normal at a vertex is the mean of the normals \(\vec{n}_e\) of the elements using this vertex (see pysdic.fem.compute_elements_normals()), weighted by their areas \(A_e\) (see pysdic.fem.compute_elements_areas()):

\[\vec{n}_v = \frac{\sum_{e \ni v} A_e \vec{n}_e}{\| \sum_{e \ni v} A_e \vec{n}_e \|}\]

The degenerated elements (zero area) are ignored.

Note

  • Input vertices_coordinates will be converted to numpy.float64.

  • Input connectivity_array will be converted to numpy.int64.

Parameters:
  • vertices_coordinates (ArrayLike) – An array of shape \((N_v, 3)\) with the coordinates of the vertices.

  • connectivity_array (ArrayLike) – An array of shape \((N_e, N_{vpe})\) with the vertex indices of each element.

  • element_type (str) – The type of the elements (case insensitive), a surface element type.

Returns:

normals – An array of shape \((N_v, 3)\) with the unit normal at each vertex. The normal is NaN for the vertices used by no (valid) element, and where the weighted sum vanishes.

Return type:

numpy.ndarray

Examples

1import numpy
2from pysdic.fem import compute_vertices_normals
3
4vertices_coordinates = numpy.array([[0, 0, 0], [1, 0, 0], [0, 1, 0], [0, 0, 1]])
5connectivity_array = numpy.array([[0, 1, 2], [0, 1, 3], [0, 2, 3], [1, 2, 3]])
6
7normals = compute_vertices_normals(vertices_coordinates, connectivity_array, "triangle_3")
8print(normals)
[[ 0.57735027 -0.57735027  0.57735027]
 [ 0.4472136   0.          0.89442719]
 [ 0.66666667  0.33333333  0.66666667]
 [ 0.89442719  0.          0.4472136 ]]