Skip to content

Forward Euler solver does not support mapped masses #5999

@alxbilger

Description

@alxbilger

The component EulerExplicitSolver does not properly support mapped masses.

When the mass matrix is diagonal (it can be UniformMass or DiagonalMass, or even a lumped MeshMatrixMass), the acceleration can be computed trivially from the force without any linear solver. However, when this diagonal mass is mapped, the acceleration is not $M^{-1} f$, but $(J^T M J)^{-1} f$. This is not considered in the current implementation.

Instead, $M^{-1} f$ is computed, but the resulting acceleration is not transmitted to the main dofs. It results in a null acceleration.

To illustrate this problem, here is a simple scene with a 2d particle submitted to gravity:

def createScene(root):
    root.addObject("DefaultAnimationLoop")

    root.addObject('RequiredPlugin', pluginName=[
        'Sofa.Component.LinearSolver.Direct',
        'Sofa.Component.Mapping.Linear',
        'Sofa.Component.Mass',
        'Sofa.Component.ODESolver.Forward',
        'Sofa.Component.StateContainer',
        'Sofa.Component.Visual',
        'SofaMatrix',
        'SofaMatrix.imgui',
    ])

    root.addObject("LineAxis", size=2)

    root.addObject("EulerExplicitSolver", symplectic=False)
    root.addObject("SparseLDLSolver", template="CompressedRowSparseMatrix")
    root.addObject("GlobalSystemMatrixImage")

    initial_position = [0.0, 0.0]
    initial_velocity = [1.0, 1.0]
    root.addObject("MechanicalObject", template="Vec2", name="particle",
        position=[initial_position], velocity=[initial_velocity])

    with root.addChild("mapped_mass") as mapped_mass_node:
        mapped_mass_node.addObject("MechanicalObject", template="Vec2", name="mapped_particle")
        mapped_mass_node.addObject("IdentityMapping", input="@../particle", output="@mapped_particle")
        mapped_mass_node.addObject("UniformMass", template="Vec2", name="mass", vertexMass=1.0)

    root.addObject("VisualPointCloud", position="@particle.position", sphereRadius=0.05, drawMode="Sphere", color="navy")
    root.addObject("TrailRenderer", template="Vec2", position="@particle.position")

    return root

In this scene, the mapping is trivial: the identity. So its presence should not change the behavior. What we observe with the current implementation:

Image

A trajectory compatible with a zero acceleration.

What we should observe:

Image

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions