pysdic.quadrangle_4_to_triangle_3#

quadrangle_4_to_triangle_3(mesh, diagonal='first', *, seed=None, propagate_vertices_properties=True, propagate_elements_properties=True)[source]#

Convert a quadrangle_4 mesh to a triangle_3 mesh by splitting each quadrangle into two triangles.

The quadrangle \(q\) with vertices \((v_0, v_1, v_2, v_3)\) gives the triangles \(2q\) and \(2q + 1\), along one of its diagonals:

  • "first": diagonal \(v_0 - v_2\), triangles \((v_0, v_1, v_2)\) and \((v_0, v_2, v_3)\).

  • "second": diagonal \(v_1 - v_3\), triangles \((v_0, v_1, v_3)\) and \((v_1, v_2, v_3)\).

  • "alternate": "first" for the even quadrangles and "second" for the odd ones.

  • "random": a random diagonal for each quadrangle (see seed).

The triangles keep the orientation of the quadrangles. The vertices are unchanged (same order).

Parameters:
  • mesh (pysdic.Mesh) – A mesh with element type "quadrangle_4".

  • diagonal (str, optional (default: "first")) – The diagonal used to split the quadrangles: "first", "second", "alternate" or "random".

  • seed (Optional[Union[Integral, numpy.random.Generator]], optional (default: None)) – The seed (or the random generator) of diagonal="random", for reproducible results. Ignored for the other diagonals.

  • propagate_vertices_properties (bool, optional (default: True)) – If True, the vertex properties are copied to the triangle mesh.

  • propagate_elements_properties (bool, optional (default: True)) – If True, the element properties are copied to both triangles of each quadrangle. The UV map (element property "uvmap") is split with the quadrangles.

Returns:

The triangle_3 mesh, with \(2 N_e\) elements.

Return type:

pysdic.Mesh

Examples

1from pysdic import Mesh, quadrangle_4_to_triangle_3
2
3mesh = Mesh([[0, 0, 0], [1, 0, 0], [1, 1, 0], [0, 1, 0]], [[0, 1, 2, 3]], element_type="quadrangle_4")
4triangle_mesh = quadrangle_4_to_triangle_3(mesh, "second")
5print(triangle_mesh.elements)  # [[0 1 3] [1 2 3]]