Repository navigation
Add BoundaryPiece and NormalDerivative fallbacks for trace syntax - #144
Merged
Merged
Conversation
The FiniteElementMethod boundary layer writes conditions as traces u(t, Γ) on named boundary pieces and as NormalDerivative(Γ)(u(t, Γ)). Both names are proposed upstream (JuliaSymbolics/Symbolics.jl#2115 and a DomainSets proposal); PDEBase defines each only while the installed package lacks it, so the fallback disappears when upstream releases. boundarypieces names the faces of a HyperRectangle in DomainSets' boundary order. Agent-Harness: Claude Code 2.1.310 Agent-Model: claude-opus-5-5 Agent-Session: e5d08c60-db9f-4954-946c-272b70ca9edb Agent-Review: unreviewed Co-authored-by: Claude Code <[email protected]>
SymbolicUtils orders the terms of a sum by comparing same-typed constant arguments with <, so u(t, Γa) + u(t, Γb) threw a MethodError for isless(::BoundaryPiece, ::BoundaryPiece). Order pieces by name, then by printed parent and geometry, consistently with isequal. Agent-Harness: Claude Code 2.1.310 Agent-Model: claude-opus-5-5 Agent-Session: e5d08c60-db9f-4954-946c-272b70ca9edb Agent-Review: unreviewed Co-authored-by: Claude Code <[email protected]>
The printed-key order with an isequal shortcut was not a strict weak order: Rectangle(0..1, 0..1) and Rectangle(0.0..1.0, 0.0..1.0) are isequal but print differently, so a third piece could sort between them. Compare (name, hash(parent), hash(geometry)) instead, which is lexicographic, consistent with isequal through hash, and needs no repr. Agent-Harness: Claude Code 2.1.310 Agent-Model: claude-opus-5-5 Agent-Session: e5d08c60-db9f-4954-946c-272b70ca9edb Agent-Review: unreviewed Co-authored-by: Claude Code <[email protected]>
xtalax-droid
pushed a commit
to xtalax-droid/PDEBase.jl
that referenced
this pull request
Oct 26, 2026
Default printing showed the whole backend mesh, and SciML#144 orders boundary pieces by repr(parent) when names tie, so sorting traces printed entire meshes. MeshDomain now prints as MeshDomain{MeshType}(2D) and Region as Region(MeshDomain{MeshType}(2D), :name), for both show and text/plain. Agent-Harness: Claude Code 2.1.310 Agent-Model: claude-opus-5-5 Agent-Session: e5d08c60-db9f-4954-946c-272b70ca9edb Agent-Review: unreviewed Co-authored-by: Claude Code <[email protected]>
This was referenced Oct 26, 2026
Merged
xtalax-droid
pushed a commit
to xtalax-droid/PDEBase.jl
that referenced
this pull request
Oct 27, 2026
Agent-Harness: Claude Code 2.1.312 Agent-Model: claude-sonnet-5-5 Agent-Session: a20a681b-e8cc-4c82-a40d-a5b8349014e2 Agent-Review: unreviewed Co-authored-by: Claude Code <[email protected]>
xtalax-droid
pushed a commit
to xtalax-droid/PDEBase.jl
that referenced
this pull request
Oct 27, 2026
Default printing showed the whole backend mesh, and SciML#144 orders boundary pieces by repr(parent) when names tie, so sorting traces printed entire meshes. MeshDomain now prints as MeshDomain{MeshType}(2D) and Region as Region(MeshDomain{MeshType}(2D), :name), for both show and text/plain. Agent-Harness: Claude Code 2.1.310 Agent-Model: claude-opus-5-5 Agent-Session: e5d08c60-db9f-4954-946c-272b70ca9edb Agent-Review: unreviewed Co-authored-by: Claude Code <[email protected]>
SymbolicUtils at its lowest compat orders mixed-type sum arguments by typeof(a) < typeof(b), and Base has no isless for two types, so u(t, Γa) + u(t, 0.5) + u(t, Γb) threw a MethodError. Add isless methods on types with BoundaryPiece in the signature: every other type sorts before a piece type. Agent-Harness: Claude Code 2.1.312 Agent-Model: claude-sonnet-5-5 Agent-Session: a20a681b-e8cc-4c82-a40d-a5b8349014e2 Agent-Review: unreviewed Co-authored-by: Claude Code <[email protected]>
xtalax-droid
pushed a commit
to xtalax-droid/PDEBase.jl
that referenced
this pull request
Oct 28, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The FiniteElementMethod.jl design (PDEBase as the shared boundary layer) writes boundary conditions as traces
u(t, Γ)on named boundary pieces, and normal-derivative conditions asNormalDerivative(Γ)(u(t, Γ)). Both names are proposed upstream:NormalDerivativein JuliaSymbolics/Symbolics.jl#2115, andBoundaryPiece/boundarypiece/boundarypiecesin a pending DomainSets proposal. This PR addssrc/fallbacks.jl, which defines each name only when the installed upstream package lacks it (@static if !isdefined(...)). Once upstream releases, PDEBase imports and re-exports the upstream name, and the fallback disappears.Added (all exported)
NormalDerivative{D <: Domain} <: SymbolicUtils.Operator, with the same semantics as Symbolics#2115: it builds a term whose operation is the operator and whose single argument is the trace, preserving symtype and shape. It hasNumandArrcall methods,isbinop = false, equality and hashing by piece, and prints asDn_wall(u(t, Γ_wall)). There is no customSubstituter; the generic one handles it.BoundaryPiece{T, P, G} <: DomainSets.Domain{T}with fieldsparent,nameandgeometry(an analytic sub-domain ornothing).parent(p)returns the parent domain, it prints asΓ_<name>, and it compares and hashes structurally, so separately built identical pieces give equal traces.boundarypieces(::HyperRectangle)names the faces in DomainSets'components(boundary(d))order::bottom, :right, :top, :leftfor a rectangle, and:x1_lo, :x1_hi, :x2_lo, …(lower then upper per axis) in other dimensions.boundarypiece(d, name)looks a piece up by name and errors with the list of valid names.Known gaps of the fallback (gone once Symbolics#2115 is released)
Two behaviours of Symbolics#2115 depend on changes inside Symbolics with no dispatch hook:
executedifftreats everyOperatorapplication as constant, andsymdiff_substitute_filteradmits onlyDifferential. A downstream package cannot reproduce them without overwriting Symbolics methods, which is piracy and is rejected during precompilation. Under the fallback, therefore:expand_derivatives(Differential(t)(Dn(u(t, Γ))))returns0instead of staying unevaluated;Symbolics.substitute_in_derivdoes not descend intoDn(...).Both are documented in the
NormalDerivativedocstring. Their tests are written as@test ... broken = !UPSTREAM_DN, so they become ordinary tests automatically when upstream is present. Later PRs in this series add the mitigations: asubstitute_tracesthat descends intoDifferentialandNormalDerivative, and an assertion that no trace remains before any derivative expansion. Boundary equations holding traces are never derivative-expanded.Tests (
test/boundary_syntax.jl)Arr), equality and hashing,expand_derivativesleavingDn(u(t, Γ))untouched, mismatched pieces not being an error at this level, and substitution.PDEBase.NormalDerivativeandPDEBase.BoundaryPieceresolve to the upstream type when upstream defines it, and to PDEBase's own otherwise.PDESystem.QA is configured to accept the four names as intentional re-exports for the day upstream defines them, and to accept qualified access to
DomainSets.HyperRectangle, because DomainSets declares nothing public. Core and QA groups pass locally.BoundaryPiecedefinesislessas a lexicographic comparison of(name, hash(parent), hash(geometry)), a strict weak order consistent withisequal, so Symbolics can order sums of traces such asu(t, Γa) - u(t, Γb). Known limitation: pieces with empty-interval geometries (2..1vs3..1) areisequalbut hash differently in IntervalSets, so they can order inconsistently.Follow-up commits 1fc8917 and 8a3372d were reviewed by an independent Claude Opus subagent (Codex workspace out of credits) and then by Codex (8a3372d approved, 1 minor, the limitation above).
🤖 Posted by an AI agent · harness: Claude Code 2.1.310 · model: claude-opus-5-5
Review: unreviewed
Session: e5d08c60-db9f-4954-946c-272b70ca9edb