Back

LinearVelocityProjectiveConstraint

sofa::component::constraint::projective::LinearVelocityProjectiveConstraint
ProjectiveConstraintSet
Doc (from source)

Impose a velocity to given DOFs (translation and rotation). impose a motion to given DOFs (translation and rotation) The motion between 2 key times is linearly interpolated

Abstract (AI generated)

Imposes linear velocity constraints on specified degrees of freedom (DOFs) using linear interpolation between predefined key velocities and times.

Metadata
module
Sofa.Component.Constraint.Projective
namespace
sofa::component::constraint::projective
include
sofa/component/constraint/projective/LinearVelocityProjectiveConstraint.h
inherits
  • ProjectiveConstraintSet
templates
  • sofa::defaulttype::Rigid3Types
  • sofa::defaulttype::Vec3Types
description

The LinearVelocityProjectiveConstraint component imposes linear velocity constraints on specified degrees of freedom (DOFs) in a simulation. It allows for precise control over the motion of selected DOFs by defining velocities at specific key times and interpolating between them.

Governing Equations or Operators Contributed:

The main contribution to the global FEM pipeline is enforcing linear velocity constraints on the specified DOFs, which modifies the system's response. The following are the key operators involved in this constraint imposition:

  1. Velocity Projection:
  2. In the context of time integration and nonlinear resolution, the velocities at constrained DOFs are explicitly set to predefined values or interpolated values between key times.

  3. Jacobian Matrix Modification (if needed):

  4. The component may modify the Jacobian matrix to enforce these constraints by applying zero Dirichlet conditions on the constrained DOFs.

Constitutive or Kinematic Laws Involved:

  • Linear Interpolation of Velocities: Given a set of key times and corresponding velocities, the linear interpolation between two key times is used to determine the velocity at any intermediate time $t$:

Let $ar{v}_i$ be the velocity at key time $t_i$, then for an arbitrary simulation time $cT$ between $t_{prev}$ and $t_{next}$:

egin{equation}
v(cT) = ((ar{v}{next} - ar{v}{prev}) * (cT - t_{prev})) / (t_{next} - t_{prev}) + ar{v}_{prev}
\end{equation}

Role in the Global FEM Pipeline:

  • Assembly Phase: The component does not contribute to assembling global operators such as mass and stiffness matrices directly but ensures that specific DOFs follow predefined velocity constraints.

  • Time Integration: During time integration, this component modifies the velocity values of constrained DOFs using linear interpolation between specified key velocities and times. It projects these velocities onto the simulation state during each time step.

  • Nonlinear Resolution: The component enforces constraints by modifying the system's response through projection methods, ensuring that the nonlinear solver accounts for predefined velocities at specific DOFs.

Numerical Methods or Discretization Choices:

The numerical method used is a linear interpolation of velocities between specified key times. This interpolation ensures smooth transitions in motion while maintaining control over the constrained DOFs.

  • Time Discretization: The simulation time $cT$ is discretized into segments defined by key times, and velocities are interpolated within these segments to provide precise velocity control at each step.

Fit into Variational / Lagrangian Mechanics Framework:

The constraint imposition does not alter the variational structure of the problem but rather enforces a specific kinematic behavior on selected DOFs. The projected velocities ensure that the constrained motion adheres to predefined paths, thereby modifying the dynamics without changing the underlying variational formulation.

Summary:

  • Role: Impose linear velocity constraints on specified DOFs (translation and rotation) at given times using linear interpolation between key frames.

  • Operators Involved:

  • Velocity projection: $v(cT)$
  • Constraint enforcement: modification of Jacobian matrix if needed to enforce fixed velocities.

The LinearVelocityProjectiveConstraint ensures that the simulation maintains prescribed motion paths for selected DOFs, allowing precise control over their behavior.

Data Fields
NameTypeDefaultHelp
d_keyVelocities VecDeriv velocities corresponding to the key times
d_continueAfterEnd bool If set to true then the last velocity will still be applied after all the key events
Links
NameTypeHelp
l_topology link to the topology container
Methods
void clearIndices ()
void addIndex (int index)
void removeIndex (int index)
void clearKeyVelocities ()
void addKeyVelocity (Real time, Deriv movement)
void init ()
void reset ()
void projectResponse (const core::MechanicalParams * mparams, DataVecDeriv & resData)
void projectVelocity (const core::MechanicalParams * mparams, DataVecDeriv & vData)
void projectPosition (const core::MechanicalParams * mparams, DataVecCoord & xData)
void projectJacobianMatrix (const core::MechanicalParams * mparams, DataMatrixDeriv & cData)
void applyConstraint (const core::MechanicalParams * mparams, linearalgebra::BaseVector * vector, const sofa::core::behavior::MultiMatrixAccessor * matrix)
void applyConstraint (const core::MechanicalParams * mparams, const sofa::core::behavior::MultiMatrixAccessor * matrix)
void projectMatrix (sofa::linearalgebra::BaseMatrix * , unsigned int )
void applyConstraint (sofa::core::behavior::ZeroDirichletCondition * matrix)
void draw (const core::visual::VisualParams * vparams)
{
  "name": "LinearVelocityProjectiveConstraint",
  "namespace": "sofa::component::constraint::projective",
  "module": "Sofa.Component.Constraint.Projective",
  "include": "sofa/component/constraint/projective/LinearVelocityProjectiveConstraint.h",
  "doc": "Impose a velocity to given DOFs (translation and rotation).\n\nimpose a motion to given DOFs (translation and rotation)\n\tThe motion between 2 key times is linearly interpolated",
  "inherits": [
    "ProjectiveConstraintSet"
  ],
  "templates": [
    "sofa::defaulttype::Rigid3Types",
    "sofa::defaulttype::Vec3Types"
  ],
  "data_fields": [
    {
      "name": "d_keyVelocities",
      "type": "VecDeriv",
      "xmlname": "velocities",
      "help": "velocities corresponding to the key times"
    },
    {
      "name": "d_continueAfterEnd",
      "type": "bool",
      "xmlname": "continueAfterEnd",
      "help": "If set to true then the last velocity will still be applied after all the key events"
    }
  ],
  "links": [
    {
      "name": "l_topology",
      "target": "BaseMeshTopology",
      "kind": "single",
      "xmlname": "topology",
      "help": "link to the topology container"
    }
  ],
  "methods": [
    {
      "name": "clearIndices",
      "return_type": "void",
      "params": [],
      "is_virtual": false,
      "is_pure_virtual": false,
      "is_static": false,
      "access": "public"
    },
    {
      "name": "addIndex",
      "return_type": "void",
      "params": [
        {
          "name": "index",
          "type": "int"
        }
      ],
      "is_virtual": false,
      "is_pure_virtual": false,
      "is_static": false,
      "access": "public"
    },
    {
      "name": "removeIndex",
      "return_type": "void",
      "params": [
        {
          "name": "index",
          "type": "int"
        }
      ],
      "is_virtual": false,
      "is_pure_virtual": false,
      "is_static": false,
      "access": "public"
    },
    {
      "name": "clearKeyVelocities",
      "return_type": "void",
      "params": [],
      "is_virtual": false,
      "is_pure_virtual": false,
      "is_static": false,
      "access": "public"
    },
    {
      "name": "addKeyVelocity",
      "return_type": "void",
      "params": [
        {
          "name": "time",
          "type": "Real"
        },
        {
          "name": "movement",
          "type": "Deriv"
        }
      ],
      "is_virtual": false,
      "is_pure_virtual": false,
      "is_static": false,
      "access": "public"
    },
    {
      "name": "init",
      "return_type": "void",
      "params": [],
      "is_virtual": false,
      "is_pure_virtual": false,
      "is_static": false,
      "access": "public"
    },
    {
      "name": "reset",
      "return_type": "void",
      "params": [],
      "is_virtual": false,
      "is_pure_virtual": false,
      "is_static": false,
      "access": "public"
    },
    {
      "name": "projectResponse",
      "return_type": "void",
      "params": [
        {
          "name": "mparams",
          "type": "const core::MechanicalParams *"
        },
        {
          "name": "resData",
          "type": "DataVecDeriv &"
        }
      ],
      "is_virtual": false,
      "is_pure_virtual": false,
      "is_static": false,
      "access": "public"
    },
    {
      "name": "projectVelocity",
      "return_type": "void",
      "params": [
        {
          "name": "mparams",
          "type": "const core::MechanicalParams *"
        },
        {
          "name": "vData",
          "type": "DataVecDeriv &"
        }
      ],
      "is_virtual": false,
      "is_pure_virtual": false,
      "is_static": false,
      "access": "public"
    },
    {
      "name": "projectPosition",
      "return_type": "void",
      "params": [
        {
          "name": "mparams",
          "type": "const core::MechanicalParams *"
        },
        {
          "name": "xData",
          "type": "DataVecCoord &"
        }
      ],
      "is_virtual": false,
      "is_pure_virtual": false,
      "is_static": false,
      "access": "public"
    },
    {
      "name": "projectJacobianMatrix",
      "return_type": "void",
      "params": [
        {
          "name": "mparams",
          "type": "const core::MechanicalParams *"
        },
        {
          "name": "cData",
          "type": "DataMatrixDeriv &"
        }
      ],
      "is_virtual": false,
      "is_pure_virtual": false,
      "is_static": false,
      "access": "public"
    },
    {
      "name": "applyConstraint",
      "return_type": "void",
      "params": [
        {
          "name": "mparams",
          "type": "const core::MechanicalParams *"
        },
        {
          "name": "vector",
          "type": "linearalgebra::BaseVector *"
        },
        {
          "name": "matrix",
          "type": "const sofa::core::behavior::MultiMatrixAccessor *"
        }
      ],
      "is_virtual": false,
      "is_pure_virtual": false,
      "is_static": false,
      "access": "public"
    },
    {
      "name": "applyConstraint",
      "return_type": "void",
      "params": [
        {
          "name": "mparams",
          "type": "const core::MechanicalParams *"
        },
        {
          "name": "matrix",
          "type": "const sofa::core::behavior::MultiMatrixAccessor *"
        }
      ],
      "is_virtual": false,
      "is_pure_virtual": false,
      "is_static": false,
      "access": "public"
    },
    {
      "name": "projectMatrix",
      "return_type": "void",
      "params": [
        {
          "name": "",
          "type": "sofa::linearalgebra::BaseMatrix *"
        },
        {
          "name": "",
          "type": "unsigned int"
        }
      ],
      "is_virtual": false,
      "is_pure_virtual": false,
      "is_static": false,
      "access": "public"
    },
    {
      "name": "applyConstraint",
      "return_type": "void",
      "params": [
        {
          "name": "matrix",
          "type": "sofa::core::behavior::ZeroDirichletCondition *"
        }
      ],
      "is_virtual": false,
      "is_pure_virtual": false,
      "is_static": false,
      "access": "public"
    },
    {
      "name": "draw",
      "return_type": "void",
      "params": [
        {
          "name": "vparams",
          "type": "const core::visual::VisualParams *"
        }
      ],
      "is_virtual": false,
      "is_pure_virtual": false,
      "is_static": false,
      "access": "public"
    }
  ],
  "description": "This component applies linear velocity constraints to specific degrees of freedom (DOFs) in a simulation. It moves the constrained DOFs along specified velocities over time, allowing for precise control over their motion.",
  "parameters": [
    {
      "name": "indices",
      "description": "Indices of the DOFs that will be affected by the constraint."
    },
    {
      "name": "keyTimes",
      "description": "A vector of times at which specific velocities should be applied to the constrained DOFs. The values in this list must be sorted in ascending order."
    },
    {
      "name": "keyVelocities",
      "description": "A vector of velocities that will be applied at each corresponding time specified in 'keyTimes'. These velocities define how fast and in what direction the DOFs should move over time."
    },
    {
      "name": "coordinates",
      "description": "Indices of specific coordinates within each DOF to which the constraint should be applied. If not provided, the constraint is applied to all components of the DOFs."
    },
    {
      "name": "continueAfterLastKeyTime",
      "description": "A boolean indicating whether the constraint should continue applying the last specified velocity after the final key time has been reached."
    }
  ],
  "functionality": [
    {
      "description": "Initializes and resets internal state, preparing for a new simulation run."
    },
    {
      "description": "Applies linear velocities to constrained DOFs based on current simulation time and defined key times/velocities."
    },
    {
      "description": "Updates the positions of constrained DOFs over time according to specified velocities."
    },
    {
      "description": "Projects constraint onto Jacobian matrix, ensuring consistency with other constraints in the system.",
      "condition": "Not currently implemented"
    },
    {
      "description": "Applies zero Dirichlet conditions to constrained DOFs, effectively fixing them at specific values during simulation steps."
    },
    {
      "description": "Draws a visual representation of the path that constrained DOFs will follow over time using key times and velocities, for debugging or visualization purposes.",
      "condition": "Only displayed if 'showBehaviorModels' flag is set in VisualParams"
    }
  ],
  "maths": "The **LinearVelocityProjectiveConstraint** component imposes linear velocity constraints on specified degrees of freedom (DOFs) in a simulation. It allows for precise control over the motion of selected DOFs by defining velocities at specific key times and interpolating between them.\n\n### Governing Equations or Operators Contributed:\n\nThe main contribution to the global FEM pipeline is enforcing linear velocity constraints on the specified DOFs, which modifies the system's response. The following are the key operators involved in this constraint imposition:\n\n1. **Velocity Projection**:\n   - In the context of time integration and nonlinear resolution, the velocities at constrained DOFs are explicitly set to predefined values or interpolated values between key times.\n   \n2. **Jacobian Matrix Modification** (if needed):\n   - The component may modify the Jacobian matrix to enforce these constraints by applying zero Dirichlet conditions on the constrained DOFs.\n\n### Constitutive or Kinematic Laws Involved:\n\n- **Linear Interpolation of Velocities**: Given a set of key times and corresponding velocities, the linear interpolation between two key times is used to determine the velocity at any intermediate time \\(t\\):\n  \n  Let \\(\bar{v}_i\\) be the velocity at key time \\(t_i\\), then for an arbitrary simulation time \\(cT\\) between \\(t_{prev}\\) and \\(t_{next}\\):\n   \n   \n   \begin{equation}\n   v(cT) = ((\bar{v}_{next} - \bar{v}_{prev}) * (cT - t_{prev})) / (t_{next} - t_{prev}) + \bar{v}_{prev}\n   \\end{equation}\n\n### Role in the Global FEM Pipeline:\n\n- **Assembly Phase**: The component does not contribute to assembling global operators such as mass and stiffness matrices directly but ensures that specific DOFs follow predefined velocity constraints.\n\n- **Time Integration**: During time integration, this component modifies the velocity values of constrained DOFs using linear interpolation between specified key velocities and times. It projects these velocities onto the simulation state during each time step.\n\n- **Nonlinear Resolution**: The component enforces constraints by modifying the system's response through projection methods, ensuring that the nonlinear solver accounts for predefined velocities at specific DOFs.\n\n### Numerical Methods or Discretization Choices:\n\nThe numerical method used is a linear interpolation of velocities between specified key times. This interpolation ensures smooth transitions in motion while maintaining control over the constrained DOFs.\n\n- **Time Discretization**: The simulation time \\(cT\\) is discretized into segments defined by key times, and velocities are interpolated within these segments to provide precise velocity control at each step.\n\n### Fit into Variational / Lagrangian Mechanics Framework:\n\nThe constraint imposition does not alter the variational structure of the problem but rather enforces a specific kinematic behavior on selected DOFs. The projected velocities ensure that the constrained motion adheres to predefined paths, thereby modifying the dynamics without changing the underlying variational formulation.\n\n### Summary:\n\n- **Role**: Impose linear velocity constraints on specified DOFs (translation and rotation) at given times using linear interpolation between key frames.\n\n- **Operators Involved**:\n  - Velocity projection: \\(v(cT)\\)\n  - Constraint enforcement: modification of Jacobian matrix if needed to enforce fixed velocities.\n\nThe LinearVelocityProjectiveConstraint ensures that the simulation maintains prescribed motion paths for selected DOFs, allowing precise control over their behavior.",
  "abstract": "Imposes linear velocity constraints on specified degrees of freedom (DOFs) using linear interpolation between predefined key velocities and times.",
  "sheet": "# LinearVelocityProjectiveConstraint\n\n## Overview\nThe **LinearVelocityProjectiveConstraint** component imposes linear velocity constraints on specific degrees of freedom (DOFs) in a simulation. It handles the interpolation between key velocities and times to ensure precise control over motion, modifying the system's response during time integration.\n\n## Mathematical Model\nGiven a set of key times and corresponding velocities, the linear interpolation between two key times is used to determine the velocity at any intermediate time \\(t\\):\n\nLet \\(\\bar{v}_i\\) be the velocity at key time \\(t_i\\), then for an arbitrary simulation time \\(cT\\) between \\(t_{prev}\\) and \\(t_{next}\\):\n\n\\[ v(cT) = (\\frac{(\\bar{v}_{next} - \\bar{v}_{prev}) * (cT - t_{prev})}{t_{next} - t_{prev}}) + \\bar{v}_{prev} \\]\n\n## Parameters and Data\n- **velocities**: Velocities corresponding to the key times (`VecDeriv` type).\n- **continueAfterEnd**: If set to true, the last velocity will still be applied after all the key events (`bool`, default: false).\n\n## Dependencies and Connections\nThis component requires a link to the topology container (`BaseMeshTopology`) and typically interacts with other components that handle mechanical state, time integration, and nonlinear resolution.\n"
}