Back

BarycentricMapperRegularGridTopology

The `BarycentricMapperRegularGridTopology` is a SOFA component in the `sofa::component::mapping::linear` namespace, designed for barycentric mapping computation on a `RegularGridTopology`. It inherits from `TopologyBarycentricMapper`, enabling it to perform barycentric mappings where points are defined within a grid of cubes. The class handles operations like resizing, clearing, and initializing the mapping based on input coordinates. It supports various methods for applying the mapping (`apply`), computing Jacobian matrices (`getJ`), and drawing visual representations of the mapping. The component also manages updates to the Jacobian matrix and provides functionalities for adding points within cubes in the grid topology. This class is particularly useful when dealing with simulations that require fine-grained control over the spatial distribution and transformation of points on a structured grid.

abstract
The `BarycentricMapperRegularGridTopology` performs barycentric mapping computations on a regular grid topology, enabling spatial transformations within structured grids.
sheet
<h1>BarycentricMapperRegularGridTopology</h1> <h2>Overview</h2> <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> <h2>Mathematical Model</h2> <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> \[ J = \frac{\partial f}{\partial x} \] <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> <h2>Dependencies and Connections</h2> <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>
description
The `BarycentricMapperRegularGridTopology` is a SOFA component in the `sofa::component::mapping::linear` namespace, designed for barycentric mapping computation on a `RegularGridTopology`. It inherits from `TopologyBarycentricMapper`, enabling it to perform barycentric mappings where points are defined within a grid of cubes. The class handles operations like resizing, clearing, and initializing the mapping based on input coordinates. It supports various methods for applying the mapping (`apply`), computing Jacobian matrices (`getJ`), and drawing visual representations of the mapping. The component also manages updates to the Jacobian matrix and provides functionalities for adding points within cubes in the grid topology. This class is particularly useful when dealing with simulations that require fine-grained control over the spatial distribution and transformation of points on a structured grid.
title
Mathematical and Physical Description of BarycentricMapperRegularGridTopology Component
description
{
  "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.",
  "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."
  },
  "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."
  }
}
{
  "name": "BarycentricMapperRegularGridTopology",
  "main": {
    "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"
      }
    ]
  },
  "desc": {
    "description": "The `BarycentricMapperRegularGridTopology` is a SOFA component in the `sofa::component::mapping::linear` namespace, designed for barycentric mapping computation on a `RegularGridTopology`. It inherits from `TopologyBarycentricMapper`, enabling it to perform barycentric mappings where points are defined within a grid of cubes. The class handles operations like resizing, clearing, and initializing the mapping based on input coordinates. It supports various methods for applying the mapping (`apply`), computing Jacobian matrices (`getJ`), and drawing visual representations of the mapping. The component also manages updates to the Jacobian matrix and provides functionalities for adding points within cubes in the grid topology. This class is particularly useful when dealing with simulations that require fine-grained control over the spatial distribution and transformation of points on a structured grid."
  },
  "maths": {
    "title": "Mathematical and Physical Description of BarycentricMapperRegularGridTopology Component",
    "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."
    }
  },
  "summary": {
    "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>"
  }
}