Back

BarycentricMapperRegularGridTopology

sofa::component::mapping::linear::BarycentricMapperRegularGridTopology
TopologyBarycentricMapper
Doc (from source)

Class allowing barycentric mapping computation on a RegularGridTopology

Abstract (AI generated)

The `BarycentricMapperRegularGridTopology` performs barycentric mapping computations on a regular grid topology, enabling spatial transformations within structured grids.

Metadata
module
Sofa.Component.Mapping.Linear
namespace
sofa::component::mapping::linear
include
sofa/component/mapping/linear/BarycentricMappers/BarycentricMapperRegularGridTopology.h
inherits
  • TopologyBarycentricMapper
templates
  • sofa::defaulttype::Vec3Types, sofa::defaulttype::Vec3Types
introduction
mathematical_formulation
{
  "barycentric_coordinates": "Barycentric coordinates represent the position of a point within a simplex (such as a triangle or tetrahedron) relative to its vertices. Given a set of points \\(V = {v_1, v_2, ..., v_n}\\) in an n-dimensional space and their corresponding barycentric weights \\(\beta_i\\), the position of a point \\(P\\) within this simplex can be expressed as: \n\n\begin{equation}\n    P = \\sum_{i=1}^n \beta_i v_i, \n\text{ where } \beta_i \\geq 0 \\text{ and } \\sum_{i=1}^n \beta_i = 1.\n\\end{equation}",
  "grid_topology": "A `RegularGridTopology` defines a structured grid composed of cubes (cells) in a three-dimensional space. Each cube has vertices, edges, faces, and the entire structure is indexed systematically.",
  "point_mapping": "Mapping points within a regular grid involves computing their barycentric coordinates relative to the vertices of the enclosing cube. Given a point \\(P\\) inside a cube with vertices \\(\textbf{V} = {v_1, v_2, ..., v_8}\\), its position can be written as: \n\n\begin{equation}\n    P = \\sum_{i=1}^8 b_i v_i,\n\\end{equation}\nwhere \\(b_i\\) are the barycentric coordinates and satisfy \\(\textbf{b}_1 + \textbf{b}_2 + ... + \textbf{b}_8 = 1.\n"
}
physical_interpretation
{
  "finite_element_simulation": "In finite element simulations, each point within the grid can represent a node or control point in the simulation domain. Barycentric coordinates provide a natural way to interpolate and extrapolate physical properties (such as displacement, velocity) from known vertices of the cubes.",
  "interpolation": "The barycentric interpolation is used to compute the value at an arbitrary point within the cube using the values at its vertices. For example, if \\(u_i\\) are the displacements at each vertex, then the interpolated displacement at point \\(P\\) inside the cube can be computed as: \n\n\begin{equation}\n    u_P = \\sum_{i=1}^8 b_i u_i.\n\\end{equation}",
  "transformation": "This mapping enables transformations such as deformation and translation by modifying the positions of vertices and then interpolating these changes to all points within the cubes. The Jacobian matrix, representing the derivative of this transformation, is used for calculating forces and other physical quantities in simulations."
}
implementation_details
{
  "data_structures": "The class maintains a list (`m_map`) of `CubeData` objects that store information about each cube in the grid topology. Each entry contains barycentric coordinates for points within cubes, facilitating efficient lookups and updates.",
  "methods_and_functions": "The `BarycentricMapperRegularGridTopology` class implements several methods:\n- **init:** Initializes the mapping based on input coordinates.\n- **apply:** Applies the barycentric mapping to compute new positions for points in the grid topology.\n- **draw:** Visualizes the mapping, useful for debugging and understanding the spatial relationships.\n- **getJ:** Computes the Jacobian matrix representing the derivative of the mapping."
}
conclusion
No maths data.
Methods
void clear (int reserve)
void resize (core::State<Out> * toModel)
bool isEmpty () virtual
void setTopology (topology::container::grid::RegularGridTopology * _topology) virtual
RegularGridTopology * getTopology ()
int addPointInCube (const int cubeIndex, const SReal * baryCoords)
void init (const typename Out::VecCoord & out, const typename In::VecCoord & in)
void draw (const core::visual::VisualParams * , const typename Out::VecCoord & out, const typename In::VecCoord & in)
void apply (typename Out::VecCoord & out, const typename In::VecCoord & in)
void applyJ (typename Out::VecDeriv & out, const typename In::VecDeriv & in)
void applyJT (typename In::VecDeriv & out, const typename Out::VecDeriv & in)
void applyJT (typename In::MatrixDeriv & out, const typename Out::MatrixDeriv & in)
const BaseMatrix * getJ (int outSize, int inSize)
{
  "name": "BarycentricMapperRegularGridTopology",
  "namespace": "sofa::component::mapping::linear",
  "module": "Sofa.Component.Mapping.Linear",
  "include": "sofa/component/mapping/linear/BarycentricMappers/BarycentricMapperRegularGridTopology.h",
  "doc": "Class allowing barycentric mapping computation on a RegularGridTopology",
  "inherits": [
    "TopologyBarycentricMapper"
  ],
  "templates": [
    "sofa::defaulttype::Vec3Types, sofa::defaulttype::Vec3Types"
  ],
  "data_fields": [],
  "links": [],
  "methods": [
    {
      "name": "clear",
      "return_type": "void",
      "params": [
        {
          "name": "reserve",
          "type": "int"
        }
      ],
      "is_virtual": false,
      "is_pure_virtual": false,
      "is_static": false,
      "access": "public"
    },
    {
      "name": "resize",
      "return_type": "void",
      "params": [
        {
          "name": "toModel",
          "type": "core::State<Out> *"
        }
      ],
      "is_virtual": false,
      "is_pure_virtual": false,
      "is_static": false,
      "access": "public"
    },
    {
      "name": "isEmpty",
      "return_type": "bool",
      "params": [],
      "is_virtual": true,
      "is_pure_virtual": false,
      "is_static": false,
      "access": "public"
    },
    {
      "name": "setTopology",
      "return_type": "void",
      "params": [
        {
          "name": "_topology",
          "type": "topology::container::grid::RegularGridTopology *"
        }
      ],
      "is_virtual": true,
      "is_pure_virtual": false,
      "is_static": false,
      "access": "public"
    },
    {
      "name": "getTopology",
      "return_type": "RegularGridTopology *",
      "params": [],
      "is_virtual": false,
      "is_pure_virtual": false,
      "is_static": false,
      "access": "public"
    },
    {
      "name": "addPointInCube",
      "return_type": "int",
      "params": [
        {
          "name": "cubeIndex",
          "type": "const int"
        },
        {
          "name": "baryCoords",
          "type": "const SReal *"
        }
      ],
      "is_virtual": false,
      "is_pure_virtual": false,
      "is_static": false,
      "access": "public"
    },
    {
      "name": "init",
      "return_type": "void",
      "params": [
        {
          "name": "out",
          "type": "const typename Out::VecCoord &"
        },
        {
          "name": "in",
          "type": "const typename In::VecCoord &"
        }
      ],
      "is_virtual": false,
      "is_pure_virtual": false,
      "is_static": false,
      "access": "public"
    },
    {
      "name": "draw",
      "return_type": "void",
      "params": [
        {
          "name": "",
          "type": "const core::visual::VisualParams *"
        },
        {
          "name": "out",
          "type": "const typename Out::VecCoord &"
        },
        {
          "name": "in",
          "type": "const typename In::VecCoord &"
        }
      ],
      "is_virtual": false,
      "is_pure_virtual": false,
      "is_static": false,
      "access": "public"
    },
    {
      "name": "apply",
      "return_type": "void",
      "params": [
        {
          "name": "out",
          "type": "typename Out::VecCoord &"
        },
        {
          "name": "in",
          "type": "const typename In::VecCoord &"
        }
      ],
      "is_virtual": false,
      "is_pure_virtual": false,
      "is_static": false,
      "access": "public"
    },
    {
      "name": "applyJ",
      "return_type": "void",
      "params": [
        {
          "name": "out",
          "type": "typename Out::VecDeriv &"
        },
        {
          "name": "in",
          "type": "const typename In::VecDeriv &"
        }
      ],
      "is_virtual": false,
      "is_pure_virtual": false,
      "is_static": false,
      "access": "public"
    },
    {
      "name": "applyJT",
      "return_type": "void",
      "params": [
        {
          "name": "out",
          "type": "typename In::VecDeriv &"
        },
        {
          "name": "in",
          "type": "const typename Out::VecDeriv &"
        }
      ],
      "is_virtual": false,
      "is_pure_virtual": false,
      "is_static": false,
      "access": "public"
    },
    {
      "name": "applyJT",
      "return_type": "void",
      "params": [
        {
          "name": "out",
          "type": "typename In::MatrixDeriv &"
        },
        {
          "name": "in",
          "type": "const typename Out::MatrixDeriv &"
        }
      ],
      "is_virtual": false,
      "is_pure_virtual": false,
      "is_static": false,
      "access": "public"
    },
    {
      "name": "getJ",
      "return_type": "const BaseMatrix *",
      "params": [
        {
          "name": "outSize",
          "type": "int"
        },
        {
          "name": "inSize",
          "type": "int"
        }
      ],
      "is_virtual": false,
      "is_pure_virtual": false,
      "is_static": false,
      "access": "public"
    }
  ],
  "description": {
    "introduction": "The `BarycentricMapperRegularGridTopology` class in the SOFA framework is designed to compute mappings between points in a regular grid topology using barycentric coordinates. This component facilitates transformations and computations on structured grids, which are common in finite element simulations.",
    "mathematical_formulation": {
      "barycentric_coordinates": "Barycentric coordinates represent the position of a point within a simplex (such as a triangle or tetrahedron) relative to its vertices. Given a set of points \\(V = {v_1, v_2, ..., v_n}\\) in an n-dimensional space and their corresponding barycentric weights \\(\beta_i\\), the position of a point \\(P\\) within this simplex can be expressed as: \n\n\begin{equation}\n    P = \\sum_{i=1}^n \beta_i v_i, \n\text{ where } \beta_i \\geq 0 \\text{ and } \\sum_{i=1}^n \beta_i = 1.\n\\end{equation}",
      "grid_topology": "A `RegularGridTopology` defines a structured grid composed of cubes (cells) in a three-dimensional space. Each cube has vertices, edges, faces, and the entire structure is indexed systematically.",
      "point_mapping": "Mapping points within a regular grid involves computing their barycentric coordinates relative to the vertices of the enclosing cube. Given a point \\(P\\) inside a cube with vertices \\(\textbf{V} = {v_1, v_2, ..., v_8}\\), its position can be written as: \n\n\begin{equation}\n    P = \\sum_{i=1}^8 b_i v_i,\n\\end{equation}\nwhere \\(b_i\\) are the barycentric coordinates and satisfy \\(\textbf{b}_1 + \textbf{b}_2 + ... + \textbf{b}_8 = 1.\n"
    },
    "physical_interpretation": {
      "finite_element_simulation": "In finite element simulations, each point within the grid can represent a node or control point in the simulation domain. Barycentric coordinates provide a natural way to interpolate and extrapolate physical properties (such as displacement, velocity) from known vertices of the cubes.",
      "interpolation": "The barycentric interpolation is used to compute the value at an arbitrary point within the cube using the values at its vertices. For example, if \\(u_i\\) are the displacements at each vertex, then the interpolated displacement at point \\(P\\) inside the cube can be computed as: \n\n\begin{equation}\n    u_P = \\sum_{i=1}^8 b_i u_i.\n\\end{equation}",
      "transformation": "This mapping enables transformations such as deformation and translation by modifying the positions of vertices and then interpolating these changes to all points within the cubes. The Jacobian matrix, representing the derivative of this transformation, is used for calculating forces and other physical quantities in simulations."
    },
    "implementation_details": {
      "methods_and_functions": "The `BarycentricMapperRegularGridTopology` class implements several methods:\n- **init:** Initializes the mapping based on input coordinates.\n- **apply:** Applies the barycentric mapping to compute new positions for points in the grid topology.\n- **draw:** Visualizes the mapping, useful for debugging and understanding the spatial relationships.\n- **getJ:** Computes the Jacobian matrix representing the derivative of the mapping.",
      "data_structures": "The class maintains a list (`m_map`) of `CubeData` objects that store information about each cube in the grid topology. Each entry contains barycentric coordinates for points within cubes, facilitating efficient lookups and updates."
    },
    "conclusion": "In summary, the `BarycentricMapperRegularGridTopology` component provides a powerful tool for simulating physical phenomena on structured grids using barycentric mappings. It enables precise control over point positions and supports various operations necessary for finite element simulations, including interpolation, transformation, and visualization."
  },
  "title": "Mathematical and Physical Description of BarycentricMapperRegularGridTopology Component",
  "abstract": "The `BarycentricMapperRegularGridTopology` performs barycentric mapping computations on a regular grid topology, enabling spatial transformations within structured grids.",
  "sheet": "<h1>BarycentricMapperRegularGridTopology</h1>\n\n<h2>Overview</h2>\n<p>The <code>BarycentricMapperRegularGridTopology</code> is a SOFA component that handles barycentric mapping computations on a regular grid topology. It inherits from the <code>TopologyBarycentricMapper</code>, providing functionalities for resizing, clearing, initializing mappings, and applying transformations within structured grids.</p>\n\n<h2>Mathematical Model</h2>\n<p>The component computes barycentric coordinates for points within a grid of cubes. The mapping is defined by the Jacobian matrix <span class=\"math inline\">\\(J\\)</span>, which relates input and output coordinates:</p>\n\\[ J = \\frac{\\partial f}{\\partial x} \\]\n<p>where <span class=\"math inline\">\\(f\\)</span> represents the mapping function, and <span class=\"math inline\">\\(x\\)</span> are the input coordinates. The Jacobian matrix is used to apply the mapping (<code>apply</code>) and its transpose (<code>applyJT</code>). The component also supports drawing visual representations of the mapping.</p>\n\n<h2>Dependencies and Connections</h2>\n<p>The <code>BarycentricMapperRegularGridTopology</code> typically requires a <code>RegularGridTopology</code> to define the grid structure. It exchanges data with other components that handle input coordinates (<span class=\"math inline\">\\(in\\)</span>) and output coordinates (<span class=\"math inline\">\\(out\\)</span>). The component fits into the scene graph by providing mappings between different levels of detail or spatial transformations within a structured grid.</p>"
}