pysdic.create_3d_quadrangle_4_heightmap#

create_3d_quadrangle_4_heightmap(function=None, *, frame=None, x_bounds=None, y_bounds=None, x_array=None, y_array=None, n_x=None, n_y=None, direct=True, uv_layout=0)[source]#

Create a 3D quadrangle_4 mesh of a height surface \(z = f(x, y)\).

The grid of vertices is given, for each axis, either by bounds and a number of vertices (uniform grid), or by an array of coordinates.

Important

n_x and n_y are numbers of vertices, not elements.

The vertex at the indices i_x along \(x\) and i_y along \(y\) (both starting from 0) is mesh.coordinates[i_y * n_x + i_x].

Parameters:
  • function (Optional[Callable[[numpy.ndarray, numpy.ndarray], ArrayLike]], optional) – The height \(f(x, y)\), called once with the 2D grids of \(x\) and \(y\) (shape \((n_x, n_y)\)). It must return a scalar or an array of the same shape. By default, \(f = 0\) (flat mesh).

  • frame (Optional[py3dframe.Frame], optional (default: None)) – The local frame of the surface: the vertices are computed in this frame and expressed in the canonical frame. By default, the canonical frame. Requires the optional package py3dframe.

  • x_bounds (Optional[Tuple[Real, Real]], optional) – The bounds of the uniform grid along \(x\) and \(y\) (with n_x and n_y).

  • y_bounds (Optional[Tuple[Real, Real]], optional) – The bounds of the uniform grid along \(x\) and \(y\) (with n_x and n_y).

  • x_array (Optional[ArrayLike], optional) – The coordinates of the grid along \(x\) and \(y\) (instead of the bounds), with at least 2 values.

  • y_array (Optional[ArrayLike], optional) – The coordinates of the grid along \(x\) and \(y\) (instead of the bounds), with at least 2 values.

  • n_x (Optional[Integral], optional) – The numbers of vertices along \(x\) and \(y\) (\(\geq 2\)). Required with the bounds, checked against the arrays if given.

  • n_y (Optional[Integral], optional) – The numbers of vertices along \(x\) and \(y\) (\(\geq 2\)). Required with the bounds, checked against the arrays if given.

  • direct (bool, optional (default: True)) – If True, the vertices of the quadrangles are ordered counterclockwise seen from above (\(+z\)), otherwise clockwise.

  • uv_layout (Integral, optional (default: 0)) – The UV mapping strategy, between 0 and 7 (see pysdic.create_uniform_quadrangle_4_mesh()).

Returns:

The quadrangle_4 mesh, with a UV map.

Return type:

pysdic.Mesh

Examples

1import numpy
2from pysdic import create_3d_quadrangle_4_heightmap
3
4mesh = create_3d_quadrangle_4_heightmap(
5    lambda x, y: numpy.sin(x) * numpy.cos(y),
6    x_bounds=(0, numpy.pi), y_bounds=(0, numpy.pi), n_x=10, n_y=20,
7)
8print(mesh.n_vertices, mesh.n_elements)  # 200 171