iMSTK
Interactive Medical Simulation Toolkit
Public Types | Public Member Functions | List of all members
imstk::NewtonSolver< SystemMatrix > Class Template Reference

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>

Inheritance diagram for imstk::NewtonSolver< SystemMatrix >:
Inheritance graph
[legend]
Collaboration diagram for imstk::NewtonSolver< SystemMatrix >:
Collaboration graph
[legend]

Public Types

using LinearSolverType = LinearSolver< SystemMatrix >
 
- Public Types inherited from imstk::NonLinearSolver< 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
 
NewtonSolveroperator= (const NewtonSolver &other)=delete
 
NewtonSolveroperator= (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.
 
- Public Member Functions inherited from imstk::NonLinearSolver< SystemMatrix >
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

- Public Attributes inherited from imstk::SolverBase
std::shared_ptr< DataTrackerm_dataTracker
 
- Protected Attributes inherited from imstk::NonLinearSolver< SystemMatrix >
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.
 

Detailed Description

template<typename SystemMatrix>
class imstk::NewtonSolver< SystemMatrix >

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.

Member Function Documentation

◆ setAbsoluteTolerance()

template<typename SystemMatrix >
void imstk::NewtonSolver< SystemMatrix >::setAbsoluteTolerance ( const double  aTolerance)

Get JacobianMatrix. Returns jacobian matrix.

Set AbsoluteTolerance

Parameters
aToleranceNew absolute tolerance value

Definition at line 196 of file imstkNewtonSolver.cpp.

Here is the caller graph for this function:

◆ setEtaMax()

template<typename SystemMatrix >
void imstk::NewtonSolver< SystemMatrix >::setEtaMax ( const double  newEtaMax)
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.

See also
updateForcingTerm()

Definition at line 135 of file imstkNewtonSolver.h.

◆ setGamma()

template<typename SystemMatrix >
void imstk::NewtonSolver< SystemMatrix >::setGamma ( const double  newGamma)
inline

Set Gamma. Sets the gamma parameter used to update the forcing term.

Parameters
newGammaNew gamma value

Definition at line 120 of file imstkNewtonSolver.h.

◆ setLinearSolver()

template<typename SystemMatrix >
void imstk::NewtonSolver< SystemMatrix >::setLinearSolver ( std::shared_ptr< LinearSolverType newLinearSolver)
inline

Set LinearSolver.

Parameters
newLinearSolverLinear solver pointer

Definition at line 65 of file imstkNewtonSolver.h.

Here is the call graph for this function:

◆ setRelativeTolerance()

template<typename SystemMatrix >
void imstk::NewtonSolver< SystemMatrix >::setRelativeTolerance ( const double  newRelativeTolerance)
inline

Set RelativeTolerance.

Parameters
newRelativeToleranceNew relative tolerance value

Definition at line 105 of file imstkNewtonSolver.h.

◆ solveGivenState()

template<typename SystemMatrix >
void imstk::NewtonSolver< SystemMatrix >::solveGivenState ( Vectord &  x)
overridevirtual

Solve the non linear system of equations G(x)=0 using Newton's method.

Parameters
xCurrent iterate

Implements imstk::NonLinearSolver< SystemMatrix >.

Definition at line 44 of file imstkNewtonSolver.cpp.

◆ updateForcingTerm()

template<typename SystemMatrix >
void imstk::NewtonSolver< SystemMatrix >::updateForcingTerm ( const double  ratio,
const double  stopTolerance,
const double  fnorm 
)

Update forcing term according to Eisenstat-Walker criteria.

See also
http://softlib.rice.edu/pub/CRPC-TRs/reports/CRPC-TR94463.pdf.
Parameters
ratioRatio of consecutive function norms
stopToleranceLinear combinarion of relative and absolute tolerances
fnormCurrent function norm
Todo:
Log this

Definition at line 171 of file imstkNewtonSolver.cpp.

◆ updateJacobian()

template<typename SystemMatrix >
double imstk::NewtonSolver< SystemMatrix >::updateJacobian ( const Vectord &  x)

Update jacobians.

Parameters
xCurrent iterate

Definition at line 135 of file imstkNewtonSolver.cpp.

Here is the caller graph for this function:

The documentation for this class was generated from the following files: