Skip to content

Support periodic boundary conditions between translated pieces - #93

Open
xtalax-droid wants to merge 11 commits into
masterfrom
periodic-bc
Open

xtalax-droid wants to merge 11 commits into
masterfrom
periodic-bc

Conversation

@xtalax-droid

Copy link
Copy Markdown
Collaborator

Problem

u(t, Γa) ~ u(t, Γb) (steady: u(Γa) ~ u(Γb)) between two boundary pieces was rejected with "periodic boundary conditions are not supported".

Design

  • The pair is split out of the conditions before PDEBase parses them, and both traces must use exactly the system's time variable (transient) or no time argument (steady); fixed, shifted or scaled time, two different fields, and non-trace right-hand sides are rejected with specific errors.
  • The field's dofs on the two pieces are matched by coordinate under the translation between the pieces' centroids, and the matching must be a bijection (no unmatched, duplicated or unused nodes; the reverse nearest search must agree). Matched dofs form classes, so a corner shared by several pairs (a fully periodic box) resolves to one master, which prefers a Dirichlet dof. Ferrite 1.7 does not support nested affine constraints, so all pairs of a field are collected into one set of classes.
  • The operators keep all dofs as unknowns. Each non-master node gets the algebraic row u_node − u_master = 0, and its Galerkin row, load and nonlinear residual/Jacobian rows are added to the master's. This is the condensed system of the identification, so it works in the transient (DAEProblem) and steady (NonlinearProblem) paths, with nonlinear terms, SUPG test spaces and mixed spaces (Taylor–Hood). consistent_du0 folds tied columns into their masters, and automatic index-2 detection skips the tied rows so periodic and non-periodic problems get the same algebraic_abstol = :auto tolerances.
  • Dirichlet data on a periodic class must agree: this is checked up front at 17 sample times and again at every evaluation of the data.
  • Clean errors: pieces that are not translates of each other (both named), another condition on a periodic piece, dirichlet = :eliminate, operators, and non-Lagrange spaces (edge elements would need orientation signs across the periodic map).

Tests

test/Interface/periodic.jl and periodic_navier_stokes.jl:

  • heat on a fully periodic box (rate 2 for P1, rate 3 for P2 on quadrilaterals); periodic in x with Dirichlet in y;
  • steady advection–diffusion with Galerkin and SUPG; coupled fields with different spaces;
  • steady nonlinear diffusion; transient viscous Burgers; a transient periodic line with Galerkin and SUPG; a fully periodic 3D cube;
  • Kovasznay flow with periodic top and bottom (rates 3 and 2); a Q2/Q1 channel past a block with periodic top/bottom, relying on the default tolerances, with inflow and outflow flux equal to 1e-3 (mass conserved);
  • every error case, including the bijection, Dirichlet agreement and time-argument checks, and an in-place load callback returning nothing.

All test groups (including QA) pass locally. The docs example runs as a standalone script; docs/make.jl has not been built locally.

Docs

docs/src/boundary_conditions.md gets a periodic section with an example and a support matrix. docs/src/equation_classes.md no longer lists periodic in the rejected class 3, and index.md, extension_contract.md, the Interface README and the supported_conditions checklist are updated.

Ferrite: version 1.7.0; Dirichlet, ConstraintHandler, apply!/apply_zero! condensation of affine constraints work through a Newton loop; nested affine constraints are not supported (ConstraintHandler.jl, "nested affine constraints currently not supported"). PeriodicDirichlet itself is not used.

Codex review: approve, no findings.

Review notes

  • Look hardest at apply_ties! and extend_pattern in src/periodic.jl (row sums, pattern extension, consistent_du0 folding) and at the tie positions in the Dual-number residual and Jacobian path of FEMNonlinear.
  • The matching tolerance is 1e-6 of the mesh diameter, shared by both matching directions.
  • Tied nodes are algebraic, so differential_vars is false on them.

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

t and others added 9 commits November 12, 2026 21:47
An equation u(t, Γa) ~ u(t, Γb) (steady: u(Γa) ~ u(Γb)) now identifies the field on two pieces that are translates of each other, instead of being rejected. Dofs are matched by coordinate, classes of matched dofs keep one master, and the operators tie the other dofs to it with algebraic rows while summing their Galerkin rows into the master's (a condensation of the identification). Works in the transient and steady paths, with nonlinear terms, SUPG and mixed element spaces.

Agent-Harness: Claude Code 2.1.322
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>
…agrange spaces

Adds steady and transient nonlinear tests, a 1D transient SUPG test and a 3D steady test, a support matrix in the docs, and a clean error for periodic pairs on non-Lagrange spaces. Fixes a self-referencing load closure that overflowed the stack for time-dependent sources.

Agent-Harness: Claude Code 2.1.322
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>
A Dirichlet piece touching both ends of a periodic pair puts two prescribed dofs in one class; both kept their own rows, silently violating the periodic condition. The data are now compared at the dofs' coordinates at five times of the interval and a mismatch is an ArgumentError naming the pieces, nodes and values.

Agent-Harness: Claude Code 2.1.322
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>
Sampling 17 times at construction gives the early error, but data such as x sin(16 pi t) can agree at every sample and differ between them. The Dirichlet value callback now compares the prescribed values of each periodic class at the time it evaluates them, on real parts for Dual numbers.

Agent-Harness: Claude Code 2.1.322
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>
Equal node counts passed validation when two nodes of one piece were within tolerance of the same partner, leaving another partner unconstrained. The match is now checked for unmatched nodes, targets used twice, unused targets and a consistent reverse nearest search, and the error names the nodes and distances.

Agent-Harness: Claude Code 2.1.322
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>
The identification rows of a periodic pair put nonzero pressure-to-pressure entries in K, so the automatic algebraic tolerance saw no index-2 structure and left the pressure in error control. Tied rows are now skipped in the detection, so periodic and non-periodic problems of the same physics get the same tolerances.

Agent-Harness: Claude Code 2.1.322
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>
load! ignores what an in-place load callback returns, so the tie wrapper must too: a callback returning nothing raised a MethodError in apply_ties!.

Agent-Harness: Claude Code 2.1.322
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>
A trace with a fixed, shifted or scaled time was converted into an ordinary periodic tie, silently solving a different problem. Both traces must now take exactly the time variable (or no time for a steady system) besides the piece, and the two traces must name one field.

Agent-Harness: Claude Code 2.1.322
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>
u(t, Γa) ~ 1 + u(t, Γb) was reported as naming two fields; it is a malformed pair. The two-field error is now tested with a declared second field.

Agent-Harness: Claude Code 2.1.322
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 13, 2026 •

Copy link
Copy Markdown
Contributor

Benchmark Results (Julia v1)

Time benchmarks
master adac1e5... master / adac1e5...
construction/heat P1 10x10 7.25 ± 0.49 ms 7.65 ± 0.73 ms 0.947 ± 0.11
construction/heat P1 20x20 9.63 ± 0.77 ms 10.5 ± 0.82 ms 0.92 ± 0.1
time_to_load 4.85 ± 0.048 s 4.87 ± 0.14 s 0.995 ± 0.031
Memory benchmarks
master adac1e5... master / adac1e5...
construction/heat P1 10x10 0.0396 M allocs: 2.12 MB 0.0404 M allocs: 2.19 MB 0.969
construction/heat P1 20x20 0.0704 M allocs: 4.74 MB 0.0715 M allocs: 4.9 MB 0.968
time_to_load 0.2 k allocs: 11.8 kB 0.2 k allocs: 11.8 kB 1

@ChrisRackauckas

Copy link
Copy Markdown
Member

🤖 Automated comment from an AI agent running as @ChrisRackauckas — not written or reviewed by Chris.

PR: #93

Reviewed head: 12d3149
Raw SHA-256: e21d14c5a71043b348640394dc54d3024c61eaf350e3ac6943e6cd43a8c192dd
Source SHA-256: 7b043324df2b4fca40bfe9dab8508ab7735bcbf35f2ec86d017c34522d453883
Source: standard-review-v1 (harness-log)
Reviewer session: 01a1d2a1-527c-71e0-b05d-bd5a2ec44ff1
Slot: 1
Confidence: unknown
Own risk fixed before author rating/discussion: yes

Risk assessment

  • Risk: medium-low (ML7)
  • Verdict: CHANGES
  • Reviewed head: 12d3149

Review report

VERDICT: CHANGES
Round: 1
Head: 12d3149
Slot: 1
CI: CI is not green
Session: 01a1d2a1-527c-71e0-b05d-bd5a2ec44ff1

Risk

medium-low (ML7: additive periodic boundary-condition support across linear, nonlinear, transient, steady, and mixed-space problems)

Blocking findings

  • Verdict: CHANGES
  • Round: 1
  • Blocking priorities: P1, P2, P2
  • Deferred P2 issues: None supplied.
  1. [P1] Verify translated facet connectivity, not only node coordinates — src/periodic.jl:80. Confirmed by running. A valid five-tetrahedron unit cube has matching vertices on opposite x faces but different triangle diagonals. The matcher accepts it, although the mapped P1 traces differ between vertices. For u_t = Δu, x-periodic conditions, natural conditions elsewhere, and the x-periodic initial field y*z, DFBDF returns Success. At t=0.01, the corresponding seam points (0,0.5,0.5) and (1,0.5,0.5) evaluate to 0.42913282764403027 and 0.0708671723563683: a jump of 0.35826565528766197. This is an incorrect periodic finite-element space; the omitted boundary contributions do not cancel for its test functions. Reject unmatched translated facet/interpolation connectivity, or implement constraints that enforce equal traces. Add this tetrahedral counterexample alongside the hexahedral test.

    Reproduction geometry: vertices (0,0,0), (1,0,0), (1,1,0), (0,1,0), (0,0,1), (1,0,1), (1,1,1), (0,1,1); positively oriented tetrahedra (1,6,3,8), (1,2,3,6), (1,3,4,8), (1,5,6,8), (3,6,7,8). The initial seam jump is also 0.5.

  2. [P2] Do not classify distinct thin-domain faces as coincident — src/periodic.jl:85. Confirmed by running. On a 4×4 Q1 mesh of [0,1]×[0,1e-7], the bottom and top faces are exact translates with a one-to-one node map. Periodic heat discretization throws periodic pieces Γ_bottom and Γ_top of u coincide: their centroids are the same point. The same mesh with Dirichlet conditions builds successfully. The global 1e-6 * diameter matching tolerance exceeds the actual translation and is unsuitable for deciding coincidence. Separate the coincidence check from the matching tolerance and test anisotropic domains.

  3. [P2] Make spatial hashing independent of the coordinate origin — src/periodic.jl:18. Confirmed by running. Translating the ordinary 4×4 unit-square mesh to [1e14,1e14+1]² changes successful periodic discretization into InexactError: Int64(7.071067811865493e19). The non-periodic control on that translated mesh builds successfully. Hashing coords[d] / tol overflows despite well-resolved coordinate differences. A square near 1e6 with side 1e-8 reproduces the same failure. Subtract a common local origin before constructing integer keys and add translation-invariance tests.

Non-blocking findings

  • docs/src/equation_classes.md:30 adds retrospective wording, including “were all periodic” and “now supported”. The supplied author instructions require descriptions of current behavior. Rewrite the row around the currently rejected classes.

What I ran

  • Reviewer: codex-cli 0.164.0, model gpt-6.1-sol. Blind review of git diff origin/master...HEAD, affected source, tests, and documentation; no author rating or GitHub discussion was read. Independent risk was recorded before runtime verification.
  • Set the requested TMPDIR; preserved the supplied JULIA_DEPOT_PATH. The checkout has no root AGENTS.md, CLAUDE.md, Julia manifest, Python project, or uv.lock. uv run --locked python --version reported Python 3.15.0, with the warning that --locked has no effect outside a project.
  • julia --version: 1.13.2. Instantiated a separate scratch environment from the checkout's dependency, compat, and test-extra declarations, with this checkout as its path dependency. Resolved Ferrite 1.7.0, PDEBase 0.1.41, ModelingToolkit 11.46.1, SciMLBase 3.58.0, OrdinaryDiffEqBDF 2.4.14, and NonlinearSolveFirstOrder 2.10.0. The generated manifest is outside the checkout.
  • julia --project=../scratch/env ../scratch/run_groups.jl: invokes the actual test/runtests.jl with GROUP set to Interface, DAE, Space, Frontend, and Integration. Interface passed 337 assertions, including periodic.jl 77/77 and periodic_navier_stokes.jl 13/13; DAE passed 95/95; Space passed 196/196; Frontend passed 782/782; Integration passed 304/304. Total: 1,714 assertions across 63 test files, five groups passed, zero failed.
  • Independent probes in ../scratch/probes.jl: the ordinary-square, thin-rectangle, and translated-square controls passed; the thin-domain and coordinate-overflow failures above reproduced. Explicit periodic condensation agreed with PᵀMP and PᵀKP; the conserved mass derivative was -2.3592239273284576e-16. For nonlinear diffusion with time-dependent Dirichlet data, the sparse Jacobian's relative infinity-norm difference from central finite differences was 1.1695993458221275e-11; its difference from ForwardDiff was zero. The initial residual norm was 2.7755575615628914e-16.
  • julia --project=../scratch/env ../scratch/seam_final_time.jl: confirmed the successful solve and final-time seam jump above. A redundant test runner was interrupted before reaching the affected suites; it repeated the same three matching failures. All Julia jobs used memory-capped scopes and two Julia threads.
  • git diff --check origin/master...HEAD passed. git status --short remained empty.

What I did not verify

  • Did not run other Julia versions, the QA group, or the documentation build. CI status was supplied by the launcher; no CI pages, PR body, comments, or prior reviews were consulted. No GitHub operations, commits, pushes, or checkout edits were performed. All commands started for this review have finished.
    AUTHOR_GRADE: {"task":"feature","score":3,"difficulty":4,"rounds":1,"author_harness":"Claude Code 2.1.322","author_model":"claude-sonnet-5-5","note":"Broad analytic periodic tests and independent Jacobian/condensation checks pass, but targeted probes confirm a successful solve with unequal periodic traces and two valid-domain matching failures; all five affected groups pass (1,714 assertions)."}

Head link: 12d3149


🤖 Posted by an AI agent — harness: codex-cli 0.164.0 · model: gpt-6.1-sol
Conversation: local session 01a1d2a1-527c-71e0-b05d-bd5a2ec44ff1 (no session URL)

t and others added 2 commits November 13, 2026 03:28
Their docstrings were not in any @docs block, which fails makedocs with :missing_docs; the helpers are internal, so the docstrings become comments.

Agent-Harness: Claude Code 2.1.322
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>
… tie mask

Periodic pairs are removed from the analysis before the region check, so a partial piece was silently accepted; they now go through the same check. The load wrapper built a BitVector of all unknowns at every evaluation; the mask is now built once.

Agent-Harness: Claude Code 2.1.322
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>
@ChrisRackauckas

Copy link
Copy Markdown
Member

🤖 Automated comment from an AI agent running as @ChrisRackauckas — not written or reviewed by Chris.

PR: #93

Reviewed head: adac1e5
Raw SHA-256: ee01418ff1d5d48d56b27682e99ba26bfaecaf7f80fce94352c984183075ea45
Source SHA-256: b3b4e6fb3eb8e8feaf00003565b05ed3211f836b84caed031155fb780d241abc
Source: standard-review-v1 (harness-log)
Reviewer session: 01a1d330-6e66-7d63-9141-9af4ec6d66d8
Slot: 1
Confidence: unknown
Own risk fixed before author rating/discussion: yes

Risk assessment

  • Risk: medium-low (ML7)
  • Verdict: MERGE
  • Reviewed head: adac1e5

Review report

VERDICT: MERGE
Round: 3
Head: adac1e5
Slot: 1
CI: CI is not green
Session: 01a1d330-6e66-7d63-9141-9af4ec6d66d8

Risk

medium-low (ML7: additive periodic-boundary support across problem classes; this delta validates region membership and caches the load mask)

Blocking findings

None in the reviewed delta. The supplied previous review contains no completed blocker.

  • Verdict: MERGE
  • Round: 3
  • Blocking priorities: none
  • Deferred P2 issues: none

Non-blocking findings

  • src/solution.jl:559 — Outside this delta: four queries on the internal boundary y=0.5 of upper_half return NaN on both the preceding and reviewed heads. Both solve u=t² inside the region with maximum absolute error 8.017597002973886e-13. The whole-mesh point search appears to select cells without this field; use the field's cellset when locating points. Confirmed behavior; the proposed cause follows from reading the unchanged locator.

What I ran

Reviewer: codex-cli 0.164.0, model gpt-6.1-sol. Risk recorded before runtime verification; no author rating consulted.

  • Read the whole git diff origin/master...HEAD, supplied previous review and delta; verified the delta equals git diff 367917cb35e2f88b08df064df529c2de86fff4b0 HEAD. Root AGENTS.md and CLAUDE.md are absent.
  • Julia 1.13.2, preserving the runtime's layered JULIA_DEPOT_PATH. Created a scratch environment from project dependencies, test extras and compat: Ferrite 1.7.0, ModelingToolkit 11.46.1, PDEBase 0.1.41, SciMLBase 3.58.0.
  • julia --project="$scratch/env" "$scratch/run_affected.jl" "$repo": includes unchanged test/runtests.jl with each GROUP. 1,520/1,520 passed: Interface 339, DAE 95, Frontend 782, Integration 304. Includes periodic 79/79 and periodic Navier–Stokes 13/13.
  • julia --project="$scratch/before-env" "$scratch/region_regression.jl" "$repo": exact added region test against archived pre-delta source, with identical dependency versions. 1 pass, 1 intended failure: invalid full-side pieces throw no exception. Current head: 2/2 pass.
  • julia --project="$scratch/env" "$scratch/new_checks.jl" "$repo": region probes 7/7, cached-load probes 16/16. Tested either invalid side, reversed pairs, field ordering, multiple mirrors, prescribed masters, repeated evaluations, Float32 and dual time. Cached-mask application allocated 0 bytes for both 16 and 1,000,000 entries. The extended solution probe passed 2/3; its boundary-query failure is reported above.
  • julia --project="$scratch/before-env" "$scratch/region_solution_probe.jl" and julia --project="$scratch/env" "$scratch/region_solution_probe.jl": 3/3 each, identical interior error and four boundary NaNs. No tolerance was changed; the accuracy check samples strictly inside the region.
  • uv run --locked python --version: Python 3.15.0, with warning that --locked has no effect outside a project. This is a Julia project with no Python project/lockfile; Python was not used for package verification.
  • git diff --check origin/master...HEAD: passed. Final head matches the requested SHA; checkout remains clean. All started commands have exited.

What I did not verify

CI, QA, documentation build, other Julia versions or platforms. No repository Manifest or interpreter pin exists, so the exact CI dependency environment was not reproduced. Review remains scoped to the delta and supplied prior blockers.

AUTHOR_GRADE: {"task":"feature","score":5,"difficulty":4,"rounds":3,"author_harness":"Claude Code 2.1.322","author_model":"claude-sonnet-5-5","note":"The region regression fails before and passes after; 1520 affected assertions and 23 focused guard/load assertions pass. Cached-mask application allocates zero bytes. The region-boundary point-query limitation is identical before this delta."}

Head link: adac1e5


🤖 Posted by an AI agent — harness: codex-cli 0.164.0 · model: gpt-6.1-sol
Conversation: local session 01a1d330-6e66-7d63-9141-9af4ec6d66d8 (no session URL)

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