autopdex.mesher.structured_mesh
- autopdex.mesher.structured_mesh(n_elements, vertices, element_type, order=1)[source]
Generate a structured 2D or 3D mesh over a quadrilateral or hexahedral domain, with an optional subdivision into simplex (triangular/tetrahedral) elements.
- Parameters:
n_elements (tuple of int) – For 2D, a tuple (nx, ny) specifying the number of elements along the x- and y-directions. For 3D, a tuple (nx, ny, nz).
vertices (array-like) – For 2D, a 4x2 array; for 3D, an 8x3 array defining the coordinates of the domain’s corner points.
element_type (str) – For 2D, either “quad” or “tri”; for 3D, either “brick” or “tet”.
order (int, optional) – The polynomial order of the elements. Currently, only linear elements (order == 1) are supported. Default is 1.
- Returns:
coords (jnp.ndarray) – An array of node coordinates. Its shape is ((n+1)*… x dim), where ‘dim’ represents the spatial dimension (2 or 3).
elements (jnp.ndarray) – An array of element connectivity. For quadrilaterals/brick elements each row lists the indices of the nodes forming the element, while for simplex elements each row lists the indices forming a triangle (3 nodes) or tetrahedron (4 nodes).
Notes
- For 2D:
The vertices should be provided as a 4x2 array in anti-clockwise order.
The mapping from a reference square ([-1, 1] x [-1, 1]) to the physical domain is performed using bilinear interpolation.
- For 3D:
The vertices should be provided as an 8x3 array, with the ordering corresponding to a standard hexahedron (e.g., starting with (-1, -1, -1) and proceeding in an anti-clockwise fashion on the bottom face, then defining the top face).
The mapping from a reference cube ([-1, 1]^3) to the physical domain is done via trilinear interpolation.
Currently, only linear (order == 1) elements are supported.