upxo.meshing.gbconformant.d3v2p0.tet_swaps module
Phase 3 of tet improvement: face and edge swaps inside grains.
2-3 swap: two tets sharing a face (a, b, c) with apexes d and e become three tets around the new edge d-e. 3-2 swap: three tets around an edge d-e (ring a, b, c) become two tets sharing the face (a, b, c). Only tets of one grain take part, the swapped face or edge is inside that grain (never on a grain surface or RVE face), so grain surfaces, conformity and grain volumes are unchanged. A swap is kept only when - the worst normalised angle quality of the tets involved rises (smallest
dihedral relative to
target, largest relative tomax_angle),
the number of tets outside the limits (below
targetor abovemax_angle) does not rise, andevery new tet has positive volume and the new tets fill exactly the volume of the old ones (so they neither overlap nor invert).
- upxo.meshing.gbconformant.d3v2p0.tet_swaps.swap_tets(points, tetrahedra, grain_ids, surface_triangles, *, enabled=True, target=30.0, max_angle=150.0, max_passes=5, progress=None, track_history=True)[source]
Return (tetrahedra, grain_ids, report) after face and edge swaps.
surface_triangles: (m, 3) node indices of every grain-surface and RVE-face triangle; their faces and edges are never swapped.
- upxo.meshing.gbconformant.d3v2p0.tet_swaps.swap_grain_tetrahedra(tets, surface, *, enabled=True, target=30.0, max_angle=150.0, max_passes=5, progress=None)[source]
Swap faces and edges of a verified GrainTetrahedra result and re-verify it.
surface: the ClosedRVE whose triangles are the grain surfaces (points numbered as the first tet nodes). Conformity (each grain’s boundary faces equal its surface triangles), positive volumes, unchanged grain volumes, quality (Gmsh minSICN), dihedral statistics and readiness are rechecked.
- upxo.meshing.gbconformant.d3v2p0.tet_swaps.insert_nodes(points, tetrahedra, grain_ids, surface_triangles, *, enabled=True, target=30.0, max_angle=150.0, cavity_rings=(1, 2, 3), max_passes=3, search_iterations=40, samples=256, seed=0, progress=None, track_history=True)[source]
Return (points, tetrahedra, grain_ids, report) after node insertion.
For each tet below target (worst first), the cavity is first the union of the stars of its interior nodes (those nodes are replaced by the new one), then the tets around each of its edges not on a grain surface (the new node splits that edge; this removes tets lying flat on a grain surface), then this grain’s tets at each of its grain-surface edges with their neighbours (splits a wide grain wedge held by one tet), then grown from the tet over faces shared with tets of the same grain that are not grain-surface faces (cavity_rings: the ring counts tried). One new node is connected to every boundary face of the cavity and placed by a direct search that maximises the worst normalised angle quality of the new tets, starting from the best of
samplesrandom points in the cavity (seeded). The result is kept only when all new tets have positive volume, they fill exactly the cavity volume, the worst quality rises and the number of tets outside the limits (below target or above max_angle) does not rise. Grain surfaces are cavity boundary faces and stay.
- upxo.meshing.gbconformant.d3v2p0.tet_swaps.insert_grain_tetrahedra(tets, surface, *, enabled=True, target=30.0, max_angle=150.0, cavity_rings=(1, 2, 3), max_passes=3, progress=None)[source]
Insert nodes into a verified GrainTetrahedra result and re-verify it.
New nodes are appended after all existing nodes, so the grain-surface nodes keep their numbering. See insert_nodes for the acceptance rule.