Back

SingleStateAccessor

sofa::core::behavior::SingleStateAccessor
Doc (from source)

Base class for components having access to one mechanical state with a specific template parameter, in order to read and/or write state variables.

Abstract (AI generated)

`SingleStateAccessor` provides access to one specific mechanical state for derived components in SOFA simulations. It ensures type-safe interaction with the mechanical states through its initialization and linking methods.

Metadata
module
Sofa.framework.Core
namespace
sofa::core::behavior
include
sofa/core/behavior/SingleStateAccessor.h
templates
  • sofa::defaulttype::Rigid2Types
  • sofa::defaulttype::Rigid3Types
  • sofa::defaulttype::Vec1Types
description

MeshOBJLoader is a component within the Sofa framework responsible for loading 3D geometry data from OBJ files, which are commonly used to represent and exchange 3D models. The OBJ format includes vertex positions, texture coordinates (UVs), normals, and face definitions, supporting edges, triangles, and quads. This description does not contain significant mathematical or physical content as it primarily serves the role of reading geometric data from files without involving governing equations, constitutive laws, or numerical methods used in FEM simulations. Therefore, its role is mainly to provide initial geometry and material information for further processing by other Sofa components involved in mechanical simulation.

Key Features:

  • Customization Options: Users can customize how the loader processes UV seams and material loading. If vertices have multiple normals or texture coordinates, it separates them into distinct vertices with the help of d_vertPosIdx and d_vertNormIdx fields.
  • Visualization Support: The component allows exporting face indices per material via the d_computeMaterialFaces option for creating subsets used in visualization.

Role in the FEM Pipeline:

MeshOBJLoader plays a preparatory role by providing initial geometric data (vertices, faces) and material properties. This data is then utilized by other Sofa components such as mesh generators, mechanical object definitions, and force fields to build the finite element model for simulation.

Numerical Methods:

The component does not involve numerical methods or discretization choices but rather focuses on accurately parsing text-based 3D geometry data into a structured format suitable for further processing within the Sofa framework.

Links
NameTypeHelp
mstate MechanicalState used by this component
Methods
void init () virtual
MechanicalState<DataTypes> * getMState ()
{
  "name": "SingleStateAccessor",
  "namespace": "sofa::core::behavior",
  "module": "Sofa.framework.Core",
  "include": "sofa/core/behavior/SingleStateAccessor.h",
  "doc": "Base class for components having access to one mechanical state with a specific template parameter, in order to read\nand/or write state variables.",
  "inherits": [],
  "templates": [
    "sofa::defaulttype::Rigid2Types",
    "sofa::defaulttype::Rigid3Types",
    "sofa::defaulttype::Vec1Types"
  ],
  "data_fields": [],
  "links": [
    {
      "name": "mstate",
      "target": "MechanicalState<DataTypes>",
      "kind": "single",
      "xmlname": "mstate",
      "help": "MechanicalState used by this component"
    }
  ],
  "methods": [
    {
      "name": "init",
      "return_type": "void",
      "params": [],
      "is_virtual": true,
      "is_pure_virtual": false,
      "is_static": false,
      "access": "public"
    },
    {
      "name": "getMState",
      "return_type": "MechanicalState<DataTypes> *",
      "params": [],
      "is_virtual": false,
      "is_pure_virtual": false,
      "is_static": false,
      "access": "public"
    }
  ],
  "description": "The `SingleStateAccessor` class in the SOFA framework is a base class for components that need to access one specific mechanical state, typically to read and/or write state variables. It inherits from the `StateAccessor` class and is templated with data types such as rigid 2D/3D or vector types. The component contains a link named `mstate`, which points to a `MechanicalState` of the same template type. This allows `SingleStateAccessor` components to interact directly with mechanical states within their context.\n\nThe main methods include an abstract `init()` method, overridden by derived classes for initialization, and non-virtual `getMState()` methods that return pointers to the linked mechanical state. The class ensures proper linking to a compatible mechanical state during its initialization phase and can warn or error if no appropriate state is found.\n\nIn practice, this component facilitates the interaction between behavioral components in SOFA simulations by providing them with access to mechanical states, which are essential for simulation mechanics such as forces, constraints, and dynamics. The `SingleStateAccessor` ensures that these interactions are type-safe and properly integrated into the overall scene graph architecture.",
  "maths": "The `SingleStateAccessor` class in the SOFA framework is primarily designed for components that need to access a specific mechanical state within a simulation context. This class does not directly contribute to the governing equations, constitutive laws, or numerical methods of finite element analysis (FEM). Instead, it serves as an intermediary component facilitating interaction with mechanical states.\n\n### Role in FEM Pipeline:\n\n1. **Mechanical State Access**: `SingleStateAccessor` enables derived components to interact with a specific `MechanicalState`, which can include state variables such as displacements, velocities, forces, and other physical quantities relevant to the simulation.\n2. **Initialization and Linking**: During initialization (`init()` method), this class ensures that the component is linked to an appropriate `MechanicalState`. If no compatible mechanical state is found in the context, it logs an error message.\n\n### Numerical Methods:\n\n`SingleStateAccessor` itself does not encode any specific numerical methods or discretization choices. Its primary function is to provide a type-safe and structured way for components to access the necessary mechanical states within their simulation contexts.\n\n### Mathematical Content:\n\nSince `SingleStateAccessor` is an abstract base class, it primarily defines interfaces rather than implementing mathematical content directly. Derived classes would use this interface to interact with mechanical state variables according to the specific requirements of their governing equations (e.g., forces, constraints).\n\n### Variational / Lagrangian Mechanics Framework:\n\nIn the broader variational or Lagrangian mechanics framework, `SingleStateAccessor` supports the consistent and type-safe access to the necessary state information for derived components. This ensures that these components can properly participate in the overall simulation pipeline without direct mathematical computation but by providing necessary data access.\n\n### Conclusion:\n\nThe `SingleStateAccessor` class serves as a foundational element within SOFA's framework, ensuring that behavioral components have the required access to mechanical states. While it does not directly contribute to solving governing equations or enforcing constitutive laws, it is crucial for maintaining the integrity and structure of simulations involving multiple interacting components.",
  "abstract": "`SingleStateAccessor` provides access to one specific mechanical state for derived components in SOFA simulations. It ensures type-safe interaction with the mechanical states through its initialization and linking methods.",
  "sheet": "# SingleStateAccessor\n\n## Overview\nThe `SingleStateAccessor` is an abstract base class designed for components that need to interact with a single mechanical state within a simulation context. This component facilitates access to state variables such as displacements, velocities, forces, and other physical quantities relevant to the simulation.\n\n## Dependencies and Connections\n`SingleStateAccessor` requires a `MechanicalState<DataTypes>` linked via the `mstate` field. It ensures that derived components are properly initialized with an appropriate mechanical state during their initialization phase (`init()` method). If no compatible mechanical state is found, it logs an error message."
}