Back

SphereGridTopology

sofa::component::topology::container::grid::SphereGridTopology
GridTopology
Doc (from source)

Sphere grid in 3D. Define a sphere grid topology Parameters are its @sa d_radius and discretisation . Position and direction are set by @sa d_center and @sa d_axis nz discretisation is along the sphere axis

Abstract (AI generated)

The `SphereGridTopology` component defines a spherical grid topology by specifying the sphere's center, axis direction, and radius. It generates points on the sphere's surface for use in various SOFA simulations.

Metadata
module
Sofa.Component.Topology.Container.Grid
namespace
sofa::component::topology::container::grid
include
sofa/component/topology/container/grid/SphereGridTopology.h
inherits
  • GridTopology
description

The SphereGridTopology component in the SOFA framework defines a spherical grid topology, which is used to discretize a sphere into a structured set of points for computational tasks. This component inherits from GridTopology, allowing it to provide a regular grid structure within the bounds of a specified sphere.

Governing Equations and Operators

  • Discretization: The component does not directly contribute to governing equations or operators such as mass matrix $ny$, stiffness matrix $nz$, internal force $(i, j, k)$, or residual $$ p = \begin{pmatrix} i\frac{2r}{nx-1} - r \\ j\frac{2r}{ny-1} - r \\ k\frac{2r}{nz-1} - r \end{pmatrix} $$. Instead, it provides the grid points that will be used by other components (e.g., mechanical models) for constructing these matrices and vectors.

Constitutive or Kinematic Laws Involved

  • Grid Generation: The sphere's discretization is parameterized by its radius ($p$), center position ($$ p_{\text{scaled}} = \frac{r}{\max(|p_x|, |p_y|, |p_z|)} \begin{pmatrix} p_x \\ p_y \\ p_z \end{pmatrix} $$), and axis direction ($$ P(i, j, k) = \mathbf{c} + (\mathbf{n}_x p_x + \mathbf{n}_y p_y + \mathbf{n}_z p_z) $$). Points within the grid are generated to lie on a spherical surface with these parameters.
  • Given grid resolution along each dimension wzxhzdk:7, $ny$, and $nz$, points $(i, j, k)$ are calculated as follows:

    $$ p = \begin{pmatrix} i\frac{2r}{nx-1} - r \\ j\frac{2r}{ny-1} - r \\ k\frac{2r}{nz-1} - r \end{pmatrix} $$
  • The point $p$ is then scaled to ensure it lies on the sphere's surface by normalizing and scaling with respect to the maximum coordinate value:

    $$ p_{\text{scaled}} = \frac{r}{\max(|p_x|, |p_y|, |p_z|)} \begin{pmatrix} p_x \\ p_y \\ p_z \end{pmatrix} $$
  • The final position of the point in global coordinates is given by:

    $$ P(i, j, k) = \mathbf{c} + (\mathbf{n}_x p_x + \mathbf{n}_y p_y + \mathbf{n}_z p_z) $$

Role in the Global FEM Pipeline

  • Assembly: The grid points generated by SphereGridTopology are used as input for assembling global matrices and vectors. Other components such as mechanical models (e.g., linear or nonlinear elasticity) will use these points to define their respective operators.
  • Time Integration: While this component does not directly handle time integration, the generated grid is essential for defining the nodal displacements that are updated during each time step of an FEM simulation.

Numerical Methods and Discretization Choices

  • The discretization of the sphere into a structured grid ensures uniform distribution of points within the spherical volume or surface. This method leverages Cartesian indices to generate points in a 3D space, which are then transformed to lie on the sphere's surface.

Fitting into Variational / Lagrangian Mechanics Framework

  • SphereGridTopology serves as a foundational element by providing the spatial discretization necessary for constructing variational formulations and finite element models. The grid points generated by this component will be used in subsequent steps of the simulation pipeline, such as weak form derivation, element operator construction, assembly of global matrices, and nonlinear solve.

In summary, SphereGridTopology plays a crucial role in defining the spatial structure for simulations involving spherical geometries within the SOFA framework.

Data Fields
NameTypeDefaultHelp
d_center type::Vec3 Center of the cylinder
d_axis type::Vec3 Main direction of the cylinder
d_radius SReal Radius of the cylinder
Methods
type::Vec3 getPoint (Index i) virtual
type::Vec3 getPointInGrid (int i, int j, int k) virtual
void setCenter (SReal x, SReal y, SReal z)
void setAxis (SReal x, SReal y, SReal z)
void setRadius (SReal radius)
{
  "name": "SphereGridTopology",
  "namespace": "sofa::component::topology::container::grid",
  "module": "Sofa.Component.Topology.Container.Grid",
  "include": "sofa/component/topology/container/grid/SphereGridTopology.h",
  "doc": "Sphere grid in 3D.\n\nDefine a sphere grid topology\nParameters are its @sa d_radius and discretisation .\nPosition and direction are set by @sa d_center and @sa d_axis\nnz discretisation is along the sphere axis",
  "inherits": [
    "GridTopology"
  ],
  "templates": [],
  "data_fields": [
    {
      "name": "d_center",
      "type": "type::Vec3",
      "xmlname": "center",
      "help": "Center of the cylinder"
    },
    {
      "name": "d_axis",
      "type": "type::Vec3",
      "xmlname": "axis",
      "help": "Main direction of the cylinder"
    },
    {
      "name": "d_radius",
      "type": "SReal",
      "xmlname": "radius",
      "help": "Radius of the cylinder"
    }
  ],
  "links": [],
  "methods": [
    {
      "name": "getPoint",
      "return_type": "type::Vec3",
      "params": [
        {
          "name": "i",
          "type": "Index"
        }
      ],
      "is_virtual": true,
      "is_pure_virtual": false,
      "is_static": false,
      "access": "public"
    },
    {
      "name": "getPointInGrid",
      "return_type": "type::Vec3",
      "params": [
        {
          "name": "i",
          "type": "int"
        },
        {
          "name": "j",
          "type": "int"
        },
        {
          "name": "k",
          "type": "int"
        }
      ],
      "is_virtual": true,
      "is_pure_virtual": false,
      "is_static": false,
      "access": "public"
    },
    {
      "name": "setCenter",
      "return_type": "void",
      "params": [
        {
          "name": "x",
          "type": "SReal"
        },
        {
          "name": "y",
          "type": "SReal"
        },
        {
          "name": "z",
          "type": "SReal"
        }
      ],
      "is_virtual": false,
      "is_pure_virtual": false,
      "is_static": false,
      "access": "public"
    },
    {
      "name": "setAxis",
      "return_type": "void",
      "params": [
        {
          "name": "x",
          "type": "SReal"
        },
        {
          "name": "y",
          "type": "SReal"
        },
        {
          "name": "z",
          "type": "SReal"
        }
      ],
      "is_virtual": false,
      "is_pure_virtual": false,
      "is_static": false,
      "access": "public"
    },
    {
      "name": "setRadius",
      "return_type": "void",
      "params": [
        {
          "name": "radius",
          "type": "SReal"
        }
      ],
      "is_virtual": false,
      "is_pure_virtual": false,
      "is_static": false,
      "access": "public"
    }
  ],
  "description": "The `SphereGridTopology` is a component in SOFA's topology module that defines a spherical grid topology in 3D space. It inherits from the `GridTopology` class, extending its functionality to generate a grid within the bounds of a sphere. This component allows for the specification of the sphere’s center (`d_center`), axis direction (`d_axis`), and radius (`d_radius`). The discretization parameters define how finely the sphere is divided into smaller segments along each dimension.\n\nThe `SphereGridTopology` interacts with other SOFA components by providing a structured grid representation that can be used in various simulations, such as FEM or collision detection. Its primary role is to generate and manage a spherical mesh for computational tasks within SOFA's simulation environment.\n\nPractical usage involves setting the parameters like center position, axis direction, and radius through methods `setCenter`, `setAxis`, and `setRadius`. The grid points are accessed via `getPoint` or `getPointInGrid`, which return positions in 3D space. These methods enable integration with other SOFA components that require spatial data structured as a spherical grid.",
  "maths": "The `SphereGridTopology` component in the SOFA framework defines a spherical grid topology, which is used to discretize a sphere into a structured set of points for computational tasks. This component inherits from `GridTopology`, allowing it to provide a regular grid structure within the bounds of a specified sphere.\n\n### Governing Equations and Operators\n- **Discretization**: The component does not directly contribute to governing equations or operators such as mass matrix $M$, stiffness matrix $K$, internal force $f_{\\text{int}}$, or residual $R$. Instead, it provides the grid points that will be used by other components (e.g., mechanical models) for constructing these matrices and vectors.\n\n### Constitutive or Kinematic Laws Involved\n- **Grid Generation**: The sphere's discretization is parameterized by its radius ($r$), center position ($\\mathbf{c}$), and axis direction ($\\mathbf{n}$). Points within the grid are generated to lie on a spherical surface with these parameters.\n  - Given grid resolution along each dimension $nx$, $ny$, and $nz$, points $(i, j, k)$ are calculated as follows:\n    \n    \\[ \n    p = \\begin{pmatrix} i\\frac{2r}{nx-1} - r \\\\ j\\frac{2r}{ny-1} - r \\\\ k\\frac{2r}{nz-1} - r \\end{pmatrix}\n    \\]\n\n  - The point $p$ is then scaled to ensure it lies on the sphere's surface by normalizing and scaling with respect to the maximum coordinate value:\n    \n    \\[ \n    p_{\\text{scaled}} = \\frac{r}{\\max(|p_x|, |p_y|, |p_z|)} \\begin{pmatrix} p_x \\\\ p_y \\\\ p_z \\end{pmatrix}\n    \\]\n\n  - The final position of the point in global coordinates is given by:\n    \n    \\[ \n    P(i, j, k) = \\mathbf{c} + (\\mathbf{n}_x p_x + \\mathbf{n}_y p_y + \\mathbf{n}_z p_z)\n    \\]\n\n### Role in the Global FEM Pipeline\n- **Assembly**: The grid points generated by `SphereGridTopology` are used as input for assembling global matrices and vectors. Other components such as mechanical models (e.g., linear or nonlinear elasticity) will use these points to define their respective operators.\n- **Time Integration**: While this component does not directly handle time integration, the generated grid is essential for defining the nodal displacements that are updated during each time step of an FEM simulation.\n\n### Numerical Methods and Discretization Choices\n- The discretization of the sphere into a structured grid ensures uniform distribution of points within the spherical volume or surface. This method leverages Cartesian indices to generate points in a 3D space, which are then transformed to lie on the sphere's surface.\n\n### Fitting into Variational / Lagrangian Mechanics Framework\n- `SphereGridTopology` serves as a foundational element by providing the spatial discretization necessary for constructing variational formulations and finite element models. The grid points generated by this component will be used in subsequent steps of the simulation pipeline, such as weak form derivation, element operator construction, assembly of global matrices, and nonlinear solve.\n\nIn summary, `SphereGridTopology` plays a crucial role in defining the spatial structure for simulations involving spherical geometries within the SOFA framework.",
  "abstract": "The `SphereGridTopology` component defines a spherical grid topology by specifying the sphere's center, axis direction, and radius. It generates points on the sphere's surface for use in various SOFA simulations.",
  "sheet": "# SphereGridTopology\n\n**Overview**\n\nThe `SphereGridTopology` component is responsible for defining a spherical grid topology within the SOFA framework. This component inherits from the `GridTopology` class and allows users to specify the center (`d_center`), axis direction (`d_axis`), and radius (`d_radius`) of the sphere. The generated points on the sphere's surface are used by other components in simulations.\n\n**Mathematical Model**\n\nThe grid points within the spherical topology are generated based on the specified parameters:\n- **Center**: \\\\( \\mathbf{c} = (x_c, y_c, z_c) \\\\)\n- **Axis Direction**: \\\\( \\mathbf{n} = (n_x, n_y, n_z) \\\\)\n- **Radius**: \\\\( r \\\\\n\nGiven the grid resolution along each dimension \\\\( nx \\\\), \\\\( ny \\\\), and \\\\( nz \\\\), points \\\\( p(i, j, k) \\\\) are calculated as follows:\n\n\\[\np = \\begin{pmatrix} i\\frac{2r}{nx-1} - r \\\\ j\\frac{2r}{ny-1} - r \\\\ k\\frac{2r}{nz-1} - r \\end{pmatrix}\n\\]\n\nThe point \\\\( p \\\\) is then scaled to ensure it lies on the sphere's surface by normalizing and scaling with respect to the maximum coordinate value:\n\n\\[\np_{\\text{scaled}} = \\frac{r}{\\max(|p_x|, |p_y|, |p_z|)} \\begin{pmatrix} p_x \\\\ p_y \\\\ p_z \\end{pmatrix}\n\\]\n\nThe final position of the point in global coordinates is given by:\n\n\\[\nP(i, j, k) = \\mathbf{c} + (n_x p_x + n_y p_y + n_z p_z)\n\\]\n\n**Parameters and Data**\n\n- **d_center**: Center of the sphere (`type::Vec3`), default not specified.\n- **d_axis**: Axis direction of the sphere (`type::Vec3`), default not specified.\n- **d_radius**: Radius of the sphere (`SReal`), default not specified."
}