Back

ConstraintParams

The `ConstraintParams` class in the SOFA (Simulation Open-Framework Architecture) framework is designed to gather and manage parameters used by constraint components during mechanical computations. It extends the `sofa::core::ExecParams` class, inheriting its execution properties and adding specific attributes for handling constraints. ### Key Features: - **Constraint Order Handling**: The class allows specifying the order of the constraints using the `setOrder()` method, which can be read back using `constOrder()`. This is useful in mechanical simulations where different levels of accuracy or types of constraints may need to be applied based on specific simulation requirements. - **Smooth Contribution Factor**: A smooth factor can be set and retrieved via `setSmoothFactor()` and `smoothFactor()`, which helps in achieving a smoother resolution of constraints, particularly beneficial for simulating soft bodies or deformable objects. - **Accessors to State Data**: Template methods are provided (`readX()`, `readV()`, `readJ()`, `readLambda()`, `readDx()`) that allow reading the position, velocity, constraint jacobian matrix, lambda (constraint force) and corrective motion vectors from a given state container. These accessors ensure that the correct data is retrieved based on the current state. - **Setup Methods**: Various methods (`setX()`, `setV()`, `setJ()`, `setDx()`, `setLambda()`) are provided for setting IDs of different vectors and matrices used in constraint computations. These methods facilitate the setup process by returning a reference to the current instance, allowing method chaining. - **Thread Safety**: The default instance of `ConstraintParams` is thread-local (`thread_local ConstraintParams threadParams;`). This ensures that each thread has its own isolated instance of the parameters, which is crucial for maintaining correct state during concurrent execution in multi-threaded simulations. ### Usage Context: The `ConstraintParams` class plays a central role in managing how constraints are applied and resolved within SOFA's simulation pipeline. It allows constraint resolution algorithms to operate with the necessary data and configuration, ensuring that mechanical systems behave as expected under various physical conditions. The methods provided by this class help in setting up the initial conditions for constraint computations and reading back the results after they have been processed. ### Example Usage: ```cpp auto params = sofa::core::ConstraintParams::defaultInstance(); params->setOrder(sofa::core::ConstraintOrder::POS_AND_VEL); params->setSmoothFactor(0.5f); auto positionData = params->readX(mechanicalState); auto velocityData = params->readV(mechanicalState); // Apply constraints using these parameters... ```

abstract
`ConstraintParams` manages parameters used by constraint components during mechanical simulations, providing methods to set and retrieve constraint orders, smooth factors, and state data.
sheet
# ConstraintParams ## Overview The `ConstraintParams` class in SOFA is designed to manage parameters used by constraint components. It extends the `sofa::core::ExecParams` class and provides methods for setting and retrieving constraint-related data such as order, smooth factors, and state information. ## Parameters and Data - **constOrder()**: Returns the current constraint order (`ConstraintOrder`). - **setOrder(ConstraintOrder o)**: Sets the constraint order to `o`. - **smoothFactor()**: Retrieves the smooth factor value (`SReal`). - **setSmoothFactor(SReal v)**: Sets the smooth factor to `v`. - **readX(const S *state)**, **readV(const S *state)**, **readJ(const S *state)**, **readLambda(S *state)**, **readDx(S *state)**: Template methods for reading position, velocity, Jacobian matrix, lambda (constraint force), and corrective motion vectors from a given state container. - **setX(ConstVecCoordId v)**, **setV(ConstVecDerivId v)**, **setJ(MatrixDerivId j)**, **setDx(VecDerivId dx)**, **setLambda(VecDerivId lambda)**: Methods for setting IDs of vectors and matrices used in constraint computations. - **defaultInstance()**: Returns the default instance of `ConstraintParams`.
description
The `ConstraintParams` class in the SOFA (Simulation Open-Framework Architecture) framework is designed to gather and manage parameters used by constraint components during mechanical computations. It extends the `sofa::core::ExecParams` class, inheriting its execution properties and adding specific attributes for handling constraints. ### Key Features: - **Constraint Order Handling**: The class allows specifying the order of the constraints using the `setOrder()` method, which can be read back using `constOrder()`. This is useful in mechanical simulations where different levels of accuracy or types of constraints may need to be applied based on specific simulation requirements. - **Smooth Contribution Factor**: A smooth factor can be set and retrieved via `setSmoothFactor()` and `smoothFactor()`, which helps in achieving a smoother resolution of constraints, particularly beneficial for simulating soft bodies or deformable objects. - **Accessors to State Data**: Template methods are provided (`readX()`, `readV()`, `readJ()`, `readLambda()`, `readDx()`) that allow reading the position, velocity, constraint jacobian matrix, lambda (constraint force) and corrective motion vectors from a given state container. These accessors ensure that the correct data is retrieved based on the current state. - **Setup Methods**: Various methods (`setX()`, `setV()`, `setJ()`, `setDx()`, `setLambda()`) are provided for setting IDs of different vectors and matrices used in constraint computations. These methods facilitate the setup process by returning a reference to the current instance, allowing method chaining. - **Thread Safety**: The default instance of `ConstraintParams` is thread-local (`thread_local ConstraintParams threadParams;`). This ensures that each thread has its own isolated instance of the parameters, which is crucial for maintaining correct state during concurrent execution in multi-threaded simulations. ### Usage Context: The `ConstraintParams` class plays a central role in managing how constraints are applied and resolved within SOFA's simulation pipeline. It allows constraint resolution algorithms to operate with the necessary data and configuration, ensuring that mechanical systems behave as expected under various physical conditions. The methods provided by this class help in setting up the initial conditions for constraint computations and reading back the results after they have been processed. ### Example Usage: ```cpp auto params = sofa::core::ConstraintParams::defaultInstance(); params->setOrder(sofa::core::ConstraintOrder::POS_AND_VEL); params->setSmoothFactor(0.5f); auto positionData = params->readX(mechanicalState); auto velocityData = params->readV(mechanicalState); // Apply constraints using these parameters... ```
classDiagram
Class Diagram for ConstraintParams sofa::core::ExecParams <|-- sofa::core::ConstraintParams: extends sofa::core::ConstraintParams : +constOrder(): ConstraintOrder sofa::core::ConstraintParams : +setOrder(ConstraintOrder): ConstraintParams& sofa::core::ConstraintParams : +smoothFactor(): SReal sofa::core::ConstraintParams : +readX<S>(S*): const Data<typename S::VecCoord>* sofa::core::ConstraintParams : +readV<S>(S*): const Data<typename S::VecDeriv>* sofa::core::ConstraintParams : +readJ<S>(S*): const Data<typename S::MatrixDeriv>* sofa::core::ConstraintParams : +readLambda<S>(S*): const Data<typename S::VecDeriv>* sofa::core::ConstraintParams : +readDx<S>(S*): const Data<typename S::VecDeriv>* sofa::core::ConstraintParams : +setSmoothFactor(SReal): ConstraintParams& sofa::core::ConstraintParams : +x(): ConstMultiVecCoordId sofa::core::ConstraintParams : +v(): ConstMultiVecDerivId sofa::core::ConstraintParams : +j(): MultiMatrixDerivId sofa::core::ConstraintParams : +dx(): MultiVecDerivId sofa::core::ConstraintParams : +lambda(): MultiVecDerivId sofa::core::ConstraintParams : +setX(ConstVecCoordId): ConstraintParams& sofa::core::ConstraintParams : +setV(ConstVecDerivId): ConstraintParams& sofa::core::ConstraintParams : +setJ(MatrixDerivId): ConstraintParams& sofa::core::ConstraintParams : +setDx(VecDerivId): ConstraintParams& sofa::core::ConstraintParams : +setLambda(VecDerivId): ConstraintParams& sofa::core::ConstraintParams : +defaultInstance(): const ConstraintParams*
purpose
  • The primary purpose of the `ConstraintParams` class is to manage and provide parameters that are necessary for resolving constraints in mechanical simulations. It ensures that constraint resolution algorithms have access to relevant data, such as positions, velocities, and forces, and can configure how these constraints should be applied (e.g., with smooth contribution factors).
  • By providing a centralized way of accessing and setting up the required vectors and matrices, `ConstraintParams` simplifies the implementation of complex mechanical models in SOFA.
  • The class also supports multi-threaded simulations by ensuring thread-local storage for its instances, which prevents data races and maintains consistency across threads.
componentType
Parameter Management Class
maths
The `ConstraintParams` class in the SOFA framework is designed to manage parameters used by constraint components during mechanical simulations. Constraints are essential for enforcing physical laws or boundary conditions on the simulated system, ensuring that it behaves according to expected real-world behavior. ### Mathematical and Physical Description: #### Constraint Order (`constOrder()`) - The order of constraints can be set using `setOrder(ConstraintOrder)`, which determines how constraints are applied. For example, `ConstraintOrder::POS_AND_VEL` indicates that both position and velocity constraints should be considered simultaneously. - Mathematically, this is represented as a system of equations where the constraint matrix defines linear or non-linear relationships between variables: \[ C(x, \.x) = 0 \] Here, \( x \) represents positions, and \( \.x \) represents velocities. #### Smooth Contribution Factor (`smoothFactor()`) - The smooth contribution factor can be set using `setSmoothFactor(SReal)` to control the resolution of constraints. This is particularly useful in simulations involving soft bodies or deformable objects where maintaining a smooth interaction between elements is crucial. - Mathematically, this can be represented as: \[ F_{\text{smooth}} = \.lambda \cdot f(x) \] Where \(\.lambda\) is the smooth factor and \(f(x)\) represents some function of positions or displacements ensuring smoothness. #### Accessors to State Data (`readX()`, `readV()` etc.) - These methods allow reading position, velocity, constraint Jacobian matrix, lambda (constraint force), and corrective motion vectors from a given state container. The access is template-based, allowing flexibility in retrieving the correct data based on the current state: - Position: \( x(t) \) - Velocity: \( \.x(t) = dx/dt \) - Constraint Jacobian Matrix (Jacobian): \( J(x) = \frac{\partial C}{\partial x} \), where \(C\) is the constraint function. - Lambda (Constraint Force): \(\.lambda\) #### Setup Methods (`setX()`, `setV()`, etc.) - These methods set IDs of vectors and matrices used in constraint computations, ensuring that all necessary data structures are correctly configured before performing simulations: - Setting Position: \( x = X_{id} \) - Setting Velocity: \( \.x = V_{id} \) - Setting Jacobian Matrix: \( J = J_{id} \) #### Thread Safety and Default Instance (`defaultInstance()`, `setExecParams()`) - The default instance is thread-local, ensuring that each thread has its own isolated instance of the parameters. This is critical for multi-threaded simulations where concurrent execution must maintain correct state isolation. ### Example Usage: 1. Retrieve default parameters and set constraint order and smooth factor: ```cpp auto params = sofa::core::ConstraintParams::defaultInstance(); params->setOrder(sofa::core::ConstraintOrder::POS_AND_VEL); params->setSmoothFactor(0.5f); ``` 2. Retrieve state data for position and velocity using template methods: ```cpp auto positionData = params->readX(mechanicalState); auto velocityData = params->readV(mechanicalState); ``` 3. Apply constraints with these parameters to ensure correct simulation behavior. In summary, the `ConstraintParams` class provides a structured way to manage and apply constraints within SOFA simulations by setting up necessary data structures and ensuring smooth and physically accurate constraint resolution.
{
  "name": "ConstraintParams",
  "main": {
    "name": "ConstraintParams",
    "namespace": "sofa::core",
    "module": "Sofa.framework.Core",
    "include": "sofa/core/ConstraintParams.h",
    "doc": "Class gathering parameters use by constraint components methods, and transmitted by visitors\nread the velocity and position\nand where the",
    "inherits": [
      "ExecParams"
    ],
    "templates": [],
    "data_fields": [],
    "links": [],
    "methods": [
      {
        "name": "constOrder",
        "return_type": "ConstraintOrder",
        "params": [],
        "is_virtual": false,
        "is_pure_virtual": false,
        "is_static": false,
        "access": "public"
      },
      {
        "name": "setOrder",
        "return_type": "ConstraintParams &",
        "params": [
          {
            "name": "o",
            "type": "ConstraintOrder"
          }
        ],
        "is_virtual": false,
        "is_pure_virtual": false,
        "is_static": false,
        "access": "public"
      },
      {
        "name": "smoothFactor",
        "return_type": "SReal",
        "params": [],
        "is_virtual": false,
        "is_pure_virtual": false,
        "is_static": false,
        "access": "public"
      },
      {
        "name": "getName",
        "return_type": "int",
        "params": [],
        "is_virtual": false,
        "is_pure_virtual": false,
        "is_static": false,
        "access": "public"
      },
      {
        "name": "readX",
        "return_type": "const Data<typename S::VecCoord> *",
        "params": [
          {
            "name": "state",
            "type": "const S *"
          }
        ],
        "is_virtual": false,
        "is_pure_virtual": false,
        "is_static": false,
        "access": "public"
      },
      {
        "name": "readV",
        "return_type": "const Data<typename S::VecDeriv> *",
        "params": [
          {
            "name": "state",
            "type": "const S *"
          }
        ],
        "is_virtual": false,
        "is_pure_virtual": false,
        "is_static": false,
        "access": "public"
      },
      {
        "name": "readJ",
        "return_type": "const Data<typename S::MatrixDeriv> *",
        "params": [
          {
            "name": "state",
            "type": "const S *"
          }
        ],
        "is_virtual": false,
        "is_pure_virtual": false,
        "is_static": false,
        "access": "public"
      },
      {
        "name": "readLambda",
        "return_type": "const Data<typename S::VecDeriv> *",
        "params": [
          {
            "name": "state",
            "type": "S *"
          }
        ],
        "is_virtual": false,
        "is_pure_virtual": false,
        "is_static": false,
        "access": "public"
      },
      {
        "name": "readDx",
        "return_type": "const Data<typename S::VecDeriv> *",
        "params": [
          {
            "name": "state",
            "type": "S *"
          }
        ],
        "is_virtual": false,
        "is_pure_virtual": false,
        "is_static": false,
        "access": "public"
      },
      {
        "name": "setSmoothFactor",
        "return_type": "ConstraintParams &",
        "params": [
          {
            "name": "v",
            "type": "SReal"
          }
        ],
        "is_virtual": false,
        "is_pure_virtual": false,
        "is_static": false,
        "access": "public"
      },
      {
        "name": "x",
        "return_type": "const ConstMultiVecCoordId &",
        "params": [],
        "is_virtual": false,
        "is_pure_virtual": false,
        "is_static": false,
        "access": "public"
      },
      {
        "name": "v",
        "return_type": "const ConstMultiVecDerivId &",
        "params": [],
        "is_virtual": false,
        "is_pure_virtual": false,
        "is_static": false,
        "access": "public"
      },
      {
        "name": "j",
        "return_type": "const MultiMatrixDerivId &",
        "params": [],
        "is_virtual": false,
        "is_pure_virtual": false,
        "is_static": false,
        "access": "public"
      },
      {
        "name": "dx",
        "return_type": "const MultiVecDerivId &",
        "params": [],
        "is_virtual": false,
        "is_pure_virtual": false,
        "is_static": false,
        "access": "public"
      },
      {
        "name": "lambda",
        "return_type": "const MultiVecDerivId &",
        "params": [],
        "is_virtual": false,
        "is_pure_virtual": false,
        "is_static": false,
        "access": "public"
      },
      {
        "name": "setX",
        "return_type": "ConstraintParams &",
        "params": [
          {
            "name": "v",
            "type": "ConstVecCoordId"
          }
        ],
        "is_virtual": false,
        "is_pure_virtual": false,
        "is_static": false,
        "access": "public"
      },
      {
        "name": "setX",
        "return_type": "ConstraintParams &",
        "params": [
          {
            "name": "v",
            "type": "ConstMultiVecCoordId"
          }
        ],
        "is_virtual": false,
        "is_pure_virtual": false,
        "is_static": false,
        "access": "public"
      },
      {
        "name": "setX",
        "return_type": "ConstraintParams &",
        "params": [
          {
            "name": "g",
            "type": "const StateSet &"
          },
          {
            "name": "v",
            "type": "ConstVecCoordId"
          }
        ],
        "is_virtual": false,
        "is_pure_virtual": false,
        "is_static": false,
        "access": "public"
      },
      {
        "name": "setV",
        "return_type": "ConstraintParams &",
        "params": [
          {
            "name": "v",
            "type": "ConstVecDerivId"
          }
        ],
        "is_virtual": false,
        "is_pure_virtual": false,
        "is_static": false,
        "access": "public"
      },
      {
        "name": "setV",
        "return_type": "ConstraintParams &",
        "params": [
          {
            "name": "v",
            "type": "ConstMultiVecDerivId"
          }
        ],
        "is_virtual": false,
        "is_pure_virtual": false,
        "is_static": false,
        "access": "public"
      },
      {
        "name": "setV",
        "return_type": "ConstraintParams &",
        "params": [
          {
            "name": "g",
            "type": "const StateSet &"
          },
          {
            "name": "v",
            "type": "ConstVecDerivId"
          }
        ],
        "is_virtual": false,
        "is_pure_virtual": false,
        "is_static": false,
        "access": "public"
      },
      {
        "name": "setJ",
        "return_type": "ConstraintParams &",
        "params": [
          {
            "name": "j",
            "type": "MatrixDerivId"
          }
        ],
        "is_virtual": false,
        "is_pure_virtual": false,
        "is_static": false,
        "access": "public"
      },
      {
        "name": "setJ",
        "return_type": "ConstraintParams &",
        "params": [
          {
            "name": "j",
            "type": "MultiMatrixDerivId"
          }
        ],
        "is_virtual": false,
        "is_pure_virtual": false,
        "is_static": false,
        "access": "public"
      },
      {
        "name": "setJ",
        "return_type": "ConstraintParams &",
        "params": [
          {
            "name": "g",
            "type": "const StateSet &"
          },
          {
            "name": "j",
            "type": "MatrixDerivId"
          }
        ],
        "is_virtual": false,
        "is_pure_virtual": false,
        "is_static": false,
        "access": "public"
      },
      {
        "name": "setDx",
        "return_type": "ConstraintParams &",
        "params": [
          {
            "name": "dx",
            "type": "VecDerivId"
          }
        ],
        "is_virtual": false,
        "is_pure_virtual": false,
        "is_static": false,
        "access": "public"
      },
      {
        "name": "setDx",
        "return_type": "ConstraintParams &",
        "params": [
          {
            "name": "dx",
            "type": "MultiVecDerivId"
          }
        ],
        "is_virtual": false,
        "is_pure_virtual": false,
        "is_static": false,
        "access": "public"
      },
      {
        "name": "setDx",
        "return_type": "ConstraintParams &",
        "params": [
          {
            "name": "g",
            "type": "const StateSet &"
          },
          {
            "name": "dx",
            "type": "MultiVecDerivId"
          }
        ],
        "is_virtual": false,
        "is_pure_virtual": false,
        "is_static": false,
        "access": "public"
      },
      {
        "name": "setLambda",
        "return_type": "ConstraintParams &",
        "params": [
          {
            "name": "lambda",
            "type": "VecDerivId"
          }
        ],
        "is_virtual": false,
        "is_pure_virtual": false,
        "is_static": false,
        "access": "public"
      },
      {
        "name": "setLambda",
        "return_type": "ConstraintParams &",
        "params": [
          {
            "name": "lambda",
            "type": "MultiVecDerivId"
          }
        ],
        "is_virtual": false,
        "is_pure_virtual": false,
        "is_static": false,
        "access": "public"
      },
      {
        "name": "setLambda",
        "return_type": "ConstraintParams &",
        "params": [
          {
            "name": "g",
            "type": "const StateSet &"
          },
          {
            "name": "lambda",
            "type": "MultiVecDerivId"
          }
        ],
        "is_virtual": false,
        "is_pure_virtual": false,
        "is_static": false,
        "access": "public"
      },
      {
        "name": "defaultInstance",
        "return_type": "const ConstraintParams *",
        "params": [],
        "is_virtual": false,
        "is_pure_virtual": false,
        "is_static": true,
        "access": "public"
      },
      {
        "name": "setExecParams",
        "return_type": "ConstraintParams &",
        "params": [
          {
            "name": "params",
            "type": "const core::ExecParams *"
          }
        ],
        "is_virtual": false,
        "is_pure_virtual": false,
        "is_static": false,
        "access": "public"
      }
    ]
  },
  "desc": {
    "description": "The `ConstraintParams` class in the SOFA (Simulation Open-Framework Architecture) framework is designed to gather and manage parameters used by constraint components during mechanical computations. It extends the `sofa::core::ExecParams` class, inheriting its execution properties and adding specific attributes for handling constraints.\n\n### Key Features:\n\n- **Constraint Order Handling**: The class allows specifying the order of the constraints using the `setOrder()` method, which can be read back using `constOrder()`. This is useful in mechanical simulations where different levels of accuracy or types of constraints may need to be applied based on specific simulation requirements.\n\n- **Smooth Contribution Factor**: A smooth factor can be set and retrieved via `setSmoothFactor()` and `smoothFactor()`, which helps in achieving a smoother resolution of constraints, particularly beneficial for simulating soft bodies or deformable objects.\n\n- **Accessors to State Data**: Template methods are provided (`readX()`, `readV()`, `readJ()`, `readLambda()`, `readDx()`) that allow reading the position, velocity, constraint jacobian matrix, lambda (constraint force) and corrective motion vectors from a given state container. These accessors ensure that the correct data is retrieved based on the current state.\n\n- **Setup Methods**: Various methods (`setX()`, `setV()`, `setJ()`, `setDx()`, `setLambda()`) are provided for setting IDs of different vectors and matrices used in constraint computations. These methods facilitate the setup process by returning a reference to the current instance, allowing method chaining.\n\n- **Thread Safety**: The default instance of `ConstraintParams` is thread-local (`thread_local ConstraintParams threadParams;`). This ensures that each thread has its own isolated instance of the parameters, which is crucial for maintaining correct state during concurrent execution in multi-threaded simulations.\n\n### Usage Context:\n\nThe `ConstraintParams` class plays a central role in managing how constraints are applied and resolved within SOFA's simulation pipeline. It allows constraint resolution algorithms to operate with the necessary data and configuration, ensuring that mechanical systems behave as expected under various physical conditions. The methods provided by this class help in setting up the initial conditions for constraint computations and reading back the results after they have been processed.\n\n### Example Usage:\n```cpp\nauto params = sofa::core::ConstraintParams::defaultInstance();\nparams->setOrder(sofa::core::ConstraintOrder::POS_AND_VEL);\nparams->setSmoothFactor(0.5f);\nauto positionData = params->readX(mechanicalState);\nauto velocityData = params->readV(mechanicalState);\n// Apply constraints using these parameters...\n```",
    "classDiagram": "Class Diagram for ConstraintParams\n\nsofa::core::ExecParams <|-- sofa::core::ConstraintParams: extends\n\nsofa::core::ConstraintParams : +constOrder(): ConstraintOrder\nsofa::core::ConstraintParams : +setOrder(ConstraintOrder): ConstraintParams&\nsofa::core::ConstraintParams : +smoothFactor(): SReal\nsofa::core::ConstraintParams : +readX<S>(S*): const Data<typename S::VecCoord>*\nsofa::core::ConstraintParams : +readV<S>(S*): const Data<typename S::VecDeriv>*\nsofa::core::ConstraintParams : +readJ<S>(S*): const Data<typename S::MatrixDeriv>*\nsofa::core::ConstraintParams : +readLambda<S>(S*): const Data<typename S::VecDeriv>*\nsofa::core::ConstraintParams : +readDx<S>(S*): const Data<typename S::VecDeriv>*\nsofa::core::ConstraintParams : +setSmoothFactor(SReal): ConstraintParams&\nsofa::core::ConstraintParams : +x(): ConstMultiVecCoordId\nsofa::core::ConstraintParams : +v(): ConstMultiVecDerivId\nsofa::core::ConstraintParams : +j(): MultiMatrixDerivId\nsofa::core::ConstraintParams : +dx(): MultiVecDerivId\nsofa::core::ConstraintParams : +lambda(): MultiVecDerivId\nsofa::core::ConstraintParams : +setX(ConstVecCoordId): ConstraintParams&\nsofa::core::ConstraintParams : +setV(ConstVecDerivId): ConstraintParams&\nsofa::core::ConstraintParams : +setJ(MatrixDerivId): ConstraintParams&\nsofa::core::ConstraintParams : +setDx(VecDerivId): ConstraintParams&\nsofa::core::ConstraintParams : +setLambda(VecDerivId): ConstraintParams&\nsofa::core::ConstraintParams : +defaultInstance(): const ConstraintParams*\n",
    "purpose": [
      "The primary purpose of the `ConstraintParams` class is to manage and provide parameters that are necessary for resolving constraints in mechanical simulations. It ensures that constraint resolution algorithms have access to relevant data, such as positions, velocities, and forces, and can configure how these constraints should be applied (e.g., with smooth contribution factors).",
      "By providing a centralized way of accessing and setting up the required vectors and matrices, `ConstraintParams` simplifies the implementation of complex mechanical models in SOFA.",
      "The class also supports multi-threaded simulations by ensuring thread-local storage for its instances, which prevents data races and maintains consistency across threads."
    ],
    "componentType": "Parameter Management Class"
  },
  "maths": {
    "maths": "The `ConstraintParams` class in the SOFA framework is designed to manage parameters used by constraint components during mechanical simulations. Constraints are essential for enforcing physical laws or boundary conditions on the simulated system, ensuring that it behaves according to expected real-world behavior.\n\n### Mathematical and Physical Description:\n\n#### Constraint Order (`constOrder()`)\n- The order of constraints can be set using `setOrder(ConstraintOrder)`, which determines how constraints are applied. For example, `ConstraintOrder::POS_AND_VEL` indicates that both position and velocity constraints should be considered simultaneously.\n- Mathematically, this is represented as a system of equations where the constraint matrix defines linear or non-linear relationships between variables:\n  \\[ C(x, \\.x) = 0 \\]\n  Here, \\( x \\) represents positions, and \\( \\.x \\) represents velocities.\n\n#### Smooth Contribution Factor (`smoothFactor()`)\n- The smooth contribution factor can be set using `setSmoothFactor(SReal)` to control the resolution of constraints. This is particularly useful in simulations involving soft bodies or deformable objects where maintaining a smooth interaction between elements is crucial.\n- Mathematically, this can be represented as:\n  \\[ F_{\\text{smooth}} = \\.lambda \\cdot f(x) \\]\n  Where \\(\\.lambda\\) is the smooth factor and \\(f(x)\\) represents some function of positions or displacements ensuring smoothness.\n\n#### Accessors to State Data (`readX()`, `readV()` etc.)\n- These methods allow reading position, velocity, constraint Jacobian matrix, lambda (constraint force), and corrective motion vectors from a given state container. The access is template-based, allowing flexibility in retrieving the correct data based on the current state:\n  - Position: \\( x(t) \\)\n  - Velocity: \\( \\.x(t) = dx/dt \\)\n  - Constraint Jacobian Matrix (Jacobian): \\( J(x) = \\frac{\\partial C}{\\partial x} \\), where \\(C\\) is the constraint function.\n  - Lambda (Constraint Force): \\(\\.lambda\\)\n\n#### Setup Methods (`setX()`, `setV()`, etc.)\n- These methods set IDs of vectors and matrices used in constraint computations, ensuring that all necessary data structures are correctly configured before performing simulations:\n  - Setting Position: \\( x = X_{id} \\)\n  - Setting Velocity: \\( \\.x = V_{id} \\)\n  - Setting Jacobian Matrix: \\( J = J_{id} \\)\n\n#### Thread Safety and Default Instance (`defaultInstance()`, `setExecParams()`)\n- The default instance is thread-local, ensuring that each thread has its own isolated instance of the parameters. This is critical for multi-threaded simulations where concurrent execution must maintain correct state isolation.\n\n### Example Usage:\n1. Retrieve default parameters and set constraint order and smooth factor:\n   ```cpp\n   auto params = sofa::core::ConstraintParams::defaultInstance();\n   params->setOrder(sofa::core::ConstraintOrder::POS_AND_VEL);\n   params->setSmoothFactor(0.5f);\n   ```\n2. Retrieve state data for position and velocity using template methods:\n   ```cpp\n   auto positionData = params->readX(mechanicalState);\n   auto velocityData = params->readV(mechanicalState);\n   ```\n3. Apply constraints with these parameters to ensure correct simulation behavior.\n\nIn summary, the `ConstraintParams` class provides a structured way to manage and apply constraints within SOFA simulations by setting up necessary data structures and ensuring smooth and physically accurate constraint resolution."
  },
  "summary": {
    "abstract": "`ConstraintParams` manages parameters used by constraint components during mechanical simulations, providing methods to set and retrieve constraint orders, smooth factors, and state data.",
    "sheet": "# ConstraintParams\n\n## Overview\nThe `ConstraintParams` class in SOFA is designed to manage parameters used by constraint components. It extends the `sofa::core::ExecParams` class and provides methods for setting and retrieving constraint-related data such as order, smooth factors, and state information.\n\n## Parameters and Data\n- **constOrder()**: Returns the current constraint order (`ConstraintOrder`).\n- **setOrder(ConstraintOrder o)**: Sets the constraint order to `o`.\n- **smoothFactor()**: Retrieves the smooth factor value (`SReal`).\n- **setSmoothFactor(SReal v)**: Sets the smooth factor to `v`.\n- **readX(const S *state)**, **readV(const S *state)**, **readJ(const S *state)**, **readLambda(S *state)**, **readDx(S *state)**: Template methods for reading position, velocity, Jacobian matrix, lambda (constraint force), and corrective motion vectors from a given state container.\n- **setX(ConstVecCoordId v)**, **setV(ConstVecDerivId v)**, **setJ(MatrixDerivId j)**, **setDx(VecDerivId dx)**, **setLambda(VecDerivId lambda)**: Methods for setting IDs of vectors and matrices used in constraint computations.\n- **defaultInstance()**: Returns the default instance of `ConstraintParams`."
  }
}