<LegacyStaticODESolver />

Doxygen: SofaCaribou::ode::LegacyStaticODESolver

Implementation of a Newton-Raphson static ODE solver.

Warning

This component provides a compatibility layer for SOFA’s linear solvers. When possible, <StaticODESolver /> should be use with one of Caribou’s linear solvers since it provides better performance.

The solver does a series of Newton-Raphson iterations where at each iteration \(k\), the following linear system is solved:

\[\begin{split}\boldsymbol{K}(\boldsymbol{u}^k) \cdot \delta \boldsymbol{u}^{k+1} &= - \boldsymbol{R}(\boldsymbol{u}^k) \\ \boldsymbol{u}^{k+1} & = \boldsymbol{u}^k + \delta \boldsymbol{u}^{k}\end{split}\]

where the stiffness matrix \(\boldsymbol{K}\) is the derivative of the residual with respect to the displacement, i.e. \(\boldsymbol{K} = \frac{\partial \boldsymbol{R}}{\partial \boldsymbol{u}}\) and is typically accumulated by the addKtoMatrix method of forcefields. If an iterative linear solver is used, it is possible that the stiffness matrix is never accumulated, instead the operation \(\boldsymbol{K}(\boldsymbol{u}^k) \cdot \delta \boldsymbol{u}^{k+1}\) is done through the addDForce method of forcefields. The residual vector \(\boldsymbol{R}(\boldsymbol{u}^k)\) is accumulated by the addForce method of forcefields.

Attribute

Format

Default

Description

printLog

bool

false

Output informative messages at the initialization and during the simulation.

newton_iterations

int

1

Number of newton iterations between each load increments (normally, one load increment per simulation time-step).

correction_tolerance_threshold

float

1e-5

Convergence criterion: The newton iterations will stop when the norm of correction |du| reach this threshold.

residual_tolerance_threshold

float

1e-5

Convergence criterion: The newton iterations will stop when the relative norm of the residual \(\frac{|R_k|}{|R_0|} = \frac{|f_k - Ku_k|}{|f_0 - Ku_0|}\) at iteration k is lower than this threshold. Use a negative value to disable this criterion.

shoud_diverge_when_residual_is_growing

bool

false

Divergence criterion: The newton iterations will stop when the residual is greater than the one from the previous iteration.

warm_start

bool

false

For iterative linear solvers, use the previous solution has a warm start. Note that for the first newton step, the current position is used as the warm start.

Quick example

XML

<Node>
    <LegacyStaticODESolver newton_iterations="10" correction_tolerance_threshold="1e-8" residual_tolerance_threshold="1e-8" printLog="1" />
    <ConjugateGradientSolver maximum_number_of_iterations="2500" residual_tolerance_threshold="1e-12" preconditioning_method="Diagonal" printLog="0" />
</Node>

Python

node.addObject('LegacyStaticODESolver', newton_iterations=10, correction_tolerance_threshold=1e-8, residual_tolerance_threshold=1e-8, printLog=True)
node.addObject('ConjugateGradientSolver', maximum_number_of_iterations=2500, residual_tolerance_threshold=1e-12, preconditioning_method="Diagonal", printLog=False)

Available python bindings

class LegacyStaticODESolver
Variables
  • iteration_times (list [int]) – List of times (in nanoseconds) that each Newton-Raphson iteration took to compute in the last call to Solve().

  • squared_residuals (list [numpy.double]) – The list of squared residual norms (\(|r|^2\)) of every newton iterations of the last solve call.

  • squared_initial_residual (numpy.double) – The initial squared residual (\(|r_0|^2\)) of the last solve call.

  • iterative_linear_solver_squared_residuals (list [ list [numpy.double] ]) – The list of squared residual norms (\(|r|^2\)) of every iterative linear solver iterations, for each newton iterations of the last solve call.

  • iterative_linear_solver_squared_rhs_norms (list [numpy.double]) – List of squared right-hand side norms (\(|b|^2\)) of every newton iterations before the call to the solve method of the iterative linear solver.