pysdic.triangle_3_compute_elements_areas#
- triangle_3_compute_elements_areas(vertices_coordinates, connectivity)[source]#
Compute the areas of triangular elements defined by the given vertices and connectivity.
The area of each triangular element is computed using the cross product of two edges of the triangle.
\[\text{Area} = \frac{1}{2} \| \vec{AB} \times \vec{AC} \|\]Note
The input
vertices_coordinateswill be converted tonumpy.float64for computation. The inputconnectivitywill be converted tonumpy.int64for computation.Warning
No tests are performed to check if the inputs array content are consistent (e.g., if the connectivity contains invalid vertex indices, …). Only the shapes and types of the input arrays are validated. The behavior of the function is undefined if the input arrays are not consistent.
- Parameters:
vertices_coordinates (ArrayLike) – An array of shape \((N_v, 3)\) representing the coordinates of the vertices.
connectivity (ArrayLike) – An array of shape \((N_e, 3)\) representing the connectivity of the triangular elements.
- Returns:
An array of shape \((N_e,)\) representing the area of each triangular element.
- Return type:
- Raises:
TypeError – If the inputs are not numpy arrays.
ValueError – If the input arrays do not have the correct shapes.
See also
pysdic.triangle_3_compute_elements_normalsFor computing the normal vectors of triangular elements.
pysdic.triangle_3_compute_vertices_normalsFor computing the normal vectors at each vertex of the mesh.
Examples
Computing the areas of triangular elements:
1import numpy as np 2from pysdic import triangle_3_compute_elements_areas 3 4vertices = np.array([[0, 0, 0], 5 [1, 0, 0], 6 [0, 1, 0], 7 [0, 0, 1]]) # shape (4, 3) 8 9connectivity = np.array([[0, 1, 2], 10 [0, 1, 3], 11 [0, 2, 3], 12 [1, 2, 3]]) # shape (4, 3) 13 14areas = triangle_3_compute_elements_areas(vertices, connectivity) 15print(areas)
[0.5, 0.5, 0.5, 0.8660254]