7 #include "imstkNonLinearSolver.h" 11 template<
typename SystemMatrix>
12 NonLinearSolver<SystemMatrix>::NonLinearSolver() : m_sigma(
std::array<double, 2>
25 template<
typename SystemMatrix>
30 std::array<double, 3> fnormSqr = { previousFnorm* previousFnorm, 0.0, 0.0 };
31 std::array<double, 3> lambda = {
m_sigma[0] *
m_sigma[1], 1.0, 1.0 };
43 if (currentFnorm < (1.0 -
m_alpha * lambda[0]) * previousFnorm)
58 lambda[2] = lambda[1];
59 lambda[1] = lambda[0];
64 if (currentFnorm < (1.0 -
m_alpha * lambda[0]) * previousFnorm)
71 fnormSqr[2] = fnormSqr[1];
72 fnormSqr[1] = currentFnorm * currentFnorm;
86 template<
typename SystemMatrix>
95 double a1 = lambda[2] * (fnorm[1] - fnorm[0]);
96 double a2 = lambda[1] * (fnorm[2] - fnorm[0]);
101 lambda[0] =
m_sigma[0] * lambda[1];
105 double b = lambda[1] * a2 - lambda[2] * a1;
106 double newLambda = -.5 * b / a;
108 if (newLambda <
m_sigma[0] * lambda[1])
110 newLambda =
m_sigma[0] * lambda[1];
113 if (newLambda >
m_sigma[1] * lambda[1])
115 newLambda =
m_sigma[1] * lambda[1];
118 lambda[0] = newLambda;
121 template<
typename SystemMatrix>
128 template<
typename SystemMatrix>
129 const std::array<double, 2>&
135 template<
typename SystemMatrix>
142 template<
typename SystemMatrix>
149 template<
typename SystemMatrix>
156 template<
typename SystemMatrix>
163 template<
typename SystemMatrix>
170 template<
typename SystemMatrix>
171 std::shared_ptr<NonLinearSystem<SystemMatrix>>
UpdateIterateType m_updateIterate
Update iteration function.
bool m_isSemiImplicit
Semi-Implicit solver.
size_t m_armijoMax
Maximum number of step length reductions.
void setAlpha(const double newAlpha)
Set/Get Alpha. Parameter to measure sufficient decrease in the line search.
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...
double m_alpha
Parameter to measure decrease.
Base class for a multi-variable nonlinear system.
void setSigma(const std::array< double, 2 > &newSigma)
Set/Get Sigma. Safeguard parameter for the the line search method.
double armijo(const Vectord &dx, Vectord &x, const double previousFnorm)
Backtracking line search method based on the Armijo-Goldstein condition.
void setSystem(std::shared_ptr< NonLinearSystem< SystemMatrix >> newSystem)
Sets the system. System of nonlinear equations.
std::array< double, 2 > m_sigma
Safeguarding bounds for the line search.
Base class for non-linear solvers.
void setArmijoMax(const size_t newArmijoMax)
Set/Get ArmijoMax. Maximum number of step length reductions.
std::shared_ptr< NonLinearSystem< SystemMatrix > > m_nonLinearSystem
System of non-linear equations.