Repository navigation
Add MeshDomain interface and domain-aware VariableMap - #145
Merged
Merged
Conversation
This was referenced Oct 26, 2026
Merged
This addresses issue SciML#5 by providing foundational abstract types and interfaces for discretizations on unstructured meshes. The key additions are: Domain types (src/domains.jl): - AbstractDiscretizedDomain{T}: Abstract supertype for mesh-based domains - MeshDomain{T,M}: Generic wrapper for mesh objects from external libraries - BoundaryRegion{D}: Named boundary regions for BC specification - ConditionalBoundary{D,C}: Boundary selection via conditions Variational method types (src/variational.jl): - AbstractVariationalMethod: Base type for variational formulations - AbstractGalerkinMethod, AbstractRitzGalerkin, AbstractPetrovGalerkin - RitzGalerkin: Marker type for standard Galerkin FEM - AbstractUnstructuredDiscretization, AbstractUnstructuredDiscreteSpace - FEM traits for querying weak/strong form support Interface functions: - get_mesh, get_boundary_markers, mark_boundary! - get_parent_domain, get_boundary_name, get_condition - get_variational_method, is_galerkin, is_symmetric_galerkin - get_supported_form Documentation added for both domain types and variational methods. Closes SciML#5 Co-Authored-By: Claude Opus 4.5 <[email protected]> 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]> Co-authored-by: ChrisRackauckas-Claude <[email protected]>
Remove @ref link to AbstractCartesianDiscreteSpace which doesn't have a docstring, causing Documenter.jl to fail. Co-Authored-By: Claude Opus 4.5 <[email protected]> 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]> Co-authored-by: ChrisRackauckas-Claude <[email protected]>
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]>
Implements the mesh-domain layer of the FiniteElementMethod design (spec 3.4, 4.1): MeshDomain over a five-function backend interface, Region for named cell sets, and a VariableMap that records the raw domain pairing per variable, expands tuple pairings, fills per-axis intervals for interval-product domains, checks mesh coordinate counts, ignores traces u(t, Γ), and exposes spatial_domain. 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]>
Gives MeshDomain its named facet sets as BoundaryPieces (boundarypiece, boundarypieces, DomainSets.boundary), adds the advisory Essential/Natural/Robin classification bckind from spec 3.4, and makes spatial_domain return nothing for systems without spatial variables. 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]>
Codex review: spatial_domain returned the whole space-time box for (t, x) ∈ Rectangle; it now keeps identity only when the pairing names exactly the spatial coordinates, builds the spatial axes otherwise, and rejects a MeshDomain pairing that also names time. boundary of a mesh with no facet sets returned an error from UnionDomain; it is now an EmptySpace of the mesh element type. 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]>
spatial_domain built the box in x̄ order, which follows the argument order of the first dependent-variable calls rather than the user's declaration, so a named face of an equal-sided box could land on the wrong coordinate. VariableMap now records the spatial variables in declared order (spatial_axes; tuple order with time dropped, or the order of split pairings in the domain list), spatial_domain builds the box in that order, and _box_axes(v) exposes it for face lookups. 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]>
Independent review: bckind(Dt(u(t, Γ)) ~ 1) returned Natural, but a time derivative of a trace is a dynamic Dirichlet condition. A Differential now counts only when its variable is not an argument the trace keeps (Dx(u(t, Γ)) still counts, Dt(u(t, Γ)) does not); NormalDerivative always counts. The signature is unchanged. 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]>
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]>
DomainSets broadcasts every Domain as a set, so boundarypiece.(Ω, (:inlet, :wall, :outlet)), the spelling of the FiniteElementMethod user API, failed with a MethodError for size. Specialise Base.broadcasted for boundarypiece on a MeshDomain to wrap the domain in a Ref, leaving the domain's broadcast style alone: a blanket Base.broadcastable(::MeshDomain) = Ref(d) made DomainSets' own -Ω and 2 * Ω, which are built on broadcasting, recurse until the stack overflowed (found by Codex review). Base.broadcasted is the documented hook but is not public, so QA allowlists it. 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]>
…riational hierarchy Removes SciML#61's AbstractDiscretizedDomain, its MeshDomain{T,M}, the markers dict (mark_boundary!, get_boundary_markers, get_mesh), BoundaryRegion, ConditionalBoundary and the whole variational hierarchy with its traits. Named facet and cell sets are read from the mesh through the mesh-domain interface and exposed as BoundaryPiece and Region. docs/src/domains.md now documents the one design, credits SciML#61 and states that PDEBase assumes no fields, quadrature rule, ansatz or linearity. 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
force-pushed
the
forge/boundary-3-meshdomain
branch
from
October 27, 2026 23:18
e753418 to
2374586
Compare
The typos check flags the interval variable Iy (docs and tests of the domain-aware VariableMap) as a misspelling of It. 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]>
…ry-3-meshdomain Integration only. 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]>
VariableMap built allivs from get_all_depvars, whose Set order differs between Julia versions, so a boundary call such as u(t, 0, y) listed before u(t, x, y) turned x̄ from [x, y] into [y, x] on lts. Sort the dependent-variable calls by position of the variable in pdesys.dvs, full calls before boundary calls, then printed arguments. Belongs to SciML#145 forge/boundary-3-meshdomain. 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]> (cherry picked from commit 1484a99b05171a2277561a23a1d1378df2c83edb)
…e/boundary-3-meshdomain Integration only; the variable_map.jl hunk is identical on both sides (conflict resolved with ours). 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]>
4 tasks done
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.
Supersedes #61 (adopts its two commits as the base of this branch; thanks to its author) and answers its review.
Depends on #144 (
BoundaryPieceandNormalDerivative). This branch is stacked on it, so until #144 merges the diff here also shows its commit.This PR is part of the shared boundary layer that the FiniteElementMethod.jl design puts in PDEBase, so that FiniteElementMethod, MethodOfLines and NeuralPDE all read meshes, boundary pieces and domain pairings the same way.
Mesh-domain interface
MeshDomain(mesh)is aDomainSets.Domainover a backend mesh, with element typeSVector{meshdim(mesh), Float64}. PDEBase defines five functions and no methods for them:meshdim;facetset_names;cellset_names;contains_point, which is optional; its fallback errors and names the mesh type;backend_mesh, whose fallback is the identity.Mesh backends add the methods.
x ∈ Ωusescontains_point. Named subsets work as follows:Region(Ω, name)is a named cell set, andregions(Ω)returns all of them.boundarypiece(Ω, name)returns a facet set as aBoundaryPiecewith no geometry. An unknown name is an error that lists the valid names.boundarypieces(Ω)returns every facet set.DomainSets.boundary(Ω)is theirUnionDomain, or an empty domain when the mesh has no facet sets.boundarypiece.(Ω, names)broadcasts overnamesfor aMeshDomain(only that call is specialised, so-Ωand2*Ωstill build aMappedDomain).MeshDomainandRegionprint compactly.Domain-aware
VariableMapThe mesh carries no coordinate names; the pairing
(x, y) ∈ Ωbinds them by position.VariableMapnow:domainsfield;intervalsper axis for aRectangleor another product of intervals, so MethodOfLines can discretize(x, y) ∈ Rectangle(...)without the user splitting the pairing;meshdim("... has 3 coordinates but the pairing names 2");u(t, Γ)whose arguments include a domain, so they are not taken as new dependent variables;spatial_domain(v), which returns the domain of the spatial coordinates. When a box pairing also names time it returns only the spatial axes, and it returnsnothingwhen there are no spatial variables.[t ∈ It, x ∈ Ix, y ∈ Iy]has the spatial domainRectangle(Ix, Iy);PDEBase._box_axes(v)returns that axis order.Every existing field, constructor (including the 10-argument positional one) and accessor is unchanged, and so is the "Could not find domain" error. One behaviour changes: in a domain list where a tuple pairing naming
xcomes before a scalar pairing forx,xnow resolves to the tuple pairing (first match wins). Before, a tuple pairing could never match.Boundary-condition kinds
PDEBase.bckind(eq)returnsEssential(),Natural()orRobin()(all subtypes ofPDEBase.BCKind) from the syntax of a trace condition. Traces appearing only outside derivatives give Essential, traces only inside spatial derivatives (NormalDerivative, or aDifferentialin a variable the trace does not keep, soDt(u(t, Γ))stays Essential) give Natural, and both give Robin. The classification is advisory, and it never derivative-expands the equation. These names are@public, not exported.Tests
test/mesh_domain.jluses a toy mesh to cover:dimension, membership throughcontains_point, andRegion;boundary, including a mesh without facet sets;bckindon Dirichlet, Neumann, Robin and trace-free conditions;domainsentries;spatial_domainexcludes time;The new public names are listed in
test/public_api.jl. Core and QA pass locally. A local check with MethodOfLines solved the 2D heat equation on(x, y) ∈ Rectangleand on split interval pairings, and got identical solutions.Follow-up commits be58e5b (axis order) and 8117d79 (
bckind) were reviewed by an independent Claude Opus subagent (Codex workspace out of credits) and then by Codex (approve, 0 findings); the earlier commits were Codex-reviewed.The commits f2e4086 (compact show) and e753418 (broadcast) were reviewed by Codex (round 2 approve, 0 findings).
How this addresses the review on #61
This branch starts from #61's two commits and then replaces their content with one design: the
MeshDomainand interface above, plusBoundaryPiece.src/domains.jl,src/variational.jl,docs/src/variational.mdand their exports are removed, anddocs/src/domains.mdis rewritten (with a short "Design notes" section). One line per review comment:domains.jl:61(markers on the domain, or read from the mesh?): read from the mesh. Facet sets and cell sets (subdomain markers, for example fluid and solid) come fromfacetset_names/cellset_names, exposed asBoundaryPieceandRegion; theboundary_markersdict,mark_boundary!andget_boundary_markersare removed.variational.jl:37(Bubnov-Galerkin vs Ritz-Galerkin): removed with the variational hierarchy; PDEBase does not name or classify the method, so there is no wrong label to carry.variational.jl:181(equal test and trial spaces do not imply symmetry):is_symmetric_galerkinis removed, for that reason.variational.jl:40(hierarchy direction): removed with the hierarchy; no type here encodes the method.variational.jl:48(linear problems only): removed; nothing in PDEBase assumes linearity now.variational.jl:195(why a common supertype for traits):AbstractFEMTrait,SupportsWeakFormandget_supported_formare removed. There was no consumer (the FEM discretizer subtypes none of them), so no reason for a shared supertype; which boundary conditions a discretizer supports is reported separately bysupported_conditions(Add supported_conditions hook for discretizers to declare BC support #147).variational.md:117(do not rely on fields; per-part quadrature, per-field ansatz): the page is removed. The new Design notes state that PDEBase assumes no fields, no single quadrature rule for the parts of a weak form, and no single ansatz per field.variational.md:187(how is the weak-form transformation step controlled?): removed with the page. PDEBase prescribes no weak-form transformation; the discretizer owns it through the existingtransform_pde_system!hook, so it is controlled where the discretizer defines it.variational.md:197(restricted to linear problems?): not restricted; the Design notes state that PDEBase makes no assumption of linearity.🤖 Posted by an AI agent · harness: Claude Code 2.1.312 · model: claude-sonnet-5-5
Review: unreviewed
Session: a20a681b-e8cc-4c82-a40d-a5b8349014e2