Back

Topology

sofa::core::topology::Topology
BaseObject
Abstract (AI generated)

The `Topology` class manages mesh topology in SOFA simulations by defining geometric elements and their connectivity, facilitating insertion/removal of topology information from nodes.

Metadata
module
Sofa.framework.Core
namespace
sofa::core::topology
include
sofa/core/topology/Topology.h
inherits
  • BaseObject
description
The `MeanComputation` component in the SOFA framework is designed to compute the mean of input coordinate vectors from multiple mechanical objects within a simulation environment. This component performs an averaging operation on the coordinates provided by various mechanical objects, which can be useful for scenarios such as processing sensor data or averaging deformation states in soft tissue models.

Governing Equations and Operators

  • Input Vectors: The MeanComputation component takes multiple coordinate vectors \$\text{edgesInTetrahedronArray}[6][2] = {{0,1}, {0,2}, {0,3}, {1,2}, {1,3}, {2,3}}$ from different MechanicalObject instances within its context. These coordinates represent the positions of points or nodes in a mechanical system.

  • Mean Computation: The mean vector \$\text{trianglesOrientationInTetrahedronArray}[4][3] = {{1,2,3}, {0,3,2}, {1,3,0}, {0,2,1}}$ is computed as the average of all input vectors:

    $(X_i, Y_i, Z_i)$


where \$\text{edgesInHexahedronArray}[12][2] = {{0,1},{0,3},{0,4},{1,2},{1,5},{2,3},{2,6},{3,7},{4,5},{4,7},{5,6},{6,7}}$ is the number of input vectors.
- Output Vector: The result of this computation, \$\text{quadsOrientationInHexahedronArray}[6][4] = {{0,3,2,1}, {4,5,6,7}, {0,1,5,4}, {1,2,6,5}, {2,3,7,6}, {3,0,4,7}}$, is stored in the d_result data field as a vector of coordinates (VecCoord).

Constitutive or Kinematic Laws Involved


The component does not directly involve any constitutive laws (such as stress-strain relationships) or kinematic laws (such as deformation gradients). Instead, it focuses on simple arithmetic averaging of coordinate vectors.

Role in the Global FEM Pipeline



  • init()): During initialization, the component identifies and collects position data from all MechanicalObject instances within its context that do not have the


Methods
const Topology * toTopology () virtual
bool insertInNode (objectmodel::BaseNode * node) virtual
bool removeInNode (objectmodel::BaseNode * node) virtual
bool hasPos () virtual
int getNbPoints ()
void setNbPoints (int ) virtual
SReal getPX (Index ) virtual
SReal getPY (Index ) virtual
SReal getPZ (Index ) virtual
{
  "name": "Topology",
  "namespace": "sofa::core::topology",
  "module": "Sofa.framework.Core",
  "include": "sofa/core/topology/Topology.h",
  "doc": "",
  "inherits": [
    "BaseObject"
  ],
  "templates": [],
  "data_fields": [],
  "links": [],
  "methods": [
    {
      "name": "toTopology",
      "return_type": "const Topology *",
      "params": [],
      "is_virtual": true,
      "is_pure_virtual": false,
      "is_static": false,
      "access": "public"
    },
    {
      "name": "insertInNode",
      "return_type": "bool",
      "params": [
        {
          "name": "node",
          "type": "objectmodel::BaseNode *"
        }
      ],
      "is_virtual": true,
      "is_pure_virtual": false,
      "is_static": false,
      "access": "public"
    },
    {
      "name": "removeInNode",
      "return_type": "bool",
      "params": [
        {
          "name": "node",
          "type": "objectmodel::BaseNode *"
        }
      ],
      "is_virtual": true,
      "is_pure_virtual": false,
      "is_static": false,
      "access": "public"
    },
    {
      "name": "hasPos",
      "return_type": "bool",
      "params": [],
      "is_virtual": true,
      "is_pure_virtual": false,
      "is_static": false,
      "access": "public"
    },
    {
      "name": "getNbPoints",
      "return_type": "int",
      "params": [],
      "is_virtual": false,
      "is_pure_virtual": false,
      "is_static": false,
      "access": "public"
    },
    {
      "name": "setNbPoints",
      "return_type": "void",
      "params": [
        {
          "name": "",
          "type": "int"
        }
      ],
      "is_virtual": true,
      "is_pure_virtual": false,
      "is_static": false,
      "access": "public"
    },
    {
      "name": "getPX",
      "return_type": "SReal",
      "params": [
        {
          "name": "",
          "type": "Index"
        }
      ],
      "is_virtual": true,
      "is_pure_virtual": false,
      "is_static": false,
      "access": "public"
    },
    {
      "name": "getPY",
      "return_type": "SReal",
      "params": [
        {
          "name": "",
          "type": "Index"
        }
      ],
      "is_virtual": true,
      "is_pure_virtual": false,
      "is_static": false,
      "access": "public"
    },
    {
      "name": "getPZ",
      "return_type": "SReal",
      "params": [
        {
          "name": "",
          "type": "Index"
        }
      ],
      "is_virtual": true,
      "is_pure_virtual": false,
      "is_static": false,
      "access": "public"
    }
  ],
  "description": "The `Topology` class in the SOFA framework is part of the core topology management system and inherits from `BaseObject`. It is primarily used for compatibility reasons, particularly with older components like `BaseMeshTopology`. The primary role of the `Topology` class is to define geometric elements (points, edges, triangles, tetrahedrons, etc.) and manage their relationships within a simulation scene. This class provides methods to insert and remove topology information from nodes (`insertInNode`, `removeInNode`). It also includes virtual methods for accessing position data such as the number of points (`getNbPoints`), setting the number of points (`setNbPoints`), and retrieving X, Y, Z coordinates for specific indices (`getPX`, `getPY`, `getPZ`). The class also handles various geometric elements such as edges, triangles, tetrahedrons, prisms, pyramids, and hexahedra. It contains constants and arrays that define the connectivity of these elements (e.g., edge lists in tetrahedrons and hexahedrons). Overall, `Topology` serves as a base class for defining and managing mesh topology within SOFA simulations.",
  "maths": "The `Topology` class in the SOFA framework is a fundamental component for managing mesh topology within simulations. It serves primarily as a compatibility layer and base class, defining geometric elements such as points, edges, triangles, tetrahedrons, prisms, pyramids, and hexahedra. The role of this class is to define and maintain connectivity information between these elements in the simulation scene.\n\n### Mathematical Description\n\n1. **Geometric Elements**:\n   - **Points**: Represent individual vertices in the mesh. Each point has coordinates \\((X_i, Y_i, Z_i)\\).\n   - **Edges**: Line segments connecting two points. For example, a tetrahedron (4-point simplex) has 6 edges defined by pairs of vertex indices.\n   - **Triangles**: Planar polygons with three vertices. A tetrahedron has 4 triangular faces.\n   - **Tetrahedrons**: Four-sided polyhedra defined by four points. Tetrahedrons are commonly used in finite element analysis due to their ability to accurately represent curved surfaces and volumes.\n   - **Hexahedra (Cubes)**: Six-faced polyhedra defined by eight vertices, often used for structured grids.\n\n2. **Connectivity Information**:\n   - The `Topology` class defines arrays that store connectivity information such as the edges of a tetrahedron and hexahedron, triangles within a tetrahedron, and quadrilaterals within a hexahedron. For example:\n     \n     - Edges in a tetrahedron are defined by pairs of vertex indices: \\(\\text{edgesInTetrahedronArray}[6][2] = {{0,1}, {0,2}, {0,3}, {1,2}, {1,3}, {2,3}}\\).\n     - Triangles in a tetrahedron are defined by triples of vertex indices: \\(\\text{trianglesOrientationInTetrahedronArray}[4][3] = {{1,2,3}, {0,3,2}, {1,3,0}, {0,2,1}}\\).\n     - Edges in a hexahedron are defined by pairs of vertex indices: \\(\\text{edgesInHexahedronArray}[12][2] = {{0,1},{0,3},{0,4},{1,2},{1,5},{2,3},{2,6},{3,7},{4,5},{4,7},{5,6},{6,7}}\\).\n     - Quadrilaterals in a hexahedron are defined by quadruples of vertex indices: \\(\\text{quadsOrientationInHexahedronArray}[6][4] = {{0,3,2,1}, {4,5,6,7}, {0,1,5,4}, {1,2,6,5}, {2,3,7,6}, {3,0,4,7}}\\).\n     - Vertices in a hexahedron are defined by sets of vertex indices: \\(\\text{verticesInHexahedronArray}[2][2][2] = {{\\{0,4\\}, \\{3,7\\}}, {\\{1,5\\}, \\{2,6\\}}}\\).\n\n### Role in the Global FEM Pipeline\n\nThe `Topology` class primarily contributes to the **discretization phase** of the Finite Element Method (FEM) simulation pipeline. It is responsible for defining and managing the mesh topology, which includes:\n\n- Defining geometric elements and their connectivity.\n- Managing the insertion (`insertInNode`) and removal (`removeInNode`) of topology information from nodes in the scene graph.\n- Providing methods to access position data such as the number of points (`getNbPoints`), setting the number of points (`setNbPoints`), and retrieving coordinates for specific indices (`getPX`, `getPY`, `getPZ`).\n\nThese methods are crucial for assembling global matrices (mass matrix \\(M\\) and stiffness matrix \\(K\\)) during the discretization phase, as well as for handling constraints and mappings in the nonlinear solve stage.\n\n### Numerical Methods and Discretization Choices\n\nThe `Topology` class does not directly implement numerical methods or solvers. Instead, it provides the necessary connectivity information required by other components that perform spatial discretization, such as the shape function evaluation and element operator assembly. This ensures consistency in the representation of the mesh and facilitates accurate finite element analysis.\n\n### Variational / Lagrangian Mechanics Framework\n\nWithin the broader variational and Lagrangian mechanics framework, the `Topology` class ensures that the geometric structure is correctly defined to support weak formulations (e.g., deriving the internal force \\(f_{\\text{int}}\\) and stiffness matrix \\(K_e\\)) and spatial discretization. The connectivity information provided by this class is essential for defining shape functions and integrating over elements, which are critical steps in transforming strong forms of partial differential equations into weak forms suitable for numerical solution.\n\n### Conclusion\n\nThe `Topology` class plays a foundational role in the SOFA framework by managing mesh topology and providing necessary geometric connectivity information. It does not directly contribute to specific FEM operators or solvers but is essential for ensuring that the discretization phase of the simulation pipeline is correctly implemented.",
  "abstract": "The `Topology` class manages mesh topology in SOFA simulations by defining geometric elements and their connectivity, facilitating insertion/removal of topology information from nodes.",
  "sheet": "# Topology\n\n**Overview**\n\nThe `Topology` class is a fundamental component for managing mesh topology within SOFA simulations. It defines geometric elements such as points, edges, triangles, tetrahedrons, prisms, pyramids, and hexahedra, along with their connectivity information. This class provides methods to insert (`insertInNode`) and remove (`removeInNode`) topology information from nodes in the scene graph, ensuring that the mesh structure is correctly defined for subsequent simulation stages.\n\n**Dependencies and Connections**\n\nThe `Topology` class typically requires or exchanges data with other components such as `BaseMeshTopology`, which handles more specific topological operations. It fits into the SOFA scene graph by managing the insertion and removal of topology information from nodes, ensuring consistency in mesh representation across different simulation stages."
}