43 NonlinearOperator & nonlinear_operator_in,
44 LinearOperator & linear_operator_in,
45 LinearSolver & linear_solver_in)
46 : solver_data(solver_data_in),
47 nonlinear_operator(nonlinear_operator_in),
48 linear_operator(linear_operator_in),
49 linear_solver(linear_solver_in)
53 std::tuple<
unsigned int ,
unsigned int >
56 unsigned int newton_iterations = 0, linear_iterations = 0;
59 residual.reinit(solution);
60 increment.reinit(solution);
61 temporary.reinit(solution);
64 nonlinear_operator.evaluate_residual(residual, solution);
66 double norm_r = residual.l2_norm();
67 double norm_r_0 = norm_r;
69 while(norm_r > this->solver_data.abs_tol and norm_r / norm_r_0 > solver_data.rel_tol and
70 newton_iterations < solver_data.max_iter)
79 linear_operator.set_solution_linearization(solution);
82 bool const update_now =
83 update.do_update and (newton_iterations % update.update_every_newton_iter == 0);
86 linear_solver.update_preconditioner(update_now);
89 unsigned int const n_iter_linear = linear_solver.solve(increment, residual);
93 double norm_r_damp = 1.0;
94 unsigned int n_iter_damp = 0;
95 unsigned int const max_iter_damp = 10;
96 double const tau = 0.5;
100 temporary = solution;
101 temporary.add(omega, increment);
104 nonlinear_operator.evaluate_residual(residual, temporary);
107 norm_r_damp = residual.l2_norm();
114 }
while(norm_r_damp >= (1.0 - tau * omega) * norm_r and n_iter_damp < max_iter_damp);
116 AssertThrow(norm_r_damp < (1.0 - tau * omega) * norm_r,
117 dealii::ExcMessage(
"Damped Newton iteration did not converge. "
118 "Maximum number of iterations exceeded!"));
121 solution = temporary;
122 norm_r = norm_r_damp;
126 linear_iterations += n_iter_linear;
129 AssertThrow(norm_r <= this->solver_data.abs_tol or norm_r / norm_r_0 <= solver_data.rel_tol,
131 "Newton solver failed to solve nonlinear problem to given tolerance. "
132 "Maximum number of iterations exceeded!"));
134 if(update.do_update and update.update_once_converged)
137 linear_operator.set_solution_linearization(solution);
139 linear_solver.update_preconditioner(
true);
142 return std::tuple<unsigned int, unsigned int>(newton_iterations, linear_iterations);
147 NonlinearOperator & nonlinear_operator;
148 LinearOperator & linear_operator;
149 LinearSolver & linear_solver;