Skip to content

[SolidMechanics][FEM] Fix FastTetrahedralCorotationalForceField stiffness matrix assembly#6154

Merged
fredroy merged 1 commit into
sofa-framework:masterfrom
th-skam:fix-fastTetraFF
Jun 26, 2026
Merged

[SolidMechanics][FEM] Fix FastTetrahedralCorotationalForceField stiffness matrix assembly#6154
fredroy merged 1 commit into
sofa-framework:masterfrom
th-skam:fix-fastTetraFF

Conversation

@th-skam

@th-skam th-skam commented Jun 15, 2026

Copy link
Copy Markdown
Contributor

A bit of an obscure bug.

In FastTetrahedralCorotationalForceField, due to a missed transpose, the mechanics change if the edge indexing changes. This is observed in case the solver template triggers the buildStiffnessMatrix path. The other paths are ok.

This can happen in a scene such as the one below. In one case, the topology uses the edges computed by the mesh loader (unstable), in the other case, it re-computes them (stable). The two components register edge indices differently. This also raises another point: do we want to have components that create element arrays in different ways?

    root.addObject("ConstraintAttachButtonSetting")
    root.addObject("VisualStyle", displayFlags="showVisualModels")
    root.addObject("DefaultAnimationLoop")

    for i in range(2):
        with root.addChild("Liver"+str(i)) as liver:
            liver.addObject("EulerImplicitSolver")
            liver.addObject("EigenSimplicialLDLT", name="LinearSolver", template='CompressedRowSparseMatrixMat3x3d')
            liver.addObject("MeshGmshLoader", name="meshLoader", filename="mesh/liver.msh", scale3d=[0.08, 0.08, 0.08], translation=[0, -0.3, -0.2])

            # Explicitly copy position & tetrahedra VS sourcing the loader
            if(i==0):
                liver.addObject("TetrahedronSetTopologyContainer", name="TetraContainer", position="@meshLoader.position", tetrahedra="@meshLoader.tetrahedra")
            else:
                liver.addObject("TetrahedronSetTopologyContainer", name="TetraContainer", src="@meshLoader")

            liver.addObject("MechanicalObject", name="mstate_gel", template="Vec3d")
            liver.addObject("FastTetrahedralCorotationalForceField", name="FF", youngModulus=4e4, poissonRatio=0.3)
            liver.addObject("MeshMatrixMass", name="Mass",totalMass=0.01)
            liver.addObject("BoxROI", name="BoxROI", box=[-0.350, -0.280, -0.360, 0.130, 0.130, -0.200 ])
            liver.addObject("RestShapeSpringsForceField", stiffness=1e3, angularStiffness=1e3, points="@BoxROI.indices")

            with liver.addChild("Visual") as visual:
                color=[]
                if(i==0):
                    color=[0, 1, 0, 1]
                else:
                    color=[1, 0, 0, 1]
                visual.addObject("OglModel", color=color)
                visual.addObject("IdentityMapping")
Screen.Recording.2026-06-15.133446.mp4

[ci-build][with-all-tests]

@th-skam th-skam 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 Jun 15, 2026
@th-skam

th-skam commented Jun 18, 2026

Copy link
Copy Markdown
Contributor Author

[ci-build][with-all-tests]

@fredroy fredroy added pr: status ready Approved a pull-request, ready to be squashed and removed pr: status to review To notify reviewers to review this pull-request labels Jun 26, 2026
@fredroy fredroy merged commit 8064720 into sofa-framework:master Jun 26, 2026
16 of 17 checks passed
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 ready Approved a pull-request, ready to be squashed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants