Guard cloned-space BC assembly in C++ - #4255
Conversation
c004515 to
00a158a
Compare
|
I narrowed the validation after CI showed that general different-degree and submesh Petrov-Galerkin assembly with BCs is supported and already covered by tests. The current check now targets only equivalent same-mesh spaces represented by distinct FunctionSpace objects, and it is bypassed for recursive MatNest sub-block assembly so existing block formulations are not rejected. |
00a158a to
bb8ae42
Compare
|
Fixed the CI issues: the BC validation helper now checks the C++ finite-element signature instead of calling the Python-only ufl_element(), and petsc.py has been formatted locally with Ruff. |
bb8ae42 to
59833d1
Compare
|
Updated again after the latest CI results. The validation is now limited to distinct spaces that share the same dofmap, which keeps the existing submesh and mixed-domain assembly tests valid. I also updated the mypy ignore for the private recursive MatNest call and verified Ruff plus the separate CI-style mypy commands locally. |
|
Could you open the PR with a clear statement of the issue, and then how the PR fixes it? I don't know what "Reject Dirichlet boundary conditions ..." means. Also, note that checks that can be performed in C++ should be done in C++ functions rather than in the Python layer. |
59833d1 to
6d8a06e
Compare
|
Thanks, updated. The PR description now starts with the concrete issue and then explains the fix. I also moved the validation from Python into the shared C++ assemble_matrix(..., bcs) path. Python now only passes check_bcs=false for PETSc block/MatNest sub-assembly, where cloned spaces are valid and diagonal handling is performed at the block level.\n\nLocally checked: clang-format, Ruff, mypy for dolfinx/demo/test, compileall, and git diff --check. |
6d8a06e to
3e1d848
Compare
|
Follow-up: fixed the docs failure by documenting the new C++ helper and pushed the amended commit. |
3e1d848 to
80506d9
Compare
|
Quick status update: I rebased this onto current main, the PR is mergeable again, and all CI checks are passing, including Spack. The earlier feedback has been addressed by moving the validation into C++ and clarifying the issue/fix in the PR description. Is there anything else you'd like changed before review? |
80506d9 to
1df8c57
Compare
|
Rebased onto The regression tests now cover scalar/vector spaces and boundary conditions on either the trial or test space. I built the C++ core and Python bindings in Developer mode in a Linux ARM64 container with PETSc 3.25.4 ( python3 -m pytest -q python/test/unit/fem/test_assembler.py python/test/unit/fem/test_bcs.py python/test/unit/fem/test_assemble_submesh.py
mpirun -np 3 python3 -m pytest -q python/test/unit/fem/test_assembler.py python/test/unit/fem/test_bcs.py python/test/unit/fem/test_assemble_submesh.pyResults: 366 passed, 1 xfailed in serial; 365 passed, 1 skipped, 1 xfailed on each of three MPI ranks. clang-format, Ruff check/format, compileall, and diff checks also passed. Strict library mypy reports the same three diagnostics on this branch and unchanged upstream The PR description is now formatted with actual paragraphs and updated validation details. Fresh CI has started and its lint job has passed; the remaining build/test jobs are still running. |
When a standalone bilinear form uses distinct cloned FunctionSpaces, Dirichlet boundary conditions can zero constrained rows or columns while diagonal insertion is skipped: the latter only runs when the test and trial spaces have the same identity. This can leave the constrained matrix without the expected diagonal entry.
Add validation in the shared C++
assemble_matrix(..., bcs)path for distinct spaces on the same mesh that share a single dofmap and element signature. If a boundary condition belongs to either space, standalone assembly raises an error before assembling the matrix. PETSc block and MatNest sub-assembly bypass this check because diagonal handling occurs at the block level.Regression tests cover MatrixCSR and PETSc assembly, scalar and vector spaces, and boundary conditions on either the trial or test space.
Validation at
1df8c57, rebased onto700e977:linux-gnu-real64-32).test_assembler.py,test_bcs.py, andtest_assemble_submesh.py: 366 passed, 1 xfailed in serial; 365 passed, 1 skipped, 1 xfailed per rank with three MPI ranks.git diff --checkpassed.700e977in the local environment; no additional diagnostics from this PR.Split from #4249 per maintainer request.
AI assistance: OpenAI Codex assisted with the implementation, rebase, testing, and PR text.