Back

MechanicalVOpVisitor

sofa::simulation::mechanicalvisitor::MechanicalVOpVisitor
BaseMechanicalVisitor
Doc (from source)

Perform a vector operation v=a+b*f

Abstract (AI generated)

The `MechanicalVOpVisitor` performs vector operations on mechanical states in the form of v = a + b * f, where a and b are vectors and f is a scalar factor, facilitating efficient and flexible computations within the SOFA simulation pipeline.

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

The MechanicalVOpVisitor is a visitor in the SOFA framework that performs vector operations on mechanical states within the simulation pipeline. Specifically, it computes the operation:

egin{equation} v = a + b \cdot f ag{1} \end{equation}

where:

  • v: vector result to be computed,
  • a: first input vector (optional),
  • b: second input vector (optional), and
  • f: scalar factor.

The operation can be interpreted as a linear combination of vectors, where the output v is a sum of two terms:

  • a scaled version of b by the factor f, if b is provided, and/or
  • an additive vector term a, if provided.

The component interacts with other components through methods like stopAtMechanicalMapping, which determines whether it should traverse mechanical mappings based on the state of flags such as mapped and only_mapped. This visitor also includes methods to set these mapping behavior flags:

  • setMapped(bool m): controls traversal through all mechanical mappings.
  • setOnlyMapped(bool m): restricts operations to only mapped states if true, otherwise operates on both mapped and unmapped states.

The visitor interacts with BaseMechanicalState objects through methods such as:

  • fwdMechanicalState(VisitorContext* ctx, sofa::core::behavior::BaseMechanicalState* mm): performs the vector operation for non-mapped states.
  • fwdMappedMechanicalState(VisitorContext* ctx, sofa::core::behavior::BaseMechanicalState* mm): performs the vector operation for mapped states based on the state of the mapped and only_mapped flags.

This visitor is designed to be thread-safe, enabling parallel processing within simulations. It fits into the broader FEM pipeline by facilitating operations such as:

  • Assembly: combining vectors in the assembly phase of the global mass and force matrices.
  • Time Integration: updating state vectors during time integration steps.
  • Nonlinear Resolution: performing vector operations within nonlinear solve steps, such as computing residuals or corrections.
  • Linear Solve: contributing to linear system solution by forming right-hand side terms in matrix-vector products.

The MechanicalVOpVisitor thus plays a crucial role in the computational mechanics workflow, enabling efficient and flexible vector operations on mechanical states within the simulation pipeline.

Methods
bool stopAtMechanicalMapping (simulation::Node * , sofa::core::BaseMapping * map) virtual
MechanicalVOpVisitor & setMapped (bool m)
MechanicalVOpVisitor & setOnlyMapped (bool m)
Result fwdMechanicalState (VisitorContext * ctx, sofa::core::behavior::BaseMechanicalState * mm) virtual
Result fwdMappedMechanicalState (VisitorContext * ctx, sofa::core::behavior::BaseMechanicalState * mm) virtual
int getInfos ()
bool isThreadSafe () virtual
{
  "name": "MechanicalVOpVisitor",
  "namespace": "sofa::simulation::mechanicalvisitor",
  "module": "Sofa.framework.Simulation.Core",
  "include": "sofa/simulation/mechanicalvisitor/MechanicalVOpVisitor.h",
  "doc": "Perform a vector operation v=a+b*f",
  "inherits": [
    "BaseMechanicalVisitor"
  ],
  "templates": [],
  "data_fields": [],
  "links": [],
  "methods": [
    {
      "name": "stopAtMechanicalMapping",
      "return_type": "bool",
      "params": [
        {
          "name": "",
          "type": "simulation::Node *"
        },
        {
          "name": "map",
          "type": "sofa::core::BaseMapping *"
        }
      ],
      "is_virtual": true,
      "is_pure_virtual": false,
      "is_static": false,
      "access": "public"
    },
    {
      "name": "setMapped",
      "return_type": "MechanicalVOpVisitor &",
      "params": [
        {
          "name": "m",
          "type": "bool"
        }
      ],
      "is_virtual": false,
      "is_pure_virtual": false,
      "is_static": false,
      "access": "public"
    },
    {
      "name": "setOnlyMapped",
      "return_type": "MechanicalVOpVisitor &",
      "params": [
        {
          "name": "m",
          "type": "bool"
        }
      ],
      "is_virtual": false,
      "is_pure_virtual": false,
      "is_static": false,
      "access": "public"
    },
    {
      "name": "fwdMechanicalState",
      "return_type": "Result",
      "params": [
        {
          "name": "ctx",
          "type": "VisitorContext *"
        },
        {
          "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": "ctx",
          "type": "VisitorContext *"
        },
        {
          "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 `MechanicalVOpVisitor` is part of the SOFA framework and inherits from `BaseMechanicalVisitor`. It performs vector operations on mechanical states within the simulation pipeline, specifically computing the operation `v = a + b * f`, where `a` and `b` are vectors and `f` is a scalar factor. This visitor interacts with other components through methods such as `stopAtMechanicalMapping`, which determines if it should stop at a mechanical mapping node based on whether `mapped` or `only_mapped` flags are set. It also has methods like `setMapped` and `setOnlyMapped` to control the behavior of traversing mappings. The component interacts with `BaseMechanicalState` through methods like `fwdMechanicalState` and `fwdMappedMechanicalState`, performing vector operations on mechanical states while respecting mapping flags. This visitor is designed for thread-safe execution, making it suitable for parallel processing within simulations.",
  "maths": "<p>The <code>MechanicalVOpVisitor</code> is a visitor in the SOFA framework that performs vector operations on mechanical states within the simulation pipeline. Specifically, it computes the operation:</p>\n\n\begin{equation}\n    v = a + b \\cdot f\n\tag{1}\n\\end{equation}\n\n<p>where:</p>\n<ul>\n<li><span class=\"math inline\">v</span>: vector result to be computed,</li>\n<li><span class=\"math inline\">a</span>: first input vector (optional),</li>\n<li><span class=\"math inline\">b</span>: second input vector (optional), and</li>\n<li><span class=\"math inline\">f</span>: scalar factor.</li>\n</ul>\n\n<p>The operation can be interpreted as a linear combination of vectors, where the output <span class=\"math inline\">v</span> is a sum of two terms:</p>\n<ul>\n<li>a scaled version of <span class=\"math inline\">b</span> by the factor <span class=\"math inline\">f</span>, if <span class=\"math inline\">b</span> is provided, and/or</li>\n<li>an additive vector term <span class=\"math inline\">a</span>, if provided.</li>\n</ul>\n\n<p>The component interacts with other components through methods like <code>stopAtMechanicalMapping</code>, which determines whether it should traverse mechanical mappings based on the state of flags such as <code>mapped</code> and <code>only_mapped</code>. This visitor also includes methods to set these mapping behavior flags:</p>\n<ul>\n<li><span class=\"math inline\">setMapped(bool m)</span>: controls traversal through all mechanical mappings.</li>\n<li><span class=\"math inline\">setOnlyMapped(bool m)</span>: restricts operations to only mapped states if true, otherwise operates on both mapped and unmapped states.</li>\n</ul>\n\n<p>The visitor interacts with <code>BaseMechanicalState</code> objects through methods such as:</p>\n<ul>\n<li><code>fwdMechanicalState(VisitorContext* ctx, sofa::core::behavior::BaseMechanicalState* mm)</code>: performs the vector operation for non-mapped states.</li>\n<li><code>fwdMappedMechanicalState(VisitorContext* ctx, sofa::core::behavior::BaseMechanicalState* mm)</code>: performs the vector operation for mapped states based on the state of the <code>mapped</code> and <code>only_mapped</code> flags.</li>\n</ul>\n\n<p>This visitor is designed to be thread-safe, enabling parallel processing within simulations. It fits into the broader FEM pipeline by facilitating operations such as:</p>\n<ul>\n<li><strong>Assembly:</strong> combining vectors in the assembly phase of the global mass and force matrices.</li>\n<li><strong>Time Integration:</strong> updating state vectors during time integration steps.</li>\n<li><strong>Nonlinear Resolution:</strong> performing vector operations within nonlinear solve steps, such as computing residuals or corrections.</li>\n<li><strong>Linear Solve:</strong> contributing to linear system solution by forming right-hand side terms in matrix-vector products.</li>\n</ul>\n\n<p>The <code>MechanicalVOpVisitor</code> thus plays a crucial role in the computational mechanics workflow, enabling efficient and flexible vector operations on mechanical states within the simulation pipeline.</p>",
  "abstract": "The `MechanicalVOpVisitor` performs vector operations on mechanical states in the form of v = a + b * f, where a and b are vectors and f is a scalar factor, facilitating efficient and flexible computations within the SOFA simulation pipeline.",
  "sheet": "# MechanicalVOpVisitor\n\n## Overview\nThe `MechanicalVOpVisitor` is part of the SOFA framework and inherits from `BaseMechanicalVisitor`. It performs vector operations on mechanical states within the simulation pipeline. Specifically, it computes the operation \\( v = a + b \times f \\), where \\(a\\) and \\(b\\) are vectors and \\(f\\) is a scalar factor.\n\n## Mathematical Model\nThe `MechanicalVOpVisitor` performs vector operations on mechanical states in the form of:\n\n\begin{equation}\n    v = a + b \times f\n\tag{1}\n\ndisplay\nwhere \\(v\\) is the resulting vector, \\(a\\) and \\(b\\) are input vectors (optional), and \\(f\\) is a scalar factor. The operation can be interpreted as a linear combination of vectors.\n\n## Parameters and Data\n- **setMapped(bool m)**: Controls traversal through all mechanical mappings.\n- **setOnlyMapped(bool m)**: Restricts operations to only mapped states if true, otherwise operates on both mapped and unmapped states.\n\n## Dependencies and Connections\nThe `MechanicalVOpVisitor` interacts with other components through methods like `stopAtMechanicalMapping`, which determines whether it should traverse mechanical mappings based on the state of flags such as `mapped` and `only_mapped`. It also includes methods to set these mapping behavior flags. The visitor interacts with `BaseMechanicalState` objects through methods such as:\n- **fwdMechanicalState(VisitorContext* ctx, sofa::core::behavior::BaseMechanicalState* mm)**: Performs the vector operation for non-mapped states.\n- **fwdMappedMechanicalState(VisitorContext* ctx, sofa::core::behavior::BaseMechanicalState* mm)**: Performs the vector operation for mapped states based on the state of the `mapped` and `only_mapped` flags."
}