Skip to content

Fix BUG-013: generalize create_chunks off concrete Ferrite.Grid - #104

Merged
KnutAM merged 2 commits into
KnutAM:mainfrom
knutambot:cb/BUG013
Sep 30, 2026
Merged

KnutAM merged 2 commits into
KnutAM:mainfrom
knutambot:cb/BUG013

Conversation

@knutambot

Copy link
Copy Markdown
Contributor

Summary

  • create_chunks in src/Multithreading/TaskChunks.jl now dispatches on Ferrite.AbstractGrid instead of the concrete Ferrite.Grid, so threading=true works for external grid implementations such as FerriteIGA.jl's BezierGrid. None of the methods used Grid-specific fields; Ferrite.create_coloring already accepts AbstractGrid, and the user-supplied-chunks overload never used the grid argument beyond dispatch.
  • Added a unit test in test/threading_utils.jl with a minimal non-Grid AbstractGrid wrapper, exercising both the automatic-coloring and user-supplied-chunks paths.
  • Added a "Threaded IGA assembly" section to docs/src/literate_tutorials/iga.jl using the real FerriteIGA.jl BezierGrid, comparing threaded vs. sequential K/r (num_tasks=2 explicit, independent of Threads.nthreads(), so the chunk-splitting logic is exercised even in a single-threaded session).
  • Added JULIA_NUM_THREADS: 2 to the docs CI job in .github/workflows/CI.yml so this comparison runs with real concurrency in CI (previously single-threaded).

Review notes

Reviewed via a read-only independent Codex pass at plan and final-diff stages:

  • Plan review caught that the docs CI job ran single-threaded, which would have left the new regression check unexercised there → added JULIA_NUM_THREADS: 2.
  • Final-diff review caught that the new @test lines were marked #src, which Literate strips from every generated output (script/markdown/notebook), so the assertions would never actually run as part of the Documentation CI job → switched to #hide (this repo's established pattern, e.g. docs/src/literate_howto/automatic_differentiation.jl), which keeps the code in generated artifacts while hiding it from the rendered docs page.
  • A second final-diff review after that fix returned no further findings.

Test plan

  • Pkg.test() passes (all suites, including the new BUG-013 test, 3/3)
  • Every tutorial and how-to under docs/src/literate_tutorials/docs/src/literate_howto runs cleanly in isolation
  • Full docs/make.jl build completes with zero @example block errors

🤖 Generated with Claude Code

https://claude.ai/code/session_01KySgpVgJ5fWR9AvPK1JQoU

Allow threading=true for any Ferrite.AbstractGrid, not just concrete
Grid, so external grid implementations (e.g. FerriteIGA.jl's
BezierGrid) can use threaded assembly.

src/Multithreading/TaskChunks.jl: relax all four create_chunks method
signatures from ::Ferrite.Grid to ::Ferrite.AbstractGrid. None of them
use Grid-specific fields; automatic coloring already goes through
Ferrite.create_coloring, which accepts AbstractGrid, and the
user-supplied-chunks overload never used the grid argument beyond
dispatch.

test/threading_utils.jl: add a unit test with a minimal non-Grid
AbstractGrid wrapper (only .cells/.nodes fields, matching Ferrite's
generic AbstractGrid accessors) exercising both the automatic-coloring
and user-supplied-chunks create_chunks paths.

docs/src/literate_tutorials/iga.jl: add a threaded-assembly section
using the real FerriteIGA.jl BezierGrid, comparing K/r against the
sequential result. Uses num_tasks=2 explicitly (independent of
Threads.nthreads()) so the chunk-splitting logic is exercised even in
a single-threaded session; the comparison lines use #hide (not #src)
so they survive into the generated script/markdown that Documenter
actually executes, not just local manual runs.

.github/workflows/CI.yml: add JULIA_NUM_THREADS: 2 to the docs job,
matching the test job, so the threaded comparison in the IGA tutorial
is exercised with real concurrency in CI (previously the docs job ran
with Julia's default of 1 thread).

Reviewed via /dual-review with Codex (read-only independent reviewer):
- Plan review caught that the docs job runs single-threaded in CI,
  which would have left the new regression check untested there ->
  added JULIA_NUM_THREADS: 2 to the docs job.
- Final-diff review caught that the two @test lines were marked #src,
  which Literate strips from every generated output (script, markdown,
  notebook) -> switched to #hide (this repo's established pattern,
  e.g. docs/src/literate_howto/automatic_differentiation.jl) so the
  assertions actually run as part of the Documentation CI job.
- Second final-diff review after that fix: no further findings.

Validation: Pkg.test() passes (all suites, including new BUG-013
unit test); every tutorial and how-to under docs/src/literate_*
runs cleanly; full docs/make.jl build completes with no @example
block errors.

Also validated BUG-024 (docs/make.jl world-age failures) as an
environmental issue, not a source bug: reproduced it live via a
competing long-lived Julia process still attached to the docs
project, then confirmed a clean docs/make.jl build once no
competing process remained. Updated identified_bugs.md accordingly;
BUG-013 marked done and its open-item section removed.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01KySgpVgJ5fWR9AvPK1JQoU
@codecov

codecov Bot commented Sep 30, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 97.31%. Comparing base (9e738eb) to head (f64c3ab).

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #104   +/-   ##
=======================================
  Coverage   97.31%   97.31%           
=======================================
  Files          32       32           
  Lines        1376     1376           
=======================================
  Hits         1339     1339           
  Misses         37       37           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Comment thread docs/src/literate_tutorials/iga.jl Outdated

# Start by loading the necessary packages
using Ferrite, FerriteIGA, LinearAlgebra, FerriteAssembly
using Test #src

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed in f64c3ab.

write_solution(vtk, dh, a)
end

using Test #src

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use hide below instead of src?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch — switched to #hide in f64c3ab, same fix as the threaded-assembly asserts earlier in the diff (found the same #src-strips-everything issue via Codex review).

…istently

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01KySgpVgJ5fWR9AvPK1JQoU

- Removed the redundant `using Test #src` at the top of iga.jl: it was
  stripped from every generated output anyway (Literate removes #src
  lines unconditionally), and the tutorial's own `using Test #hide`
  right before the threaded-assembly assertions already covers all
  @test lines further down in the file.
- Switched the pre-existing bottom-of-file
  `@test norm(norm.(qe.data)) ≈ 679.3207411544098` from #src to #hide,
  for the same reason as the threaded-assembly assertions fixed
  earlier in this PR: #src strips the line from every generated
  script/markdown/notebook, so it never actually runs as part of the
  Documentation CI job.

Validation: re-ran the iga.jl tutorial standalone and the full
docs/make.jl build (both clean, no errors); Pkg.test() passes (all
suites, including the BUG-013 unit test).
@KnutAM
KnutAM merged commit 0084073 into KnutAM:main Sep 30, 2026
10 checks passed
@knutambot
knutambot deleted the cb/BUG013 branch September 30, 2026 19:42
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