Back

CentralDifferenceSolver

The `CentralDifferenceSolver` is an explicit time integrator in the SOFA framework, specifically designed for forward integration methods such as central difference (also known as Verlet or Leap-frog). This solver computes the next position and velocity based on current and previous positions using explicit integration steps. It inherits from the base `OdeSolver` class and provides a `solve` method that updates the mechanical state by integrating forces over time with optional Rayleigh damping. The component interacts with other SOFA components through its inherited methods, such as `solve`, which takes parameters like the current execution context (`core::ExecParams*`), time step (`SReal dt`), and result identifiers for positions (`sofa::core::MultiVecCoordId`) and velocities (`sofa::core::MultiVecDerivId`). It also provides methods to calculate integration factors between different derivative orders. The `CentralDifferenceSolver` has two data fields: `d_rayleighMass`, which is a Rayleigh damping coefficient related to mass, and `d_threadSafeVisitor`, a boolean flag that controls whether realloc and free operations are used in the interaction force field. The solver supports both optimized and unoptimized versions for different computational requirements.

abstract
The CentralDifferenceSolver is an explicit time integrator using central difference (Verlet or Leap-frog) for forward integration, handling Rayleigh damping and providing methods to solve ODEs explicitly.
sheet
<h1>CentralDifferenceSolver</h1> <h2>Overview</h2> <p>The CentralDifferenceSolver is an explicit time integrator in the SOFA framework that uses central difference (also known as Verlet or Leap-frog) for forward integration. It inherits from the base <code>OdeSolver</code> class and provides methods to solve ordinary differential equations (ODEs) explicitly using current and previous positions.</p> <h2>Mathematical Model</h2> <p>The central difference method can be described by the following steps:</p> <ul> <li><strong>Initialization</strong>: Given initial position \(\mathbf{x}_0\) and velocity \(\mathbf{v}_0\).</li> <li><strong>Force Calculation**: At time step \(t_k = k \Delta t\), the forces acting on particles are computed based on their positions. The force vector is denoted as \(\mathbf{F}(\mathbf{x}_k)\). <ul> <li>For Rayleigh damping, an additional term is added to the force:</li> </ul> </li> <li><strong>Rayleigh Damping**: The effective acceleration \(\ddot{\mathbf{x}}_k^{eff}\) takes into account the Rayleigh damping coefficient \(r\): <p>\[\ddot{\mathbf{x}}_k^{eff} = M^{-1}(\mathbf{F}(\mathbf{x}_k) + r (M \dot{\mathbf{x}}_{k-1}))\]</p> </li> <li><strong>Velocity Update**: The velocity at the next time step is given by:</li> <ul> <li>If there's no Rayleigh damping, we have a standard Verlet integration: \[\mathbf{v}_{k+1} = \mathbf{v}_k + \Delta t \ddot{\mathbf{x}}_k^{eff}\]</p> </li> <li><strong>Position Update**: The position at the next time step is computed as:</li> <p>\[\mathbf{x}_{k+1} = \mathbf{x}_k + \Delta t \mathbf{v}_{k+1}\]</p> <p>The method is symplectic, meaning it conserves energy in the long term for conservative systems. For Rayleigh damping, the force updates are modified to account for the additional dissipative forces:</p> \[\ddot{\mathbf{x}}_k^{eff} = M^{-1}(\mathbf{F}(\mathbf{x}_k) + r (M \dot{\mathbf{x}}_{k-1}))\] <p>The Rayleigh damping term modifies the effective acceleration by introducing a linear function of velocity, which models viscous damping.</p> <h2>Parameters and Data</h2> <ul> <li><strong>d_rayleighMass (SReal)</strong>: Rayleigh damping coefficient related to mass. Default value is not specified but can be set via the XML configuration.</li> <li><strong>d_threadSafeVisitor (bool)</strong>: If true, do not use realloc and free visitors in fwdInteractionForceField. This flag ensures thread safety during operations involving interaction force fields.</li> </ul>
description
The `CentralDifferenceSolver` is an explicit time integrator in the SOFA framework, specifically designed for forward integration methods such as central difference (also known as Verlet or Leap-frog). This solver computes the next position and velocity based on current and previous positions using explicit integration steps. It inherits from the base `OdeSolver` class and provides a `solve` method that updates the mechanical state by integrating forces over time with optional Rayleigh damping. The component interacts with other SOFA components through its inherited methods, such as `solve`, which takes parameters like the current execution context (`core::ExecParams*`), time step (`SReal dt`), and result identifiers for positions (`sofa::core::MultiVecCoordId`) and velocities (`sofa::core::MultiVecDerivId`). It also provides methods to calculate integration factors between different derivative orders. The `CentralDifferenceSolver` has two data fields: `d_rayleighMass`, which is a Rayleigh damping coefficient related to mass, and `d_threadSafeVisitor`, a boolean flag that controls whether realloc and free operations are used in the interaction force field. The solver supports both optimized and unoptimized versions for different computational requirements.
maths
<h3>Description</h3> <p>The <code>CentralDifferenceSolver</code>, also known as the Verlet or Leap-frog integrator, is an explicit time integration method used to advance a system's state in time. It uses both the current and previous positions of particles to calculate their future positions.</p> <h4>Mathematical Formulation</h4> <p>The central difference method can be described by the following steps:</p> <ul> <li><strong>Initialization</strong>: Given initial position \(\mathbf{x}_0\) and velocity \(\mathbf{v}_0\).</li> <li><strong>Force Calculation**: At time step \(t_k = k \Delta t\), the forces acting on particles are computed based on their positions. The force vector is denoted as \(\mathbf{F}(\mathbf{x}_k)\). <ul> <li>For Rayleigh damping, an additional term is added to the force:</li> </ul> </li> <li><strong>Rayleigh Damping**: The effective acceleration \(\ddot{\mathbf{x}}_k^{eff}\) takes into account the Rayleigh damping coefficient \(r\): <p>\[\ddot{\mathbf{x}}_k^{eff} = M^{-1}(\mathbf{F}(\mathbf{x}_k) + r (M \dot{\mathbf{x}}_{k-1}))\]\</li> <li><strong>Velocity Update**: The velocity at the next time step is given by:</li> <ul> <li>If there's no Rayleigh damping, we have a standard Verlet integration: \[\mathbf{v}_{k+1} = \mathbf{v}_k + \Delta t \ddot{\mathbf{x}}_k^{eff}\]\</li> </ul> </li> <li><strong>Position Update**: The position at the next time step is computed as:</li> <p>\[\mathbf{x}_{k+1} = \mathbf{x}_k + \Delta t \mathbf{v}_{k+1}\]\</p> <p>The method is symplectic, meaning it conserves energy in the long term for conservative systems. For Rayleigh damping, the force updates are modified to account for the additional dissipative forces:</p> \[\ddot{\mathbf{x}}_k^{eff} = M^{-1}(\mathbf{F}(\mathbf{x}_k) + r (M \dot{\mathbf{x}}_{k-1}))\] <p>The Rayleigh damping term modifies the effective acceleration by introducing a linear function of velocity, which models viscous damping.</p> <h4>Integration Factors</h4> <p>To determine how much an input derivative affects an output derivative, integration factors are defined. For instance, for position (0th order), velocity (1st order), and acceleration (2nd order):</p> \[\text{matrix}[3][3] = \begin{bmatrix} 1 & dt & dt^2 \\ 0 & 1 & dt \\ 0 & 0 & 0 \end{bmatrix}\] <p>where the integration factors for each derivative order are:</p> \[\text{vect}[3] = [dt^2, dt, 1]\]</p>
{
  "name": "CentralDifferenceSolver",
  "main": {
    "name": "CentralDifferenceSolver",
    "namespace": "sofa::component::odesolver::forward",
    "module": "Sofa.Component.ODESolver.Forward",
    "include": "sofa/component/odesolver/forward/CentralDifferenceSolver.h",
    "doc": "Explicit time integrator using central difference (also known as Verlet of Leap-frog).\n\nExplicit time integrator using central difference (also known as Verlet of Leap-frop).\n@see http://www.dynasupport.com/support/tutorial/users.guide/time.integration\n@see http://en.wikipedia.org/wiki/Leapfrog_method",
    "inherits": [
      "OdeSolver"
    ],
    "templates": [],
    "data_fields": [
      {
        "name": "d_rayleighMass",
        "type": "SReal",
        "xmlname": "rayleighMass",
        "help": "Rayleigh damping coefficient related to mass"
      },
      {
        "name": "d_threadSafeVisitor",
        "type": "bool",
        "xmlname": "threadSafeVisitor",
        "help": "If true, do not use realloc and free visitors in fwdInteractionForceField."
      }
    ],
    "links": [],
    "methods": [
      {
        "name": "solve",
        "return_type": "void",
        "params": [
          {
            "name": "params",
            "type": "const core::ExecParams *"
          },
          {
            "name": "dt",
            "type": "SReal"
          },
          {
            "name": "xResult",
            "type": "sofa::core::MultiVecCoordId"
          },
          {
            "name": "vResult",
            "type": "sofa::core::MultiVecDerivId"
          }
        ],
        "is_virtual": true,
        "is_pure_virtual": false,
        "is_static": false,
        "access": "public"
      },
      {
        "name": "getIntegrationFactor",
        "return_type": "SReal",
        "params": [
          {
            "name": "inputDerivative",
            "type": "int"
          },
          {
            "name": "outputDerivative",
            "type": "int"
          }
        ],
        "is_virtual": true,
        "is_pure_virtual": false,
        "is_static": false,
        "access": "public"
      },
      {
        "name": "getSolutionIntegrationFactor",
        "return_type": "SReal",
        "params": [
          {
            "name": "outputDerivative",
            "type": "int"
          }
        ],
        "is_virtual": true,
        "is_pure_virtual": false,
        "is_static": false,
        "access": "public"
      }
    ]
  },
  "desc": {
    "description": "The `CentralDifferenceSolver` is an explicit time integrator in the SOFA framework, specifically designed for forward integration methods such as central difference (also known as Verlet or Leap-frog). This solver computes the next position and velocity based on current and previous positions using explicit integration steps. It inherits from the base `OdeSolver` class and provides a `solve` method that updates the mechanical state by integrating forces over time with optional Rayleigh damping.\n\nThe component interacts with other SOFA components through its inherited methods, such as `solve`, which takes parameters like the current execution context (`core::ExecParams*`), time step (`SReal dt`), and result identifiers for positions (`sofa::core::MultiVecCoordId`) and velocities (`sofa::core::MultiVecDerivId`). It also provides methods to calculate integration factors between different derivative orders.\n\nThe `CentralDifferenceSolver` has two data fields: `d_rayleighMass`, which is a Rayleigh damping coefficient related to mass, and `d_threadSafeVisitor`, a boolean flag that controls whether realloc and free operations are used in the interaction force field. The solver supports both optimized and unoptimized versions for different computational requirements."
  },
  "maths": {
    "maths": "<h3>Description</h3>\n<p>The <code>CentralDifferenceSolver</code>, also known as the Verlet or Leap-frog integrator, is an explicit time integration method used to advance a system's state in time. It uses both the current and previous positions of particles to calculate their future positions.</p>\n\n<h4>Mathematical Formulation</h4>\n<p>The central difference method can be described by the following steps:</p>\n<ul>\n<li><strong>Initialization</strong>: Given initial position \\(\\mathbf{x}_0\\) and velocity \\(\\mathbf{v}_0\\).</li>\n<li><strong>Force Calculation**: At time step \\(t_k = k \\Delta t\\), the forces acting on particles are computed based on their positions. The force vector is denoted as \\(\\mathbf{F}(\\mathbf{x}_k)\\).\n    <ul>\n        <li>For Rayleigh damping, an additional term is added to the force:</li>\n    </ul>\n</li>\n<li><strong>Rayleigh Damping**: The effective acceleration \\(\\ddot{\\mathbf{x}}_k^{eff}\\) takes into account the Rayleigh damping coefficient \\(r\\):\n    <p>\\[\\ddot{\\mathbf{x}}_k^{eff} = M^{-1}(\\mathbf{F}(\\mathbf{x}_k) + r (M \\dot{\\mathbf{x}}_{k-1}))\\]\\</li>\n<li><strong>Velocity Update**: The velocity at the next time step is given by:</li>\n    <ul>\n        <li>If there's no Rayleigh damping, we have a standard Verlet integration:\n            \\[\\mathbf{v}_{k+1} = \\mathbf{v}_k + \\Delta t \\ddot{\\mathbf{x}}_k^{eff}\\]\\</li>\n    </ul>\n</li>\n<li><strong>Position Update**: The position at the next time step is computed as:</li>\n    <p>\\[\\mathbf{x}_{k+1} = \\mathbf{x}_k + \\Delta t \\mathbf{v}_{k+1}\\]\\</p>\n<p>The method is symplectic, meaning it conserves energy in the long term for conservative systems. For Rayleigh damping, the force updates are modified to account for the additional dissipative forces:</p>\n\\[\\ddot{\\mathbf{x}}_k^{eff} = M^{-1}(\\mathbf{F}(\\mathbf{x}_k) + r (M \\dot{\\mathbf{x}}_{k-1}))\\]\n\n<p>The Rayleigh damping term modifies the effective acceleration by introducing a linear function of velocity, which models viscous damping.</p>\n<h4>Integration Factors</h4>\n<p>To determine how much an input derivative affects an output derivative, integration factors are defined. For instance, for position (0th order), velocity (1st order), and acceleration (2nd order):</p>\n\\[\\text{matrix}[3][3] = \\begin{bmatrix} 1 & dt & dt^2 \\\\ 0 & 1 & dt \\\\ 0 & 0 & 0 \\end{bmatrix}\\]\n<p>where the integration factors for each derivative order are:</p>\n\\[\\text{vect}[3] = [dt^2, dt, 1]\\]</p>"
  },
  "summary": {
    "abstract": "The CentralDifferenceSolver is an explicit time integrator using central difference (Verlet or Leap-frog) for forward integration, handling Rayleigh damping and providing methods to solve ODEs explicitly.",
    "sheet": "<h1>CentralDifferenceSolver</h1>\n\n<h2>Overview</h2>\n<p>The CentralDifferenceSolver is an explicit time integrator in the SOFA framework that uses central difference (also known as Verlet or Leap-frog) for forward integration. It inherits from the base <code>OdeSolver</code> class and provides methods to solve ordinary differential equations (ODEs) explicitly using current and previous positions.</p>\n\n<h2>Mathematical Model</h2>\n<p>The central difference method can be described by the following steps:</p>\n<ul>\n<li><strong>Initialization</strong>: Given initial position \\(\\mathbf{x}_0\\) and velocity \\(\\mathbf{v}_0\\).</li>\n<li><strong>Force Calculation**: At time step \\(t_k = k \\Delta t\\), the forces acting on particles are computed based on their positions. The force vector is denoted as \\(\\mathbf{F}(\\mathbf{x}_k)\\).\n    <ul>\n        <li>For Rayleigh damping, an additional term is added to the force:</li>\n    </ul>\n</li>\n<li><strong>Rayleigh Damping**: The effective acceleration \\(\\ddot{\\mathbf{x}}_k^{eff}\\) takes into account the Rayleigh damping coefficient \\(r\\):\n    <p>\\[\\ddot{\\mathbf{x}}_k^{eff} = M^{-1}(\\mathbf{F}(\\mathbf{x}_k) + r (M \\dot{\\mathbf{x}}_{k-1}))\\]</p>\n</li>\n<li><strong>Velocity Update**: The velocity at the next time step is given by:</li>\n    <ul>\n        <li>If there's no Rayleigh damping, we have a standard Verlet integration:\n            \\[\\mathbf{v}_{k+1} = \\mathbf{v}_k + \\Delta t \\ddot{\\mathbf{x}}_k^{eff}\\]</p>\n</li>\n<li><strong>Position Update**: The position at the next time step is computed as:</li>\n    <p>\\[\\mathbf{x}_{k+1} = \\mathbf{x}_k + \\Delta t \\mathbf{v}_{k+1}\\]</p>\n<p>The method is symplectic, meaning it conserves energy in the long term for conservative systems. For Rayleigh damping, the force updates are modified to account for the additional dissipative forces:</p>\n\\[\\ddot{\\mathbf{x}}_k^{eff} = M^{-1}(\\mathbf{F}(\\mathbf{x}_k) + r (M \\dot{\\mathbf{x}}_{k-1}))\\]\n\n<p>The Rayleigh damping term modifies the effective acceleration by introducing a linear function of velocity, which models viscous damping.</p>\n<h2>Parameters and Data</h2>\n<ul>\n<li><strong>d_rayleighMass (SReal)</strong>: Rayleigh damping coefficient related to mass. Default value is not specified but can be set via the XML configuration.</li>\n<li><strong>d_threadSafeVisitor (bool)</strong>: If true, do not use realloc and free visitors in fwdInteractionForceField. This flag ensures thread safety during operations involving interaction force fields.</li>\n</ul>"
  }
}