Hermes2D  3.0
Hermes::Hermes2D::NewtonSolver< Scalar > Class Template Reference

#include <newton_solver.h>

+ Inheritance diagram for Hermes::Hermes2D::NewtonSolver< Scalar >:

Public Member Functions

 NewtonSolver (DiscreteProblem< Scalar > *dp)
 
 NewtonSolver (WeakFormSharedPtr< Scalar > wf, SpaceSharedPtr< Scalar > space)
 
 NewtonSolver (WeakFormSharedPtr< Scalar > wf, std::vector< SpaceSharedPtr< Scalar > > spaces)
 
virtual void solve (Scalar *coeff_vec)
 
Scalar * get_sln_vector ()
 Get sln vector.
 
virtual void set_spaces (std::vector< SpaceSharedPtr< Scalar > > spaces)
 DiscreteProblemWeakForm helper.
 
virtual void set_weak_formulation (WeakFormSharedPtr< Scalar > wf)
 DiscreteProblemWeakForm helper.
 
virtual void set_verbose_output (bool to_set)
 See Hermes::Mixins::Loggable.
 
virtual void assemble_residual (bool store_previous_residual)
 
virtual bool assemble_jacobian (bool store_previous_jacobian)
 
virtual bool assemble (bool store_previous_jacobian, bool store_previous_residual)
 
virtual void init_solving (Scalar *coeff_vec)
 Initialization - called at the beginning of solving.
 
virtual bool isOkay () const
 State querying helpers.
 
std::string getClassName () const
 
- Public Member Functions inherited from Hermes::Hermes2D::Solver< Scalar >
 Solver (bool initialize_discrete_problem=true)
 
 Solver (DiscreteProblem< Scalar > *dp)
 
 Solver (WeakFormSharedPtr< Scalar > wf, SpaceSharedPtr< Scalar > space)
 
 Solver (WeakFormSharedPtr< Scalar > wf, std::vector< SpaceSharedPtr< Scalar > > spaces)
 
virtual void solve ()
 Basic solve method.
 
virtual void solve (MeshFunctionSharedPtr< Scalar > initial_guess)
 
virtual void solve (std::vector< MeshFunctionSharedPtr< Scalar > > initial_guess)
 
virtual void set_time (double time)
 set time information for time-dependent problems.
 
virtual void set_time_step (double time_step)
 
virtual std::vector
< SpaceSharedPtr< Scalar > > 
get_spaces ()
 Get all spaces as a std::vector.
 
- Public Member Functions inherited from Hermes::Hermes2D::Mixins::SettableSpaces< Scalar >
virtual void set_space (SpaceSharedPtr< Scalar > space)
 
virtual SpaceSharedPtr< Scalar > get_space (int n)
 
- Public Member Functions inherited from Hermes::Hermes2D::Mixins::DiscreteProblemWeakForm< Scalar >
WeakFormSharedPtr< Scalar > get_weak_formulation () const
 

Additional Inherited Members

- Protected Member Functions inherited from Hermes::Hermes2D::Mixins::DiscreteProblemWeakForm< Scalar >
 DiscreteProblemWeakForm (WeakFormSharedPtr< Scalar > wf=WeakFormSharedPtr< Scalar >(nullptr))
 
- Protected Attributes inherited from Hermes::Hermes2D::Solver< Scalar >
DiscreteProblem< Scalar > * dp
 FE problem being solved.
 
bool own_dp
 This instance owns its DP.
 
- Protected Attributes inherited from Hermes::Hermes2D::Mixins::DiscreteProblemWeakForm< Scalar >
WeakFormSharedPtr< Scalar > wf
 Weak formulation.
 

Detailed Description

template<typename Scalar>
class Hermes::Hermes2D::NewtonSolver< Scalar >

Class for Newton's method.
Typical usage:
// Initialize Newton's solver.
// Here wf is Hermes2D::WeakForm<double>, space is Hermes2D::Space<double>
Hermes::Hermes2D::NewtonSolver<double> newton_solver(&wf, &space);
Set a whole bunch of parameters according to your liking.
See the class documentation for all possible parameters.
newton_solver.set_tolerance(1e-6);
newton_solver.set_max_allowed_iterations(15);
newton_solver.set_max_allowed_residual_norm(1e6);
newton_solver.set_min_allowed_damping_coeff(1e-3);

// Solve the linear problem.
try
{
   newton_solver.solve();

   double* sln_vector = newton_solver.get_sln_vector();

   Hermes::Hermes2D::Solution<double>::vector_to_solution(sln_vector, &space, &sln);
}
// All kinds of Exceptions may happen (Linear algebraic solver, some bad parameters, some data not initialized...)
catch(Hermes::Exceptions::Exception& e)
{
 e.print_msg();
 return -1;
}
// For illustrative purposes, otherwise one can just catch std::exception directly, as Hermes::Exceptions::Exception derive from it.
catch(std::exception& e)
{
 std::cout << e.what();
 return -1;
}

Definition at line 72 of file newton_solver.h.

Member Function Documentation

template<typename Scalar >
bool Hermes::Hermes2D::NewtonSolver< Scalar >::assemble ( bool  store_previous_jacobian,
bool  store_previous_residual 
)
virtual
Returns
Information if the jacobian structure was reused.

After the first time we assemble the matrix on the new reference space, we can no longer reuse the previous one.

Definition at line 100 of file newton_solver.cpp.

template<typename Scalar >
bool Hermes::Hermes2D::NewtonSolver< Scalar >::assemble_jacobian ( bool  store_previous_jacobian)
virtual
Returns
Information if the jacobian structure was reused.

After the first time we assemble the matrix on the new reference space, we can no longer reuse the previous one.

Definition at line 89 of file newton_solver.cpp.

template<typename Scalar >
void Hermes::Hermes2D::NewtonSolver< Scalar >::solve ( Scalar *  coeff_vec)
virtual

Basic solve method - in linear solvers it serves only as an initial guess for iterative solvers.

Parameters
[in]coeff_vecinitiall guess.

Implements Hermes::Hermes2D::Solver< Scalar >.

Definition at line 62 of file newton_solver.cpp.


The documentation for this class was generated from the following files: