Skip to content

Allow submeshes as boundary pieces; add a per-field boundary-completeness check - #54

Merged
xtalax merged 10 commits into
masterfrom
feat/submesh-boundaries
Nov 5, 2026
Merged

xtalax merged 10 commits into
masterfrom
feat/submesh-boundaries

Conversation

@xtalax-droid

Copy link
Copy Markdown
Collaborator

Two boundary features, requested together: boundary pieces given as submeshes, and a boundary-completeness check.

Submeshes as boundary pieces. add_boundary_pieces!(grid, name => submesh, ...; atol = nothing) (also a method taking a dictionary) is exported and documented. It adds a facet set name to the parent Ferrite.Grid and returns the grid, so every existing route (boundarypiece(MeshDomain(grid), name), FEMSpace, the PDESystem) takes the new piece like any other; the named-facet-set route is unchanged. It is a function on the grid, not a FEMDiscretization keyword, because pieces are created before the PDESystem exists and MeshDomain belongs to PDEBase. Matching is by node coordinates (two Ferrite grids number their nodes independently): each submesh node maps to the nearest parent node within atol (default 1e-8 times the larger of 1 and the parent's largest extent), and a submesh cell matches the parent facet with exactly those corner nodes; higher-order cells match through their corner nodes. The call is atomic: if one piece fails, nothing is added.

Boundary completeness, not a hard error by default. An unlisted boundary is a legitimate natural (zero-flux, symmetry or outflow) condition, and the DFG cylinder outflow and every insulated-wall example rely on it. Two new FEMDiscretization keywords: natural = [pieces] declares pieces natural, boundary_check = :warn | :error | :off (default :warn; :error gives strict MethodOfLines-style completeness).

Rule Default How to change Test (test/shared/frontend_tests/boundaries.jl unless noted)
Two conditions on one facet via overlapping pieces error none "two conditions on one facet"; "overlapping pieces" in errors.jl
Piece not on the boundary (was a warning) error none "a piece that is not on the boundary"; test/Space/space.jl
Submesh node with no parent node within atol error naming the node and position atol "submesh errors"
Submesh cell matching no parent facet error none "submesh errors"
Submesh cell matching an interior facet error none "submesh errors"
Wrong dimension, duplicate or existing name, atol <= 0 error none "submesh errors"
Uncovered boundary facets for a field whose equation has a flux one @warn per discretize call, per field, listing pieces with facet counts and facets in no named piece natural, a zero Neumann condition, or boundary_check "a boundary with no condition warns once", "one warning per call covers every field", "a boundary outside every named piece is counted", "a mesh with no named pieces"
Declared natural, or explicit zero Neumann silent n/a "natural = [pieces] declares", "an explicit zero Neumann condition is silent"
boundary_check = :error the same message as an ArgumentError n/a "boundary_check = :error is strict"
boundary_check = :off no check n/a "boundary_check = :off skips the check"

Fields whose equation has no flux (a pressure, say) are not checked. Pure-Neumann (rank-deficient) detection is skipped: a time-dependent problem with a mass matrix is well-posed and detecting a singular steady problem is not cheap, and steady problems are rejected until M4; the docs say so. End-to-end tests solve a 2D box with four 1D submeshes (reversed node numbering, mixed orientation) and a 3D hexahedral box with six quadrilateral face submeshes, against the exact solution to 1e-8.

Impact on existing tests: the warn test in errors.jl now matches the aggregated message; the check_facetsets interior-facet assertion in test/Space/space.jl is now an error; test/qa/qa.jl adds three Ferrite names (vertices, reference_facets, getrefdim) to the ExplicitImports ignore list, with a comment. FEMDiscretization gains two fields (natural, boundary_check). Docs: a "Boundary completeness" section and submesh pieces in docs/src/boundary_conditions.md, plus docs/src/discretization.md and the README.

Local results on Julia 1.12.1: Core 1, QA 21, Frontend 254 (including 41 new), Integration 304, Solution 215, Space 196, all pass; docs build exits 0; Runic 1.13 clean; Codex approved after four rounds (earlier rounds found and fixed a crash on meshes with no facet sets, an atol = 0 crash and an integer overflow for translated meshes). lts was not run. CI is billing-blocked.


🤖 Posted by an AI agent · harness: Claude Code 2.1.312 · model: claude-sonnet-5-5
Review: unreviewed
Session: 43e03fde-3384-4386-bae9-03e81f19ba7c

t and others added 9 commits November 3, 2026 19:01
Maps each cell of a lower-dimensional Ferrite grid to a facet of the parent by node coordinates and adds the facets as a named facet set. A facet set containing interior facets is now an error rather than a warning, since a piece lies on the boundary.

Agent-Harness: Claude Code 2.1.312
Agent-Model: claude-sonnet-5-5
Agent-Session: 43e03fde-3384-4386-bae9-03e81f19ba7c
Agent-Review: unreviewed
Co-authored-by: Claude Code <agent@noreply.juliahub.com>
Boundary facets with no condition for a field whose equation has a flux now give one aggregated warning per discretize call. FEMDiscretization(natural = [pieces]) declares them zero-flux, boundary_check = :error makes the warning an error and :off skips it.

Agent-Harness: Claude Code 2.1.312
Agent-Model: claude-sonnet-5-5
Agent-Session: 43e03fde-3384-4386-bae9-03e81f19ba7c
Agent-Review: unreviewed
Co-authored-by: Claude Code <agent@noreply.juliahub.com>
Agent-Harness: Claude Code 2.1.312
Agent-Model: claude-sonnet-5-5
Agent-Session: 43e03fde-3384-4386-bae9-03e81f19ba7c
Agent-Review: unreviewed
Co-authored-by: Claude Code <agent@noreply.juliahub.com>
Agent-Harness: Claude Code 2.1.312
Agent-Model: claude-sonnet-5-5
Agent-Session: 43e03fde-3384-4386-bae9-03e81f19ba7c
Agent-Review: unreviewed
Co-authored-by: Claude Code <agent@noreply.juliahub.com>
Agent-Harness: Claude Code 2.1.312
Agent-Model: claude-sonnet-5-5
Agent-Session: 43e03fde-3384-4386-bae9-03e81f19ba7c
Agent-Review: unreviewed
Co-authored-by: Claude Code <agent@noreply.juliahub.com>
Agent-Harness: Claude Code 2.1.312
Agent-Model: claude-sonnet-5-5
Agent-Session: 43e03fde-3384-4386-bae9-03e81f19ba7c
Agent-Review: unreviewed
Co-authored-by: Claude Code <agent@noreply.juliahub.com>
Keeps both sides: master's M4 (steady, eliminate, observed, SUPG, multifield, operators) and the submesh boundary pieces with the per-field boundary-completeness check. The DFG cylinder example and docs declare the outlet natural.

Agent-Harness: Claude Code 2.1.312
Agent-Model: claude-sonnet-5-5
Agent-Session: 43e03fde-3384-4386-bae9-03e81f19ba7c
Agent-Review: unreviewed
Co-authored-by: Claude Code <agent@noreply.juliahub.com>
…tests

These tests have no boundary conditions on purpose, so they print the completeness warning on every run (12 lines in the Frontend log). They now declare natural sides; the two @test_logs that assert the warning are unchanged.

Agent-Harness: Claude Code 2.1.312
Agent-Model: claude-sonnet-5-5
Agent-Session: 43e03fde-3384-4386-bae9-03e81f19ba7c
Agent-Review: unreviewed
Co-authored-by: Claude Code <agent@noreply.juliahub.com>
Agent-Harness: Claude Code 2.1.312
Agent-Model: claude-sonnet-5-5
Agent-Session: 43e03fde-3384-4386-bae9-03e81f19ba7c
Agent-Review: unreviewed
Co-authored-by: Claude Code <agent@noreply.juliahub.com>
@github-actions

github-actions Bot commented Nov 4, 2026 •

Copy link
Copy Markdown
Contributor

Benchmark Results (Julia v1)

Time benchmarks
master 1b429d8... master / 1b429d8...
construction/heat P1 10x10 8.99 ± 3.8 ms 5.62 ± 0.44 ms 1.6 ± 0.69
construction/heat P1 20x20 8.73 ± 4.7 ms 8.32 ± 1 ms 1.05 ± 0.57
time_to_load 4.53 ± 0.19 s 4.51 ± 0.064 s 1 ± 0.044
Memory benchmarks
master 1b429d8... master / 1b429d8...
construction/heat P1 10x10 0.0375 M allocs: 2.01 MB 0.0393 M allocs: 2.11 MB 0.952
construction/heat P1 20x20 0.0624 M allocs: 4.31 MB 0.0702 M allocs: 4.73 MB 0.911
time_to_load 0.201 k allocs: 12.2 kB 0.201 k allocs: 12.2 kB 1

Agent-Harness: Claude Code 2.1.312
Agent-Model: claude-sonnet-5-5
Agent-Session: 43e03fde-3384-4386-bae9-03e81f19ba7c
Agent-Review: unreviewed
Co-authored-by: Claude Code <agent@noreply.juliahub.com>
@xtalax
xtalax marked this pull request as ready for review November 5, 2026 03:24
@xtalax
xtalax merged commit 2fb767a into master Nov 5, 2026
45 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants