Skip to content

[SpringForceField] Add stiffness matrix computation to JointSpringForceField#5936

Open
alxbilger wants to merge 2 commits intosofa-framework:masterfrom
alxbilger:joint
Open

[SpringForceField] Add stiffness matrix computation to JointSpringForceField#5936
alxbilger wants to merge 2 commits intosofa-framework:masterfrom
alxbilger:joint

Conversation

@alxbilger
Copy link
Contributor

@alxbilger alxbilger commented Feb 4, 2026

Supersedes #5895.

Blind attempt to implement buildStiffnessMatrix in JointSpringForceField. The implementation is based on addDForce, and in particular the method addSpringDForce.

I tested the scene JointSpringForceField.scn in the examples, but I suspect a problem in the scene. There are no unit tests, so this implementation couldn't be tested.

[with-all-scenes]


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: enhancement About a possible enhancement pr: status to review To notify reviewers to review this pull-request pr: AI-aided Label notifying the reviewers that part or all of the PR has been generated with the help of an AI labels Feb 4, 2026
@fredroy
Copy link
Contributor

fredroy commented Feb 4, 2026

[ci-build][with-all-scenes]

Comment on lines +400 to +410
df1_dx1(spring.m1, spring.m1) += worldKT;
df1_dx2(spring.m1, spring.m2) += -worldKT;
df2_dx1(spring.m2, spring.m1) += -worldKT;
df2_dx2(spring.m2, spring.m2) += worldKT;

//rotation
const Mat worldKR = rot * mR * rotInv;
df1_dx1(spring.m1 + N, spring.m1 + N) += worldKR;
df1_dx2(spring.m1 + N, spring.m2 + N) += -worldKR;
df2_dx1(spring.m2 + N, spring.m1 + N) += -worldKR;
df2_dx2(spring.m2 + N, spring.m2 + N) += worldKR;
Copy link
Contributor

Choose a reason for hiding this comment

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

Just noticed this, bringing some attention to it. The signs here are opposite from the SpringForceField.

If that's how it should be, we can merge it.

for (sofa::Index e = 0; e < n; ++e)
{
const Spring& s = ss[e];
const Mat& m = this->dfdx[e];
const unsigned p1 = Deriv::total_size * s.m1;
const unsigned p2 = Deriv::total_size * s.m2;
df1_dx1(p1, p1) += -m;
df1_dx2(p1, p2) += m;
df2_dx1(p2, p1) += m;
df2_dx2(p2, p2) += -m;

@hugtalbot hugtalbot added pr: status wip Development in the pull-request is still in progress and removed pr: status to review To notify reviewers to review this pull-request labels Mar 12, 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: enhancement About a possible enhancement pr: status wip Development in the pull-request is still in progress

Projects

None yet

Development

Successfully merging this pull request may close these issues.

JointSpringForceField scene not working

5 participants