pysdic.fem.compute_elements_centers#
- compute_elements_centers(vertices_coordinates, connectivity_array, element_type)[source]#
Compute the center of each element of a mesh.
The center of an element is the image \(X(\Xi_c)\) of the center \(\Xi_c\) of the reference element, the mean of the Gauss points of the element type (e.g. \((\frac{1}{3}, \frac{1}{3})\) for the triangles and \((0, 0)\) for the quadrangles). For linear elements, it is the mean of the vertices of the element (centroid of the triangles, mean of the 4 vertices of the quadrangles).
Any element type is supported.
Note
Input
vertices_coordinateswill be converted tonumpy.float64.Input
connectivity_arraywill be converted tonumpy.int64.
- Parameters:
vertices_coordinates (ArrayLike) – An array of shape \((N_v, E)\) 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).
- Returns:
centers – An array of shape \((N_e, E)\) with the center of each element.
- Return type:
Examples
1import numpy 2from pysdic.fem import compute_elements_centers 3 4vertices_coordinates = numpy.array([[0, 0, 0], [3, 0, 0], [0, 3, 0], [3, 3, 3]]) 5connectivity_array = numpy.array([[0, 1, 2], [1, 3, 2]]) 6 7centers = compute_elements_centers(vertices_coordinates, connectivity_array, "triangle_3") 8print(centers)
[[1. 1. 0.] [2. 2. 1.]]