Skip to content

Regions: abutting operands share one interface within a tolerance, and a near-gap check (#325) - #382

Merged
rmrsk merged 22 commits into
mainfrom
abutting-interfaces
Nov 27, 2026
Merged

rmrsk merged 22 commits into
mainfrom
abutting-interfaces

Conversation

@rmrsk

@rmrsk rmrsk commented Nov 27, 2026 •

Copy link
Copy Markdown
Owner

Summary

Closes #325.

Background

Parts of a model often meet face to face, and parts from different tools are rarely exactly flush: they overlap a little, or leave a hair-thin gap. Two regions whose operands abut had two coincident faces at the contact, so the queries named one interface as two surfaces depending on the side asked from, and from the later region's side of flush faces the region across came out as the background. A thin gap was a layer of the outside between two parts, below any grid's resolution, which a cut-cell code sees as tiny cut cells. #325 asks for one interface at such contacts, and a check that reports parts that nearly touch.

The design was settled with the maintainer on the issue (API: #325 (comment)), with four later decisions:

  • the gap is closed in the region functions as well as in the queries;
  • the weld acts only in the thin band where two surfaces face each other, so every region function stays exact elsewhere;
  • the tolerance can be given as a length, in C++ and in a model file, because a real gap can be small next to the whole object;
  • the weld is a tape feature, TapeFeature::Weld: the first receipt showed region and domain queries on many-region scenes up to a quarter slower on a device, from the weld's code alone, so a plain Tape<T> compiles none of it;
  • the tolerance defaults to 0 (only exact contacts are welded): which gaps are flaws and which are geometry depends on the model, not its units or size, so a gap is closed only when the model or the program sets a tolerance.

Solution

The weld. In a tape that lists TapeFeature::Weld (Tape<T, TapeFeature::Weld>), two regions closer than the interface tolerance share one interface, the later region's face, seen from either side. Every weld path is under if constexpr, so a plain Tape<T> compiles the region code it did before, and its tolerance is 0. The weld's rarely taken parts (the band's arithmetic, the welded region test, the welded background, the search for the region across from the surface) are out of line, so the region loops keep only a comparison.

  • Tape::weldedSolid() grows a region's solid into a gap to a later one: min(own, max((own + later - e)/2, own - e)) with e = c max(0, 2 eps - |own| - |later|), where c = max(0, -n_own . n_later) (by central differences) is how much the two surfaces face each other. Between surfaces that face each other, a gap narrower than the tolerance is filled by the earlier region up to the later one's face, across its whole width or not at all; faces side by side in one plane (a channel's cap flush with the end of the block it bores) are not welded.
  • region(), the region functions, regionDistances(), the background's function and the subdomain functions use it. They are exact outside the band within twice the tolerance of both surfaces, continuous everywhere (the weld tapers to nothing at the band's edge), and keep their sign outside welded gaps.
  • closestSurface(p, region) names the later face where the two come within the tolerance (own + later <= eps). The region across is the last region whose solid holds the point, as before; when none does and another region's solid is near enough to reach the surface, the point is moved onto the surface (along the solid's normal by its value), and the last region whose solid reaches that point within the tolerance is across. A region flush with or welded to the asked region is thus found from any depth, with its material.
  • firstRegionChange(): leaving a region straight into a later one is one crossing, on the later region's face.

The tolerance.

  • TapeOptions::m_interfaceTolerance: a fraction of the box's diagonal, default 0, which welds only exact contacts (overlapping or exactly flush regions) and closes no gap.
  • TapeOptions::m_interfaceLength (std::optional<double>): a length, which replaces the fraction when set.
  • Tape::getInterfaceTolerance(): the tolerance as a length, on the host and a device.

The language. object overlay(weld = 1e-6) { ... } sets the length for the whole object, once. Model::tapeOptions() carries it to a tape; DomainObject::tapeOptions() gives a domain's own object the whole model's tolerance as a length (its box is smaller), so its tape welds exactly as the whole model's. Printing keeps the setting as written.

The near-gap check. findNearGaps(tape, width = 1e-3, resolution = 64) (EBGeometry_SurfacePieces.hpp) reports the pairs of regions a thin layer of the outside separates, wider than the tolerance and narrower than width, each with its narrowest gap and where. ebgstudio prints them when it reads a model (check, and the viewer on load): regions 'left' and 'right' nearly touch: gap 0.001 at (1.0005, 0.013, 0.009).

ebgstudio, the language examples and the MPI integrations compile models with Tape<T, TapeFeature::Weld> and model.tapeOptions(), and domains' own objects with own.tapeOptions().

The Weld probe (Performance/Weld): region() and regionDistances() at random points of the Regions probe's particles (the feature's cost where it does nothing), and region() and closestSurface() near the hair-thin gaps of a stack of 4 x 4 x 4 blocks (where every query reaches a weld).

Docs: a "Regions that touch" section on the regions page; the feature, the options, findNearGaps() and tapeOptions() on the API pages; Weld in the features table; overlay(weld = ...) on the language page; the Weld probe on the performance page.

Side-effects

  • Region function values change only inside the band of a weld (within twice the tolerance of two surfaces facing each other), by at most twice the tolerance. Beyond the band, on the later region's side of a welded gap, the earlier region's function is its plain distance to the earlier solid, which differs from the exact opposite of the later one's by the gap.
  • No change for a plain Tape<T>. Only a tape that lists TapeFeature::Weld welds.
  • In a welding tape, ties go to the later face. Where a point is within the tolerance of being as near a later region's face as its own region's (at the default tolerance, 0: an exact tie, as at flush faces), closestSurface() names the later face; a plain tape names the region's own unless the later one is strictly nearer.
  • At the default tolerance a welding tape closes no gap. Parts that are only roughly flush stay separated by their gaps until a tolerance is set (overlay(weld = ...), m_interfaceLength); findNearGaps() and ebgstudio's report on loading list them.
  • Tape::Layout gains one T. DomainObject gains its tape options.
  • EBGeometry.hpp's includes are in sorted order again (EBGeometry_FaceParts.hpp was out of place).
  • A welding tape's region queries cost a little more than a plain tape's (see Performance).

Alternative solutions

  • Labels only: the gap stays in the region functions while the labels skip it. Rejected: labels and geometry would disagree.
  • The approved growth term everywhere, min(own, (own + later - eps)/2): it lowered a region's function far from any contact, and grew a layer in front of faces side by side in one plane (the cooling block's inlet). Restricted to the band and weighted by how much the faces face each other.
  • A default of 1e-5 of the box's diagonal (above the rounding of single precision and the flushness of exported meshes): it welds a real gap in a model whose features are much smaller than the whole, without a message. The default is 0, and the near-gap report shows what a tolerance would close.
  • A tolerance only as a fraction of the box: a domain's own object would weld at a shorter length than the whole model, and a real small gap could be welded shut.
  • The weld on for every tape with an Overlay (the approved default): its code alone, reached from every region query, made the region and domain kernels spill more on a device, up to +26% on many-region scenes even after moving its rare paths out of line. A feature keeps that cost to the tapes that weld.

Performance

Receipt: Performance/receipts/abutting-interfaces-4164bfef.md (on 9963dc61, against the base 235ade11).

  • Host: yellow, accepted. One minor case: TapeBVHUnion/maps64-as-written/signedDistance/float/host +8.2%. It is a plain tape, which compiles none of the weld; the host evaluator's out-of-line functions (nm -C -S) are the same as the base's, so this is code placement. The maintainer accepted it: "Accept as acceptable side effect of the feature".
  • CUDA: green across 448 cases. The plain tape kernels are unchanged; the 8 Weld probe kernels are new.
  • What the weld costs on a real assembly (outside the receipt; the NASA gantry, 731 regions, one per part, welding tape at a tolerance of 1e-5 of the diagonal against plain tape, median of 5): on the host, region(), regionDistances() and four firstRegionChange() per ray within ±1%; on the device, +1.5% to +3.7% in float and within ±0.5% in double.

Where to look

  • Source/EBGeometry_TapeImplem.hpp: weldedSolid(), laterSolid(), regionFunction(); region(), signedDistance(p, region) (the background's branch), regionDistances(); closestSurface(p, region) (the tie rule and the region across); firstRegionChange() (the later face).
  • Source/EBGeometry_Tape.hpp: the options and the contracts of the region queries.
  • Source/EBGeometry_SurfacePieces.hpp: findNearGaps().
  • Source/EBGeometry_LanguageSyntaxImplem.hpp, EBGeometry_LanguageImplem.hpp, EBGeometry_Language.hpp: the overlay's settings, tapeOptions().
  • Studio/main.cpp, Studio/Kernels.hpp: the welding tape type, the near-gap report and the tape options.
  • Performance/Weld/main.cpp: the new probe.
  • Verified:
    • the debug unit tests in both precisions, including the weld tests: abutting cubes from both sides with their materials, gaps welded and not, tolerance 0, a ray in both directions, two spheres welded by a neck, faces side by side in one plane, exact values away from the band, continuity across a weld, a gap just wider than the tolerance staying open, an exact tie at tolerance 0, the length option, the language setting and its errors, and two surfaces crossing at 10°, 90° and 150° (a fillet along the crossing at the acute angle, none at the others);
    • a Release CUDA build of the region tests (sm_86, CUDA 12.5), run on the GPU, including a [gpu] case comparing welded answers with the host;
    • a smoke comparison of the region, domain and domain-object probes against the base: the same answers in every case;
    • pre-commit (format, REUSE, codespell, Doxygen, device math) and the Sphinx HTML with warnings as errors.
  • Not verified: HIP (CI compiles it); the viewer by hand.

Reviewer checklist (to be completed by a human)

  • The test suite compiles and runs to completion without warnings or errors.
  • All relevant new features are documented in the user documentation (Sphinx).
  • This contribution does not break existing sections in the user documentation.
  • All relevant APIs are documented in the doxygen documentation.
  • Appropriate labels have been assigned to this PR.
  • New or revised proper licensing and copyright information is in place.
  • A PR review has been run using @claude review.
  • The continuous integration and testing hooks at GitHub run to completion.
  • The performance receipt is current (CI's Performance-receipt passes), and every regression in it is explained.

🤖 Generated with Claude Code

https://claude.ai/code/session_012mR37bzMSJWYPpFgLhy9sk

…and findNearGaps() (#325, the API)

TapeOptions::m_interfaceTolerance, a fraction of the box's diagonal (default 1e-5), is
kept on the tape as a length (Tape::getInterfaceTolerance()). findNearGaps() reports the
pairs of regions a thin layer of the background separates. The weld itself follows.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012mR37bzMSJWYPpFgLhy9sk
@rmrsk rmrsk added enhancement New feature or request csg Affects constructive solid geometry functionalities gpu Affects device code or launch labels Nov 27, 2026
@rmrsk rmrsk mentioned this pull request Nov 27, 2026
34 of 51 tasks
rmrsk and others added 4 commits November 27, 2026 08:55
A region's solid is grown into a gap narrower than the tolerance between surfaces
that face each other, up to the later region's face (Tape::weldedSolid()): the
region functions, region(), the background and the subdomain functions agree,
and are exact away from the thin band of the weld. closestSurface() names the
later face where the two come within the tolerance, with the region across it
from either side; firstRegionChange() reports one crossing on the later face.
ebgstudio reports near gaps when it reads a model, and compiles a domain's own
object with the whole model's tolerance as a length.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012mR37bzMSJWYPpFgLhy9sk
… not itself (a device stack bound)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012mR37bzMSJWYPpFgLhy9sk
…eLength, overlay(weld = ...)) (#325)

TapeOptions::m_interfaceLength, when set, replaces the fraction of the box. A model sets
it with overlay(weld = <length>), once for the whole object; Model::tapeOptions() carries
it to a tape, and DomainObject::tapeOptions() gives a domain's own object the whole
model's tolerance as a length, so both tapes weld alike. ebgstudio, the language
examples and the docs compile models with them.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012mR37bzMSJWYPpFgLhy9sk
…the surface's nearest point

The rule that took any region no farther than the surface named a neighbor that
does not touch the surface (two shells side by side). The region holding the point
is across, as before; only when none does is the point moved onto the surface,
where a region flush with it or welded to it is found.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012mR37bzMSJWYPpFgLhy9sk
@rmrsk rmrsk self-assigned this Nov 27, 2026
…Geometry.hpp's includes sorted

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012mR37bzMSJWYPpFgLhy9sk
@rmrsk

rmrsk commented Nov 27, 2026

Copy link
Copy Markdown
Owner Author

@claude review

@github-actions

github-actions Bot commented Nov 27, 2026 •

Copy link
Copy Markdown

Claude finished @rmrsk's task in 1m 15s —— View job


Review of #382: abutting interfaces welded within a tolerance, plus findNearGaps()

I read the diffs of Source/, Studio/main.cpp and the language changes. I did not build or run anything, so the numbers in the PR body are unchecked here. Overall the design is coherent and well documented. I found nothing blocking. The points below are worth a look before the receipt.

  • Read the Tape, SurfacePieces, Language and Studio diffs
  • Checked the weld arithmetic, the tie rule, the region-across fallback, findNearGaps() and the weld setting

Findings

1. weldedSolid() is discontinuous at the band's edge, and the docs say it is not (Source/EBGeometry_TapeImplem.hpp, weldedSolid(); docs in EBGeometry_Tape.hpp)

The function returns own outside the band and min(own, max((own + later - e)/2, own - e)) inside. These two do not agree on the band's boundary.

  • Take e = eps (faces fully facing) and later = 0.5 eps.
  • At own = eps - 0 the value is min(eps, max(0.25 eps, 0)) = 0.25 eps. At own = eps it is eps.
  • The same jump of up to eps occurs at later = eps.

The jump is always downward on the way into the band, so sign and zero level set are kept. The values still stay lower bounds, so marching is safe. But the doc comment says the function "keeps its sign everywhere and its value away from the band" and calls the region functions distance bounds. It never says they are discontinuous.

A cut-cell code that interpolates or differences the function across the band's edge would see a step of up to 1e-5 of the diagonal. That is probably harmless in practice. I suggest one sentence in the @details saying so, or tapering e to zero toward the band edge (for example by multiplying it by (1 - own/eps)(1 - later/eps)-style factors) if continuity matters.

2. closestSurface()'s region-across fallback adds work to the commonest case (EBGeometry_TapeImplem.hpp, the block after "Across the region's own surface…")

It runs whenever !byLater && across == 0 && n > 1, which is every query of a point whose region faces the background. It costs 6 extra regionSolid evaluations for the normal, plus up to n more at the nearest point. This is probably the source of the extra spill the PR reports on the region and domain kernels.

  • Consider skipping it when own.m_value is more than eps deep (not applicable) or, better, when no other region's box reaches within eps of the point. A cheap box test on each region would avoid the finite differences for most points.
  • Whatever you decide, the receipt's device section should show this cost explicitly.

3. The findNearGaps() contract is slightly stronger than the code (EBGeometry_SurfacePieces.hpp)

The doc says gaps narrower than the interface tolerance "are closed, so never reported". The weld closes a gap only where the two surfaces face each other (c > 0). A sub-tolerance gap between surfaces that do not face each other is not closed. A ray that crosses it can report it with m_gap < eps.

Either state this in the doc, or skip reports with gap <= getInterfaceTolerance() so the contract holds. The second option is a one-line condition at if (gap <= width).

4. Float precision of the normal estimate (weldedSolid())

h = 0.25 * tolerance, which is 2.5e-6 * diagonal at the default. In single precision, central differences of two values with a relative error of about 1e-7 give a normal error of a few percent. facing is clamped, so this is safe. For a box far from the origin the error grows, and facing could drop noticeably below 1 for faces that truly face each other, which leaves a thin gap partly unwelded. The float tests pass per the PR. A float test with the geometry offset from the origin (say by 100 diagonals) would show whether this matters.

Smaller notes

  • findNearGaps() expects <algorithm>, which is included. OK.
  • Studio::check builds the whole-model tape in printNearGaps(...) and then again for the domains. One shared tape would avoid the second build.
  • The tie rule changes from own + later < 0 to <= eps even when eps = 0, so at exact ties the later face is now named. That matches the PR's description. A test that pins an exact tie at m_interfaceTolerance = 0 would document it, if one is not already there.
  • The weld setting rejects a repeat with a clear message. The language has no functions or loops, so an overlay is never evaluated twice and the "set once" rule cannot misfire.
  • DomainObject::tapeOptions() takes the diagonal from m_object (the whole model), as intended. The unbounded-box case falls back to 0, which matches Tape.
  • Docs: the new Regions.rst and LanguageModels.rst text reads well and follows the no-measurements rule. I did not rebuild Sphinx here.

Process

  • The PR's Performance section says the receipt follows these review rounds, which matches CLAUDE.md. Items 1 and 2 may change the library, so the receipt should be recorded after they are settled.
  • HIP and the viewer are listed as unverified. CI's GPU-HIP job covers the first.

I made no code changes.
· branch abutting-interfaces

…only when one can reach, findNearGaps' contract)

The weld tapers with the distances to both surfaces, so the region functions are
continuous, across either surface too, and a gap is welded across its whole width
or not at all. closestSurface() seeks the surface's nearest point only when another
region's solid is near enough to reach it. ebgstudio's check builds the model's
tape once. Tests: continuity, a gap just wider than the tolerance, an exact tie at
a tolerance of 0.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012mR37bzMSJWYPpFgLhy9sk
@rmrsk

rmrsk commented Nov 27, 2026

Copy link
Copy Markdown
Owner Author

@claude review

@github-actions

github-actions Bot commented Nov 27, 2026 •

Copy link
Copy Markdown

Claude finished @rmrsk's task in 37s —— View job


Review of #382, round 2 (head 896704d)

I read the full TapeImplem.hpp diff and the findNearGaps() and language changes. I did not build or run anything, so the tests and the numbers in the PR body are unchecked here. I found no blocking issue.

Round 1 items, as the head commit handles them

  • Continuity: e = facing * max(0, 2 eps - |own| - |later|) is zero as soon as either |own| or |later| reaches the band's edge. The early return a_own at the band's edge therefore agrees with the interior formula, and the function is continuous. The @details text now matches this.
  • Cost of the region-across search: the finite-difference normal and the nearest-point search now run only when nearestOther <= eps + |own|. That is the right gate. The receipt's device section should still show the region and domain kernels' spill, as the PR body says.
  • findNearGaps() contract: the doc now says a sub-tolerance gap between surfaces that do not face each other may be reported. That matches the code.

Remaining notes (non-blocking)

  1. Float normal estimate in weldedSolid(). h = 0.25 * eps is about 2.5e-6 * diagonal at the default. In single precision, with the geometry far from the origin, the central difference is noisy. facing can then fall below 1 for faces that truly face each other, and a gap is only partly welded. The clamp keeps it safe, but a float test with the geometry offset by about 100 diagonals would show whether it matters. It could also be accepted as a documented limit.
  2. Float overflow of the length. m_interfaceLength is checked as < 1e300 in double, then cast with T(...). For float, a value above 3.4e38 becomes inf. weldedSolid then treats it as a huge band. The only effect is that nonsense input is not rejected in float. Compare against Math::Limits<T>::max() after the cast if you want it caught.
  3. region() and signedDistance(p, 0) pay laterSolid (a loop over the later regions) for every point within eps of a region's solid. That is cheap and correctly gated by own < eps. weldedSolid also computes laterSolid six more times for the normal, only inside the band. I see no problem, but keep an eye on it in the device receipt.
  4. firstRegionChange() re-trace. The extra traceProgram on a from -> later crossing reads the later region's solid record with record + 1 + count. I checked that this reads the same way as the existing record layout. The reach of 100 * tol * scale + eps is generous. If a later solid is entered within reach that is not the face the ray left through, the crossing moves forward by up to reach. That is within the documented tolerance, so I mention it only so you know it is deliberate.
  5. Studio::check still builds the whole-model tape twice (once for near-gaps and once for the domains), as in round 1. This is a nit.

Process

  • Nothing in this round changes the library beyond what the head commit already has, so the receipt can be recorded once you are satisfied with the notes above. Notes 1 and 2 would be the only reasons to touch Source/ again.
  • HIP and the viewer remain unverified here. CI's GPU-HIP job covers the first.

I made no code changes.
· branch abutting-interfaces

…w round 2)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012mR37bzMSJWYPpFgLhy9sk
@rmrsk

rmrsk commented Nov 27, 2026

Copy link
Copy Markdown
Owner Author

Round 2 notes: (1) single precision far from the origin is documented as a limit in weldedSolid()'s details; (2) fixed in 856a0f2: a length the precision cannot hold is refused; (3, 4) deliberate, as noted; (5) stale: check builds the tape once since 896704d (Studio/main.cpp:438). @claude review

@github-actions

github-actions Bot commented Nov 27, 2026 •

Copy link
Copy Markdown

Claude finished @rmrsk's task in 12s —— View job


Review of #382, round 3 (head 856a0f2)

I read the round 2 fix commit (856a0f2). I did not build or run anything, so the tests and the numbers in the PR body are unchecked here. I found no blocking issue.

Round 2 notes, as the head handles them

  1. Float normal far from the origin: accepted as a documented limit in weldedSolid()'s details. I have no objection.
  2. Interface length the precision cannot hold: Tape::Tape now refuses it. After T(*a_options.m_interfaceLength), an EBGEOMETRY_REQUIRE checks < Math::Limits<T>::max(). A float overflow to inf is caught, and the check runs once per tape, as the rules ask. It also uses Math::Limits, not std::numeric_limits. One small point: a NaN length fails the < test, so it is refused too, which is right. A death test with abortsWith() for a length such as 1e39 in float would pin the new check. I did not look for an existing one in Tests/.
  3. Items 3 and 4: deliberate, and the reasons are consistent with the docs. Nothing to add.
  4. Studio::check building the tape twice: my round 2 note was stale, as you say. I did not re-read Studio/main.cpp in this round, so I take the single build at Studio/main.cpp:438 from your comment.

Process

  • Nothing in this round needs another change to Source/, so the code looks converged and the receipt can be recorded.
  • Per CLAUDE.md, the receipt's device section should show the region and domain kernels' extra spill, and tape-change-check applies, since Tape::Layout and the evaluator's region functions changed.
  • HIP and the viewer remain unverified here. CI's GPU-HIP job covers the first.

I made no code changes.
· branch abutting-interfaces

rmrsk and others added 3 commits November 27, 2026 11:44
The weld's code, though it runs only within the tolerance of two surfaces, raised
the spills of every region and domain kernel on a device, and region queries on
many-region scenes ran up to a quarter slower there. It is now compiled only into
a tape that lists TapeFeature::Weld; a plain Tape<T> compiles the region code it
did before (its tolerance is 0). The weld's band arithmetic, the welded region test,
the welded background and the search for the region across from the surface are
out of line. ebgstudio, the language examples and the MPI integrations compile
models with the feature.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012mR37bzMSJWYPpFgLhy9sk
… welds and at them

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012mR37bzMSJWYPpFgLhy9sk
@rmrsk

rmrsk commented Nov 27, 2026

Copy link
Copy Markdown
Owner Author

@claude review — since round 3 the weld became a tape feature (TapeFeature::Weld, 5b61f22): a plain Tape compiles the base's region code; the weld's rare paths are out of line; ebgstudio, examples and integrations use the feature; new Weld probe (c3fe35d).

@github-actions

github-actions Bot commented Nov 27, 2026 •

Copy link
Copy Markdown

Claude finished @rmrsk's task in 36s —— View job


Review of #382, round 4 (head c3fe35d): the weld as TapeFeature::Weld

I read the feature gating in EBGeometry_Tape.hpp and EBGeometry_TapeImplem.hpp, the tie rule, firstRegionChange(), the constructor's tolerance handling, and the test and probe wiring. I did not build or run anything, so the tests, ptxas registers and probe numbers are unchecked here. I found no blocking issue.

What I checked

  • Gating. Every weld path I found in the tape is under if constexpr (hasFeature<TapeFeature::Weld>): weldedSolid(), the firstRegionChange() re-trace, the byLater tie rule and the nearestOther search in closestSurface(). The else branches keep the base's rules. For example, byLater = (met != 0U) && (-later.m_value > own.m_value) is the base's strict test. A plain Tape<T> therefore takes the base's region code. This matches the PR body.
  • Tolerance. A tape without the feature sets m_interfaceTolerance = T(0) whatever the options say. The m_interfaceLength range check now runs after the cast, so a float overflow is refused. TestRegions.cpp has a case, "a tape without TapeFeature::Weld keeps its regions' solids as they are", that pins this.
  • Cheap early exit. weldedSolid() returns a_own as soon as either |own| or |later| is outside 2 eps, so the band's work stays out of line. With tolerance 0 the band is empty, and the !(x < band) form also handles NaN.
  • Call sites. The new Weld tests, the Studio, the examples and the MPI integrations use Tape<T, TapeFeature::Weld>. Language.hpp documents the pairing with model.tapeOptions().

Non-blocking notes

  1. Silent no-op without the feature. overlay(weld = ...), TapeOptions::m_interfaceTolerance and m_interfaceLength are accepted and ignored by a plain Tape<T>. This is documented and tested, but it is an easy trap. A user who reads overlay(weld = 1e-6) in a model file and builds a plain tape gets exact-contact behavior with no message. Two cheap options:
    • Have Model::tapeOptions()'s doc and the overlay section of LanguageModels.rst say explicitly that the tape type must list TapeFeature::Weld. I saw this only in Language.hpp:986, so please check that the Sphinx page says it.
    • Or EBGEOMETRY_REQUIRE that a plain tape's options leave both tolerance fields at their defaults. I would not add this, because the defaults are non-zero and it would break existing callers.
  2. The PR body is slightly stale. The Summary says "the approved default" was the weld on for every Overlay. Side-effects still says "Only a tape that lists TapeFeature::Weld welds", which is right. The Solution header text "In a tape that lists…" is also right. Only the Performance section still reads "Not recorded yet", and that is correct for now.
  3. closestSurface() tie rule, plain vs welding. A plain tape names the later face only when it is strictly nearer. A welding tape names it at own + later <= eps, which at eps = 0 includes exact ties. The two tapes therefore differ at exact ties even with tolerance 0. That is intended per the PR, and a welding tape at tolerance 0 is pinned by a test. I mention it so the docs on closestSurface() say "a tape that welds" and not just "the tolerance".
  4. firstRegionChange() re-trace reach. reach = 100 * tol * scale + eps uses m_interfaceTolerance directly, so with a user-chosen large m_interfaceLength (for example 1e-2 of the box) the crossing can move forward by up to that length. This is within the documented tolerance, so there is nothing to change.
  5. Tape::Layout size. It gains one T for every tape, welding or not. This is harmless, but tape-change-check should confirm that plain float kernels' ptxas registers and stack are unchanged. They are the claim this feature exists to protect, so they are worth stating in the receipt as well as the Weld cases.

Process

  • Per CLAUDE.md, the receipt can now be recorded, provided you consider the rounds converged. This round changes nothing in Source/.
  • The receipt should include:
    • the plain-tape Regions and Domain cases, which should show no movement. This is the point of making the weld a feature;
    • the new Weld probe cases, which will show as new;
    • the tape-change-check results (float kernel registers, nm -C -S of the host evaluator) for the plain tape.
  • HIP and the viewer are still unverified. CI's GPU-HIP job covers the first.

I made no code changes.
· branch abutting-interfaces

…age page says a model's weld needs TapeFeature::Weld (review round 4)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012mR37bzMSJWYPpFgLhy9sk
@rmrsk

rmrsk commented Nov 27, 2026

Copy link
Copy Markdown
Owner Author

Round 4 notes: (1) LanguageModels.rst now says a model's weld needs a tape with TapeFeature::Weld; (3) the region queries' contracts say which rules only a welding tape adds (1d8217d); (2) the PR body's Performance section is filled with the receipt; (4) deliberate; (5) the receipt's device build table reports the plain kernels. @claude review

@github-actions

github-actions Bot commented Nov 27, 2026 •

Copy link
Copy Markdown

Claude finished @rmrsk's task in 18s —— View job


Review of #382, round 5 (head 1d8217d)

I checked your round 4 notes against the branch. I did not build or run anything, so the tests and numbers are unchecked here. I found no blocking code issue. One process item needs your attention: the receipt.

Round 4 notes, as the head handles them

  1. Silent no-op without the feature: LanguageModels.rst:140 now says a model's weld takes effect only in a tape that lists TapeFeature::Weld, used with model.tapeOptions(). ImplemRegions.rst:88-102 shows Tape<T, TapeFeature::Weld>. Resolved.
  2. The receipt (not resolved on the branch):
    • The branch has no receipt. Performance/receipts/ holds only face-parts-e86287a4.md and more-shapes-532f1e6a.md, which belong to other PRs.
    • The 12 commits on the branch (2c3f163 to 1d8217d) have no receipt commit.
    • The PR body I was given still reads "Performance: Not recorded yet". You say it is now filled, so that may have changed after my context was fetched.
    • If you recorded the receipt locally, it still needs to be committed and pushed. Per CLAUDE.md, Scripts/run-performance.sh compare $(git merge-base HEAD origin/main) --record writes it and removes the earlier PRs' receipts. CI's Performance-receipt check, which CI-passed requires, reads the receipt from the branch, not the PR body.
  3. Tie rule wording: 1d8217d makes the region queries' contracts say which rules only a welding tape adds. I did not re-read each contract line by line, but the commit message matches the request.
  4. firstRegionChange() reach: deliberate, as before.
  5. Plain-kernel registers in the receipt: I can't confirm that. The receipt isn't in the branch for me to read (see item 2).

Process

  • Code: the rounds have converged. Rounds 1 to 4 turned up no blocking issue, and this round changed nothing in Source/.
  • Remaining before hand-over:
    • Commit and push the receipt (it needs your go-ahead to push).
    • After that, the maintainer's call to promote the PR (gh pr ready), with the labels checked.
    • A fully green full CI run on the final head.
  • HIP and the viewer are still unverified here. CI's GPU-HIP job covers the first.

I made no code changes.
· branch abutting-interfaces

rmrsk and others added 2 commits November 27, 2026 15:31
…CUDA green)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012mR37bzMSJWYPpFgLhy9sk
…d (an assembly's crossings)

On an assembly of 730 parts, every region change along a ray asked region() just past a
surface, where the weld recomputed the smallest of all the later parts' solids, and its
normal estimate differenced that smallest six times: ray queries ran about a fifth slower.
region() and regionDistances() now pass the smallest later solid they have, and whose,
and the normal is taken from that one solid. A welding tape's trace takes a later region
entered within the tolerance of the nearest crossing, in place of a second trace.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012mR37bzMSJWYPpFgLhy9sk
@rmrsk

rmrsk commented Nov 27, 2026

Copy link
Copy Markdown
Owner Author

@claude review — since round 5: on the Gantry (730 parts) the weld recomputed all later parts' solids at every ray crossing; 536a5f9 passes the later solid region()/regionDistances() already have (and whose), takes the band's normal from that one solid, and replaces the second trace in firstRegionChange() with a slack in the trace loop. Gantry, weld/plain: CPU within ±1%, GPU float +1.5% to +3.7%, double within ±0.5%.

@github-actions

github-actions Bot commented Nov 27, 2026 •

Copy link
Copy Markdown

Claude finished @rmrsk's task in 58s —— View job


Review of #382, round 6 (head 536a5f9): the weld reuses the later solids

I read the diff of 536a5f9 (Tape.hpp, TapeImplem.hpp) and the code around it. I did not build or run anything, so the Gantry numbers and the tests are unchecked here. I found no blocking issue in the code. Two process items and two small notes follow.

What I checked

  • region() passes the right later solid. laterSeen is the minimum of regionSolid(j, 0, p) over the regions above k. laterSolid(k, p) takes regionSolid(j, sharedMasks(k, j), p). The two are the same exactly when region k has no masks, so shared = 0. The unmasked test (mask count of k is 0) is that condition. A masked region passes 0U and gets the old whole evaluation. laterRegion is set together with laterSeen, so laterRegion != 0 always means the value is real. The loop returns before the update on own < 0, which is fine.
  • regionDistances()'s uniform path. unmasked is regionSolid(k, masks, p), and uniform guarantees sharedMasks(1, k) == masks. So the later it passes and the shared that weldInBand() recomputes for the normal agree.
  • weldInBand() fallback. With a_laterRegion == 0 (all later values at max, or NaN) it differences the whole later minimum as before.
  • firstRegionChange(). The plain-tape else branch is the old code. In the weld branch a hit is taken if it is the first one, or if hit.m_t <= nearest + slack. nearest keeps the smallest crossing seen, so a third region cannot drift the window. The removed second trace needed !first.m_entering. A later solid's first hit is an entry whenever the ray starts outside it, which holds for the regions above from, so I see no case where the new form is wrong. The refinement after the loop still works from first.m_t.

Notes (non-blocking)

  1. Tie-break differs between the two scans. laterSolid() scans upward with a strict <, so on equal values it names the lowest j. region() and regionDistances() scan downward with a strict <, so they name the highest k. When two later solids are equal at the point, the normal can differ, and so can facing and the welded value. That happens where two later parts abut each other inside another region's band, which an assembly has often. The effect is tiny, but it can make region(p) and the sign of signedDistance(p, k) disagree there, and the docs promise they agree. Scanning laterSolid() downward, or using <= in the two downward loops, makes them name the same region.
  2. Plain tape. regionFunction() is not under the feature. It now calls laterSolid(k, p, &nearest) and passes nearest to a weldedSolid() that ignores it. The compiler should drop it, but the tape-change-check step the repo asks for is the proof. Compare the plain float kernels' ptxas registers and the host nm -C -S with the base, now that laterSolid() has a compare-and-select in place of a min.

Process

  • The receipt is stale. 129843b records the receipt before this commit, and 536a5f9 changes Source/. Per CLAUDE.md, record it again on the final code. CI's Performance-receipt checks that it matches the base fingerprint, and the PR body's Performance section should then be updated. I could not tell from the diff whether Performance/receipts/abutting-interfaces-eba8a0ad.md still matches.
  • No probe covers what this commit fixed. The Weld probe has region(), regionDistances() and closestSurface() cases, but no ray crossing (firstRegionChange()) on a many-part assembly. The slowdown you found on the Gantry is the case that would catch a return of it. A small stack-of-blocks case with a ray through all of them would do. It is a new case, so it only adds to the set.
  • The commit adds no test. The reuse path (an unmasked region against a masked one) and the new slack in the trace are behavior changes. A test that compares region() and regionDistances() between a tape whose regions have masks and one whose regions have none would pin the unmasked branch. A ray through two flush parts of a stack with a third part behind them would pin the slack.

I made no code changes.
· branch abutting-interfaces

…n tape's own loop, a ray case and tests)

laterSolid() names the nearest later region from the top down, as region() and
regionDistances() do. A plain tape's region function calls the original loop. The Weld
probe gains blocks/regionChanges, every region change along rays through the stack; a
test compares a welding tape's regions with and without masks, and a ray through a
stack with a welded gap and flush faces.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012mR37bzMSJWYPpFgLhy9sk
@rmrsk

rmrsk commented Nov 27, 2026

Copy link
Copy Markdown
Owner Author

Round 6 notes: (1) laterSolid() now scans from the top down like region()/regionDistances(), so ties name the same later region; (2) a plain tape's regionFunction() calls the original min loop (if constexpr), the receipt's kernel table and host comparison check it; probe: Weld/blocks/regionChanges; tests: masked vs unmasked agreement, a ray through a welded gap and flush faces. @claude review

@github-actions

github-actions Bot commented Nov 27, 2026 •

Copy link
Copy Markdown

Claude finished @rmrsk's task in 27s —— View job


Review of #382, round 7 (head eb43556)

I read the diff of eb43556 (TapeImplem.hpp, TestRegions.cpp). I did not build or run anything, so the tests and the numbers are unchecked here. I found no blocking issue.

Round 6 notes, as the head handles them

  1. Tie-break. laterSolid() with an a_nearest now scans j = n … a_region+1 with a strict <, as region() and regionDistances() do, so on equal values all three name the highest region. The nullptr path keeps an upward min loop. It returns the same value, since min does not depend on order. Resolved.
  2. Plain tape. regionFunction() has an if constexpr (hasFeature<TapeFeature::Weld>) split. The plain branch is max(regionSolid(k, 0, p), -laterSolid(k, p)). It takes no nearest and no weldedSolid() call. That is the base's expression, up to the laterSolid() helper, so the nm -C -S and ptxas comparison in the receipt is what shows it. Resolved, pending that evidence.
  3. Tests and probe.
    • The new case compares a welding tape with and without masks, at points inside, around and past the welded gap and the flush faces. It also checks regionDistances() against signedDistance(p, k).
    • The ray case pins the four region changes and the later face on each crossing between blocks, for both tapes.
    • The reference is a different tape (masked vs plain), not the code run a second way. That fits the repo's rule.
    • The Weld/blocks/regionChanges case covers the Gantry slowdown.

Non-blocking notes

  1. Ties and the masked path. The test's mask is a box above every region, so it changes no value. It pins the unmasked reuse path against the masked one at all. It does not hit a case where a mask changes the later solid's value, which is where sharedMasks matters. Round 6 asked for one test with a mask that does something. You may want a clip that cuts into a later block, but this is optional.
  2. No test pins the tie itself. A point equidistant from two later regions that sit inside a third's band would show that region(), regionDistances() and laterSolid() agree. This is a small addition if you want it.
  3. Float. The test uses gap = 4e-4 and i * 2e-4 steps with a looseMargin on the masked comparison. That is fine at the 1e-3 length, and I see no float trouble. CI's float run on this case will confirm.

Process

  • The receipt is stale again. eb43556 changes Source/ (EBGeometry_TapeImplem.hpp) and the probes (Performance/Weld/main.cpp, a new case). Per CLAUDE.md, record it again on the final code (Scripts/run-performance.sh compare $(git merge-base HEAD origin/main) --record) and update the PR body's Performance section. CI's Performance-receipt will fail on the old fingerprint. Recording needs a quiet machine and your go.
  • The tape-change-check evidence for the plain tape (float kernel registers, host nm -C -S) belongs in that receipt, because the plain regionFunction() changed in this round.
  • Code: rounds 1 to 7 turned up no blocking issue, so the code looks converged. After the receipt, promotion is your call (gh pr ready), with the labels checked and a green full CI.
  • HIP and the viewer remain unverified here. CI's GPU-HIP job covers the first.

I made no code changes.
· branch abutting-interfaces

rmrsk and others added 3 commits November 27, 2026 17:59
…one minor; CUDA green)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012mR37bzMSJWYPpFgLhy9sk
…eaves a fillet, at a right or obtuse one none

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012mR37bzMSJWYPpFgLhy9sk
@rmrsk
rmrsk marked this pull request as ready for review November 27, 2026 18:34
@rmrsk rmrsk added ray tracing Affects ray tracing functionality performance Addresses performance issues or the performance test suite documentation Improvements or additions to documentation examples Improvements, additions, or modifications to examples labels Nov 27, 2026
@rmrsk
rmrsk marked this pull request as draft November 27, 2026 18:51
…ntacts

Which gaps are flaws and which are geometry depends on the model, not on its
units or size: a fraction of the box closes a real gap in a model whose
features are much smaller than the whole. A gap is now closed only when the
caller (or the model, overlay(weld = ...)) says how wide a gap may be closed;
findNearGaps() reports the gaps to choose it from. The tests that relied on
the old default give 1e-5 of the diagonal explicitly.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012mR37bzMSJWYPpFgLhy9sk
@rmrsk

rmrsk commented Nov 27, 2026

Copy link
Copy Markdown
Owner Author

@claude review

@github-actions

github-actions Bot commented Nov 27, 2026 •

Copy link
Copy Markdown

Claude finished @rmrsk's task in 48s —— View job


Review of #382, round 8 (head aff2565)

I read the commits since round 7: f171ee4 (acute-angle fillet test), aff2565 (default tolerance 0) and the two receipt commits. I did not build or run anything, so the tests and numbers are unchecked here. I found no blocking code issue. The receipt is stale, and a few comments and PR-body statements still describe the old 1e-5 default.

What I checked

  • The default flip. TapeOptions::m_interfaceTolerance is now 0.0, and its doc says "at least 0 and less than 1". Regions.rst, ImplemRegions.rst and LanguageModels.rst agree with it. The weld band is empty at tolerance 0, so a welding tape with default options welds only exact contacts. The closestSurface() tie rule still names the later face at exact ties, as the PR describes.
  • Tests. TestRegions.cpp now sets m_interfaceTolerance = 1e-5 explicitly where a case needs the old behavior, instead of relying on the default. That keeps those cases independent of the default.

Findings

  1. The receipt no longer matches the code (blocking for CI). Performance/receipts/abutting-interfaces-0bfedaa9.md records head: eb435566. Since then aff2565 changed Source/EBGeometry_Tape.hpp (the default value, plus comments) and Source/EBGeometry_LanguageImplem.hpp (a comment). Source/ is part of the fingerprint (PERF_MEASURED_PATHS = Source EBGeometry.hpp Performance), so Performance-receipt should fail on head-fingerprint. The code change is a constant and comments, and the plain tape ignores that field. The tolerance reaches only a welding tape, so no timing should move. The file still has to be recorded again, and the accepted yellow verdict re-accepted, since CLAUDE.md says a push that changes the library needs a new receipt. That needs a quiet machine and your go. If you prefer to avoid the full rerun, CLAUDE.md gives no exception for comment-only or constant-only changes, so that is your call.
  2. Stale comment. Source/EBGeometry_Language.hpp:909 says tapeOptions() gives "the default fraction of the whole object's box". The default fraction is now 0 and no length is set, so say "the tolerance the model sets, else 0". The same change touches the receipt's head (item 1), so fix both in one push.
  3. Stale PR body. These statements no longer hold:
    • Background/Solution says "default 1e-5; 0 welds only exact contacts".
    • Side-effects says "at the default tolerance, gaps narrower than 1e-5 of the box's diagonal are welded", which is no longer true.
    • The line "(the approved default)" in Alternative solutions now reads oddly.
    • The Gantry figures were measured with a 1e-5 tolerance. They are still fair for the cost of the weld, but say so.
    • Where to look and Verified do not mention that a model or program must now set a length to close any gap.
  4. Behavior note for ebgstudio users. With default options, a model that has hair-thin gaps now keeps them open, and findNearGaps() reports them. That is the intent, as the docs say. Check that Studio/main.cpp's near-gap message tells the user how to close them (overlay(weld = ...)), since the default no longer does it. I did not find that text. It is optional.

Smaller notes (carried over, optional)

  • Round 7 note 1: a test with a mask that changes a later solid's value, so sharedMasks matters in the reuse path.
  • Round 7 note 2: a test of an exact tie between two later regions.

Process

  • Code: rounds 1 to 8 found no blocking issue.
  • Remaining before hand-over: the comment fix (item 2), a new receipt on the final code (item 1), the PR body update (item 3), then promotion at your request and a green full CI.
  • HIP and the viewer remain unverified here. CI's GPU-HIP job covers the first.

I made no code changes.
· branch abutting-interfaces

rmrsk and others added 3 commits November 27, 2026 19:58
…udio says how to close the gaps it reports)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012mR37bzMSJWYPpFgLhy9sk
…one minor; CUDA green)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012mR37bzMSJWYPpFgLhy9sk
@rmrsk
rmrsk marked this pull request as ready for review November 27, 2026 20:05
@rmrsk
rmrsk merged commit de7b7f2 into main Nov 27, 2026
35 of 58 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

csg Affects constructive solid geometry functionalities documentation Improvements or additions to documentation enhancement New feature or request examples Improvements, additions, or modifications to examples gpu Affects device code or launch performance Addresses performance issues or the performance test suite ray tracing Affects ray tracing functionality

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Regions: abutting operands share one interface (the later face wins within a tolerance), and a near-gap check

1 participant