Back

MeshGmshLoader

sofa::component::io::mesh::MeshGmshLoader
MeshLoader
Doc (from source)

Specific mesh loader for Gmsh file format.

Abstract (AI generated)

The `MeshGmshLoader` loads mesh data from Gmsh files into SOFA simulations, parsing geometric and topological information for subsequent FEM-based simulations.

Metadata
module
Sofa.Component.IO.Mesh
namespace
sofa::component::io::mesh
include
sofa/component/io/mesh/MeshGmshLoader.h
inherits
  • MeshLoader
name
namespace
category
inheritsFrom
  • sofa::core::loader::MeshLoader
briefDescription
detailedDescription
methods
{
  "addInGroup(type::vector\u003c sofa::core::loader::PrimitiveGroup\u003e\u0026 group,int tag,int eid)": "This function adds an element with a given ID to a specified primitive group. It is used for organizing elements into groups that can be referenced in other parts of a SOFA simulation setup.",
  "doLoad()": "This method is overridden from the base class MeshLoader. It handles the core functionality of loading the mesh data by calling readGmsh with an open file stream and the Gmsh format version as arguments.",
  "normalizeGroup(type::vector\u003c sofa::core::loader::PrimitiveGroup\u003e\u0026 group)": "A utility method that processes and organizes the data within a primitive group, ensuring it\u0027s in a consistent form suitable for use by the rest of the simulation framework.",
  "readGmsh(std::ifstream \u0026file, const unsigned int gmshFormat)": "A helper function that parses a Gmsh .msh file according to its version. It handles both lower (2.x) and higher (4.x) formats of Gmsh files, reading the data into internal buffers."
}
usageExample
{
  "description": "To use MeshGmshLoader, one would typically include it as a component in a SOFA scene file. The following is an example of how to define and configure a MeshGmshLoader node within a SOFA .scn scene description:",
  "exampleCode": "\u003cNode name=\u0027meshLoader\u0027\u003e\n\t\u003cMeshGmshLoader filename=\u0027myMesh.msh\u0027/\u003e\n\u003c/Node\u003e"
}

The MeshGmshLoader is an IO component within the SOFA framework designed to load mesh data from Gmsh files. Its primary function is to parse and process geometric and topological information contained in .msh files, which are typically generated by the Gmsh pre-processing tool for finite element analysis (FEA). The loaded data includes various types of elements such as points, lines, triangles, quadrangles, tetrahedra, hexahedra, prisms, and their second-order counterparts. This component plays a crucial role in preparing the mesh for subsequent FEM-based simulations within SOFA.

Governing Equations or Operators Contributed:

  • Mesh Representation: The MeshGmshLoader does not directly contribute to governing equations such as mass matrix $M$, stiffness matrix $K$, internal force vector $m{f}_{ ext{int}}$, or residual vector $m{R}$. Instead, it focuses on generating the necessary mesh data that will be used in these operators during FEM simulations.

Constitutive Laws and Kinematic Measures:

  • Mesh Geometry: The component loads nodal coordinates (vertices) which form the basis for defining geometric elements such as edges, triangles, quadrilaterals, tetrahedra, hexahedra, etc. These elements are essential for spatial discretization in FEM simulations.
  • Element Types: It supports a variety of element types including linear and quadratic versions of lines, triangles, and tetrahedra. The geometry of these elements is described by their connectivity (nodal indices) and vertex positions $m{X}_i$.

Role in the Global FEM Pipeline:

  • Mesh Generation: During the mesh generation phase, MeshGmshLoader reads a Gmsh file and extracts nodal coordinates and element connectivities. It populates internal buffers with this information for later use.
  • Element Definition: The loaded mesh data is used to define elements in the scene graph of SOFA simulations. This includes setting up connectivity matrices that map node indices to elements, which are critical for assembling global stiffness and mass matrices during spatial discretization.

Numerical Methods or Discretization Choices:

  • File Parsing: The component employs parsing techniques specific to Gmsh file formats (version 2.x and 4.x) to read and interpret the content accurately. It processes different sections of a .msh file such as nodes, elements, and element groups.

Broad Variational / Lagrangian Mechanics Framework:

  • Mesh Initialization: The MeshGmshLoader initializes the mesh data required for variational formulations in FEM simulations. Specifically, it provides the nodal coordinates and connectivity information necessary to construct shape functions and evaluate weak forms of equilibrium equations.

Summary:

While the MeshGmshLoader itself does not directly implement governing physics or constitutive laws, its role is pivotal in preparing the mesh data that will be used throughout various stages of a FEM simulation pipeline. By accurately parsing and loading geometric and topological information from Gmsh files, it ensures that subsequent components can effectively utilize this data for spatial discretization, assembly of system matrices, and nonlinear solve steps.

Methods
bool doLoad () virtual
void doClearBuffers () virtual
bool readGmsh (int & file, const unsigned int gmshFormat)
void addInGroup (int & group, int tag, int eid)
void normalizeGroup (int & group)
{
  "name": "MeshGmshLoader",
  "namespace": "sofa::component::io::mesh",
  "module": "Sofa.Component.IO.Mesh",
  "include": "sofa/component/io/mesh/MeshGmshLoader.h",
  "doc": "Specific mesh loader for Gmsh file format.",
  "inherits": [
    "MeshLoader"
  ],
  "templates": [],
  "data_fields": [],
  "links": [],
  "methods": [
    {
      "name": "doLoad",
      "return_type": "bool",
      "params": [],
      "is_virtual": true,
      "is_pure_virtual": false,
      "is_static": false,
      "access": "public"
    },
    {
      "name": "doClearBuffers",
      "return_type": "void",
      "params": [],
      "is_virtual": true,
      "is_pure_virtual": false,
      "is_static": false,
      "access": "protected"
    },
    {
      "name": "readGmsh",
      "return_type": "bool",
      "params": [
        {
          "name": "file",
          "type": "int &"
        },
        {
          "name": "gmshFormat",
          "type": "const unsigned int"
        }
      ],
      "is_virtual": false,
      "is_pure_virtual": false,
      "is_static": false,
      "access": "protected"
    },
    {
      "name": "addInGroup",
      "return_type": "void",
      "params": [
        {
          "name": "group",
          "type": "int &"
        },
        {
          "name": "tag",
          "type": "int"
        },
        {
          "name": "eid",
          "type": "int"
        }
      ],
      "is_virtual": false,
      "is_pure_virtual": false,
      "is_static": false,
      "access": "protected"
    },
    {
      "name": "normalizeGroup",
      "return_type": "void",
      "params": [
        {
          "name": "group",
          "type": "int &"
        }
      ],
      "is_virtual": false,
      "is_pure_virtual": false,
      "is_static": false,
      "access": "protected"
    }
  ],
  "description": {
    "name": "MeshGmshLoader",
    "namespace": "sofa::component::io::mesh",
    "category": "IO",
    "inheritsFrom": [
      "sofa::core::loader::MeshLoader"
    ],
    "briefDescription": "The MeshGmshLoader is a component in the SOFA (Simulation Open-Framework Architecture) framework that loads mesh data from Gmsh files into a simulation.",
    "detailedDescription": "This class is designed to load geometric and topological information from .msh files, which are commonly used by the Gmsh pre-processing tool. The MeshGmshLoader reads the file content, processes it according to the Gmsh file format specifications, and converts this data into a form usable within SOFA's simulation framework. It supports both lower version (format 2.x) and higher version (format 4.x) Gmsh files.\n\nThe component is capable of loading point, line, triangle, quadrangle, tetrahedron, hexahedron, prism elements, as well as second-order versions of lines, triangles, and tetrahedrons. It also supports reading groups of primitives (edges, triangles, tetrahedra, hexahedra) for use in defining various simulation properties or constraints.\n\nInternally, the MeshGmshLoader maintains buffers to store edge, triangle, tetrahedron, quadrangle, and hexahedron data as well as high-order edge positions. It provides methods to add these elements into predefined groups which can be used later for specific purposes within the simulation.",
    "methods": {
      "doLoad()": "This method is overridden from the base class MeshLoader. It handles the core functionality of loading the mesh data by calling readGmsh with an open file stream and the Gmsh format version as arguments.",
      "readGmsh(std::ifstream &file, const unsigned int gmshFormat)": "A helper function that parses a Gmsh .msh file according to its version. It handles both lower (2.x) and higher (4.x) formats of Gmsh files, reading the data into internal buffers.",
      "addInGroup(type::vector< sofa::core::loader::PrimitiveGroup>& group,int tag,int eid)": "This function adds an element with a given ID to a specified primitive group. It is used for organizing elements into groups that can be referenced in other parts of a SOFA simulation setup.",
      "normalizeGroup(type::vector< sofa::core::loader::PrimitiveGroup>& group)": "A utility method that processes and organizes the data within a primitive group, ensuring it's in a consistent form suitable for use by the rest of the simulation framework."
    },
    "usageExample": {
      "description": "To use MeshGmshLoader, one would typically include it as a component in a SOFA scene file. The following is an example of how to define and configure a MeshGmshLoader node within a SOFA .scn scene description:",
      "exampleCode": "<Node name='meshLoader'>\n\t<MeshGmshLoader filename='myMesh.msh'/>\n</Node>"
    }
  },
  "maths": "The `MeshGmshLoader` is an IO component within the SOFA framework designed to load mesh data from Gmsh files. Its primary function is to parse and process geometric and topological information contained in `.msh` files, which are typically generated by the Gmsh pre-processing tool for finite element analysis (FEA). The loaded data includes various types of elements such as points, lines, triangles, quadrangles, tetrahedra, hexahedra, prisms, and their second-order counterparts. This component plays a crucial role in preparing the mesh for subsequent FEM-based simulations within SOFA.\n\n### Governing Equations or Operators Contributed:\n- **Mesh Representation:** The `MeshGmshLoader` does not directly contribute to governing equations such as mass matrix \\(M\\), stiffness matrix \\(K\\), internal force vector \\(\bm{f}_{\text{int}}\\), or residual vector \\(\bm{R}\\). Instead, it focuses on generating the necessary mesh data that will be used in these operators during FEM simulations.\n\n### Constitutive Laws and Kinematic Measures:\n- **Mesh Geometry:** The component loads nodal coordinates (vertices) which form the basis for defining geometric elements such as edges, triangles, quadrilaterals, tetrahedra, hexahedra, etc. These elements are essential for spatial discretization in FEM simulations.\n- **Element Types:** It supports a variety of element types including linear and quadratic versions of lines, triangles, and tetrahedra. The geometry of these elements is described by their connectivity (nodal indices) and vertex positions \\(\bm{X}_i\\).\n\n### Role in the Global FEM Pipeline:\n- **Mesh Generation:** During the **mesh generation** phase, `MeshGmshLoader` reads a Gmsh file and extracts nodal coordinates and element connectivities. It populates internal buffers with this information for later use.\n- **Element Definition:** The loaded mesh data is used to define elements in the scene graph of SOFA simulations. This includes setting up connectivity matrices that map node indices to elements, which are critical for assembling global stiffness and mass matrices during spatial discretization.\n\n### Numerical Methods or Discretization Choices:\n- **File Parsing:** The component employs parsing techniques specific to Gmsh file formats (version 2.x and 4.x) to read and interpret the content accurately. It processes different sections of a `.msh` file such as nodes, elements, and element groups.\n\n### Broad Variational / Lagrangian Mechanics Framework:\n- **Mesh Initialization:** The `MeshGmshLoader` initializes the mesh data required for variational formulations in FEM simulations. Specifically, it provides the nodal coordinates and connectivity information necessary to construct shape functions and evaluate weak forms of equilibrium equations.\n\n### Summary:\nWhile the `MeshGmshLoader` itself does not directly implement governing physics or constitutive laws, its role is pivotal in preparing the mesh data that will be used throughout various stages of a FEM simulation pipeline. By accurately parsing and loading geometric and topological information from Gmsh files, it ensures that subsequent components can effectively utilize this data for spatial discretization, assembly of system matrices, and nonlinear solve steps.",
  "abstract": "The `MeshGmshLoader` loads mesh data from Gmsh files into SOFA simulations, parsing geometric and topological information for subsequent FEM-based simulations.",
  "sheet": "# MeshGmshLoader\n\n## Overview\nThe `MeshGmshLoader` is an IO component in the SOFA framework designed to load mesh data from Gmsh files. It reads `.msh` files generated by the Gmsh pre-processing tool and processes them according to the Gmsh file format specifications, converting this data into a form usable within SOFA's simulation framework.\n\n## Practical Notes\nThe `MeshGmshLoader` supports both lower version (format 2.x) and higher version (format 4.x) Gmsh files. It is capable of loading various types of elements including points, lines, triangles, quadrangles, tetrahedra, hexahedra, prisms, and their second-order counterparts. This component ensures that the mesh data is accurately parsed and loaded for use in subsequent FEM-based simulations within SOFA."
}