20 #ifndef __mast_eigen_nonlinear_solver_h__ 21 #define __mast_eigen_nonlinear_solver_h__ 37 namespace EigenWrapper {
39 template <
typename ScalarType,
40 typename LinearSolverType,
47 using vector_t = Eigen::Matrix<scalar_t, Eigen::Dynamic, 1>;
51 "Scalar type of function and nonlinear solver must be same");
53 "Vector type of function and nonlinear solver must be same");
79 inline void solve(FuncType &func,
91 func.init_vector(res);
94 func.init_matrix(jac);
96 func.residual(x, res);
112 <<
" Iter: " << std::setw(5) << iter
113 <<
" : || res ||_2 = " 114 << std::setw(15) << res_l2;
118 func.jacobian(x, jac);
120 dx = LinearSolverType(jac).solve(res);
126 <<
" : || dx ||_2 = " 127 << std::setw(15) << dx_l2 << std::endl;
137 func.residual(x, res);
143 <<
" Iter: " << std::setw(5) << iter
144 <<
" : || res ||_2 = " 145 << std::setw(15) << res_l2;
147 if (res_l2/res0_l2 < rtol) {
151 <<
" Terminating due to residual norm relative convergence" 158 <<
" Terminating due to residual norm convergence" 165 <<
" Terminating due to step norm convergence" 168 if (iter >= max_iter) {
172 <<
" Terminating due to maximum iterations" 189 #endif // __mast_eigen_nonlinear_solver_h__
typename FuncType::matrix_t matrix_t
std::enable_if< std::is_same< typename Eigen::internal::traits< VecType >::Scalar, real_t >::value, real_t >::type real_norm(const VecType &v)
std::enable_if< Dim< 3, ScalarType >::typesource_load_multiplier(const SourceLoadFieldType *f, const SectionAreaType *s, ContextType &c) { Assert0(f, "Invalid pointer");Assert0(s, "Invalid pointer");return f-> value(c) *s -> value(c)
virtual ~NonlinearSolver()
Eigen::Matrix< scalar_t, Eigen::Dynamic, 1 > vector_t
void solve(FuncType &func, vector_t &x)
initialize the solver for function object func that provides the residual and jacobian evaluation...