镜像站点 · 本页由第三方 GitHub 只读镜像提供,非 GitHub 官方站点,不接受任何登录或凭据输入。前往 github.com
Skip to content

[Mass] Make MeshMatrixMass positive definite on hexahedra and quads - #6410

Open
fredroy wants to merge 1 commit into
sofa-framework:masterfrom
fredroy:meshmatrixmass-hexa-quad-pd
Open

fredroy wants to merge 1 commit into
sofa-framework:masterfrom
fredroy:meshmatrixmass-hexa-quad-pd

Conversation

@fredroy

@fredroy fredroy commented Oct 16, 2026 •

Copy link
Copy Markdown
Contributor

This was 99.99% AI generated 🥴 as I am not really an expert on mass.
But I felt that it was quite serious to make the AI do it 🤖
But is will a good starting point for those who know

and I am a bit amazed that the references itselves stored a blow-up 🙃


The non-lumped mass matrix only stores vertex and edge masses. On hexahedra it used rhoV * (1/20 per vertex, 1/40 per edge), whose element eigenvalues are rhoV/40 * {5, 3, 1, -1}: the checkerboard mode has negative mass, so any hexahedral MeshMatrixMass was indefinite (e.g. 42 negative eigenvalues out of 576 in TetrahedronHyperelasticityFEMForceField_invertedTets.scn). On quads, rhoA * (1/8, 1/16) was singular (eigenvalues rhoA/16 * {4, 2, 2, 0}).

Start from the consistent mass matrices (trilinear hexa: rhoV/216 * (8, 4, 2, 1), bilinear quad: rhoA/36 * (4, 2, 1)) and add the couplings that cannot be stored (face and body diagonals, quad diagonals) to the vertex mass:

  • hexa: rhoV/216 * (15 vertex, 4 edge), eigenvalues rhoV/216 * {27, 19, 11, 3}
  • quad: rhoA/36 * (5 vertex, 2 edge), eigenvalues rhoA/36 * {9, 5, 5, 1} Total mass and row sums (the lumped masses, also used for the weight) are unchanged; the lumping coefficients are updated accordingly (27/15 and 9/5).

Re-enable MeshMatrixMass_test.cpp, which was dropped from the CMake list in #5920, and add tests checking that the assembled matrix is positive definite, sums to totalMass and has the lumped masses as row sums, including after topological changes.

Example scenes:

Mass spectrum:
Inverted-tets scene: it had 42 negative eigenvalues out of 576 (smallest −4.2e-4); it now has none (smallest +1.2e-4).
Other hexahedral scenes: the remaining non-lumped ones were also indefinite on master and are now positive definite: TetrahedronHyperelasticityFEMForceField.scn, EulerExplicitIntegrationScheme.scn, MatrixLinearSystem.scn and rigidifiedSectionsInBeam.scn.
Quad scene: VisualMesh.scn was singular and is now positive definite.
Tetra and triangle scenes: unchanged.
Explicit scene: EulerExplicitIntegrationScheme.scn blew up on master (displacement 524 at t=0.03 s). With the fix it falls freely as expected (0.0045, about ½gt²).
Implicit scenes: trajectories change by less than 0.1%.

Regression references:

EulerExplicitIntegrationScheme.scn (3000 steps), whose stored reference is the blow-up.


[with-all-tests]

[NOPE-depends-on https://github.com/https://github.com/sofa-framework/Regression/pull/145]
(to fix when the new regression system is merged)


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: fix Fix a bug pr: status to review To notify reviewers to review this pull-request topic for next dev-meeting PR to be discussed in sofa-dev meeting pr: AI-aided Label notifying the reviewers that part or all of the PR has been generated with the help of an AI labels Oct 16, 2026
@alxbilger

Copy link
Copy Markdown
Contributor

I don't understand how the coupling terms were perceived by Claude in this PR. They are still missing with this PR right?
Note that FEMMass should give the exact mass matrix, including the coupling terms. I don't knowe exactly how it compares to the this PR.

The non-lumped mass matrix only stores vertex and edge masses. On hexahedra it
used rho*V * (1/20 per vertex, 1/40 per edge), whose element eigenvalues are
rho*V/40 * {5, 3, 1, -1}: the checkerboard mode has negative mass, so any
hexahedral MeshMatrixMass was indefinite (e.g. 42 negative eigenvalues out of
576 in TetrahedronHyperelasticityFEMForceField_invertedTets.scn). On quads,
rho*A * (1/8, 1/16) was singular (eigenvalues rho*A/16 * {4, 2, 2, 0}).

Start from the consistent mass matrices (trilinear hexa: rho*V/216 * (8, 4, 2, 1),
bilinear quad: rho*A/36 * (4, 2, 1)) and add the couplings that cannot be stored
(face and body diagonals, quad diagonals) to the vertex mass:
- hexa: rho*V/216 * (15 vertex, 4 edge), eigenvalues rho*V/216 * {27, 19, 11, 3}
- quad: rho*A/36 * (5 vertex, 2 edge), eigenvalues rho*A/36 * {9, 5, 5, 1}
Total mass and row sums (the lumped masses, also used for the weight) are
unchanged; the lumping coefficients are updated accordingly (27/15 and 9/5).

Re-enable MeshMatrixMass_test.cpp, which was dropped from the CMake list in
sums to totalMass and has the lumped masses as row sums, including after
topological changes.
@fredroy
fredroy force-pushed the meshmatrixmass-hexa-quad-pd branch from a135fa9 to 93aea83 Compare October 28, 2026 02:10
@alxbilger

alxbilger commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor

For the records, this PR fixes diffusion on hexas in #6431. Without it, it explodes.

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 topic for next dev-meeting PR to be discussed in sofa-dev meeting

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants