Back

MergeVectors

sofa::component::engine::generate::MergeVectors
DataEngine
Doc (from source)

Apply a merge operation to combine several inputs.

Abstract (AI generated)

`MergeVectors` combines multiple input vectors into a single output vector, facilitating data manipulation within SOFA simulations.

Metadata
module
Sofa.Component.Engine.Generate
namespace
sofa::component::engine::generate
include
sofa/component/engine/generate/MergeVectors.h
inherits
  • DataEngine
templates
  • sofa::defaulttype::Rigid2Types::VecCoord
  • sofa::defaulttype::Rigid2Types::VecDeriv
  • sofa::defaulttype::Rigid3Types::VecCoord
  • sofa::defaulttype::Rigid3Types::VecDeriv
  • type::vector<SReal>
  • type::vector<bool>
  • type::vector<int>
  • type::vector<type::Vec2>
  • type::vector<type::Vec2u>
  • type::vector<type::Vec3>
  • type::vector<type::Vec4>
description

The MergeVectors component in the SOFA framework is designed to combine multiple input vectors into a single output vector. It does not implement any governing equations or physical laws directly, but rather serves as a utility for data manipulation within the simulation pipeline.

Mathematical Description:

Input Vectors and Output Vector

The MergeVectors component takes several input vectors $\{\mathbf{v}_1, \mathbf{v}_2, \\ldots, \mathbf{v}_{N}\}$ where each vector $\mathbf{v}_i$ can be of various types such as int, bool, Vec2, Vec3, etc. The number of input vectors is specified by the user through the field f_nbInputs (denoted as $N$).

The goal of the component is to merge these input vectors into a single output vector $\mathbf{v}_{out}$.

Merging Operation

In practice, the merging operation involves concatenating the individual elements from each input vector. For example, if there are three input vectors:

egin{align*}
\mathbf{v}1 &= [a_1, a_2, \ldots, a{N_1}]\
\mathbf{v}2 &= [b_1, b_2, \ldots, b{N_2}]\
\mathbf{v}3 &= [c_1, c_2, \ldots, c{N_3}]

end{align*}

the resulting output vector $\mathbf{v}_{out}$ would be:

egin{equation*}
\mathbf{v}{out} = [a_1, a_2, \ldots, a{N_1}, b_1, b_2, \ldots, b_{N_2}, c_1, c_2, \ldots, c_{N_3}]

end{equation*}

This operation is performed using the core::objectmodel::vectorData<VecValue>::merge function which combines all input vectors into a single output vector.

Role in the Global FEM Pipeline:

The MergeVectors component does not contribute to any of the core physical or numerical aspects of the finite element method (FEM) simulation pipeline such as mass matrix, stiffness matrix, internal forces, or nonlinear solve. Instead, it serves a utility role within the SOFA framework by facilitating data manipulation tasks.

Numerical Methods and Discretization Choices:

Since MergeVectors does not implement any numerical methods or discretization choices specific to FEM, its operation is purely algorithmic in nature, focusing on efficient merging of vector data.

Variational / Lagrangian Mechanics Framework:

The component does not involve any variational principles, Lagrangian mechanics, or other physical formulations. It merely handles the task of merging multiple vectors into a single output vector.

Summary:

MergeVectors is a utility component in SOFA used for combining multiple input vectors into one output vector. Its primary role is to support data manipulation tasks within the simulation pipeline rather than contributing to any specific physical or numerical computations inherent to FEM.

Data Fields
NameTypeDefaultHelp
f_nbInputs unsigned int Number of input vectors
vf_inputs VecValue
f_output VecValue Output vector
Methods
void parse (sofa::core::objectmodel::BaseObjectDescription * arg) virtual
void parseFields (const int & str)
void init () virtual
void reinit () virtual
void doUpdate () virtual
{
  "name": "MergeVectors",
  "namespace": "sofa::component::engine::generate",
  "module": "Sofa.Component.Engine.Generate",
  "include": "sofa/component/engine/generate/MergeVectors.h",
  "doc": "Apply a merge operation to combine several inputs.",
  "inherits": [
    "DataEngine"
  ],
  "templates": [
    "sofa::defaulttype::Rigid2Types::VecCoord",
    "sofa::defaulttype::Rigid2Types::VecDeriv",
    "sofa::defaulttype::Rigid3Types::VecCoord",
    "sofa::defaulttype::Rigid3Types::VecDeriv",
    "type::vector<SReal>",
    "type::vector<bool>",
    "type::vector<int>",
    "type::vector<type::Vec2>",
    "type::vector<type::Vec2u>",
    "type::vector<type::Vec3>",
    "type::vector<type::Vec4>"
  ],
  "data_fields": [
    {
      "name": "f_nbInputs",
      "type": "unsigned int",
      "xmlname": "nbInputs",
      "help": "Number of input vectors"
    },
    {
      "name": "vf_inputs",
      "type": "VecValue"
    },
    {
      "name": "f_output",
      "type": "VecValue",
      "xmlname": "output",
      "help": "Output vector"
    }
  ],
  "links": [],
  "methods": [
    {
      "name": "parse",
      "return_type": "void",
      "params": [
        {
          "name": "arg",
          "type": "sofa::core::objectmodel::BaseObjectDescription *"
        }
      ],
      "is_virtual": true,
      "is_pure_virtual": false,
      "is_static": false,
      "access": "public"
    },
    {
      "name": "parseFields",
      "return_type": "void",
      "params": [
        {
          "name": "str",
          "type": "const int &"
        }
      ],
      "is_virtual": false,
      "is_pure_virtual": false,
      "is_static": false,
      "access": "public"
    },
    {
      "name": "init",
      "return_type": "void",
      "params": [],
      "is_virtual": true,
      "is_pure_virtual": false,
      "is_static": false,
      "access": "public"
    },
    {
      "name": "reinit",
      "return_type": "void",
      "params": [],
      "is_virtual": true,
      "is_pure_virtual": false,
      "is_static": false,
      "access": "public"
    },
    {
      "name": "doUpdate",
      "return_type": "void",
      "params": [],
      "is_virtual": true,
      "is_pure_virtual": false,
      "is_static": false,
      "access": "public"
    }
  ],
  "description": "The `MergeVectors` component in the SOFA framework is designed to combine multiple input vectors into a single output vector. It inherits from `DataEngine`, which indicates that it manages data and performs computations within the scene graph architecture of SOFA.\n\n**Role and Purpose:**\n`MergeVectors` facilitates the merging of several inputs, each represented as vectors (e.g., integers, booleans, 2D/3D/4D coordinates). This can be useful in various scenarios where combining multiple data streams or results is necessary for further processing within a simulation.\n\n**Interactions with Other Components:**\n- The `MergeVectors` component interacts with other components through its input and output fields. Specifically, it receives multiple input vectors (`vf_inputs`) and produces one merged output vector (`f_output`).\n- It uses the `DataEngine` interface to manage data dependencies and trigger updates when inputs change.\n\n**Practical Usage Guidance:**\n- The component requires specifying the number of input vectors via the `nbInputs` field. This determines how many individual vectors are to be merged together.\n- Each input vector should be appropriately defined and connected to the `vf_inputs` field for merging.\n- The resulting merged vector is output through the `f_output` field, which can then be used by other components in the simulation pipeline.",
  "maths": "The `MergeVectors` component in the SOFA framework is designed to combine multiple input vectors into a single output vector. It does not implement any governing equations or physical laws directly, but rather serves as a utility for data manipulation within the simulation pipeline.\n\n### Mathematical Description:\n\n#### Input Vectors and Output Vector\nThe `MergeVectors` component takes several input vectors \\(\\{\\mathbf{v}_1, \\mathbf{v}_2, \\\\ldots, \\mathbf{v}_{N}\\}\\) where each vector \\(\\mathbf{v}_i\\) can be of various types such as `int`, `bool`, `Vec2`, `Vec3`, etc. The number of input vectors is specified by the user through the field `f_nbInputs` (denoted as \\(N\\)).\n\nThe goal of the component is to merge these input vectors into a single output vector \\(\\mathbf{v}_{out}\\).\n\n#### Merging Operation\nIn practice, the merging operation involves concatenating the individual elements from each input vector. For example, if there are three input vectors:\n\n\begin{align*}\n\\mathbf{v}_1 &= [a_1, a_2, \\\\ldots, a_{N_1}]\\\\\n\\mathbf{v}_2 &= [b_1, b_2, \\\\ldots, b_{N_2}]\\\\\n\\mathbf{v}_3 &= [c_1, c_2, \\\\ldots, c_{N_3}]\n\rend{align*}\n\nthe resulting output vector \\(\\mathbf{v}_{out}\\) would be:\n\n\begin{equation*}\n\\mathbf{v}_{out} = [a_1, a_2, \\\\ldots, a_{N_1}, b_1, b_2, \\\\ldots, b_{N_2}, c_1, c_2, \\\\ldots, c_{N_3}]\n\rend{equation*}\n\nThis operation is performed using the `core::objectmodel::vectorData<VecValue>::merge` function which combines all input vectors into a single output vector.\n\n### Role in the Global FEM Pipeline:\n\nThe `MergeVectors` component does not contribute to any of the core physical or numerical aspects of the finite element method (FEM) simulation pipeline such as mass matrix, stiffness matrix, internal forces, or nonlinear solve. Instead, it serves a utility role within the SOFA framework by facilitating data manipulation tasks.\n\n### Numerical Methods and Discretization Choices:\n\nSince `MergeVectors` does not implement any numerical methods or discretization choices specific to FEM, its operation is purely algorithmic in nature, focusing on efficient merging of vector data.\n\n### Variational / Lagrangian Mechanics Framework:\n\nThe component does not involve any variational principles, Lagrangian mechanics, or other physical formulations. It merely handles the task of merging multiple vectors into a single output vector.\n\n### Summary:\n`MergeVectors` is a utility component in SOFA used for combining multiple input vectors into one output vector. Its primary role is to support data manipulation tasks within the simulation pipeline rather than contributing to any specific physical or numerical computations inherent to FEM.",
  "abstract": "`MergeVectors` combines multiple input vectors into a single output vector, facilitating data manipulation within SOFA simulations.",
  "sheet": "# MergeVectors\n\n## Overview\nThe `MergeVectors` component is part of the `sofa::component::engine::generate` namespace and inherits from `DataEngine`. It serves as a utility for merging several input vectors into one output vector. This functionality supports data manipulation tasks within the SOFA simulation pipeline.\n\n## Parameters and Data\n- **f_nbInputs**: Number of input vectors (`unsigned int`).\n- **vf_inputs**: Input vectors (`VecValue`).\n- **f_output**: Output vector (`VecValue`).\n\n## Dependencies and Connections\nThe `MergeVectors` component requires multiple input vectors to be connected to the `vf_inputs` field. The number of inputs is specified by `f_nbInputs`. The merged output vector is available through the `f_output` field, which can then be used by other components in the simulation pipeline."
}