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

[Mass] Fix MeshMatrixMass totalMass when initialized from vertexMass/edgemass - #6411

Open
fredroy wants to merge 1 commit into
sofa-framework:masterfrom
fredroy:fix_meshmatrixmass-totalmass-init
Open

fredroy wants to merge 1 commit into
sofa-framework:masterfrom
fredroy:fix_meshmatrixmass-totalmass-init

Conversation

@fredroy

@fredroy fredroy commented Oct 16, 2026 •

Copy link
Copy Markdown
Contributor

from #6410 , AI detected that there was a probleme with initialization from vertexmass/edgemass. 🥸
So this makes totalMass consistent with the applied mass matrix when initialized from vertexMass/edgeMass.

It adds unit tests as well.
Same as before, mass' experts opinions are welcome 😶‍🌫️


  • initFromVertexAndEdgeMass: each edge mass is applied twice (M(i,j) and M(j,i)), so totalMass = sum(vertexMass) + 2 * sum(edgeMass). When lumped, totalMass = coeff * sum(vertexMass), which is what addMDx applies.
  • initFromVertexMass (lumping): the given vertexMass are the lumped masses (behavior before [SofaMiscForceField] Fix addForce function in MeshMatrixMass #2305, and what totalMass and massDensity already assume). Store vertexMass / massLumpingCoeff, since the lumping coefficient is applied wherever the lumped mass is used.
  • Re-enable MeshMatrixMass_test.cpp and add tests checking that totalMass is the sum of the mass matrix entries (assembled and applied through addMDx) for both init paths, on tetra and hexa meshes.

Behavior changes:

  • lumping=true with vertexMass only: the applied mass is now exactly the given vertexMass, instead of massLumpingCoeff (2 for triangles/quads, 2.5 for tetrahedra/hexahedra) times it. Free fall under gravity is unchanged, but objects are lighter relative to stiffness, constraints and contacts. d_vertexMass now holds vertexMass / massLumpingCoeff after init. totalMass and massDensity are unchanged.
  • vertexMass + edgeMass: the dynamics are unchanged, only the reported totalMass and massDensity change. The corrected massDensity also gives the right mass to elements added by topological changes.
  • No scene in the repository sets vertexMass or edgeMass on a MeshMatrixMass, so no regression reference is affected.

[with-all-tests]


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

…edgeMass

- initFromVertexAndEdgeMass: each edge mass is applied twice (M(i,j) and
  M(j,i)), so totalMass = sum(vertexMass) + 2 * sum(edgeMass). When lumped,
  totalMass = coeff * sum(vertexMass), which is what addMDx applies.
- initFromVertexMass (lumping): the given vertexMass are the lumped masses
  (behavior before sofa-framework#2305, and what totalMass and massDensity already
  assume). Store vertexMass / massLumpingCoeff, since the lumping
  coefficient is applied wherever the lumped mass is used.
- Re-enable MeshMatrixMass_test.cpp and add tests checking that totalMass is
  the sum of the mass matrix entries (assembled and applied through addMDx)
  for both init paths, on tetra and hexa meshes.

Behavior changes:
- lumping=true with vertexMass only: the applied mass is now exactly the
  given vertexMass, instead of massLumpingCoeff (2 for triangles/quads, 2.5
  for tetrahedra/hexahedra) times it. Free fall under gravity is unchanged,
  but objects are lighter relative to stiffness, constraints and contacts.
  d_vertexMass now holds vertexMass / massLumpingCoeff after init.
  totalMass and massDensity are unchanged.
- vertexMass + edgeMass: the dynamics are unchanged, only the reported
  totalMass and massDensity change. The corrected massDensity also gives the
  right mass to elements added by topological changes.
- No scene in the repository sets vertexMass or edgeMass on a
  MeshMatrixMass, so no regression reference is affected.
@fredroy fredroy 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 pr: fast merge Minor change that can be merged without waiting for the 7 review days and removed pr: fast merge Minor change that can be merged without waiting for the 7 review days labels Oct 16, 2026

@bakpaul bakpaul left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Not an expert but seems OK for me

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.

2 participants