FixedProjectiveConstraint
This component belongs to the category of Projective Constraint. The FixedProjectiveConstraint projects a constant velocity. If the fixed points have a zero velocity at the simulation start, they will keep a zero velocity i.e. be fixed.
As introduced in the page about the Projective Constraint, the FixedProjectiveConstraint corresponds to a projection matrix noted which will multiply the system matrix
so that:
. This projection matrix
is the identity matrix in which the diagonal value corresponding to the indices of the fixed points equals zero. These lines and columns equals 0. As a consequence, when the integration scheme (ODESolver) will call the
projectResponse() or projectVelocity() the constraint will be applied, ensuring that the desired degrees of freedom remain fixed.
Example of a system of size 6, with a fixed constraint at the indice 5:
By projecting this matrix on the right hand side vector we have
. This ensures to have the projection
, thus preventing any time evolution of the fifth degree of freedom. In such case, we function projectResponse():
template <class DataTypes>
void FixedProjectiveConstraint<DataTypes>::projectResponse(const core::MechanicalParams* mparams, DataVecDeriv& resData)
{
SOFA_UNUSED(mparams);
helper::WriteAccessor<DataVecDeriv> res (resData );
const SetIndexArray & indices = d_indices.getValue();
if( d_fixAll.getValue() )
{
// fix everything
typename VecDeriv::iterator it;
for( it = res.begin(); it != res.end(); ++it )
{
*it = Deriv();
}
}
else
{
for (SetIndexArray::const_iterator it = indices.begin(); it != indices.end(); ++it)
{
res[*it] = Deriv();
}
}
}
Data
The FixedProjectiveConstraint can be initialized using three input data:
- indices: corresponding to the indices of the fixed points
- fixAll: filters all the DOF to implement a fixed object
- activate_projectVelocity: if true, projects not only a constant but a zero velocity
Usage
The FixedProjectiveConstraint requires a MechanicalObject to store the degrees of freedom associated to the nodes, as well as a Mass so that the system matrix is not null. An integration scheme and a solver are also necessary to solve the linear system at each time step.
Note that if only a part of the degrees of freedom must be constraint, you can use the PartialFixedProjectiveConstraint working in the same way as the FixedProjectiveConstraint.
Example
This component is used as follows in XML format:
or using SofaPython3:
An example scene involving a FixedProjectiveConstraint is available in examples/Component/Constraint/Projective/FixedProjectiveConstraint.scn
Target: Sofa.Component.Constraint.Projective
namespace: sofa::component::constraint::projective
parents:
ProjectiveConstraintSet
Data:
| Name | Description | Default value |
|---|---|---|
| name | object name | unnamed |
| printLog | if true, emits extra messages at runtime. | 0 |
| tags | list of the subsets the objet 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 |
| group | ID of the group containing this constraint. This ID is used to specify which constraints are solved by which solver, by specifying in each solver which groups of constraints it should handle. | 0 |
| endTime | The constraint stops acting after the given value. Use a negative value for infinite constraints | -1 |
| indices | Indices of the fixed points | |
| fixAll | filter all the DOF to implement a fixed object | 0 |
| activate_projectVelocity | activate project velocity to set velocity | 0 |
| Visualization | ||
| showObject | draw or not the fixed constraints | 1 |
| drawSize | 0 -> point based rendering, >0 -> radius of spheres | 0 |
Links:
| Name | Description |
|---|---|
| context | Graph Node containing this object (or BaseContext::getDefault() if no graph is used) |
| slaves | Sub-objects used internally by this object |
| master | nullptr for regular objects, or master object for which this object is one sub-objects |
| mechanicalStates | List of mechanical states to which this component is associated |
| mstate | MechanicalState used by this component |
| topology | link to the topology container |