iMSTK
Interactive Medical Simulation Toolkit
|
Base class for non-linear solvers. More...
#include <imstkNonLinearSolver.h>
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 | |
![]() | |
std::shared_ptr< DataTracker > | m_dataTracker |
Base class for non-linear solvers.
Definition at line 24 of file imstkNonLinearSolver.h.
double imstk::NonLinearSolver< SystemMatrix >::armijo | ( | const Vectord & | dx, |
Vectord & | x, | ||
const double | previousFnorm | ||
) |
Backtracking line search method based on the Armijo-Goldstein condition.
dx | Computed direction. |
x | Current iterate. |
Temporaries used in the line search
Initialize temporaries
Update x and keep books on lambda
Update function norms
Apply the three point parabolic model
Definition at line 27 of file imstkNonLinearSolver.cpp.
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.
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.
void imstk::NonLinearSolver< SystemMatrix >::setAlpha | ( | const double | newAlpha | ) |
Set/Get Alpha. Parameter to measure sufficient decrease in the line search.
newAlpha | New alpha parameter. |
Definition at line 137 of file imstkNonLinearSolver.cpp.
void imstk::NonLinearSolver< SystemMatrix >::setArmijoMax | ( | const size_t | newArmijoMax | ) |
Set/Get ArmijoMax. Maximum number of step length reductions.
newArmijoMax | New iteration parameter. |
Definition at line 151 of file imstkNonLinearSolver.cpp.
void imstk::NonLinearSolver< SystemMatrix >::setSigma | ( | const std::array< double, 2 > & | newSigma | ) |
Set/Get Sigma. Safeguard parameter for the the line search method.
newSigma | New sigma parameter. |
Definition at line 123 of file imstkNonLinearSolver.cpp.
void imstk::NonLinearSolver< SystemMatrix >::setSystem | ( | std::shared_ptr< NonLinearSystem< SystemMatrix >> | newSystem | ) |
Sets the system. System of nonlinear equations.
newSystem | Non-linear system replacement. |
Definition at line 165 of file imstkNonLinearSolver.cpp.
|
inline |
Set a customized iterate update function.
newUpdateIterate | Function used to update iterates. Default: x+=dx. |
Definition at line 98 of file imstkNonLinearSolver.h.