ValuesFromPositions
Assign values to primitives (vertex/edge/triangle/tetrahedron) based on a linear interpolation of values along a direction. This class find all the points/edges/triangles/tetrahedra located inside a given box.
The `ValuesFromPositions` component interpolates input values along a specified direction for points, edges, triangles, and tetrahedra, generating scalar or vector output fields based on linear interpolation.
- module
- Sofa.Component.Engine.Select
- namespace
- sofa::component::engine::select
- include
- sofa/component/engine/select/ValuesFromPositions.h
- inherits
-
- DataEngine
- templates
-
- sofa::defaulttype::Rigid3Types
- sofa::defaulttype::Vec3Types
- description
Mathematical and Physical Description of ValuesFromPositions
The ValuesFromPositions component in the SOFA framework is designed to interpolate input values along a specified direction for various geometric primitives such as points, edges, triangles, and tetrahedra. This interpolation process generates scalar or vector output fields based on the selected configuration.
Governing Equations and Operators
- Linear Interpolation of Scalar Values:
The component performs linear interpolation of input values along a specified direction\mathbf{d}. Given a set of input values $ V = [v_0, v_1, \ldots, v_n] $ and the corresponding positions along the direction vector $ P = [p_0, p_1, \ldots, p_n] $, the interpolated value at any position $ x $ can be computed as:
- Direction Vector and Interpolation:
The direction vector $\mathbf{d}$ is specified by the user, and the interpolation is performed along this direction.
Constitutive or Kinematic Laws Involved
- Linear Interpolation:
-
Given a point position $ p_i $, its value $ v(p_i) $ is determined using linear interpolation based on the nearest input values. The interpolation formula is given above.
-
Vector Output:
If vector output is selected, the direction vector $\mathbf{d}$ is assigned to each geometric primitive's position.
Role in the Global FEM Pipeline
- Assembly Phase:
- The component reads rest positions (
f_X0), edge, triangle, and tetrahedron topologies from the simulation graph. It then computes scalar or vector values for each element based on the interpolation formula. - Nonlinear Resolution: Not applicable as this component does not contribute to nonlinear residual computation.
- Linear Solve: Not applicable since no linear system is solved by this component.
Numerical Methods and Discretization Choices
- Interpolation of Scalar Values:
- For each geometric primitive (point, edge, triangle, tetrahedron), the value at its centroid or representative position is computed using linear interpolation along the direction $\mathbf{d}$.
- Vector Output:
- The direction vector $\mathbf{d}$ is assigned to each geometric primitive's position.
Broad Variational / Lagrangian Mechanics Framework Context
While this component does not directly contribute to the variational or Lagrangian mechanics framework, it can be used as part of a broader simulation pipeline. For example, scalar values computed by ValuesFromPositions could represent material properties such as stiffness coefficients that are interpolated based on spatial coordinates.
Summary
The ValuesFromPositions component in SOFA performs linear interpolation of input values along a specified direction for points, edges, triangles, and tetrahedra. It generates scalar or vector output fields depending on the configuration and is useful for assigning material properties or other scalar/vector fields to geometric primitives based on spatial coordinates.
Data Fields
| Name | Type | Default | Help |
|---|---|---|---|
f_inputValues |
VecReal | |
Input values |
f_direction |
CPos | |
Direction along which the values are interpolated |
f_X0 |
VecCoord | |
Rest position coordinates of the degrees of freedom |
f_values |
VecReal | |
Values of the points contained in the ROI |
f_edgeValues |
VecReal | |
Values of the edges contained in the ROI |
f_triangleValues |
VecReal | |
Values of the triangles contained in the ROI |
f_tetrahedronValues |
VecReal | |
Values of the tetrahedra contained in the ROI |
p_fieldType |
sofa::helper::OptionsGroup | |
field type of output elements |
p_drawVectors |
bool | |
draw vectors line |
p_vectorLength |
float | |
vector length visualisation. |
Methods
void
init
()
virtual
void
reinit
()
virtual
void
doUpdate
()
virtual
void
draw
(const core::visual::VisualParams * vparams)
virtual
bool
canCreate
(T *& obj, core::objectmodel::BaseContext * context, core::objectmodel::BaseObjectDescription * arg)
void
updateValues
(TempData & _data)
Real
valueFromPosition
(const CPos & p, const TempData & data)
Real
valueFromPoint
(const PointID & pid, const TempData & data)
Real
valueFromEdge
(const Edge & e, const TempData & data)
Real
valueFromTriangle
(const Triangle & t, const TempData & data)
Real
valueFromTetrahedron
(const Tetra & t, const TempData & data)
void
updateVectors
(TempData & _data)
Vec3
vectorFromPosition
(const CPos & p, const TempData & data)
Vec3
vectorFromPoint
(const PointID & pid, const TempData & data)
Vec3
vectorFromEdge
(const Edge & e, const TempData & data)
Vec3
vectorFromTriangle
(const Triangle & t, const TempData & data)
Vec3
vectorFromTetrahedron
(const Tetra & t, const TempData & data)
{
"name": "ValuesFromPositions",
"namespace": "sofa::component::engine::select",
"module": "Sofa.Component.Engine.Select",
"include": "sofa/component/engine/select/ValuesFromPositions.h",
"doc": "Assign values to primitives (vertex/edge/triangle/tetrahedron) based on a linear interpolation of values along a direction.\n\nThis class find all the points/edges/triangles/tetrahedra located inside a given box.",
"inherits": [
"DataEngine"
],
"templates": [
"sofa::defaulttype::Rigid3Types",
"sofa::defaulttype::Vec3Types"
],
"data_fields": [
{
"name": "f_inputValues",
"type": "VecReal",
"xmlname": "inputValues",
"help": "Input values"
},
{
"name": "f_direction",
"type": "CPos",
"xmlname": "direction",
"help": "Direction along which the values are interpolated"
},
{
"name": "f_X0",
"type": "VecCoord",
"xmlname": "position",
"help": "Rest position coordinates of the degrees of freedom"
},
{
"name": "f_values",
"type": "VecReal",
"xmlname": "values",
"help": "Values of the points contained in the ROI"
},
{
"name": "f_edgeValues",
"type": "VecReal",
"xmlname": "edgeValues",
"help": "Values of the edges contained in the ROI"
},
{
"name": "f_triangleValues",
"type": "VecReal",
"xmlname": "triangleValues",
"help": "Values of the triangles contained in the ROI"
},
{
"name": "f_tetrahedronValues",
"type": "VecReal",
"xmlname": "tetrahedronValues",
"help": "Values of the tetrahedra contained in the ROI"
},
{
"name": "p_fieldType",
"type": "sofa::helper::OptionsGroup",
"xmlname": "fieldType",
"help": "field type of output elements"
},
{
"name": "p_drawVectors",
"type": "bool",
"xmlname": "drawVectors",
"help": "draw vectors line"
},
{
"name": "p_vectorLength",
"type": "float",
"xmlname": "drawVectorLength",
"help": "vector length visualisation. "
}
],
"links": [],
"methods": [
{
"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": "draw",
"return_type": "void",
"params": [
{
"name": "vparams",
"type": "const core::visual::VisualParams *"
}
],
"is_virtual": true,
"is_pure_virtual": false,
"is_static": false,
"access": "public"
},
{
"name": "canCreate",
"return_type": "bool",
"params": [
{
"name": "obj",
"type": "T *&"
},
{
"name": "context",
"type": "core::objectmodel::BaseContext *"
},
{
"name": "arg",
"type": "core::objectmodel::BaseObjectDescription *"
}
],
"is_virtual": false,
"is_pure_virtual": false,
"is_static": true,
"access": "public"
},
{
"name": "updateValues",
"return_type": "void",
"params": [
{
"name": "_data",
"type": "TempData &"
}
],
"is_virtual": false,
"is_pure_virtual": false,
"is_static": false,
"access": "protected"
},
{
"name": "valueFromPosition",
"return_type": "Real",
"params": [
{
"name": "p",
"type": "const CPos &"
},
{
"name": "data",
"type": "const TempData &"
}
],
"is_virtual": false,
"is_pure_virtual": false,
"is_static": false,
"access": "protected"
},
{
"name": "valueFromPoint",
"return_type": "Real",
"params": [
{
"name": "pid",
"type": "const PointID &"
},
{
"name": "data",
"type": "const TempData &"
}
],
"is_virtual": false,
"is_pure_virtual": false,
"is_static": false,
"access": "protected"
},
{
"name": "valueFromEdge",
"return_type": "Real",
"params": [
{
"name": "e",
"type": "const Edge &"
},
{
"name": "data",
"type": "const TempData &"
}
],
"is_virtual": false,
"is_pure_virtual": false,
"is_static": false,
"access": "protected"
},
{
"name": "valueFromTriangle",
"return_type": "Real",
"params": [
{
"name": "t",
"type": "const Triangle &"
},
{
"name": "data",
"type": "const TempData &"
}
],
"is_virtual": false,
"is_pure_virtual": false,
"is_static": false,
"access": "protected"
},
{
"name": "valueFromTetrahedron",
"return_type": "Real",
"params": [
{
"name": "t",
"type": "const Tetra &"
},
{
"name": "data",
"type": "const TempData &"
}
],
"is_virtual": false,
"is_pure_virtual": false,
"is_static": false,
"access": "protected"
},
{
"name": "updateVectors",
"return_type": "void",
"params": [
{
"name": "_data",
"type": "TempData &"
}
],
"is_virtual": false,
"is_pure_virtual": false,
"is_static": false,
"access": "protected"
},
{
"name": "vectorFromPosition",
"return_type": "Vec3",
"params": [
{
"name": "p",
"type": "const CPos &"
},
{
"name": "data",
"type": "const TempData &"
}
],
"is_virtual": false,
"is_pure_virtual": false,
"is_static": false,
"access": "protected"
},
{
"name": "vectorFromPoint",
"return_type": "Vec3",
"params": [
{
"name": "pid",
"type": "const PointID &"
},
{
"name": "data",
"type": "const TempData &"
}
],
"is_virtual": false,
"is_pure_virtual": false,
"is_static": false,
"access": "protected"
},
{
"name": "vectorFromEdge",
"return_type": "Vec3",
"params": [
{
"name": "e",
"type": "const Edge &"
},
{
"name": "data",
"type": "const TempData &"
}
],
"is_virtual": false,
"is_pure_virtual": false,
"is_static": false,
"access": "protected"
},
{
"name": "vectorFromTriangle",
"return_type": "Vec3",
"params": [
{
"name": "t",
"type": "const Triangle &"
},
{
"name": "data",
"type": "const TempData &"
}
],
"is_virtual": false,
"is_pure_virtual": false,
"is_static": false,
"access": "protected"
},
{
"name": "vectorFromTetrahedron",
"return_type": "Vec3",
"params": [
{
"name": "t",
"type": "const Tetra &"
},
{
"name": "data",
"type": "const TempData &"
}
],
"is_virtual": false,
"is_pure_virtual": false,
"is_static": false,
"access": "protected"
}
],
"description": "The `ValuesFromPositions` component in the SOFA framework is designed to assign values to geometric primitives (points, edges, triangles, tetrahedra) based on linear interpolation along a specified direction. It operates by interpolating input values provided along a given direction and mapping these values to specific elements within a defined region of interest (ROI). The component can generate both scalar and vector output fields for the assigned elements.\n\n### Interactions with Other Components\n- **Mechanical State and Topology**: `ValuesFromPositions` relies on the mechanical state and mesh topology provided by other components in the simulation graph. It specifically uses rest position coordinates (`f_X0`) and topological data (edges, triangles, tetrahedra) to perform its operations.\n- **Data Engine**: As a subclass of `core::DataEngine`, it inherits methods for initialization (`init`), reinitialization (`reinit`), and updating the computed values (`doUpdate`). It also implements drawing functionality (`draw`) for visualizing vectors if enabled.\n\n### Data Fields\n- **Input Fields**:\n - `f_inputValues`: Input scalar values to be interpolated along a direction.\n - `f_direction`: Direction vector along which interpolation is performed.\n - `f_X0`: Rest position coordinates of the geometric elements.\n - `f_edges`, `f_triangles`, `f_tetrahedra`: Topological data for edges, triangles, and tetrahedra.\n- **Output Fields**:\n - `f_values`, `f_edgeValues`, `f_triangleValues`, `f_tetrahedronValues`: Output scalar values assigned to points, edges, triangles, and tetrahedra respectively.\n - `f_pointVectors`, `f_edgeVectors`, `f_triangleVectors`, `f_tetrahedronVectors`: Output vector fields for the respective geometric primitives if vector output is selected.\n- **Parameters**:\n - `p_fieldType`: Selects whether to compute scalar or vector values.\n - `p_drawVectors`: Toggles visualization of computed vectors.\n - `p_vectorLength`: Sets the length of visualized vectors.\n\n### Practical Usage Guidance\nThe component is useful for assigning scalar or vector values to geometric primitives based on linear interpolation. It can be configured by setting input values and a direction, and it updates these values based on topology data from other components in the simulation graph. The `p_fieldType` parameter determines whether to compute scalars or vectors, while `p_drawVectors` controls the visualization of computed vectors with adjustable length.",
"maths": "### Mathematical and Physical Description of `ValuesFromPositions`\n\nThe `ValuesFromPositions` component in the SOFA framework is designed to interpolate input values along a specified direction for various geometric primitives such as points, edges, triangles, and tetrahedra. This interpolation process generates scalar or vector output fields based on the selected configuration.\n\n#### Governing Equations and Operators\n\n1. **Linear Interpolation of Scalar Values**:\n The component performs linear interpolation of input values along a specified direction `\\mathbf{d}`. Given a set of input values \\( V = [v_0, v_1, \\ldots, v_n] \\) and the corresponding positions along the direction vector \\( P = [p_0, p_1, \\ldots, p_n] \\), the interpolated value at any position \\( x \\) can be computed as:\n \n \\[ v(x) = v_i + (v_{i+1} - v_i) \\frac{x - p_i}{p_{i+1} - p_i}, \\quad \\text{for } p_i \\leq x < p_{i+1} \\]\n\n2. **Direction Vector and Interpolation**:\n The direction vector \\(\\mathbf{d}\\) is specified by the user, and the interpolation is performed along this direction.\n\n#### Constitutive or Kinematic Laws Involved\n\n- **Linear Interpolation**: \n - Given a point position \\( p_i \\), its value \\( v(p_i) \\) is determined using linear interpolation based on the nearest input values. The interpolation formula is given above.\n\n3. **Vector Output**:\n If vector output is selected, the direction vector \\(\\mathbf{d}\\) is assigned to each geometric primitive's position.\n\n#### Role in the Global FEM Pipeline\n\n- **Assembly Phase**: \n - The component reads rest positions (`f_X0`), edge, triangle, and tetrahedron topologies from the simulation graph. It then computes scalar or vector values for each element based on the interpolation formula.\n- **Nonlinear Resolution**: Not applicable as this component does not contribute to nonlinear residual computation.\n- **Linear Solve**: Not applicable since no linear system is solved by this component.\n\n#### Numerical Methods and Discretization Choices\n\n1. **Interpolation of Scalar Values**:\n - For each geometric primitive (point, edge, triangle, tetrahedron), the value at its centroid or representative position is computed using linear interpolation along the direction \\(\\mathbf{d}\\).\n2. **Vector Output**: \n - The direction vector \\(\\mathbf{d}\\) is assigned to each geometric primitive's position.\n\n#### Broad Variational / Lagrangian Mechanics Framework Context\n\nWhile this component does not directly contribute to the variational or Lagrangian mechanics framework, it can be used as part of a broader simulation pipeline. For example, scalar values computed by `ValuesFromPositions` could represent material properties such as stiffness coefficients that are interpolated based on spatial coordinates.\n\n### Summary\n\nThe `ValuesFromPositions` component in SOFA performs linear interpolation of input values along a specified direction for points, edges, triangles, and tetrahedra. It generates scalar or vector output fields depending on the configuration and is useful for assigning material properties or other scalar/vector fields to geometric primitives based on spatial coordinates.",
"abstract": "The `ValuesFromPositions` component interpolates input values along a specified direction for points, edges, triangles, and tetrahedra, generating scalar or vector output fields based on linear interpolation.",
"sheet": "# ValuesFromPositions\n\n## Overview\nThe `ValuesFromPositions` component is an engine that assigns values to geometric primitives (points, edges, triangles, tetrahedra) by interpolating input values along a specified direction. It operates within the SOFA framework and inherits from `DataEngine`, providing methods for initialization (`init`), reinitialization (`reinit`), updating computed values (`doUpdate`), and drawing vectors if visualization is enabled.\n\n## Mathematical Model\nThe component performs linear interpolation of input values along a specified direction vector \\(\\mathbf{d}\\). Given a set of input values \\(V = [v_0, v_1, \\ldots, v_n]\\) at positions \\(P = [p_0, p_1, \\ldots, p_n]\\), the interpolated value at any position \\(x\\) is computed as:\n\n\\[ v(x) = v_i + (v_{i+1} - v_i) \\frac{x - p_i}{p_{i+1} - p_i}, \\quad \\text{for } p_i \\leq x < p_{i+1}. \\]\n\nFor vector output, the direction vector \\(\\mathbf{d}\\) is assigned to each geometric primitive's position.\n\n## Parameters and Data\n- **Input Fields**:\n - `f_inputValues`: Input scalar values to be interpolated along a direction.\n - `f_direction`: Direction vector along which interpolation is performed.\n - `f_X0`: Rest position coordinates of the geometric elements.\n- **Output Fields**:\n - `f_values`, `f_edgeValues`, `f_triangleValues`, `f_tetrahedronValues`: Output scalar values assigned to points, edges, triangles, and tetrahedra respectively.\n - `p_fieldType`: Selects whether to compute scalar or vector values.\n - `p_drawVectors`: Toggles visualization of computed vectors.\n - `p_vectorLength`: Sets the length of visualized vectors."
}