MechanicalVSizeVisitor
Get vector size */
The `MechanicalVSizeVisitor` traverses mechanical states within a simulation scene to accumulate vector sizes, providing essential data aggregation functionality.
- module
- Sofa.framework.Simulation.Core
- namespace
- sofa::simulation::mechanicalvisitor
- include
- sofa/simulation/mechanicalvisitor/MechanicalVSizeVisitor.h
- inherits
-
- BaseMechanicalVisitor
- description
The MechanicalVSizeVisitor is a specialized visitor in the SOFA framework designed to traverse and accumulate vector sizes from mechanical states within a simulation scene. It does not directly implement any governing equations, constitutive laws, or kinematic models; rather, its role is to gather information about the size (number of elements) of specific vectors associated with mechanical states.
Role in the Global FEM Pipeline:
-
Assembly Phase: Although
MechanicalVSizeVisitordoes not directly contribute to assembling mass matrix $M$, stiffness matrix $K$, internal force $oldsymbol{f}_{int}$, or residual $oldsymbol{R}$, it can be used as part of a larger pipeline where such data is gathered and processed. -
Time Integration: It is not involved in time integration schemes like implicit Euler or Newmark-type methods. Its role is purely informational.
-
Nonlinear Solution and Linear Solve: The visitor does not contribute to nonlinear solution techniques (e.g., Newton–Raphson) or linear solvers such as Krylov subspace methods or direct sparse factorizations.
Numerical Methods:
The MechanicalVSizeVisitor iterates over nodes and mechanical states, updating its internal state based on the vectors it encounters. It accumulates sizes of specified vectors (denoted by v) into a result pointer (result). The method fwdMechanicalState and fwdMappedMechanicalState are called during traversal to gather these sizes.
Mathematical Description:
The visitor is instantiated with an execution parameters object (ExecParams), a pointer to accumulate results (size_t* resultPtr), and a specific vector identifier (sofa::core::ConstMultiVecId vecid). During the traversal, for each mechanical state mm, it performs the following steps:
- Identify Vector: It identifies a vector with ID
v.getId(mm). -
Check Validity: If the identified vector is not null (
$$ *result += mm\text{->}vSize(\text{this}\text{->}params, id) $$!id.isNull()), it proceeds to get its size usingmm->vSize(this->params, id)and updates the result pointer: -
Continue Traversal: It returns
RESULT_CONTINUEto indicate that traversal should continue to other mechanical states.
Interaction with the Variational / Lagrangian Mechanics Framework:
The MechanicalVSizeVisitor does not directly interact with variational or Lagrangian mechanics formulations. Instead, it provides a utility function for gathering vector sizes which can be used in various parts of the simulation pipeline where such information is required.
Conclusion:
In summary, while MechanicalVSizeVisitor does not implement any governing equations, constitutive laws, or numerical methods specific to FEM, it serves as an important utility component for gathering vector sizes across a simulation scene. This can be useful in contexts where data aggregation is necessary.
Methods
Result
fwdMechanicalState
(simulation::Node * , sofa::core::behavior::BaseMechanicalState * mm)
virtual
Result
fwdMappedMechanicalState
(simulation::Node * , sofa::core::behavior::BaseMechanicalState * mm)
virtual
int
getInfos
()
bool
isThreadSafe
()
virtual
{
"name": "MechanicalVSizeVisitor",
"namespace": "sofa::simulation::mechanicalvisitor",
"module": "Sofa.framework.Simulation.Core",
"include": "sofa/simulation/mechanicalvisitor/MechanicalVSizeVisitor.h",
"doc": "Get vector size */",
"inherits": [
"BaseMechanicalVisitor"
],
"templates": [],
"data_fields": [],
"links": [],
"methods": [
{
"name": "fwdMechanicalState",
"return_type": "Result",
"params": [
{
"name": "",
"type": "simulation::Node *"
},
{
"name": "mm",
"type": "sofa::core::behavior::BaseMechanicalState *"
}
],
"is_virtual": true,
"is_pure_virtual": false,
"is_static": false,
"access": "public"
},
{
"name": "fwdMappedMechanicalState",
"return_type": "Result",
"params": [
{
"name": "",
"type": "simulation::Node *"
},
{
"name": "mm",
"type": "sofa::core::behavior::BaseMechanicalState *"
}
],
"is_virtual": true,
"is_pure_virtual": false,
"is_static": false,
"access": "public"
},
{
"name": "getInfos",
"return_type": "int",
"params": [],
"is_virtual": false,
"is_pure_virtual": false,
"is_static": false,
"access": "public"
},
{
"name": "isThreadSafe",
"return_type": "bool",
"params": [],
"is_virtual": true,
"is_pure_virtual": false,
"is_static": false,
"access": "public"
}
],
"description": "The `MechanicalVSizeVisitor` is a specialized visitor in the SOFA framework, designed to traverse and accumulate vector sizes from mechanical states within a simulation scene. It inherits from `BaseMechanicalVisitor`, indicating its role as part of the mechanical traversal mechanism used for various operations on nodes and mechanical states.\n\n**Role and Purpose:**\nThe primary purpose of `MechanicalVSizeVisitor` is to gather information about the size (number of elements) of specific vectors associated with mechanical states. This is useful for simulations that need to process or aggregate data across different parts of a mechanical system, such as computing total vector sizes.\n\n**Interactions with Other Components:**\nThe `MechanicalVSizeVisitor` interacts primarily through its virtual methods `fwdMechanicalState` and `fwdMappedMechanicalState`. These methods are called during the traversal process by the simulation core to visit each mechanical state. The visitor updates a result pointer (`result`) with the size of vectors identified by a given vector ID (`v`).\n\n**Practical Usage Guidance:**\nThe visitor is instantiated with an `ExecParams` object, a result pointer for storing accumulated sizes, and a specific vector ID (`ConstMultiVecId`). It iterates over nodes and mechanical states, updating its internal state based on the vectors it encounters. The method `getInfos` provides debugging information about which vector size was being processed.\n\n**Data Fields:**\nThe visitor contains two primary data fields: `v`, a `sofa::core::ConstMultiVecId`, which specifies the vector to gather sizes for, and `result`, a pointer to a `size_t` where accumulated results are stored.",
"maths": "The `MechanicalVSizeVisitor` is a specialized visitor in the SOFA framework designed to traverse and accumulate vector sizes from mechanical states within a simulation scene. It does not directly implement any governing equations, constitutive laws, or kinematic models; rather, its role is to gather information about the size (number of elements) of specific vectors associated with mechanical states.\n\n### Role in the Global FEM Pipeline:\n\n- **Assembly Phase**: Although `MechanicalVSizeVisitor` does not directly contribute to assembling mass matrix $M$, stiffness matrix $K$, internal force $\boldsymbol{f}_{int}$, or residual $\boldsymbol{R}$, it can be used as part of a larger pipeline where such data is gathered and processed.\n\n- **Time Integration**: It is not involved in time integration schemes like implicit Euler or Newmark-type methods. Its role is purely informational.\n\n- **Nonlinear Solution and Linear Solve**: The visitor does not contribute to nonlinear solution techniques (e.g., Newton–Raphson) or linear solvers such as Krylov subspace methods or direct sparse factorizations.\n\n### Numerical Methods:\n\nThe `MechanicalVSizeVisitor` iterates over nodes and mechanical states, updating its internal state based on the vectors it encounters. It accumulates sizes of specified vectors (denoted by `v`) into a result pointer (`result`). The method `fwdMechanicalState` and `fwdMappedMechanicalState` are called during traversal to gather these sizes.\n\n### Mathematical Description:\n\nThe visitor is instantiated with an execution parameters object (`ExecParams`), a pointer to accumulate results (`size_t* resultPtr`), and a specific vector identifier (`sofa::core::ConstMultiVecId vecid`). During the traversal, for each mechanical state `mm`, it performs the following steps:\n\n1. **Identify Vector**: It identifies a vector with ID `v.getId(mm)`.\n2. **Check Validity**: If the identified vector is not null (`!id.isNull()`), it proceeds to get its size using `mm->vSize(this->params, id)` and updates the result pointer:\n \n \n \\[ *result += mm\\text{->}vSize(\\text{this}\\text{->}params, id) \\]\n\n3. **Continue Traversal**: It returns `RESULT_CONTINUE` to indicate that traversal should continue to other mechanical states.\n\n### Interaction with the Variational / Lagrangian Mechanics Framework:\n\nThe `MechanicalVSizeVisitor` does not directly interact with variational or Lagrangian mechanics formulations. Instead, it provides a utility function for gathering vector sizes which can be used in various parts of the simulation pipeline where such information is required.\n\n### Conclusion:\n\nIn summary, while `MechanicalVSizeVisitor` does not implement any governing equations, constitutive laws, or numerical methods specific to FEM, it serves as an important utility component for gathering vector sizes across a simulation scene. This can be useful in contexts where data aggregation is necessary.",
"abstract": "The `MechanicalVSizeVisitor` traverses mechanical states within a simulation scene to accumulate vector sizes, providing essential data aggregation functionality.",
"sheet": "# MechanicalVSizeVisitor\n\n## Overview\n\nThe `MechanicalVSizeVisitor` is a specialized visitor component in the SOFA framework that traverses and accumulates vector sizes from mechanical states within a simulation scene. It inherits from `BaseMechanicalVisitor`, indicating its role as part of the mechanical traversal mechanism used for various operations on nodes and mechanical states.\n\n## Parameters and Data\n\nThe visitor contains two primary data fields:\n- **`v`:** A `sofa::core::ConstMultiVecId` that specifies the vector to gather sizes for.\n- **`result`:** A pointer to a `size_t` where accumulated results are stored.\n\n## Dependencies and Connections\n\nThe `MechanicalVSizeVisitor` interacts primarily through its virtual methods `fwdMechanicalState` and `fwdMappedMechanicalState`. These methods are called during the traversal process by the simulation core to visit each mechanical state. The visitor updates a result pointer (`result`) with the size of vectors identified by a given vector ID (`v`).\n\n## Practical Notes\n\nThe visitor is instantiated with an `ExecParams` object, a result pointer for storing accumulated sizes, and a specific vector ID (`ConstMultiVecId`). It iterates over nodes and mechanical states, updating its internal state based on the vectors it encounters. The method `getInfos` provides debugging information about which vector size was being processed."
}