pysdic.create_uniform_quadrangle_4_mesh#
- create_uniform_quadrangle_4_mesh(vertices, x_connect=False, y_connect=False, x_swap=False, y_swap=False, direct=True, uv_layout=0)[source]#
Create the quadrilateral connectivity and properties for a uniform grid mesh.
The mesh is defined in a local \((n_x, n_y)\) grid of vertices, where \(n_x\) is the number of vertices along the x direction and \(n_y\) is the number of vertices along the y direction.
If
x_connectis True, the mesh is connected in the x direction (cylindrical topology) by adding a fictive column of vertices at \(x = n_x\) that is equal to the first column of vertices at \(x = 0\) and connecting them with quadrilaterals. Ifx_swapis True, the order of the vertices in the x direction is reversed during thex_connectoperation, so the vertex at \(x = n_x, y = i\) is connected to the vertex at \(x = 0, y = n_y - 1 - i\) instead of \(x = 0, y = i\).The same applies for the y direction with the
y_connectandy_swapoptions.
\((n_x, n_y)\) grid of vertices and the corresponding quadrilateral connectivity and selected
x_connect,y_connect,x_swapandy_swapoptions.#If
directis True, the quadrilaterals are defined in counterclockwise order for an observer looking from above, otherwise they are defined in clockwise order.counterclockwise order for
direct=True: \((i_X, i_Y), (i_X + 1, i_Y), (i_X + 1, i_Y + 1), (i_X, i_Y + 1)\)clockwise order for
direct=False: \((i_X, i_Y), (i_X, i_Y + 1), (i_X + 1, i_Y + 1), (i_X + 1, i_Y)\)
Vertices are ordered first along the x direction, then along the y direction. So the vertex at y index
i_Yand x indexi_X(both starting from 0) is located at:mesh.vertices[i_Y * n_x + i_X, :]
- Parameters:
vertices (ArrayLike) – An array of shape \((n_x, n_y, E)\) containing the vertex positions in E-dimensional space.
x_connect (bool, optional (default:
False)) – If True, connect the mesh in the x direction by adding a fictive column of vertices at \(x = n_x\) that is equal to the first column of vertices at \(x = 0\) and connecting them with quadrilaterals.y_connect (bool, optional (default:
False)) – If True, connect the mesh in the y direction by adding a fictive row of vertices at \(y = n_y\) that is equal to the first row of vertices at \(y = 0\) and connecting them with quadrilaterals.x_swap (bool, optional (default:
False)) – If True, reverse the order of the vertices in the x direction during thex_connectoperation, so the vertex at \(x = n_x, y = i\) is connected to the vertex at \(x = 0, y = n_y - 1 - i\) instead of \(x = 0, y = i\).y_swap (bool, optional (default:
False)) – If True, reverse the order of the vertices in the y direction during they_connectoperation, so the vertex at \(x = i, y = n_y\) is connected to the vertex at \(x = n_x - 1 - i, y = 0\) instead of \(x = i, y = 0\).direct (bool, optional (default:
True)) – If True, the quadrilaterals are defined in counterclockwise order for an observer looking from above, otherwise they are defined in clockwise order.uv_layout (Integral, optional (default:
0)) – The UV mapping strategy. Must be an integer between 0 and 7.
- Returns:
The generated quadrilateral mesh as a
pysdic.Meshobject with the specified connectivity and UV mapping.- Return type:
UV Mapping#
The UV coordinates are generated based on the vertex positions in the mesh and uniformly distributed in the range [0, 1] for the
OpenGL texture mapping convention(See https://learnopengl.com/Getting-started/Textures). Several UV mapping strategies are available and synthesized in theuv_layoutparameter.An image is defined by its four corners:
Lower-left corner : pixel with array coordinates
image[height-1, 0]but OpenGL convention is (0,0) at lower-leftUpper-left corner : pixel with array coordinates
image[0, 0]but OpenGL convention is (0,1) at upper-leftLower-right corner : pixel with array coordinates
image[height-1, width-1]but OpenGL convention is (1,0) at lower-rightUpper-right corner : pixel with array coordinates
image[0, width-1]but OpenGL convention is (1,1) at upper-right
The following options are available for
uv_layoutand their corresponding vertex mapping:uv_layout
Vertex lower-left corner
Vertex upper-left corner
Vertex lower-right corner
Vertex upper-right corner
0
(0, 0)
(0, n_y-1)
(n_x-1, 0)
(n_x-1, n_y-1)
1
(0, 0)
(n_x-1, 0)
(0, n_y-1)
(n_x-1, n_y-1)
2
(n_x-1, 0)
(0, 0)
(n_x-1, n_y-1)
(0, n_y-1)
3
(0, n_y-1)
(0, 0)
(n_x-1, n_y-1)
(n_x-1, 0)
4
(0, n_y-1)
(n_x-1, n_y-1)
(0, 0)
(n_x-1, 0)
5
(n_x-1, 0)
(n_x-1, n_y-1)
(0, 0)
(0, n_y-1)
6
(n_x-1, n_y-1)
(0, n_y-1)
(n_x-1, 0)
(0, 0)
7
(n_x-1, n_y-1)
(n_x-1, 0)
(0, n_y-1)
(0, 0)
The table above gives for the 4 corners of a image the corresponding vertex in the mesh.