Loading...
Searching...
No Matches
newton.h
Go to the documentation of this file.
# ifndef _RHEO_NEWTON_H
# define _RHEO_NEWTON_H
//
// This file is part of Rheolef.
//
// Copyright (C) 2000-2009 Pierre Saramito <Pierre.Saramito@imag.fr>
//
// Rheolef is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// Rheolef is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Rheolef; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// =========================================================================
// AUTHOR: Pierre.Saramito@imag.fr
// DATE: 14 oct 2009
namespace rheolef {
} // namespace rheolef
namespace rheolef {
// [verbatim_newton]
template <class Problem, class Field>
int newton (const Problem& P, Field& uh, Float& tol, size_t& max_iter, odiststream *p_derr = 0)
// [verbatim_newton]
{
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;
}
}
//>newton:
}// namespace rheolef
# endif // _RHEO_NEWTON_H
rheolef::odiststream
odiststream: see the diststream page for the full documentation
Definition diststream.h:137
rheolef::Float
double Float
see the Float page for the full documentation
Definition Float.h:143
rheolef
This file is part of Rheolef.
Definition compiler_eigen.h:39
rheolef::newton
int newton(const Problem &P, Field &uh, Float &tol, size_t &max_iter, odiststream *p_derr=0)
see the newton page for the full documentation
Definition newton.h:98