Repository navigation
Conversation
Fix several bugs in the 'zerob' boundary-condition branch of the H(Curl) + Grad(H^1) mass matrix construction: - Zero global-boundary Grad(H^1) rows in mop21 instead of mop12. The old code indexed mop12 (size hcurl nce x hgrad nce) with Grad(H^1) row indices, writing out of bounds and corrupting the heap. The loop now starts at cell_np+1 since vertex rows are already zeroed. - Add unit diagonals for Grad(H^1) Dirichlet rows to block (2,2) rather than block (1,1). - Add vertex Grad(H^1) diagonals following the 'none' pattern (interior vertices plus owned processor-boundary vertices), instead of only vertices shared with other processors, and skip vertex DOFs in the boundary-DOF loop so each gets exactly one unit diagonal. Add a regression test to test_hcurl_grad that L2-projects an analytic field with vanishing tangential boundary component using the 'zerob' mass matrix at orders 1-3, serial and MPI, checking solver convergence and projection error. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01NKQvs9uG822LSFyCgTSuSz
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.
Primary changes
Fixes the
'zerob'boundary-condition branch ofhcurl_grad_getmop(src/fem/hcurl_grad_operators.F90). Nothing in the repository calls this branch yet. Any use of it corrupted the heap ("double free or corruption"), which made it unusable:mop12(jr,:), butmop12is sized(hcurl nce, hgrad nce). They are now zeroed inmop21(jr,:). The loop also now starts atcell_np+1, since vertex rows are already zeroed. As a result, every global-boundary row is zeroed in both blocks:mop11/mop12for H(Curl) andmop21/mop22for Grad(H^1).(1,1). They now go into block(2,2).'none'pattern: all non-processor-boundary vertices, plus shared vertices on the owning processor. The boundary-DOF loop now skips vertex DOFs, so each vertex gets exactly one unit diagonal.Adds a regression test to
src/tests/fem/test_hcurl_grad.{F90,py}(test_zerob_proj). It L2-projects an analytic field whose tangential component vanishes on the cube boundary, using the'zerob'mass matrix, at orders 1–3, in serial and with MPI. It checks that the CG solve converges (true relative residual < 1e-8) and that the projection error matches reference values: 2.756e-2, 2.097e-3 and 1.460e-4 for orders 1, 2 and 3.Secondary changes
None.
API changes
No API or input-file changes. The test program
test_hcurl_gradhas a new optional namelist flag,zerob_test, which defaults toF.Testing
Built against Ubuntu 24.04 system libraries with OpenMPI and
OMP_NUM_THREADS=2.mallocassertion. After the fix, all 6 pass.femsuite passes: 313 passed, 221 skipped (the PETSc variants, since PETSc was not in the build), 0 failed.generate_stack.py -l) is clean.Generated by Claude Code