pysdic.triangle_3_to_triangle_6#

triangle_3_to_triangle_6(mesh, *, propagate_vertices_properties=True, propagate_elements_properties=True)[source]#

Convert a triangle_3 mesh to a triangle_6 mesh by adding a vertex at the middle of each edge.

The triangle \((v_0, v_1, v_2)\) gives the element \((v_0, v_1, v_2, m_{01}, m_{12}, m_{20})\), where \(m_{ab}\) is the mid-edge vertex of the edge \(v_a - v_b\). A mid-edge vertex is shared by the two elements of its edge, so the mesh stays conforming.

The original vertices are unchanged (same order, indices \(0\) to \(N_v - 1\)). The mid-edge vertices are added after them, one per edge, in the lexicographic order of the (sorted) indices of the vertices of their edge. They are at the middle of the straight edges: the geometry of the mesh is unchanged, curved edges can be obtained by moving them afterwards.

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

  • propagate_vertices_properties (bool, optional (default: True)) – If True, the vertex properties are copied to the original vertices and interpolated (mean of the two vertices of the edge) at the mid-edge vertices. Only floating point properties can be interpolated.

  • propagate_elements_properties (bool, optional (default: True)) – If True, the element properties are copied (same elements). The UV map (element property "uvmap") is interpolated at the mid-edge vertices in each element, so the seams of the UV map are respected.

Returns:

The triangle_6 mesh, with the same \(N_e\) elements and \(N_v + N_{edges}\) vertices.

Return type:

pysdic.Mesh

Raises:
  • TypeError – If mesh is not a pysdic.Mesh.

  • ValueError – If the element type is not "triangle_3", or if a vertex property to propagate is not a floating point property.

Examples

1from pysdic import Mesh, triangle_3_to_triangle_6
2
3mesh = Mesh([[0, 0], [1, 0], [0, 1], [1, 1]], [[0, 1, 2], [1, 3, 2]], element_type="triangle_3")
4quadratic_mesh = triangle_3_to_triangle_6(mesh)
5print(quadratic_mesh.n_vertices)  # 9: 4 corners and 5 edges
6print(quadratic_mesh.elements)  # [[0 1 2 4 6 5] [1 3 2 7 8 6]]