Repository navigation
Regions: abutting operands share one interface within a tolerance, and a near-gap check (#325) - #382
Conversation
…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
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
…Geometry.hpp's includes sorted Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012mR37bzMSJWYPpFgLhy9sk
|
@claude review |
|
Claude finished @rmrsk's task in 1m 15s —— View job Review of #382: abutting interfaces welded within a tolerance, plus
|
…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
|
@claude review |
|
Claude finished @rmrsk's task in 37s —— View job Review of #382, round 2 (head
|
…w round 2) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012mR37bzMSJWYPpFgLhy9sk
|
Claude finished @rmrsk's task in 12s —— View job Review of #382, round 3 (head
|
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012mR37bzMSJWYPpFgLhy9sk
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
|
Claude finished @rmrsk's task in 36s —— View job Review of #382, round 4 (head
|
…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
|
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 |
|
Claude finished @rmrsk's task in 18s —— View job Review of #382, round 5 (head
|
…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
|
@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%. |
|
Claude finished @rmrsk's task in 58s —— View job Review of #382, round 6 (head
|
…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
|
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 |
|
Claude finished @rmrsk's task in 27s —— View job Review of #382, round 7 (head
|
…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
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012mR37bzMSJWYPpFgLhy9sk
…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
|
@claude review |
|
Claude finished @rmrsk's task in 48s —— View job Review of #382, round 8 (head
|
…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
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012mR37bzMSJWYPpFgLhy9sk
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:
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 plainTape<T>compiles none of it;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 underif constexpr, so a plainTape<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))withe = c max(0, 2 eps - |own| - |later|), wherec = 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 thanwidth, 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>andmodel.tapeOptions(), and domains' own objects withown.tapeOptions().The Weld probe (
Performance/Weld):region()andregionDistances()at random points of the Regions probe's particles (the feature's cost where it does nothing), andregion()andclosestSurface()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()andtapeOptions()on the API pages;Weldin the features table;overlay(weld = ...)on the language page; the Weld probe on the performance page.Side-effects
Tape<T>. Only a tape that listsTapeFeature::Weldwelds.closestSurface()names the later face; a plain tape names the region's own unless the later one is strictly nearer.overlay(weld = ...),m_interfaceLength);findNearGaps()and ebgstudio's report on loading list them.Tape::Layoutgains oneT.DomainObjectgains its tape options.EBGeometry.hpp's includes are in sorted order again (EBGeometry_FaceParts.hppwas out of place).Alternative solutions
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.Performance
Receipt:
Performance/receipts/abutting-interfaces-4164bfef.md(on9963dc61, against the base235ade11).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".region(),regionDistances()and fourfirstRegionChange()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.[gpu]case comparing welded answers with the host;Reviewer checklist (to be completed by a human)
@claude review.🤖 Generated with Claude Code
https://claude.ai/code/session_012mR37bzMSJWYPpFgLhy9sk