Problem
The methods addToTotalForces() and removeFromTotalForces() are currently defined in the base State class (lines 116-118 in Sofa/framework/Core/src/sofa/core/State.h). However, these methods are mechanics-specific and should not be in the generic State class.
Rationale
- Concept of forces is mechanics-specific: The notion of "force" is inherently tied to mechanical simulations and has no meaning in other physics domains.
- Limits State reusability: Having these methods in the base State class prevents State from being reused for other physics simulations such as:
- Electrical simulations (where "force" is not applicable)
- Thermal simulations (heat flow, not forces)
- Other non-mechanical physics
Suggested Solution
Move the following methods from State to MechanicalState:
void addToTotalForces(core::ConstVecDerivId forceId) override;
void removeFromTotalForces(core::ConstVecDerivId forceId) override;
Also move related members:
AccumulationVecId<TDataTypes, V_DERIV, V_READ> accumulatedForces;
const AccumulationVecId<TDataTypes, V_DERIV, V_READ>& readTotalForces() const;
This would make the base State class truly generic and extensible for any physics domain, while keeping mechanical-specific functionality in MechanicalState.
Impact
This is a refactoring that would improve the architecture's extensibility for non-mechanical physics simulations while maintaining backward compatibility through MechanicalState.
Problem
The methods
addToTotalForces()andremoveFromTotalForces()are currently defined in the baseStateclass (lines 116-118 inSofa/framework/Core/src/sofa/core/State.h). However, these methods are mechanics-specific and should not be in the generic State class.Rationale
Suggested Solution
Move the following methods from
StatetoMechanicalState:void addToTotalForces(core::ConstVecDerivId forceId) override;void removeFromTotalForces(core::ConstVecDerivId forceId) override;Also move related members:
AccumulationVecId<TDataTypes, V_DERIV, V_READ> accumulatedForces;const AccumulationVecId<TDataTypes, V_DERIV, V_READ>& readTotalForces() const;This would make the base
Stateclass truly generic and extensible for any physics domain, while keeping mechanical-specific functionality inMechanicalState.Impact
This is a refactoring that would improve the architecture's extensibility for non-mechanical physics simulations while maintaining backward compatibility through
MechanicalState.