Back

ReadState

sofa::component::playback::ReadState
BaseObject
Doc (from source)

Read State vectors from file at each timestep.

Abstract (AI generated)

`ReadState` reads state vectors from an external file at each timestep, enabling playback functionalities in SOFA simulations. It supports time-based inputs and transformations like scaling, rotation, and translation.

Metadata
module
Sofa.Component.Playback
namespace
sofa::component::playback
include
sofa/component/playback/ReadState.h
inherits
  • BaseObject
description

The ReadState component in the SOFA framework is designed to read state vectors from an external file at each time step, enabling playback or replay functionalities. It does not contribute directly to any governing equations such as mass matrix $M$, stiffness matrix $K$, internal force $f_{int}$, or residual $R$. Instead, it focuses on managing and loading predefined mechanical states from a specified input file.

Governing Equations and Operators:

  • Mass Matrix ($M$): Not directly involved in its computations.
  • Stiffness Matrix ($K$): Not involved.
  • Internal Force ($f_{int}$): Not involved.
  • Residual ($R$): Not involved.

Constitutive or Kinematic Laws:

ReadState does not implement any specific constitutive laws, strain measures, stress tensors, hyperelastic potentials, damping models, constraint Jacobians, etc. It simply reads predefined state data and applies transformations if needed.

Role in the Global FEM Pipeline:

  • Assembly: ReadState does not contribute to the assembly of global matrices or vectors.
  • Time Integration: The component manages time-based state inputs but does not perform any time integration schemes (e.g., implicit Euler, Newmark).
  • Nonlinear Solve: Not involved in nonlinear resolution methods such as Newton-Raphson iteration.
  • Linear Solve: Not involved in linear system solves.
  • Constraint Handling: The component does not directly handle constraints but can apply transformations like scaling, rotation, and translation to the loaded state data.

Numerical Methods or Discretization Choices:

ReadState primarily reads and processes state vectors from a file. It supports various numerical methods such as reading state data at each time step, applying transformations (scaling, rotation, translation), and managing loop conditions for re-reading files if specified.

Integration into the Variational / Lagrangian Mechanics Framework:

The component operates outside of the variational or Lagrangian mechanics framework by simply loading predefined mechanical states. It does not modify or contribute to any specific variational formulations or discretizations.

Summary:

ReadState is a utility component in SOFA that facilitates playback functionalities by reading and applying state vectors from an external file, without contributing to the core numerical or physical aspects of the simulation pipeline.

Data Fields
NameTypeDefaultHelp
d_interval double time duration between inputs
d_shift double shift between times in the file and times when they will be read
d_loop bool set to 'true' to re-read the file when reaching the end
d_scalePos double scale the input mechanical object
d_rotation type::Vec3 rotate the input mechanical object
d_translation type::Vec3 translate the input mechanical object
Methods
void init () virtual
void bwdInit () virtual
void reset () virtual
void setTime (double time)
void handleEvent (sofa::core::objectmodel::Event * event) virtual
void processReadState ()
void processReadState (double time)
bool readNext (double time, int & lines)
bool canCreate (T * obj, core::objectmodel::BaseContext * context, core::objectmodel::BaseObjectDescription * arg)
{
  "name": "ReadState",
  "namespace": "sofa::component::playback",
  "module": "Sofa.Component.Playback",
  "include": "sofa/component/playback/ReadState.h",
  "doc": "Read State vectors from file at each timestep.",
  "inherits": [
    "BaseObject"
  ],
  "templates": [],
  "data_fields": [
    {
      "name": "d_interval",
      "type": "double",
      "xmlname": "interval",
      "help": "time duration between inputs"
    },
    {
      "name": "d_shift",
      "type": "double",
      "xmlname": "shift",
      "help": "shift between times in the file and times when they will be read"
    },
    {
      "name": "d_loop",
      "type": "bool",
      "xmlname": "loop",
      "help": "set to 'true' to re-read the file when reaching the end"
    },
    {
      "name": "d_scalePos",
      "type": "double",
      "xmlname": "scalePos",
      "help": "scale the input mechanical object"
    },
    {
      "name": "d_rotation",
      "type": "type::Vec3",
      "xmlname": "rotation",
      "help": "rotate the input mechanical object"
    },
    {
      "name": "d_translation",
      "type": "type::Vec3",
      "xmlname": "translation",
      "help": "translate the input mechanical object"
    }
  ],
  "links": [],
  "methods": [
    {
      "name": "init",
      "return_type": "void",
      "params": [],
      "is_virtual": true,
      "is_pure_virtual": false,
      "is_static": false,
      "access": "public"
    },
    {
      "name": "bwdInit",
      "return_type": "void",
      "params": [],
      "is_virtual": true,
      "is_pure_virtual": false,
      "is_static": false,
      "access": "public"
    },
    {
      "name": "reset",
      "return_type": "void",
      "params": [],
      "is_virtual": true,
      "is_pure_virtual": false,
      "is_static": false,
      "access": "public"
    },
    {
      "name": "setTime",
      "return_type": "void",
      "params": [
        {
          "name": "time",
          "type": "double"
        }
      ],
      "is_virtual": false,
      "is_pure_virtual": false,
      "is_static": false,
      "access": "public"
    },
    {
      "name": "handleEvent",
      "return_type": "void",
      "params": [
        {
          "name": "event",
          "type": "sofa::core::objectmodel::Event *"
        }
      ],
      "is_virtual": true,
      "is_pure_virtual": false,
      "is_static": false,
      "access": "public"
    },
    {
      "name": "processReadState",
      "return_type": "void",
      "params": [],
      "is_virtual": false,
      "is_pure_virtual": false,
      "is_static": false,
      "access": "public"
    },
    {
      "name": "processReadState",
      "return_type": "void",
      "params": [
        {
          "name": "time",
          "type": "double"
        }
      ],
      "is_virtual": false,
      "is_pure_virtual": false,
      "is_static": false,
      "access": "public"
    },
    {
      "name": "readNext",
      "return_type": "bool",
      "params": [
        {
          "name": "time",
          "type": "double"
        },
        {
          "name": "lines",
          "type": "int &"
        }
      ],
      "is_virtual": false,
      "is_pure_virtual": false,
      "is_static": false,
      "access": "public"
    },
    {
      "name": "canCreate",
      "return_type": "bool",
      "params": [
        {
          "name": "obj",
          "type": "T *"
        },
        {
          "name": "context",
          "type": "core::objectmodel::BaseContext *"
        },
        {
          "name": "arg",
          "type": "core::objectmodel::BaseObjectDescription *"
        }
      ],
      "is_virtual": false,
      "is_pure_virtual": false,
      "is_static": true,
      "access": "public"
    }
  ],
  "description": "The `ReadState` component in the SOFA framework is part of the playback module and reads state vectors from file at each timestep, allowing for replaying previously recorded mechanical states. It inherits from `BaseObject`, making it a foundational object within the SOFA scene graph.\n\n**Role and Purpose:**\nThe primary role of `ReadState` is to load predefined mechanical states from an external file, enabling playback or replay functionalities in simulations. This component can handle time-based state inputs and apply transformations such as scaling, rotation, and translation to the loaded data.\n\n**Interactions with Other Components:**\nThe `ReadState` interacts with other SOFA components through its methods and API:\n- **Init Methods**: It implements `init`, `bwdInit`, and `reset` for initialization, backward initialization, and resetting state respectively.\n- **Event Handling**: The `handleEvent` method manages events related to the simulation's progression (e.g., `AnimateBeginEvent`).\n- **Time Management**: `setTime` sets the current time in the context of the playback.\n- **State Processing**: Methods like `processReadState`, `readNext`, and supporting visitors propagate and update the mechanical state based on file content, ensuring that the simulation reflects the loaded state at each timestep.\n\n**Practical Usage Guidance:**\nThe component is configured via several data fields:\n- **`interval`**: Sets the time duration between input reads.\n- **`shift`**: Adds a shift to the times specified in the file for when they are read.\n- **`loop`**: Determines whether the file should be re-read after reaching its end.\n- **`scalePos`, `rotation`, and `translation`**: Allow transformations on the loaded mechanical object to adjust position, rotation, and scale as needed.\n\n**Data Fields Summary:**\n- `d_filename`: Path to the input state file.\n- `d_interval`: Time duration between inputs.\n- `d_shift`: Shift between times in the file and read times.\n- `d_loop`: Boolean flag for re-reading the file at end.\n- `d_scalePos`: Scale factor for the mechanical object.\n- `d_rotation` and `d_translation`: Transformation parameters to adjust the loaded state.",
  "maths": "The `ReadState` component in the SOFA framework is designed to read state vectors from an external file at each time step, enabling playback or replay functionalities. It does not contribute directly to any governing equations such as mass matrix $M$, stiffness matrix $K$, internal force $f_{int}$, or residual $R$. Instead, it focuses on managing and loading predefined mechanical states from a specified input file.\n\n### Governing Equations and Operators:\n- **Mass Matrix** ($M$): Not directly involved in its computations.\n- **Stiffness Matrix** ($K$): Not involved.\n- **Internal Force** ($f_{int}$): Not involved.\n- **Residual** ($R$): Not involved.\n\n### Constitutive or Kinematic Laws:\n`ReadState` does not implement any specific constitutive laws, strain measures, stress tensors, hyperelastic potentials, damping models, constraint Jacobians, etc. It simply reads predefined state data and applies transformations if needed.\n\n### Role in the Global FEM Pipeline:\n- **Assembly**: `ReadState` does not contribute to the assembly of global matrices or vectors.\n- **Time Integration**: The component manages time-based state inputs but does not perform any time integration schemes (e.g., implicit Euler, Newmark).\n- **Nonlinear Solve**: Not involved in nonlinear resolution methods such as Newton-Raphson iteration.\n- **Linear Solve**: Not involved in linear system solves.\n- **Constraint Handling**: The component does not directly handle constraints but can apply transformations like scaling, rotation, and translation to the loaded state data.\n\n### Numerical Methods or Discretization Choices:\n`ReadState` primarily reads and processes state vectors from a file. It supports various numerical methods such as reading state data at each time step, applying transformations (scaling, rotation, translation), and managing loop conditions for re-reading files if specified.\n\n### Integration into the Variational / Lagrangian Mechanics Framework:\nThe component operates outside of the variational or Lagrangian mechanics framework by simply loading predefined mechanical states. It does not modify or contribute to any specific variational formulations or discretizations.\n\n### Summary:\n`ReadState` is a utility component in SOFA that facilitates playback functionalities by reading and applying state vectors from an external file, without contributing to the core numerical or physical aspects of the simulation pipeline.",
  "abstract": "`ReadState` reads state vectors from an external file at each timestep, enabling playback functionalities in SOFA simulations. It supports time-based inputs and transformations like scaling, rotation, and translation.",
  "sheet": "# ReadState\n\n## Overview\nThe `ReadState` component is part of the SOFA framework's playback module. Its primary role is to read state vectors from an external file at each timestep, enabling playback functionalities in simulations. It supports time-based inputs and transformations such as scaling, rotation, and translation.\n\n## Parameters and Data\n- **interval**: Time duration between input reads (`double`, default: not specified).\n- **shift**: Adds a shift to the times specified in the file for when they are read (`double`, default: not specified).\n- **loop**: Determines whether the file should be re-read after reaching its end (`bool`, default: `false`).\n- **scalePos**: Scale factor for the mechanical object (`double`, default: not specified).\n- **rotation**: Rotation parameters to adjust the loaded state (`type::Vec3`, default: not specified).\n- **translation**: Translation parameters to adjust the loaded state (`type::Vec3`, default: not specified)."
}