Repository navigation
Description
Regions whose operands abut exactly (two cubes sharing a face) have two coincident faces at the contact: the earlier operand's and the later one's. The queries then report the one interface as two different surfaces depending on the side asked from, so its surface id, label and part change across it. Requested 2026-11-10, after #321 (PR #323).
Today: with A first and B on top in an Overlay, closestSurface(p, A) names A's own face (on a tie the region's own surface wins) and closestSurface(p, B) names B's. firstRegionChange() keeps the earlier crossing on a tie too. The workaround is geometric: let the earlier operand reach a little into the later one, so that its face lies under the later one and only the later face remains. SurfaceSelector::interface(A, B) already catches both faces, so a boundary condition by interface is right either way.
Proposal: the later operand's face wins at a coincident face, within a tolerance. This is what a slight overlap gives, without changing the geometry: an Overlay can then be written with abutting parts.
closestSurface(p, region): where the region's own value and a later region's agree within the tolerance, the later one's face is the surface, so both sides name the same surface, label and part.firstRegionChange(): where leaving the earlier solid and entering the later one happen at the sametwithin the tolerance, the later face is reported, so rays, the viewer andfindSurfacePieces()see one piece.- The subdomain queries inherit it; the region functions do not change (both are zero at the contact).
- The tolerance: exact ties happen only for analytic shapes on exact coordinates; meshes from different tools are flush only to about 1e-6 of their size. A default of a small multiple of the march tolerance at the object's scale (as the section cut's nudge uses), and a
TapeOptionssetting for parts that are only roughly flush. - Cost: comparisons on near-ties only; no extra evaluations elsewhere; device-safe.
- Tests: abutting cubes from both sides name one surface; a rotated pair flush only to rounding, within the tolerance; a ray across the contact reports one crossing, on the later face.
Not covered: small gaps. Parts slightly apart leave a thin sliver of the background (region 0) between them. That is geometry, not a tie, and closing it would change the region functions. A check instead: checkLabels() or a sibling reports regions that nearly touch ("regions 1 and 2 nearly touch, gap 3e-6"), so the input can be fixed or an overlap built in.
Roadmap: #232.
Generated by Claude Code
Activity
rmrsk commentedon Nov 27, 2026
API proposal for approval (#325)
Agreed in the design discussion (2026-11-27): the tolerance lives in
TapeOptionsonly; the gap is closed in the region functions as well as in the queries; the near-gap check is in the same pull request. Branch:abutting-interfaces, offmain.The rule
Let A be a region and B the smallest of the solids of the regions after it (as in the region function today, without the masks the two share), and ε the tolerance as a length. Where
S_A + S_B < ε, the two are one interface: B's face.S_A' = min(S_A, (S_A + S_B - ε) / 2),f_A = max(S_A', -S_B).Overlapping or flush operands are unchanged. A gap narrower than ε is filled by the earlier region up to the later one's face: both functions are zero on B's face,
f_A = -f_Bon B's side, andf_Astays 1-Lipschitz (a distance bound, so marching stays safe).region(), the background, the whole object and the subdomain functions use the grown solids.closestSurface(p, region)names B's face whereS_A + S_B < ε, from either side. The neighbor region and material across it are the other region's, from both sides; today, from the later region's side of flush faces, the neighbor comes out as the background.firstRegionChange()reports one crossing at the interface, on B's face, in either direction; a ray traces the ungrown solids, so the crossing stays exact where the shapes have ray forms.sqrt(R ε). Only contacts between different regions are welded.The tolerance
Why 1e-5 of the diagonal: above float rounding of distances (a few 1e-7 of the coordinates) and the flushness of meshes exported by different tools (about 1e-6); below what an embedded-boundary grid resolves (rarely finer than 1e-4 of the domain); below the default march tolerance (1e-4), so the weld never decides more than a marched surface resolves.
The near-gap check
Host only, beside
findSurfacePieces()(EBGeometry_SurfacePieces.hpp):ebgstudioprints what it finds when a model loads, for exampleregions 1 and 2 nearly touch: gap 3.1e-6 at (0.2, 0, 0.5).Usage
Tests
Abutting cubes name one surface, with the right neighbor material, from both sides; a rotated pair flush only to rounding is welded; a gap of 1e-6 of the diagonal is closed and one of 1e-4 is reported by
findNearGaps()and not closed; a ray across the contact reports one crossing in each direction; two nearly touching spheres in different regions are welded by a neck; tolerance 0 keeps today's behavior for a gap. Each device-callable query also as a[gpu]case.Checks
The region functions and render kernels change: ptxas registers, stack and spills of the region kernels against the base, and a receipt with host and CUDA sections.
Regions: welded within the interface tolerance (#325)
Regions: the interface tolerance as a length (TapeOptions::m_interfac…
Regions: the weld is a tape feature, TapeFeature::Weld (#325)
Regions: abutting operands share one interface within a tolerance, an…