24 #ifndef __NEWTON_SOLVER_H 25 #define __NEWTON_SOLVER_H 29 #include <dolfin/common/MPI.h> 30 #include <dolfin/common/Variable.h> 36 class GenericLinearSolver;
37 class GenericLinearAlgebraFactory;
40 class NonlinearProblem;
61 NewtonSolver(MPI_Comm comm, std::shared_ptr<GenericLinearSolver> solver,
141 { _relaxation_parameter = relaxation_parameter; }
149 {
return _relaxation_parameter; }
169 std::size_t iteration);
186 virtual void solver_setup(std::shared_ptr<const GenericMatrix> A,
187 std::shared_ptr<const GenericMatrix> P,
189 std::size_t iteration);
209 double relaxation_parameter,
211 std::size_t iteration);
216 std::size_t _newton_iteration;
219 std::size_t _krylov_iterations;
222 double _relaxation_parameter;
225 double _residual, _residual0;
228 std::shared_ptr<GenericLinearSolver> _solver;
231 std::shared_ptr<GenericMatrix> _matA;
234 std::shared_ptr<GenericMatrix> _matP;
237 std::shared_ptr<GenericVector> _dx;
240 std::shared_ptr<GenericVector> _b;
Common base class for DOLFIN variables.
Definition: Variable.h:35
virtual ~NewtonSolver()
Destructor.
Definition: NewtonSolver.cpp:93
std::size_t iteration() const
Definition: NewtonSolver.cpp:232
double relative_residual() const
Definition: NewtonSolver.cpp:252
Definition: NonlinearProblem.h:36
void set_relaxation_parameter(double relaxation_parameter)
Definition: NewtonSolver.h:140
std::size_t krylov_iterations() const
Definition: NewtonSolver.cpp:237
double residual() const
Definition: NewtonSolver.cpp:242
GenericLinearSolver & linear_solver() const
Definition: NewtonSolver.cpp:257
Base class for LinearAlgebra factories.
Definition: GenericLinearAlgebraFactory.h:46
std::pair< std::size_t, bool > solve(NonlinearProblem &nonlinear_function, GenericVector &x)
Definition: NewtonSolver.cpp:99
virtual void solver_setup(std::shared_ptr< const GenericMatrix > A, std::shared_ptr< const GenericMatrix > P, const NonlinearProblem &nonlinear_problem, std::size_t iteration)
Definition: NewtonSolver.cpp:302
Definition: Parameters.h:94
virtual bool converged(const GenericVector &r, const NonlinearProblem &nonlinear_problem, std::size_t iteration)
Definition: NewtonSolver.cpp:271
static Parameters default_parameters()
Definition: NewtonSolver.cpp:45
This class provides a general solver for linear systems Ax = b.
Definition: GenericLinearSolver.h:37
double get_relaxation_parameter()
Definition: NewtonSolver.h:148
Definition: NewtonSolver.h:45
double residual0() const
Definition: NewtonSolver.cpp:247
NewtonSolver(MPI_Comm comm=MPI_COMM_WORLD)
Create nonlinear solver.
Definition: NewtonSolver.cpp:87
This class defines a common interface for vectors.
Definition: GenericVector.h:47
virtual void update_solution(GenericVector &x, const GenericVector &dx, double relaxation_parameter, const NonlinearProblem &nonlinear_problem, std::size_t iteration)
Definition: NewtonSolver.cpp:319