Back

MechanicalGetMomentumVisitor

sofa::simulation::mechanicalvisitor::MechanicalGetMomentumVisitor
MechanicalVisitor
Doc (from source)

Compute the linear and angular momenta @author Matthieu Nesme, 2015

Abstract (AI generated)

The `MechanicalGetMomentumVisitor` computes the total linear and angular momenta of mechanical systems by traversing nodes in the scene graph and accumulating contributions from mass elements.

Metadata
module
Sofa.framework.Simulation.Core
namespace
sofa::simulation::mechanicalvisitor
include
sofa/simulation/mechanicalvisitor/MechanicalGetMomentumVisitor.h
inherits
  • MechanicalVisitor
description

The MechanicalGetMomentumVisitor is a component in the SOFA framework designed to compute the linear and angular momenta for mechanical systems. This visitor facilitates the traversal of nodes in the scene graph, accumulating contributions from mass elements at each node.

Governing Equations:

The linear momentum \$$p\$$ and angular momentum \$$L\$$ are defined as follows:
- Linear Momentum: \$$ p = \sum_i m_i v_i \$$, where \$m_i\$ is the mass of each particle, and \$v_i\$ is its velocity.

  • Angular Momentum: \$$ L = \sum_i r_i \times (m_i v_i) \$$, where \$r_i\$ is the position vector relative to a reference point, \$m_i\$ is the mass of each particle, and \$v_i\$ is its velocity.

Constitutive Laws:

The component does not define any constitutive laws but relies on the masses defined in the mechanical system. The linear momentum \$$p\$$ and angular momentum \$$L\$$ are computed from these mass contributions using the following relationships:
- For each mass element, the visitor retrieves its contribution to the total linear and angular momenta.

Role in the Global FEM Pipeline:

The MechanicalGetMomentumVisitor is used during the execution phase of the simulation. It iterates over nodes containing mass elements, accumulating their contributions to the total linear and angular momentum. This process involves the following steps:
1. Traversal: The visitor traverses the scene graph using its inherited methods from sofa::simulation::MechanicalVisitor.
2. Accumulation: During traversal, it processes each mass element by calling fwdMass, which accumulates contributions to the total momenta stored in \$m_momenta\$.
3. Initialization and Resetting: Before starting the traversal, the execute method initializes or resets the momenta vector.
4. Final Computation: The final accumulated values are returned via the getMomentum method as a 6-dimensional vector (type::Vec6) representing both linear and angular momentum components.

Numerical Methods:

The component does not involve any specific numerical discretization methods but relies on the existing structure of mass elements in the scene graph. It accumulates contributions from each node, which can be seen as a form of summation over discrete points (masses) within the system.

Integration into Variational / Lagrangian Mechanics Framework:

The visitor operates at a higher level by aggregating momentum contributions rather than directly solving variational problems or constitutive equations. It provides essential diagnostic information about the overall dynamics of the mechanical system, which can be used for further analysis, such as energy conservation checks or dynamic stability assessments.

Summary:

The MechanicalGetMomentumVisitor computes and aggregates linear and angular momenta from mass elements in a SOFA simulation. This component plays a crucial role in diagnostics and validation by providing total momentum information.

Methods
const type::Vec6 & getMomentum ()
Result fwdMass (simulation::Node * , core::behavior::BaseMass * mass) virtual
void execute (sofa::core::objectmodel::BaseContext * c, bool precomputedTraversalOrder) virtual
{
  "name": "MechanicalGetMomentumVisitor",
  "namespace": "sofa::simulation::mechanicalvisitor",
  "module": "Sofa.framework.Simulation.Core",
  "include": "sofa/simulation/mechanicalvisitor/MechanicalGetMomentumVisitor.h",
  "doc": "Compute the linear and angular momenta\n@author Matthieu Nesme, 2015",
  "inherits": [
    "MechanicalVisitor"
  ],
  "templates": [],
  "data_fields": [],
  "links": [],
  "methods": [
    {
      "name": "getMomentum",
      "return_type": "const type::Vec6 &",
      "params": [],
      "is_virtual": false,
      "is_pure_virtual": false,
      "is_static": false,
      "access": "public"
    },
    {
      "name": "fwdMass",
      "return_type": "Result",
      "params": [
        {
          "name": "",
          "type": "simulation::Node *"
        },
        {
          "name": "mass",
          "type": "core::behavior::BaseMass *"
        }
      ],
      "is_virtual": true,
      "is_pure_virtual": false,
      "is_static": false,
      "access": "public"
    },
    {
      "name": "execute",
      "return_type": "void",
      "params": [
        {
          "name": "c",
          "type": "sofa::core::objectmodel::BaseContext *"
        },
        {
          "name": "precomputedTraversalOrder",
          "type": "bool"
        }
      ],
      "is_virtual": true,
      "is_pure_virtual": false,
      "is_static": false,
      "access": "public"
    }
  ],
  "description": "The `MechanicalGetMomentumVisitor` is a SOFA component designed to compute the linear and angular momenta for mechanical systems within the simulation framework. This visitor inherits from `sofa::simulation::MechanicalVisitor`, which facilitates traversing nodes in the scene graph to process mechanical data.\n\n### Role and Purpose:\nThe primary role of this component is to accumulate and provide the total linear and angular momentum of a given mechanical system. It processes each node containing mass elements, summing up their individual momenta contributions. This information can be critical for understanding the dynamics of simulations involving complex interactions and forces.\n\n### Interactions with Other Components:\nThe `MechanicalGetMomentumVisitor` interacts primarily through the SOFA API via its inherited methods from `MechanicalVisitor`. It uses the following public methods:\n- `getMomentum()`: Returns a constant reference to the computed momenta as a 6-dimensional vector (`type::Vec6`).\n- `fwdMass(simulation::Node*, core::behavior::BaseMass*)`: Processes mass elements, accumulating their contribution to the total momentum.\n- `execute(sofa::core::objectmodel::BaseContext*, bool)`: Initiates the traversal and computation process.\n\n### Practical Usage:\nThe component is typically instantiated with a set of mechanical parameters (`const core::MechanicalParams*`) and then used by calling its methods. The momenta are computed during the execution phase, which involves iterating over nodes to aggregate mass-related data. This visitor can be integrated into larger simulation workflows where momentum computation is required for further analysis or visualization.",
  "maths": "The `MechanicalGetMomentumVisitor` is a component in the SOFA framework designed to compute the linear and angular momenta for mechanical systems. This visitor facilitates the traversal of nodes in the scene graph, accumulating contributions from mass elements at each node.\n\n### Governing Equations:\nThe linear momentum \\\\[p\\\\] and angular momentum \\\\[L\\\\] are defined as follows:\n- **Linear Momentum**: \\\\[ p = \\sum_i m_i v_i \\\\], where \\\\(m_i\\\\) is the mass of each particle, and \\\\(v_i\\\\) is its velocity.\n\n- **Angular Momentum**: \\\\[ L = \\sum_i r_i \\times (m_i v_i) \\\\], where \\\\(r_i\\\\) is the position vector relative to a reference point, \\\\(m_i\\\\) is the mass of each particle, and \\\\(v_i\\\\) is its velocity.\n\n### Constitutive Laws:\nThe component does not define any constitutive laws but relies on the masses defined in the mechanical system. The linear momentum \\\\[p\\\\] and angular momentum \\\\[L\\\\] are computed from these mass contributions using the following relationships:\n- For each mass element, the visitor retrieves its contribution to the total linear and angular momenta.\n\n### Role in the Global FEM Pipeline:\nThe `MechanicalGetMomentumVisitor` is used during the execution phase of the simulation. It iterates over nodes containing mass elements, accumulating their contributions to the total linear and angular momentum. This process involves the following steps:\n1. **Traversal**: The visitor traverses the scene graph using its inherited methods from `sofa::simulation::MechanicalVisitor`.\n2. **Accumulation**: During traversal, it processes each mass element by calling `fwdMass`, which accumulates contributions to the total momenta stored in \\\\(m_momenta\\\\).\n3. **Initialization and Resetting**: Before starting the traversal, the `execute` method initializes or resets the momenta vector.\n4. **Final Computation**: The final accumulated values are returned via the `getMomentum` method as a 6-dimensional vector (`type::Vec6`) representing both linear and angular momentum components.\n\n### Numerical Methods:\nThe component does not involve any specific numerical discretization methods but relies on the existing structure of mass elements in the scene graph. It accumulates contributions from each node, which can be seen as a form of summation over discrete points (masses) within the system.\n\n### Integration into Variational / Lagrangian Mechanics Framework:\nThe visitor operates at a higher level by aggregating momentum contributions rather than directly solving variational problems or constitutive equations. It provides essential diagnostic information about the overall dynamics of the mechanical system, which can be used for further analysis, such as energy conservation checks or dynamic stability assessments.\n\n### Summary:\nThe `MechanicalGetMomentumVisitor` computes and aggregates linear and angular momenta from mass elements in a SOFA simulation. This component plays a crucial role in diagnostics and validation by providing total momentum information.",
  "abstract": "The `MechanicalGetMomentumVisitor` computes the total linear and angular momenta of mechanical systems by traversing nodes in the scene graph and accumulating contributions from mass elements.",
  "sheet": "\n# MechanicalGetMomentumVisitor\n\n## Overview\nThe `MechanicalGetMomentumVisitor` is a component within the SOFA framework designed to compute the linear and angular momenta for mechanical systems. It inherits from `sofa::simulation::MechanicalVisitor`, enabling it to traverse nodes in the scene graph and process mass elements, accumulating their contributions to the total momenta.\n\n## Mathematical Model\nThe linear momentum \\( p \\) and angular momentum \\( L \\) are defined as follows:\n- **Linear Momentum**: \\\\[ p = \\sum_i m_i v_i \\\\], where \\(m_i\\) is the mass of each particle, and \\(v_i\\) is its velocity.\n\n- **Angular Momentum**: \\\\[ L = \\sum_i r_i \\times (m_i v_i) \\\\], where \\(r_i\\) is the position vector relative to a reference point, \\(m_i\\) is the mass of each particle, and \\(v_i\\) is its velocity.\n\nThe visitor processes each node containing mass elements, summing up their individual contributions to compute the total linear and angular momenta."
}