MCPcopy Create free account
hub / github.com/FEniCS/dolfinx / get_triangles

Function get_triangles

cpp/dolfinx/refinement/plaza.cpp:36–66  ·  view source on GitHub ↗

----------------------------------------------------------------------------- 2D version of subdivision allowing for uniform subdivision (flag) @param[in] indices Vector containing the global indices for the original vertices and potential new vertices at each edge. If an edge is not refined its corresponding entry is -1. Size `num_vertices + num_edges` @param[in] longest_edge Local index of the l

Source from the content-addressed store, hash-verified

34/// sub-triangles.
35/// @returns Local indices for each sub-divived triangle
36std::pair<std::array<std::int32_t, 12>, std::size_t>
37get_triangles(std::span<const std::int64_t> indices,
38 const std::int32_t longest_edge, bool uniform)
39{
40 // NOTE: The assumption below is based on the UFC ordering of a triangle, i.e.
41 // that the N-th edge of a triangle is the edge where the N-th vertex is not
42 // part of the set. v0 and v1 are at ends of longest_edge (e2) opposite vertex
43 // has same index as longest_edge
44 const std::int32_t v0 = (longest_edge + 1) % 3;
45 const std::int32_t v1 = (longest_edge + 2) % 3;
46 const std::int32_t v2 = longest_edge;
47 const std::int32_t e0 = v0 + 3;
48 const std::int32_t e1 = v1 + 3;
49 const std::int32_t e2 = v2 + 3;
50
51 // Longest edge must be marked
52 assert(indices[e2] >= 0);
53
54 // If all edges marked, consider uniform refinement
55 if (uniform and indices[e0] >= 0 and indices[e1] >= 0)
56 return {{e0, e1, v2, e1, e2, v0, e2, e0, v1, e2, e1, e0}, 12};
57
58 if (indices[e0] >= 0 and indices[e1] >= 0)
59 return {{e2, v2, e0, e2, e0, v1, e2, v2, e1, e2, e1, v0}, 12};
60 else if (indices[e0] >= 0 and indices[e1] < 0)
61 return {{e2, v2, e0, e2, e0, v1, e2, v2, v0}, 9};
62 else if (indices[e0] < 0 and indices[e1] >= 0)
63 return {{e2, v2, v1, e2, v2, e1, e2, e1, v0}, 9};
64 else
65 return {{e2, v2, v1, e2, v2, v0}, 6};
66}
67
68//-----------------------------------------------------------------------------
69// 3D version of subdivision

Callers 1

get_simplicesMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected