SpringForceField
This component implements a physics-based spring force field for simulating elastic connections between particles or points. It's designed for modeling systems where objects are connected by springs (e.g., molecular dynamics, cloth simulation, soft tissue modeling).
Overview
The SpringForceField component creates a physics-based spring system that:
- Applies Hooke's law forces proportional to displacement from rest length
- Includes viscous damping for energy dissipation
- Supports individual spring properties (stiffness, damping, rest length, activation state)
- Handles topological changes automatically
- Provides visualization options for debugging
Physics Model
The component implements a linear spring model where each connection (spring) provides the force model:
where:
- k_s = Spring stiffness
- l = Current length
- l_0 = Rest length
- u = Unit vector along spring
- v = Relative velocity
- k_d = Damping coefficient
A spring-based force field between two mechanical states, applying Hookean elastic forces with damping.
Rigid3d
Templates:
- Rigid3d
Target: Sofa.Component.SolidMechanics.Spring
namespace: sofa::component::solidmechanics::spring
parents:
- PairInteractionForceField
Data
| Name | Description | Default value |
|---|---|---|
| name | object name | unnamed |
| printLog | if true, emits extra messages at runtime. | 0 |
| tags | list of the subsets the object belongs to | |
| bbox | this object bounding box | |
| componentState | The state of the component among (Dirty, Valid, Undefined, Loading, Invalid). | Undefined |
| listening | if true, handle the events, otherwise ignore the events | 0 |
| rayleighStiffness | Rayleigh damping - stiffness matrix coefficient | 0 |
| stiffness | uniform stiffness for the all springs | 100 |
| damping | uniform damping for the all springs | 5 |
| spring | pairs of indices, stiffness, damping, rest length | |
| lengths | List of lengths to create the springs. Must have the same than indices1 & indices2, or if only one element, it will be applied to all springs. If empty, 0 will be applied everywhere | |
| elongationOnly | ///< List of boolean stating on the fact that the spring should only apply forces on elongations. Must have the same than indices1 & indices2, or if only one element, it will be applied to all springs. If empty, False will be applied everywhere | 0 |
| enabled | ///< List of boolean stating on the fact that the spring is enabled. Must have the same than indices1 & indices2, or if only one element, it will be applied to all springs. If empty, True will be applied everywhere | 1 |
| springsIndices1 | List of indices in springs from the first mstate | |
| springsIndices2 | List of indices in springs from the second mstate | |
| Visualization | ||
| showArrowSize | size of the axis | 0.01 |
| drawMode | The way springs will be drawn: - 0: Line - 1:Cylinder - 2: Arrow | 0 |
Links
| Name | Description | Destination type name |
|---|---|---|
| context | Graph Node containing this object (or BaseContext::getDefault() if no graph is used) | BaseContext |
| slaves | Sub-objects used internally by this object | BaseObject |
| master | nullptr for regular objects, or master object for which this object is one sub-objects | BaseObject |
| mechanicalStates | List of mechanical states to which this component is associated | BaseMechanicalState |
| object1 | First object associated to this component | MechanicalState<Rigid3d> |
| object2 | Second object associated to this component | MechanicalState<Rigid3d> |
Vec1d
Templates:
- Vec1d
Target: Sofa.Component.SolidMechanics.Spring
namespace: sofa::component::solidmechanics::spring
parents:
- PairInteractionForceField
Data
| Name | Description | Default value |
|---|---|---|
| name | object name | unnamed |
| printLog | if true, emits extra messages at runtime. | 0 |
| tags | list of the subsets the object belongs to | |
| bbox | this object bounding box | |
| componentState | The state of the component among (Dirty, Valid, Undefined, Loading, Invalid). | Undefined |
| listening | if true, handle the events, otherwise ignore the events | 0 |
| rayleighStiffness | Rayleigh damping - stiffness matrix coefficient | 0 |
| stiffness | uniform stiffness for the all springs | 100 |
| damping | uniform damping for the all springs | 5 |
| spring | pairs of indices, stiffness, damping, rest length | |
| lengths | List of lengths to create the springs. Must have the same than indices1 & indices2, or if only one element, it will be applied to all springs. If empty, 0 will be applied everywhere | |
| elongationOnly | ///< List of boolean stating on the fact that the spring should only apply forces on elongations. Must have the same than indices1 & indices2, or if only one element, it will be applied to all springs. If empty, False will be applied everywhere | 0 |
| enabled | ///< List of boolean stating on the fact that the spring is enabled. Must have the same than indices1 & indices2, or if only one element, it will be applied to all springs. If empty, True will be applied everywhere | 1 |
| springsIndices1 | List of indices in springs from the first mstate | |
| springsIndices2 | List of indices in springs from the second mstate | |
| Visualization | ||
| showArrowSize | size of the axis | 0.01 |
| drawMode | The way springs will be drawn: - 0: Line - 1:Cylinder - 2: Arrow | 0 |
Links
| Name | Description | Destination type name |
|---|---|---|
| context | Graph Node containing this object (or BaseContext::getDefault() if no graph is used) | BaseContext |
| slaves | Sub-objects used internally by this object | BaseObject |
| master | nullptr for regular objects, or master object for which this object is one sub-objects | BaseObject |
| mechanicalStates | List of mechanical states to which this component is associated | BaseMechanicalState |
| object1 | First object associated to this component | MechanicalState<Vec1d> |
| object2 | Second object associated to this component | MechanicalState<Vec1d> |
Vec2d
Templates:
- Vec2d
Target: Sofa.Component.SolidMechanics.Spring
namespace: sofa::component::solidmechanics::spring
parents:
- PairInteractionForceField
Data
| Name | Description | Default value |
|---|---|---|
| name | object name | unnamed |
| printLog | if true, emits extra messages at runtime. | 0 |
| tags | list of the subsets the object belongs to | |
| bbox | this object bounding box | |
| componentState | The state of the component among (Dirty, Valid, Undefined, Loading, Invalid). | Undefined |
| listening | if true, handle the events, otherwise ignore the events | 0 |
| rayleighStiffness | Rayleigh damping - stiffness matrix coefficient | 0 |
| stiffness | uniform stiffness for the all springs | 100 |
| damping | uniform damping for the all springs | 5 |
| spring | pairs of indices, stiffness, damping, rest length | |
| lengths | List of lengths to create the springs. Must have the same than indices1 & indices2, or if only one element, it will be applied to all springs. If empty, 0 will be applied everywhere | |
| elongationOnly | ///< List of boolean stating on the fact that the spring should only apply forces on elongations. Must have the same than indices1 & indices2, or if only one element, it will be applied to all springs. If empty, False will be applied everywhere | 0 |
| enabled | ///< List of boolean stating on the fact that the spring is enabled. Must have the same than indices1 & indices2, or if only one element, it will be applied to all springs. If empty, True will be applied everywhere | 1 |
| springsIndices1 | List of indices in springs from the first mstate | |
| springsIndices2 | List of indices in springs from the second mstate | |
| Visualization | ||
| showArrowSize | size of the axis | 0.01 |
| drawMode | The way springs will be drawn: - 0: Line - 1:Cylinder - 2: Arrow | 0 |
Links
| Name | Description | Destination type name |
|---|---|---|
| context | Graph Node containing this object (or BaseContext::getDefault() if no graph is used) | BaseContext |
| slaves | Sub-objects used internally by this object | BaseObject |
| master | nullptr for regular objects, or master object for which this object is one sub-objects | BaseObject |
| mechanicalStates | List of mechanical states to which this component is associated | BaseMechanicalState |
| object1 | First object associated to this component | MechanicalState<Vec2d> |
| object2 | Second object associated to this component | MechanicalState<Vec2d> |
Vec3d
Templates:
- Vec3d
Target: Sofa.Component.SolidMechanics.Spring
namespace: sofa::component::solidmechanics::spring
parents:
- PairInteractionForceField
Data
| Name | Description | Default value |
|---|---|---|
| name | object name | unnamed |
| printLog | if true, emits extra messages at runtime. | 0 |
| tags | list of the subsets the object belongs to | |
| bbox | this object bounding box | |
| componentState | The state of the component among (Dirty, Valid, Undefined, Loading, Invalid). | Undefined |
| listening | if true, handle the events, otherwise ignore the events | 0 |
| rayleighStiffness | Rayleigh damping - stiffness matrix coefficient | 0 |
| stiffness | uniform stiffness for the all springs | 100 |
| damping | uniform damping for the all springs | 5 |
| spring | pairs of indices, stiffness, damping, rest length | |
| lengths | List of lengths to create the springs. Must have the same than indices1 & indices2, or if only one element, it will be applied to all springs. If empty, 0 will be applied everywhere | |
| elongationOnly | ///< List of boolean stating on the fact that the spring should only apply forces on elongations. Must have the same than indices1 & indices2, or if only one element, it will be applied to all springs. If empty, False will be applied everywhere | 0 |
| enabled | ///< List of boolean stating on the fact that the spring is enabled. Must have the same than indices1 & indices2, or if only one element, it will be applied to all springs. If empty, True will be applied everywhere | 1 |
| springsIndices1 | List of indices in springs from the first mstate | |
| springsIndices2 | List of indices in springs from the second mstate | |
| Visualization | ||
| showArrowSize | size of the axis | 0.01 |
| drawMode | The way springs will be drawn: - 0: Line - 1:Cylinder - 2: Arrow | 0 |
Links
| Name | Description | Destination type name |
|---|---|---|
| context | Graph Node containing this object (or BaseContext::getDefault() if no graph is used) | BaseContext |
| slaves | Sub-objects used internally by this object | BaseObject |
| master | nullptr for regular objects, or master object for which this object is one sub-objects | BaseObject |
| mechanicalStates | List of mechanical states to which this component is associated | BaseMechanicalState |
| object1 | First object associated to this component | MechanicalState<Vec3d> |
| object2 | Second object associated to this component | MechanicalState<Vec3d> |
Vec6d
Templates:
- Vec6d
Target: Sofa.Component.SolidMechanics.Spring
namespace: sofa::component::solidmechanics::spring
parents:
- PairInteractionForceField
Data
| Name | Description | Default value |
|---|---|---|
| name | object name | unnamed |
| printLog | if true, emits extra messages at runtime. | 0 |
| tags | list of the subsets the object belongs to | |
| bbox | this object bounding box | |
| componentState | The state of the component among (Dirty, Valid, Undefined, Loading, Invalid). | Undefined |
| listening | if true, handle the events, otherwise ignore the events | 0 |
| rayleighStiffness | Rayleigh damping - stiffness matrix coefficient | 0 |
| stiffness | uniform stiffness for the all springs | 100 |
| damping | uniform damping for the all springs | 5 |
| spring | pairs of indices, stiffness, damping, rest length | |
| lengths | List of lengths to create the springs. Must have the same than indices1 & indices2, or if only one element, it will be applied to all springs. If empty, 0 will be applied everywhere | |
| elongationOnly | ///< List of boolean stating on the fact that the spring should only apply forces on elongations. Must have the same than indices1 & indices2, or if only one element, it will be applied to all springs. If empty, False will be applied everywhere | 0 |
| enabled | ///< List of boolean stating on the fact that the spring is enabled. Must have the same than indices1 & indices2, or if only one element, it will be applied to all springs. If empty, True will be applied everywhere | 1 |
| springsIndices1 | List of indices in springs from the first mstate | |
| springsIndices2 | List of indices in springs from the second mstate | |
| Visualization | ||
| showArrowSize | size of the axis | 0.01 |
| drawMode | The way springs will be drawn: - 0: Line - 1:Cylinder - 2: Arrow | 0 |
Links
| Name | Description | Destination type name |
|---|---|---|
| context | Graph Node containing this object (or BaseContext::getDefault() if no graph is used) | BaseContext |
| slaves | Sub-objects used internally by this object | BaseObject |
| master | nullptr for regular objects, or master object for which this object is one sub-objects | BaseObject |
| mechanicalStates | List of mechanical states to which this component is associated | BaseMechanicalState |
| object1 | First object associated to this component | MechanicalState<Vec6d> |
| object2 | Second object associated to this component | MechanicalState<Vec6d> |