Skip to content

[SolidMechanics.FEM.Elastic] FIX stiffness matrix of HexahedralFEMForceField - #6475

Open
alxbilger wants to merge 3 commits into
sofa-framework:masterfrom
alxbilger:fixhexahedral
Open

alxbilger wants to merge 3 commits into
sofa-framework:masterfrom
alxbilger:fixhexahedral

Conversation

@alxbilger

Copy link
Copy Markdown
Contributor

Based on:

The element stiffness blocks were rotated as Rᵀ·K·R instead of R·K·Rᵀ. The force is f = R·K·(x₀ − Rᵀ·x), so the stiffness is −R·K·Rᵀ, which is what addDForce already computes. The assembled matrices therefore disagreed with addDForce whenever an element was rotated. They only coincided when there was no rotation, which is why existing tests never caught it. The bug was found by the new derivative-consistency checks (see #).

Changes

  • HexahedralFEMForceField: addKToMatrix and buildStiffnessMatrix now use R·K·Rᵀ.
  • HexahedralFEMForceFieldAndMass: same fix in addKToMatrix (diagonal blocks only, as before) and in the stiffness part of addMBKToMatrix.

Tests

  • Re-enabled HexahedralFEMForceField_stiffness.large in ElasticForceFieldsStiffness_test: a random rotated and deformed hexahedron, checking that addDForce, addKToMatrix and buildStiffnessMatrix are consistent.
  • Added HexahedralFEMForceFieldAndMass_stiffness.large. It doesn't test addKToMatrix, since that method only assembles the diagonal blocks.

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: fix Fix a bug 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 Nov 30, 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: fix Fix a bug pr: status to review To notify reviewers to review this pull-request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant