Skip to content

[LinearSolver] ADD tests for J·A⁻¹·Jᵀ computation in direct solvers - #6481

Open
alxbilger wants to merge 1 commit into
sofa-framework:masterfrom
alxbilger:testcompliance
Open

alxbilger wants to merge 1 commit into
sofa-framework:masterfrom
alxbilger:testcompliance

Conversation

@alxbilger

Copy link
Copy Markdown
Contributor

Adds tests that check the constraint compliance matrix W = fact·J·A⁻¹·Jᵀ computed by the direct linear solvers against a dense reference. They are meant to protect a coming change of the concrete type of J (JMatrixType). The tests write J only through the BaseMatrix interface (resize / add / compress), so they don't depend on the concrete type and should keep passing unchanged after the switch.

New test: Sofa.Component.LinearSolver.Direct/tests/ComplianceMatrix_test.cpp

A typed test runs in a small scene:

  • Linear system: a MatrixLinearSystem holding a 9×9 SPD matrix A.
  • Two MechanicalObjects in separate child nodes: a Vec3 object with 2 nodes (columns 0–5) and a Vec1 object with 3 nodes (columns 6–8). A couples the two ranges.
  • J: 5 constraint rows. Some touch one object, some touch both, and one row is empty.

Solvers covered:

  • SparseLDLSolver, parallelInverseProduct off and on
  • AsyncSparseLDLSolver
  • EigenSimplicialLDLT, parallelInverseProduct off and on. It doesn't override addJMInvJtLocal, so it covers the generic MatrixLinearSolver path (single-threaded and parallel).

Checks:

  • addJMInvJt with a J of the solver's own JMatrixType
  • addJMInvJt adds to the result instead of overwriting it
  • addJMInvJt with a J of another type (FullMatrix), which exercises the conversion in getLocalJ
  • buildComplianceMatrix, with J gathered from the MechanicalObjects by MechanicalGetConstraintJacobianVisitor
  • regularization: the term is added on the diagonal of non-empty rows only, and the empty row stays at 0
  • buildComplianceMatrix called again after the constraint Jacobian changed, to make sure the previous J isn't reused

Extended test: SofaCHOLMOD/tests/EigenCholmodSupernodalLLT_test.cpp

  • AddJMInvJtMatchesDenseReference now writes J through BaseMatrix::add instead of SparseMatrix::set.
  • New scene fixture with the same problem, testing the CHOLMOD-specific addJMInvJtLocal through the public API:
    • addJMInvJt, including adding to the result and a J of another type
    • buildComplianceMatrix, including the regularization of non-empty rows only

Notes

  • addMInvJt is deliberately left untested. It has no caller in the codebase and will be removed in a separate PR. (Its generic implementation also returns fact·J instead of fact·J·A⁻¹, because it reads back the RHS vector instead of the solution.)
  • The test CMakeLists.txt files now link Sofa.Component.StateContainer.

By submitting this pull request, I acknowledge that
I have read, understand, and agree SOFA Developer Certificate of Origin (DCO).


Reviewers will merge this pull-request only if

  • it builds with SUCCESS for all platforms on the CI.
  • it does not generate new warnings.
  • it does not generate new unit test failures.
  • it does not generate new scene test failures.
  • it does not break API compatibility.
  • it is more than 1 week old (or has fast-merge label).

@alxbilger alxbilger added pr: status to review To notify reviewers to review this pull-request pr: test PR adding test(s) in SOFA pr: AI-aided Label notifying the reviewers that part or all of the PR has been generated with the help of an AI labels Dec 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr: AI-aided Label notifying the reviewers that part or all of the PR has been generated with the help of an AI pr: status to review To notify reviewers to review this pull-request pr: test PR adding test(s) in SOFA

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant