sofa-framework / sofa

Real-time multi-physics simulation with an emphasis on medical simulation.
https://www.sofa-framework.org
GNU Lesser General Public License v2.1
871 stars 297 forks source link

[SofaDeformable] Make SpringForceField a ForceField (not an InteractionForceField) #2554

Closed alxbilger closed 1 year ago

alxbilger commented 2 years ago

Contains https://github.com/sofa-framework/sofa/pull/2557

This PR is the first step toward the conversion of the interaction force fields into simple force fields. This PR concerns the class SpringForceField and all its derived classes, including StiffSpringForceField which is used extensively to create springs.

The changes maintain the backward compatibility with current scenes. However, the signature of some functions changed. That's why it's breaking. It is now impossible to construct a StiffSpringForceField between 2 objects in C++. Instead a utility function is provided.

To maintain the backward compatibility and to facilitate the design of a simulation scene, StiffSpringForceField continues to accept two Data attributes ('object1' and 'object2') corresponding to two different objects. However, they don't correspond to any Data or Link in the component. Actually, during its creation, the component will instantiate other components in order to link both objects into one. In the end, the component is able to work on a single mechanical state while keeping the same physical behavior.

The component now instantiates:

  1. A new Node
  2. A new mechanical state which will be the fusion of the provided objects,
  3. A SubsetMultiMapping that will make the link between the two provided objects and the new mechanical state
  4. The spring force field

Since SubsetMultiMapping was initially in SofaMiscMapping, it has been moved into SofaBaseMechanics. A compatibility layer is available.

Other components using StiffSpringForceField had to be adapted to create also the extra components. An example is AttachBodyPerformer which creates the spring between an object and the mouse (shift + clic).

WARNING: Since StiffSpringForceField is now necessarily located in a mapped node, its stiffness matrix is not mapped in case of a built linear system. The forces are then computed explicitly only. This issue will be addressed in the new design of the matrix assembly.

TODO:

[ci-depends-on https://github.com/sofa-framework/SofaPython3/pull/224]


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

alxbilger commented 2 years ago

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

alxbilger commented 2 years ago

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

alxbilger commented 2 years ago

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

fredroy commented 2 years ago

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

alxbilger commented 2 years ago

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

alxbilger commented 2 years ago

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

sofabot commented 2 years ago

[ci-depends-on] detected during build #16.

To unlock the merge button, you must

sofabot commented 2 years ago

[ci-depends-on] detected during build #17.

To unlock the merge button, you must

sofabot commented 2 years ago

[ci-depends-on] detected during build #18.

To unlock the merge button, you must

sofabot commented 2 years ago

[ci-depends-on] detected during build #19.

To unlock the merge button, you must

sofabot commented 2 years ago

[ci-depends-on] detected during build #20.

To unlock the merge button, you must

sofabot commented 2 years ago

[ci-depends-on] detected during build #21.

To unlock the merge button, you must

sofabot commented 2 years ago

[ci-depends-on] detected during build #22.

To unlock the merge button, you must

sofabot commented 2 years ago

[ci-depends-on] detected during build #23.

To unlock the merge button, you must

alxbilger commented 2 years ago

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

sofabot commented 2 years ago

[ci-depends-on] detected during build #24.

To unlock the merge button, you must

alxbilger commented 2 years ago

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

sofabot commented 2 years ago

[ci-depends-on] detected during build #25.

To unlock the merge button, you must

sofabot commented 2 years ago

[ci-depends-on] detected during build #26.

To unlock the merge button, you must

fredroy commented 2 years ago

Just a note for the reviewers: SubsetMultiMapping was moved to SofaBaseMechanics for dependency reasons (but the problem will be solved in the new sofang architecture a priori)

sofabot commented 2 years ago

[ci-depends-on] detected during build #27.

To unlock the merge button, you must

sofabot commented 2 years ago

[ci-depends-on] detected during build #28.

To unlock the merge button, you must

alxbilger commented 1 year ago

This PR was considered to simplify the dev of #2777 but it is no longer required.