iMSTK
Interactive Medical Simulation Toolkit
|
Newton method. This version of the newton method is based on the work by Tim Kelly and others at NC State University. The algorithm is globally convergent in the sense that for any initial iterate the iteration either converge to a root of F or fails. Global convergence is achieved using a line search sub-process and the Armijo rule. More...
#include <imstkNewtonSolver.h>
Public Types | |
using | LinearSolverType = LinearSolver< SystemMatrix > |
![]() | |
using | JacobianType = std::function< const SystemMatrix &(const Vectord &)> |
using | UpdateIterateType = std::function< void(const Vectord &, Vectord &)> |
using | FunctionType = NonLinearSystem< SparseMatrixd >::VectorFunctionType |
Public Member Functions | |
NewtonSolver (const NewtonSolver &other)=delete | |
Dissallow copy & move. | |
NewtonSolver (const NewtonSolver &&other)=delete | |
NewtonSolver & | operator= (const NewtonSolver &other)=delete |
NewtonSolver & | operator= (const NewtonSolver &&other)=delete |
void | solveGivenState (Vectord &x) override |
Solve the non linear system of equations G(x)=0 using Newton's method. More... | |
void | solve () override |
void | updateForcingTerm (const double ratio, const double stopTolerance, const double fnorm) |
Update forcing term according to Eisenstat-Walker criteria. More... | |
void | setLinearSolver (std::shared_ptr< LinearSolverType > newLinearSolver) |
Set LinearSolver. More... | |
auto | getLinearSolver () const -> std::shared_ptr< LinearSolverType > |
Get LinearSolver. | |
double | updateJacobian (const Vectord &x) |
Update jacobians. More... | |
void | setAbsoluteTolerance (const double aTolerance) |
Get JacobianMatrix. Returns jacobian matrix. More... | |
double | getAbsoluteTolerance () const |
Get AbsoluteTolerance. Returns current tolerance value. | |
void | setRelativeTolerance (const double newRelativeTolerance) |
Set RelativeTolerance. More... | |
double | getRelativeTolerance () const |
Get RelativeTolerance. Returns current relative tolerance value. | |
void | setGamma (const double newGamma) |
Set Gamma. Sets the gamma parameter used to update the forcing term. More... | |
double | getGamma () const |
Get Gamma. Returns current gamma value. | |
void | setEtaMax (const double newEtaMax) |
Set EtaMax. Maximum error tolerance for residual in inner iteration. The inner iteration terminates when the relative linear residual is smaller than eta*| F(x_c) |. eta is determined by the modified Eisenstat-Walker formula if etamax > 0. If etamax < 0, then eta = |etamax| for the entire iteration. More... | |
double | getEtaMax () const |
Get EtaMax. Returns current etaMax value. | |
void | setMaxIterations (const size_t newMaxIterations) |
Set MaxIterations. The maximum number of nonlinear iterations. | |
size_t | getMaxIterations () const |
Get MaxIterations. Returns current maximum nonlinear iterations. | |
void | setUseArmijo (const bool value) |
Set the useArmijo flag. If useArmijo is true a line search is performed using the Armijo-Goldstein condition. | |
bool | getUseArmijo () const |
Get MaxIterations. Returns current maximum nonlinear iterations. | |
void | setForcingTerm (const double value) |
Set the useArmijo flag. If useArmijo is true a line search is performed using the Armijo-Goldstein condition. | |
double | getForcingTerm () const |
Get MaxIterations. Returns current maximum nonlinear iterations. | |
void | setToFullyImplicit () override |
Set the Newton solver to be fully implicit. | |
void | setToSemiImplicit () override |
Set the Newton solver to be fully implicit. | |
![]() | |
double | armijo (const Vectord &dx, Vectord &x, const double previousFnorm) |
Backtracking line search method based on the Armijo-Goldstein condition. More... | |
void | parabolicModel (const std::array< double, 3 > &fnorm, std::array< double, 3 > &lambda) |
Three-point safeguarded parabolic model for a line search. Upon return lambda[0] will contain the new value of lambda given by the parabolic model. More... | |
void | setSigma (const std::array< double, 2 > &newSigma) |
Set/Get Sigma. Safeguard parameter for the the line search method. More... | |
const std::array< double, 2 > & | getSigma () const |
void | setAlpha (const double newAlpha) |
Set/Get Alpha. Parameter to measure sufficient decrease in the line search. More... | |
double | getAlpha () const |
void | setArmijoMax (const size_t newArmijoMax) |
Set/Get ArmijoMax. Maximum number of step length reductions. More... | |
size_t | getArmijoMax () const |
void | setSystem (std::shared_ptr< NonLinearSystem< SystemMatrix >> newSystem) |
Sets the system. System of nonlinear equations. More... | |
std::shared_ptr< NonLinearSystem< SystemMatrix > > | getSystem () const |
void | setUpdateIterate (const UpdateIterateType &newUpdateIterate) |
Set a customized iterate update function. More... | |
Additional Inherited Members | |
![]() | |
std::shared_ptr< DataTracker > | m_dataTracker |
![]() | |
std::array< double, 2 > | m_sigma |
Safeguarding bounds for the line search. | |
double | m_alpha |
Parameter to measure decrease. | |
size_t | m_armijoMax |
Maximum number of step length reductions. | |
std::shared_ptr< NonLinearSystem< SystemMatrix > > | m_nonLinearSystem |
System of non-linear equations. | |
UpdateIterateType | m_updateIterate |
Update iteration function. | |
bool | m_isSemiImplicit = false |
Semi-Implicit solver. | |
Newton method. This version of the newton method is based on the work by Tim Kelly and others at NC State University. The algorithm is globally convergent in the sense that for any initial iterate the iteration either converge to a root of F or fails. Global convergence is achieved using a line search sub-process and the Armijo rule.
Definition at line 24 of file imstkNewtonSolver.h.
void imstk::NewtonSolver< SystemMatrix >::setAbsoluteTolerance | ( | const double | aTolerance | ) |
Get JacobianMatrix. Returns jacobian matrix.
Set AbsoluteTolerance
aTolerance | New absolute tolerance value |
Definition at line 196 of file imstkNewtonSolver.cpp.
|
inline |
Set EtaMax. Maximum error tolerance for residual in inner iteration. The inner iteration terminates when the relative linear residual is smaller than eta*| F(x_c) |. eta is determined by the modified Eisenstat-Walker formula if etamax > 0. If etamax < 0, then eta = |etamax| for the entire iteration.
Definition at line 135 of file imstkNewtonSolver.h.
|
inline |
Set Gamma. Sets the gamma parameter used to update the forcing term.
newGamma | New gamma value |
Definition at line 120 of file imstkNewtonSolver.h.
|
inline |
Set LinearSolver.
newLinearSolver | Linear solver pointer |
Definition at line 65 of file imstkNewtonSolver.h.
|
inline |
Set RelativeTolerance.
newRelativeTolerance | New relative tolerance value |
Definition at line 105 of file imstkNewtonSolver.h.
|
overridevirtual |
Solve the non linear system of equations G(x)=0 using Newton's method.
x | Current iterate |
Implements imstk::NonLinearSolver< SystemMatrix >.
Definition at line 44 of file imstkNewtonSolver.cpp.
void imstk::NewtonSolver< SystemMatrix >::updateForcingTerm | ( | const double | ratio, |
const double | stopTolerance, | ||
const double | fnorm | ||
) |
Update forcing term according to Eisenstat-Walker criteria.
ratio | Ratio of consecutive function norms |
stopTolerance | Linear combinarion of relative and absolute tolerances |
fnorm | Current function norm |
Definition at line 171 of file imstkNewtonSolver.cpp.
double imstk::NewtonSolver< SystemMatrix >::updateJacobian | ( | const Vectord & | x | ) |
Update jacobians.
x | Current iterate |
Definition at line 135 of file imstkNewtonSolver.cpp.