Skip to content

[Example] Add a scene checking the projection of mapped matrices - #6262

Open
fredroy wants to merge 5 commits into
sofa-framework:masterfrom
fredroy:showcase_mapping_diff
Open

[Example] Add a scene checking the projection of mapped matrices#6262
fredroy wants to merge 5 commits into
sofa-framework:masterfrom
fredroy:showcase_mapping_diff

Conversation

@fredroy

@fredroy fredroy commented Aug 25, 2026

Copy link
Copy Markdown
Contributor

Claude:

Adds a self-checking example for the assembly of force fields acting on mapped states.

The scene runs the same mechanical system twice: once with a spring acting directly on two top-level states, once with the same spring acting on two identity-mapped children. Since J = I, the projected matrix JTKJ must equal K, so both sub-trees must follow exactly the same trajectory.
A WriteState on each top-level state records the result, and the two files must be identical.


This test is intended to show the validity of #6256 .
The mapped positions are supposed to be identical with the "direct" positions but with master it does not. (and it does with #6256)

Configuration direct P1.x mapped Q1.x Result
union (before the fix) 0.457469 0.470485 DIFFERENT
cartesian product (the fix) 0.457469 0.457469 identical
#6260 + union 0.457469 0.470485 DIFFERENT
#6260 + cartesian product 0.457469 0.457469 identical

( I did the tests by myself 👀)

The output files does serve as a self-contained regression test but it can be added as a regular regression test as well.


EDIT: converted to unit tests, with the following combinations:

Matrix Linear system Projection method
FullMatrix MatrixLinearSystem MatrixProjectionMethod
FullMatrix MatrixLinearSystem ConstantSparsityProjectionMethod
CompressedRowSparseMatrixd MatrixLinearSystem MatrixProjectionMethod
CompressedRowSparseMatrixd MatrixLinearSystem ConstantSparsityProjectionMethod
CompressedRowSparseMatrixd ConstantSparsityPatternSystem MatrixProjectionMethod
CompressedRowSparseMatrixd ConstantSparsityPatternSystem ConstantSparsityProjectionMethod

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).

@fredroy fredroy 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 Aug 25, 2026
Comment thread examples/Validation/MatrixProjectionEquivalence.scn Outdated
@alxbilger

Copy link
Copy Markdown
Contributor

Excellent idea to have this scene. I thought I had something similar somewhere. There is intermediateMapping in examples/Component/LinearSystem/MatrixLinearSystem.scn, but I don't test it numerically.

Can Claude translate it to a C++ unit test? I also would like to apply this test on ConstantSparsityPatternSystem instead of MatrixLinearSystem and/or ConstantSparsityProjectionMethod instead of MatrixProjectionMethod (= 4 combinations).

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.

2 participants