pysdic.Mesh.locate_points#
- Mesh.locate_points(points, *, n_subdivisions=None, max_iteration=20, tolerance=1e-10)[source]#
Locate points in a 2D surface mesh (\(K = 2\), \(E = 2\)): compute the element containing each point and its natural coordinates.
Shortcut for
pysdic.fem.locate_points()with the coordinates, connectivity and element type of the mesh (see this function for the method and the parameters).The points are flattened in C order: the point
points[i, j]of a batch of shape \((H, W, 2)\) gives the integration pointi * W + j. Points outside the mesh or not finite are unlocated.See also
cast_rays()to locate the intersections of rays with a 3D surface mesh.
- Parameters:
points (ArrayLike) – The coordinates of the points, an array of shape \((\dots, 2)\).
n_subdivisions (Optional[Integral], optional (default:
None)) – The number of segments per edge of the reference element for the first approximation (ignored fortriangle_3).max_iteration (Integral, optional (default:
20)) – The maximum number of Newton iterations (ignored fortriangle_3).tolerance (Real, optional (default:
1e-10)) – The tolerance on the natural coordinates (convergence of the Newton iterations and membership of the elements).
- Returns:
One point per input point, \(N_p = \prod (\dots)\). The points outside the mesh are unlocated (element index
-1).- Return type:
- Raises:
ValueError – If the mesh is not a 2D surface mesh with an element type, or
pointsdoes not have a last dimension of size 2.
Examples
1from pysdic import Mesh 2 3mesh = Mesh([[0, 0], [1, 0], [0, 1]], [[0, 1, 2]], element_type="triangle_3") 4 5integration_points = mesh.locate_points([[0.2, 0.3], [1.0, 1.0]]) 6print(integration_points.natural_coordinates, integration_points.element_indices) 7# [[0.2 0.3] [nan nan]] [ 0 -1]