Skip to content

Add weak_form and classify (strong-to-weak stage e) - #1

Merged
xtalax merged 5 commits into
masterfrom
forge/m1-1-weakform
Oct 26, 2026
Merged

xtalax merged 5 commits into
masterfrom
forge/m1-1-weakform

Conversation

@xtalax-droid

@xtalax-droid xtalax-droid commented Oct 24, 2026 •

Copy link
Copy Markdown
Collaborator

PR 1 of 4 for milestone M1 (spec §11.1): the Galerkin projection and term classification, stage e of the strong-to-weak transform. This PR is symbolic only and does not touch Ferrite.

What

src/weakform.jl adds the FEM data types of spec §5.2 and two functions.

  • Types: TestSlots(V, W, hK), VolumeTerm, FacetTerm{P}, WeakForm{A} and KernelSpec{F,T}.
  • classify(integrand, slots, test) expands the integrand and puts each additive term into one bucket. A term with no state slot is :source. A term whose first derivative with respect to every state slot is state-free is :bilinear. Anything else is :nonlinear. Each bucket also carries a timedep flag (it contains T) and a paramdep flag (it contains P).
  • weak_form(analysis; test) is the Galerkin projection. Each equation e contributes a mass term mass[e]·V and the classified volume integrand −G·W + R·V. Each natural condition contributes the classified facet term Φ·V, keyed by its boundary piece. The residual convention is Σ∫vol + Σ∮facet = 0. Essential conditions stay in analysis.essential.

classify ranges over the declared state slots (U, G, and H when present), not over a hard-coded list. This prevents the regression in report 5 §1e, where Hessian terms were misfiled as sources.

src/ reads the analysis object by field name only and never names a PDEBase.StrongForm type.

Why

This implements spec §5.1 stage e and §5.2. Stages 0 to d belong to PDEBase.StrongForm.analyse (§4.4), which is not released yet. Until it is, test/strongform_seam.jl (module StrongFormSeam) is a test-only stand-in. It implements the §5.2 types and analyse, ported from the verified dauntless prototype. Replacing it with PDEBase's version will be a test-only change.

Tests

test/weakform.jl (Core group) checks the output term for term against the prototype's outputs (test_linear.out, test_nonlinear.out, test_multifield.out, test_testspace.out).

  • Cases (i), (ii), (ii-b) and (ii-c). These include the Neumann condition rescaled by k, the Robin condition split into a facet bilinear term plus a facet source, and the Dirichlet data.
  • Case (iii), k = 1 + u², with nonlinear volume and facet terms.
  • The two-field cross-diffusion case, with natural conditions routed per equation.
  • The timedep and paramdep flags.
  • The Hessian-slot regression.
  • In case (ii-c), the stand-in rejects ∂ₙu = h on an anisotropic flux.

GROUP=Core Pkg.test() passes. The new file has 30 tests. Runic is clean. Codex review approved it with no findings.

Reviewer notes

  • The stand-in reads mass[e] as the whole time-derivative part, Σ_f m_ef·Ud_f, and natural[i].eq as a 1-based index. These readings have been sent to PDEBase so its analyse matches.
  • Splitting an expression into terms uses SymbolicUtils.operation(ex) === (+), which relies on Symbolics 7 internals.

Follow-up commits

  • 0654711 moves the tests to the SciMLTesting per-group layout: test/WeakForm/weakform.jl (group WeakForm) and the stand-in for PDEBase's analyse at test/shared/strongform_seam.jl.

  • a8ceef9 builds the test-function gradient slots with the public Symbolics.variable, because Symbolics.variables is not public and failed the ExplicitImports QA check. QA now passes 20/20.

  • a168de3 renames dorder to derivative_order in the test stand-in, because the Typos spell check flagged it. A local typos run exits 0.

  • 14c21ed adds docs/src/api.md with an @autodocs block, so Documenter's missing-docs check covers every docstring, including those of the stacked PRs. A local makedocs run passes.

All four follow-up commits were approved by Codex review with no findings.


🤖 Posted by an AI agent · harness: Claude Code 2.1.310 · model: claude-opus-5-5
Review: unreviewed
Session: d6252e53-ed42-4149-9811-233262edb2ef

xtalax and others added 3 commits October 24, 2026 20:44
Galerkin projection of a strong-form analysis into mass, volume and facet terms, with each additive term classified as source, bilinear or nonlinear over the declared state slots (spec 5.1 stage e, 5.2). The analysis is read by field so PDEBase.StrongForm can replace the test-only seam in test/strongform_seam.jl without changes to src.

Agent-Harness: Claude Code 2.1.310
Agent-Model: claude-opus-5-5
Agent-Session: d6252e53-ed42-4149-9811-233262edb2ef
Agent-Review: unreviewed
Co-authored-by: Claude Code <agent@noreply.juliahub.com>
Follow the SciMLTesting folder layout used by MethodOfLines: one test/<Group>/ folder per group declared in test_groups.toml, with helpers in test/shared/, which run_tests never executes because it is not a declared group.

Agent-Harness: Claude Code 2.1.310
Agent-Model: claude-opus-5-5
Agent-Session: d6252e53-ed42-4149-9811-233262edb2ef
Agent-Review: unreviewed
Co-authored-by: Claude Code <agent@noreply.juliahub.com>
Symbolics.variables is not public, which fails ExplicitImports' all_qualified_accesses_are_public check in the QA group. Symbolics.variable(:W, i) builds the same symbols.

Agent-Harness: Claude Code 2.1.310
Agent-Model: claude-opus-5-5
Agent-Session: d6252e53-ed42-4149-9811-233262edb2ef
Agent-Review: unreviewed
Co-authored-by: Claude Code <agent@noreply.juliahub.com>
xtalax and others added 2 commits October 24, 2026 21:24
The Typos spell check flags dorder; a descriptive name is clearer than a whitelist entry.

Agent-Harness: Claude Code 2.1.310
Agent-Model: claude-opus-5-5
Agent-Session: d6252e53-ed42-4149-9811-233262edb2ef
Agent-Review: unreviewed
Co-authored-by: Claude Code <agent@noreply.juliahub.com>
makedocs checks that every docstring in the module is included in the manual; an @autodocs block over FiniteElementMethod covers these and later docstrings. The module docstring stays on the home page, so the block lists types, functions, constants and macros only.

Agent-Harness: Claude Code 2.1.310
Agent-Model: claude-opus-5-5
Agent-Session: d6252e53-ed42-4149-9811-233262edb2ef
Agent-Review: unreviewed
Co-authored-by: Claude Code <agent@noreply.juliahub.com>
@xtalax
xtalax merged commit a196733 into master Oct 26, 2026
13 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