MathOp
Apply a math operation to combine several inputs.
MathOp applies mathematical operations to combine multiple input values into one output value, serving as an engine for arithmetic and logical operations within SOFA simulations.
- module
- Sofa.Component.Engine.Transform
- namespace
- sofa::component::engine::transform
- include
- sofa/component/engine/transform/MathOp.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::Vec3>
- description
The MathOp component in the Sofa framework applies mathematical operations to combine multiple input values into a single output value. The supported operations include addition, subtraction, multiplication, division, logical AND, OR, NOT, and more. Here is the detailed description of its mathematical and physical aspects:
-
Governing Equations: MathOp does not directly govern any fundamental equations in continuum mechanics or FEM. Instead, it operates on scalar values or vectors to combine them according to user-defined operations.
-
Constitutive/Kinematic Laws: This component does not implement constitutive laws (such as stress-strain relations) nor kinematic laws (like deformation gradients). It merely applies arithmetic and logical operations to provided inputs.
-
Role in the Global FEM Pipeline:
-
MathOp functions primarily during the update phase, where it aggregates multiple input values into a single output value. This can be seen as part of pre-processing or post-processing steps within the simulation pipeline but does not directly participate in assembling global matrices, time integration, nonlinear solves, or linear solves.
-
Numerical Methods: MathOp supports operations on various data types including vectors of real numbers (
SReal), integers (int), booleans (bool), 2D and 3D vectors (type::Vec2,type::Vec3), as well as rigid body transformations (Rigid2Types::VecCoord,Rigid2Types::VecDeriv,Rigid3Types::VecCoord,Rigid3Types::VecDeriv). The operations are performed in a straightforward manner, without involving complex numerical methods or discretization schemes. -
Variational/Lagrangian Mechanics Framework: MathOp is not directly tied to the variational principles or Lagrangian mechanics. It serves as a utility component for combining input values through specified mathematical operations and does not contribute to the mechanical energy formulation or equation of motion derivation.
In summary, MathOp facilitates simple arithmetic and logical operations on multiple inputs to produce a single output value but is not involved in core FEM simulation processes like spatial discretization, time integration, or nonlinear solution procedures.
Data Fields
| Name | Type | Default | Help |
|---|---|---|---|
f_nbInputs |
unsigned int | |
Number of input values |
f_op |
sofa::helper::OptionsGroup | |
Selected operation to apply |
f_output |
VecValue | |
Output values |
Methods
void
parse
(sofa::core::objectmodel::BaseObjectDescription * arg)
virtual
void
parseFields
(const int & str)
void
init
()
virtual
void
reinit
()
virtual
void
doUpdate
()
virtual
void
createInputs
(int nb)
{
"name": "MathOp",
"namespace": "sofa::component::engine::transform",
"module": "Sofa.Component.Engine.Transform",
"include": "sofa/component/engine/transform/MathOp.h",
"doc": "Apply a math 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::Vec3>"
],
"data_fields": [
{
"name": "f_nbInputs",
"type": "unsigned int",
"xmlname": "nbInputs",
"help": "Number of input values"
},
{
"name": "f_op",
"type": "sofa::helper::OptionsGroup",
"xmlname": "op",
"help": "Selected operation to apply"
},
{
"name": "f_output",
"type": "VecValue",
"xmlname": "output",
"help": "Output values"
}
],
"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"
},
{
"name": "createInputs",
"return_type": "void",
"params": [
{
"name": "nb",
"type": "int"
}
],
"is_virtual": false,
"is_pure_virtual": false,
"is_static": false,
"access": "protected"
}
],
"description": "The MathOp component is an engine in the Sofa framework that applies a mathematical operation to combine several input values into one output value.",
"parameters": [
{
"name": "nbInputs",
"description": "Number of input values for the math operation. Default is 2.",
"type": "integer"
},
{
"name": "op",
"description": "Selected mathematical operation to apply on the inputs. The operations supported include addition, subtraction, multiplication, division, and logical operations like AND, OR etc., depending upon the data types of input values.",
"type": "string"
},
{
"name": "output",
"description": "Output values resulting from applying the selected math operation on the inputs.",
"type": "vector"
}
],
"inputs": [
{
"name": "input1",
"description": "Input values. Multiple inputs can be added based on nbInputs parameter.",
"type": "vector"
},
{
"name": "nbInputs",
"description": "Number of input values for the math operation.",
"type": "integer"
}
],
"outputs": [
{
"name": "output",
"description": "Resultant output value after applying the selected mathematical operation on the inputs.",
"type": "vector"
}
],
"maths": "The MathOp component in the Sofa framework applies mathematical operations to combine multiple input values into a single output value. The supported operations include addition, subtraction, multiplication, division, logical AND, OR, NOT, and more. Here is the detailed description of its mathematical and physical aspects:\n\n- **Governing Equations**: MathOp does not directly govern any fundamental equations in continuum mechanics or FEM. Instead, it operates on scalar values or vectors to combine them according to user-defined operations.\n\n- **Constitutive/Kinematic Laws**: This component does not implement constitutive laws (such as stress-strain relations) nor kinematic laws (like deformation gradients). It merely applies arithmetic and logical operations to provided inputs.\n\n- **Role in the Global FEM Pipeline**:\n - MathOp functions primarily during the update phase, where it aggregates multiple input values into a single output value. This can be seen as part of pre-processing or post-processing steps within the simulation pipeline but does not directly participate in assembling global matrices, time integration, nonlinear solves, or linear solves.\n\n- **Numerical Methods**: MathOp supports operations on various data types including vectors of real numbers (`SReal`), integers (`int`), booleans (`bool`), 2D and 3D vectors (`type::Vec2`, `type::Vec3`), as well as rigid body transformations (`Rigid2Types::VecCoord`, `Rigid2Types::VecDeriv`, `Rigid3Types::VecCoord`, `Rigid3Types::VecDeriv`). The operations are performed in a straightforward manner, without involving complex numerical methods or discretization schemes.\n\n- **Variational/Lagrangian Mechanics Framework**: MathOp is not directly tied to the variational principles or Lagrangian mechanics. It serves as a utility component for combining input values through specified mathematical operations and does not contribute to the mechanical energy formulation or equation of motion derivation.\n\nIn summary, MathOp facilitates simple arithmetic and logical operations on multiple inputs to produce a single output value but is not involved in core FEM simulation processes like spatial discretization, time integration, or nonlinear solution procedures.",
"abstract": "MathOp applies mathematical operations to combine multiple input values into one output value, serving as an engine for arithmetic and logical operations within SOFA simulations.",
"sheet": "<p># MathOp</p>\n\n<p><strong>Overview:</strong> MathOp is a component in the Sofa framework that applies mathematical operations to combine several inputs into a single output. It inherits from <code>DataEngine</code> and supports various data types including vectors of real numbers, integers, booleans, 2D and 3D vectors, and rigid body transformations.</p>\n\n<h4 id=\"parameters-and-data\">Parameters and Data</h4>\n<ul>\n<li><strong>f_nbInputs (unsigned int)</strong>: Number of input values. Default: Not specified.</li>\n<li><strong>f_op (sofa::helper::OptionsGroup)</strong>: Selected operation to apply. Options include addition, subtraction, multiplication, division, logical AND, OR, NOT, etc.</li>\n<li><strong>f_output (VecValue)</strong>: Output values resulting from the applied operations.</li>\n</ul>\n\n<h4 id=\"practical-notes\">Practical Notes</h4>\n<p>Ensure that the number of inputs specified in <code>f_nbInputs</code> matches the actual input data provided to avoid runtime errors. The component supports a wide range of operations and data types, making it versatile for various use cases within SOFA simulations.</p>"
}