iMSTK
Interactive Medical Simulation Toolkit
Public Types | Public Member Functions | Protected Attributes | List of all members
imstk::NonLinearSolver< SystemMatrix > Class Template Referenceabstract

Base class for non-linear solvers. More...

#include <imstkNonLinearSolver.h>

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

Public Types

using JacobianType = std::function< const SystemMatrix &(const Vectord &)>
 
using UpdateIterateType = std::function< void(const Vectord &, Vectord &)>
 
using FunctionType = NonLinearSystem< SparseMatrixd >::VectorFunctionType
 

Public Member Functions

virtual void solveGivenState (Vectord &x)=0
 Main solve routine.
 
virtual void solve () override=0
 
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...
 
virtual void setToFullyImplicit ()
 Set the Newton solver to be fully implicit.
 
virtual void setToSemiImplicit ()
 Set the Newton solver to be fully implicit.
 

Protected Attributes

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.
 

Additional Inherited Members

- Public Attributes inherited from imstk::SolverBase
std::shared_ptr< DataTrackerm_dataTracker
 

Detailed Description

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

Base class for non-linear solvers.

Definition at line 24 of file imstkNonLinearSolver.h.

Member Function Documentation

◆ armijo()

template<typename SystemMatrix >
double imstk::NonLinearSolver< SystemMatrix >::armijo ( const Vectord &  dx,
Vectord &  x,
const double  previousFnorm 
)

Backtracking line search method based on the Armijo-Goldstein condition.

Parameters
dxComputed direction.
xCurrent iterate.

Temporaries used in the line search

Initialize temporaries

Todo:
log this
Todo:
Log this

Update x and keep books on lambda

Todo:
Log this

Update function norms

Apply the three point parabolic model

Todo:
Add to logger

Definition at line 27 of file imstkNonLinearSolver.cpp.

Here is the call graph for this function:

◆ parabolicModel()

template<typename SystemMatrix >
void imstk::NonLinearSolver< SystemMatrix >::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.

Parameters
lambda[1]Current step length lambda[2] Previous step length
fnorm[0]Value of |F(x)|^2 fnorm[1] Value of |F(x + lambda[1]*dx)|^2 fnorm[2] Value of |F(x + lambda[2]*dx)|^2

Compute the coefficients for the interpolation polynomial: p(lambda) = fnorm[0] + (b*lambda + a*lambda^2)/d1, where d1 = (lambda[1] - lambda[2])*lambda[1]*lambda[2] < 0 if a > 0, then we have a concave up curvature and lambda defaults to: lambda = sigma[0]*lambda

Definition at line 88 of file imstkNonLinearSolver.cpp.

Here is the caller graph for this function:

◆ setAlpha()

template<typename SystemMatrix >
void imstk::NonLinearSolver< SystemMatrix >::setAlpha ( const double  newAlpha)

Set/Get Alpha. Parameter to measure sufficient decrease in the line search.

Parameters
newAlphaNew alpha parameter.

Definition at line 137 of file imstkNonLinearSolver.cpp.

◆ setArmijoMax()

template<typename SystemMatrix >
void imstk::NonLinearSolver< SystemMatrix >::setArmijoMax ( const size_t  newArmijoMax)

Set/Get ArmijoMax. Maximum number of step length reductions.

Parameters
newArmijoMaxNew iteration parameter.

Definition at line 151 of file imstkNonLinearSolver.cpp.

◆ setSigma()

template<typename SystemMatrix >
void imstk::NonLinearSolver< SystemMatrix >::setSigma ( const std::array< double, 2 > &  newSigma)

Set/Get Sigma. Safeguard parameter for the the line search method.

Parameters
newSigmaNew sigma parameter.

Definition at line 123 of file imstkNonLinearSolver.cpp.

◆ setSystem()

template<typename SystemMatrix >
void imstk::NonLinearSolver< SystemMatrix >::setSystem ( std::shared_ptr< NonLinearSystem< SystemMatrix >>  newSystem)

Sets the system. System of nonlinear equations.

Parameters
newSystemNon-linear system replacement.

Definition at line 165 of file imstkNonLinearSolver.cpp.

◆ setUpdateIterate()

template<typename SystemMatrix >
void imstk::NonLinearSolver< SystemMatrix >::setUpdateIterate ( const UpdateIterateType &  newUpdateIterate)
inline

Set a customized iterate update function.

Parameters
newUpdateIterateFunction used to update iterates. Default: x+=dx.

Definition at line 98 of file imstkNonLinearSolver.h.


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