upxo.meshing.gbconformant.d3v2p1.mesh_tables module
Integer-row and edge tables: the results of np.unique(axis=0), from one-dimensional keys.
np.unique(a, axis=0) sorts rows through a structured view, which is several times slower than sorting one integer per row. For non-negative-shifted integer rows the two orders agree: pack each row into one int64 with the first column most significant, sort the keys, and unpack. The unique rows, the inverse and the counts are then equal to numpy’s, element for element and in the same order. When the columns are too wide to pack at once (a grain label in front of three node numbers of a large mesh), the leading columns are replaced by their rank among the distinct values, which keeps the order, and packing continues; the unique rows are then read back from the input. Rows that still do not fit, and anything that is not integer, go to np.unique.
- upxo.meshing.gbconformant.d3v2p1.mesh_tables.unique_rows(rows, return_inverse=False, return_counts=False)[source]
np.unique(rows, axis=0, return_inverse=…, return_counts=…) for an integer array.
Returns the unique rows (sorted lexicographically, dtype of
rows), then the inverse when asked (always one-dimensional, one entry per row) and then the counts when asked. Equal to numpy’s results for integer rows; other arrays and rows that do not pack are handed to numpy.
- upxo.meshing.gbconformant.d3v2p1.mesh_tables.node_element_index(elements, n_points)[source]
(numbers, offsets): the elements around each node, as the code of d3v2p0 builds them.
numbers[offsets[n]:offsets[n + 1]]are the numbers of the elements (tets, triangles) that contain noden, ascending; equal tonp.argsort(elements.ravel(), kind='stable') // kfor k nodes per element, with the matching cumulative counts. A counting sort (a compressed sparse row matrix) builds it in linear time. An element that repeats a node would be merged by the sparse format, and without scipy there is no such format: both cases use the argsort.
- upxo.meshing.gbconformant.d3v2p1.mesh_tables.triangle_edges(triangles)[source]
The three edges of every triangle as sorted node pairs, shape (3 * n, 2), triangle by triangle.
- class upxo.meshing.gbconformant.d3v2p1.mesh_tables.EdgeIncidence(triangles)[source]
Bases:
objectThe edges of a triangle list and the triangles around each, as d3v2p0’s facet code builds them.
edgesare the unique sorted node pairs (lexicographic order),inversemaps each of the 3 * n triangle edges (triangle by triangle) to its unique edge,countsis the number of triangles on each edge,orderlists the triangle edges grouped by unique edge (stable) andoffsetsare the group starts. Triangle number of a triangle edgeeise // 3.