upxo.meshing.gbconformant.d3v2p0.small_grains module

Conservative whole-grain absorption before voxel refinement.

Each sequential merge uses current face adjacency, never batch merge chains. New cubical boundary-link defects are forbidden. Existing defects are reported and must still pass the downstream topology cleaner before surface extraction.

upxo.meshing.gbconformant.d3v2p0.small_grains.remove_small_grains(labels, *, enabled=True, min_voxels=4, protected_ids=(), protect_rve=False, max_passes=10, selection='shared_area', spacing=(1.0, 1.0, 1.0), preserve_recipient_components=True, track_history=True)[source]

Absorb entire IDs with count < min_voxels; return copy and JSON report.

All nonnegative labels (including zero) are grains. Threshold is measured on the input grid, before upscaling. Protected IDs cannot be removed but may receive voxels. Disconnected pieces of an ID are removed together. A protected island should be listed explicitly. No IDs are renumbered. Exact checks favour correctness; this first version is not optimized for thousands of candidates. Failed proposals leave the working array intact.

track_history builds the per-pass history in the report (grains still below the floor, voxels merged, proposals rejected); off, it stays empty and the extra bookkeeping is skipped.