Solvers inheriting Caribou's Newton Raphson solver class can now register callbacks at different steps of a Newton iteration.
For example, the following C++ code prints the stiffness matrix just after the latter as been assembled:
using E = SofaCaribou::ode::NewtonRaphsonSolver::Event;
using NR = SofaCaribou::ode::NewtonRaphsonSolver;
solver->register_callback(E::MATRIX_ASSEMBLED, [](const NR & solver) {
std::cout << solver.A();
});
Or to get the solution vector once solved in python
from SofaCaribou import NewtonRaphsonSolver
E = NewtonRaphsonSolver.Event
root.solver.register_callback(
E.INCREMENT_SOLVED,
lambda s: print(s.dx())
)
The following events are available:
enum class Event : unsigned int {
/** Event triggered at the very beginning of the Newton iteration. */
ITERATION_BEGIN = 0,
/** Event triggered after the system matrix has been assembled. */
MATRIX_ASSEMBLED,
/** Event triggered after the system matrix has been analyzed. */
MATRIX_ANALYZED,
/** Event triggered after the system matrix has been factorized. */
MATRIX_FACTORIZED,
/** Event triggered after the system solution vector has been solved. */
INCREMENT_SOLVED,
/** Event triggered after the system solution vector has been propagated through mappings. */
INCREMENT_PROPAGATED,
/** Event triggered after the system force vector has been updated. */
RESIDUAL_UPDATED,
/** Event triggered at the very end of the Newton iteration. */
ITERATION_END,
};
Solvers inheriting Caribou's Newton Raphson solver class can now register callbacks at different steps of a Newton iteration.
For example, the following C++ code prints the stiffness matrix just after the latter as been assembled:
Or to get the solution vector once solved in python
The following events are available: