Simulation
Main controller of the scene. Defines how the scene is inited at the beginning, and updated at each time step. Derives from Base in order to use smart pointers and model the parameters as Datas, which makes their edition easy in the GUI.
The `Simulation` component controls the initialization and updates of the SOFA scene graph, managing nodes and coordinating simulation steps.
- module
- Sofa.framework.Simulation.Core
- namespace
- sofa::simulation
- include
- sofa/simulation/Simulation.h
- description
The Simulation class in the SOFA framework serves as an interface for controlling and interacting with simulations involving physical models, objects, and interactions. It does not directly implement or contribute to specific mathematical operators such as the mass matrix $M$, stiffness matrix $K$, internal force $f_{int}$, or residual $R$. Instead, it provides a high-level control mechanism that orchestrates the simulation workflow by invoking various methods for initializing, animating, and updating the scene graph.
Key Components:
-
Node Management: The
Simulationclass provides methods to manage nodes within the SOFA framework. This includes loading new scenes (load), unloading existing ones (unload), and initializing textures for visual components (initTextures). -
Simulation Control: Methods such as
reset,updateContext,computeBBox,draw,animate, andupdateVisualenable control over the simulation. For example,animateperforms one step in the animation loop with a specified time step $\Delta t$, whileupdateVisualupdates the visual representation. -
File Operations: The class supports exporting scenes to various formats such as
.obj(exportOBJ) and graph representations (exportGraph). It also allows dumping the state of a scene to a file (dumpState).
Role in the FEM Pipeline:
While the Simulation class itself does not directly participate in the discretization, assembly, or numerical solution phases of the finite element method (FEM), it serves as the main controller that coordinates these processes. For instance, it initializes and updates mechanical systems, manages time integration through animation loops, and handles interactions with visualization components.
Numerical Methods:
The Simulation class does not directly encode specific numerical methods or discretization choices. Instead, it relies on other SOFA components (e.g., solvers, force fields) to perform these tasks. The class's primary role is to manage the high-level flow of simulation steps and ensure that all necessary operations are performed in a consistent manner.
Variational / Lagrangian Mechanics Framework:
The Simulation class does not directly contribute to variational or Lagrangian mechanics formulations. However, it ensures that these principles are applied consistently by coordinating the initialization, time integration, and visualization steps of the simulation workflow. The methods provided by this class enable users to set up and run simulations in a manner consistent with the broader framework's design philosophy.
Summary:
The Simulation component is primarily responsible for orchestrating the overall flow of a simulation within the SOFA framework. It does not contribute directly to specific mathematical operators or numerical schemes but rather provides a high-level interface for managing nodes, controlling the simulation process, and exporting results.
Methods
Simulation &
operator=
(const Simulation & n)
NodeSPtr
createNewGraph
(const int & name)
virtual
NodeSPtr
createNewNode
(const int & name)
virtual
bool
isDirectedAcyclicGraph
()
virtual
{
"name": "Simulation",
"namespace": "sofa::simulation",
"module": "Sofa.framework.Simulation.Core",
"include": "sofa/simulation/Simulation.h",
"doc": "Main controller of the scene.\n Defines how the scene is inited at the beginning, and updated at each time step.\n Derives from Base in order to use smart pointers and model the parameters as Datas, which makes their edition easy in the GUI.",
"inherits": [],
"templates": [],
"data_fields": [],
"links": [],
"methods": [
{
"name": "operator=",
"return_type": "Simulation &",
"params": [
{
"name": "n",
"type": "const Simulation &"
}
],
"is_virtual": false,
"is_pure_virtual": false,
"is_static": false,
"access": "public"
},
{
"name": "createNewGraph",
"return_type": "NodeSPtr",
"params": [
{
"name": "name",
"type": "const int &"
}
],
"is_virtual": true,
"is_pure_virtual": true,
"is_static": false,
"access": "public"
},
{
"name": "createNewNode",
"return_type": "NodeSPtr",
"params": [
{
"name": "name",
"type": "const int &"
}
],
"is_virtual": true,
"is_pure_virtual": true,
"is_static": false,
"access": "public"
},
{
"name": "isDirectedAcyclicGraph",
"return_type": "bool",
"params": [],
"is_virtual": true,
"is_pure_virtual": true,
"is_static": false,
"access": "public"
}
],
"description": "The `Simulation` class in the SOFA (Simulation Open Framework Agreement) framework serves as an interface for interacting with and controlling simulations involving physical models, objects, and interactions.\n\n### Key Components:\n- **Node Management:** The class provides methods to manage simulation nodes such as loading new scenes (`load`), unloading existing ones (`unload`), and initializing the textures of visual components (`initTextures`).\n\n- **Simulation Control:** Methods for resetting simulations (`reset`) to their initial state, updating simulation contexts (`updateContext`), computing bounding boxes (`computeBBox`, `computeTotalBBox`), drawing scenes based on visual parameters (`draw`), performing steps in the animation loop (`animate` and `updateVisual`), and managing time within the simulation.\n\n- **File Operations:** Exporting scenes to various formats such as `.obj` (`exportOBJ`) or graph representations (`exportGraph`), dumping the state of a scene to a file (`dumpState`).\n\n### Usage Scenarios:\n1. **Loading Scenes:** Loading new scenes from files with specified extensions and handling reloads if necessary.\n2. **Running Simulations:** Initializing scenes, animating them over time, and updating visual components at each frame for real-time visualization or rendering.\n3. **Debugging and Logging:** Dumping the state of a scene to log files during simulation runs for debugging purposes.\n4. **Exporting Scenes:** Exporting scenes in different formats (e.g., OBJ, SOFA graph representation) for further processing or archiving.\n\n### Example Usage:\n```cpp\n#include <sofa/simulation/Simulation.h>\n\nint main() {\n sofa::simulation::NodeSPtr scene = sofa::simulation::load(\"path/to/scene.scn\"); // Load a SOFA scene file\n sofa::simulation::initTextures(scene.get()); // Initialize textures for visual components\n while (true) { // Simulation loop\n sofa::simulation::animate(0.1, scene.get()); // Perform one step in the animation loop with time step 0.1s\n sofa::simulation::updateVisual(scene.get()); // Update the visual representation\n }\n}\n```\nIn this example, a SOFA scene file is loaded, textures are initialized for its visual components, and then an infinite simulation loop is started where the scene is animated frame by frame while updating its visual representation.\n\n### Notes:\n- The `Simulation` class acts as a central point for controlling and interacting with simulations within the SOFA framework. It abstracts away much of the complexity involved in managing nodes, time-stepping, and visual rendering, allowing users to focus on setting up their simulation scenarios.",
"summary": "The Simulation class in the SOFA framework provides methods for loading, unloading, resetting, animating, drawing, and exporting scenes, enabling control over simulations involving physical models and interactions.",
"maths": "The `Simulation` class in the SOFA framework serves as an interface for controlling and interacting with simulations involving physical models, objects, and interactions. It does not directly implement or contribute to specific mathematical operators such as the mass matrix $M$, stiffness matrix $K$, internal force $f_{int}$, or residual $R$. Instead, it provides a high-level control mechanism that orchestrates the simulation workflow by invoking various methods for initializing, animating, and updating the scene graph.\n\n### Key Components:\n- **Node Management:** The `Simulation` class provides methods to manage nodes within the SOFA framework. This includes loading new scenes (`load`), unloading existing ones (`unload`), and initializing textures for visual components (`initTextures`).\n\n- **Simulation Control:** Methods such as `reset`, `updateContext`, `computeBBox`, `draw`, `animate`, and `updateVisual` enable control over the simulation. For example, `animate` performs one step in the animation loop with a specified time step $\\Delta t$, while `updateVisual` updates the visual representation.\n\n- **File Operations:** The class supports exporting scenes to various formats such as `.obj` (`exportOBJ`) and graph representations (`exportGraph`). It also allows dumping the state of a scene to a file (`dumpState`).\n\n### Role in the FEM Pipeline:\nWhile the `Simulation` class itself does not directly participate in the discretization, assembly, or numerical solution phases of the finite element method (FEM), it serves as the main controller that coordinates these processes. For instance, it initializes and updates mechanical systems, manages time integration through animation loops, and handles interactions with visualization components.\n\n### Numerical Methods:\nThe `Simulation` class does not directly encode specific numerical methods or discretization choices. Instead, it relies on other SOFA components (e.g., solvers, force fields) to perform these tasks. The class's primary role is to manage the high-level flow of simulation steps and ensure that all necessary operations are performed in a consistent manner.\n\n### Variational / Lagrangian Mechanics Framework:\nThe `Simulation` class does not directly contribute to variational or Lagrangian mechanics formulations. However, it ensures that these principles are applied consistently by coordinating the initialization, time integration, and visualization steps of the simulation workflow. The methods provided by this class enable users to set up and run simulations in a manner consistent with the broader framework's design philosophy.\n\n### Summary:\nThe `Simulation` component is primarily responsible for orchestrating the overall flow of a simulation within the SOFA framework. It does not contribute directly to specific mathematical operators or numerical schemes but rather provides a high-level interface for managing nodes, controlling the simulation process, and exporting results.",
"abstract": "The `Simulation` component controls the initialization and updates of the SOFA scene graph, managing nodes and coordinating simulation steps.",
"sheet": "# Simulation\n\n## Overview\nThe `Simulation` class serves as the main controller for the SOFA scene. It handles the initialization of scenes, node management, and orchestrates the simulation workflow by invoking methods for animation, visualization updates, and file operations.\n\n## Parameters and Data\nThe `Simulation` component does not expose significant data fields directly; its functionality is primarily driven through method invocations rather than configurable parameters.\n\n## Dependencies and Connections\nThe `Simulation` class interacts with various components within the SOFA scene graph to manage nodes, control simulation steps, and handle file operations. It relies on other components for specific functionalities such as time integration, force computation, and visualization."
}