.\" .de Id .. .de Sp .if n .sp .if t .sp 0.4 .. .TH newton 4rheolef "rheolef-6.7" "rheolef-6.7" "rheolef-6.7" .\" label: /*Class:newton .SH NAME \fBnewton\fP -- Newton nonlinear algorithm .\" skip: @findex newton .\" skip: @cindex nonlinear problem .\" skip: @cindex Newton method .SH DESCRIPTION Nonlinear Newton algorithm for the resolution of the following problem: .\" begin_example .Sp .nf F(u) = 0 .Sp .fi .\" end_example A simple call to the algorithm writes: .\" begin_example .Sp .nf my_problem P; field uh (Vh); newton (P, uh, tol, max_iter); .Sp .fi .\" end_example The \fBmy_problem\fP class may contains methods for the evaluation of F (aka residue) and its derivative: .\" begin_example .Sp .nf class my_problem { public: my_problem(); field residue (const field& uh) const; Float dual_space_norm (const field& mrh) const; void update_derivative (const field& uh) const; field derivative_solve (const field& mrh) const; }; .Sp .fi .\" end_example The \fBdual_space_norm\fP returns a scalar from the weighted residual field term \fBmrh\fP returned by the \fBresidue\fP function: this scalar is used as stopping criteria for the algorithm. The \fBupdate_derivative\fP and \fBderivative_solver\fP members are called at each step of the Newton algorithm. See the example \fBp_laplacian.h\fP in the user's documentation for more. .\" skip start:AUTHOR: .\" skip start:DATE: .\" skip start:METHODS: .\" END .SH IMPLEMENTATION .\" begin_example .Sp .nf template int newton (Problem P, Field& uh, Float& tol, size_t& max_iter, odiststream *p_derr = 0) { if (p_derr) *p_derr << "# Newton:" << std::endl << "# n r" << std::endl << std::flush; for (size_t n = 0; true; n++) { Field rh = P.residue(uh); Float r = P.dual_space_norm(rh); if (p_derr) *p_derr << n << " " << r << std::endl << std::flush; if (r <= tol) { tol = r; max_iter = n; return 0; } if (n == max_iter) { tol = r; return 1; } P.update_derivative (uh); Field delta_uh = P.derivative_solve (-rh); uh += delta_uh; } } .Sp .fi .\" end_example