22 #ifndef __HERMES_COMMON_NONLINEAR_MATRIX_SOLVER_H_
23 #define __HERMES_COMMON_NONLINEAR_MATRIX_SOLVER_H_
45 ResidualNormRelativeToPrevious = 0x0001,
46 ResidualNormRatioToInitial = 0x0002,
47 ResidualNormRatioToPrevious = 0x0004,
48 ResidualNormAbsolute = 0x0008,
49 SolutionChangeAbsolute = 0x0010,
50 SolutionChangeRelative = 0x0020
59 AboveMaxAllowedResidualNorm,
68 template <
typename Scalar>
81 virtual void solve(Scalar* coeff_vec);
102 #pragma region damping-public
142 #pragma region jacobian_recalculation-public
158 #pragma region damping-private
178 #pragma region jacobian_recalculation-private
184 double sufficient_improvement_factor_jacobian;
185 unsigned int max_steps_with_reused_jacobian;
191 virtual void assemble_residual(
bool store_previous_residual) = 0;
192 virtual bool assemble_jacobian(
bool store_previous_jacobian) = 0;
193 virtual bool assemble(
bool store_previous_jacobian,
bool store_previous_residual) = 0;
245 virtual bool isOkay()
const;
246 inline std::string
getClassName()
const {
return "NonlinearMatrixSolver"; }
276 #pragma region OutputAttachable
281 const OutputParameterDoubleVector& solution_change_norms()
const {
return this->p_solution_change_norms; };
282 const OutputParameterUnsignedInt& successful_steps_damping()
const {
return this->p_successful_steps_damping; };
283 const OutputParameterUnsignedInt& successful_steps_jacobian()
const {
return this->p_successful_steps_jacobian; };
284 const OutputParameterDoubleVector& damping_factors()
const {
return this->p_damping_factors; };
285 const OutputParameterBool& residual_norm_drop()
const {
return this->p_residual_norm_drop; };
286 const OutputParameterBoolVector& iterations_with_recalculated_jacobian()
const {
return this->p_iterations_with_recalculated_jacobian; };
301 Scalar* previous_sln_vector;
302 bool use_initial_guess_for_iterative_solvers;
General namespace for the Hermes library.
General (linear/nonlinear) matrix solver functionality.
int max_allowed_iterations
Maximum number of iterations allowed.
unsigned int necessary_successful_steps_to_increase
necessary number of steps to increase back the damping coeff.
void set_max_allowed_residual_norm(double max_allowed_residual_norm_to_set)
virtual bool isOkay() const
State querying helpers.
Exception interface Basically a std::exception, but with a constructor with string and with print_msg...
bool tolerance_set[NonlinearConvergenceMeasurementTypeCount]
info about set tolerances.
NonlinearConvergenceMeasurementType
This specifies the quantity that is compared to newton_tolerance (settable by set_tolerance()).
bool force_reuse_jacobian_values(unsigned int &successful_steps_with_reused_jacobian)
For deciding if the jacobian is reused at this point.
virtual void on_reused_jacobian_step_end()
General (abstract) vector representation in Hermes.
void set_initial_auto_damping_coeff(double coeff)
int get_current_iteration_number()
Shortcut method for getting the current iteration.
double auto_damping_ratio
void set_manual_damping_coeff(bool onOff, double coeff)
bool manual_damping
Manual / auto.
virtual double update_solution_return_change_norm(Scalar *linear_system_solution)=0
std::string getClassName() const
Get class name, for the purpose of messaging.
OutputParameterDoubleVector p_residual_norms
virtual void on_damping_factor_updated()
virtual void solve(Scalar *coeff_vec)
General (abstract) sparse matrix representation in Hermes.
void finalize_solving()
Internal.
virtual void free()
Frees the instances.
Vector< Scalar > * residual_back
Backup vector for unsuccessful reuse of Jacobian.
void set_min_allowed_damping_coeff(double min_allowed_damping_coeff_to_set)
Class using time measurement Can be used directly (is not abstract), so one can use e...
SparseMatrix< Scalar > * previous_jacobian
Previous structures (e.g. in Picard's residual calculation)
void set_sufficient_improvement_factor(double ratio)
bool do_initial_step_return_finished()
Initial step.
Basic cs (Compressed sparse) matrix classes and operations.
double manual_damping_factor
Manual.
Base class for defining interface for nonlinear solvers.
double max_allowed_residual_norm
int get_num_iters() const
Get the number of iterations.
virtual double calculate_residual_norm()
Norm for convergence.
double min_allowed_damping_coeff
Minimum allowed damping coeff.
virtual bool handle_convergence_state_return_finished(NonlinearConvergenceState state)
int num_iters
To be filled and returned on demand.
NonlinearConvergenceState
Nonlinear Convergence state.
interface for both linear and nonlinear algebraic solvers.
bool calculate_damping_factor(unsigned int &successful_steps)
Calculates the new_ damping coefficient.
void set_auto_damping_ratio(double ratio)
void set_max_allowed_iterations(int max_allowed_iterations)
Set the maximum number of iterations, thus co-determine when to stop iterations.
File containing definition of exceptions classes.
nonlinear_convergence_measurement.
void step_info()
Output info about the step.
virtual void on_reused_jacobian_step_begin()
Mixins classes for algebraic purposes.
virtual void init_solving(Scalar *coeff_vec)
double sufficient_improvement_factor
Sufficient improvement for continuing.
bool handleMultipleTolerancesAnd
double tolerance[NonlinearConvergenceMeasurementTypeCount]
Tolerances for all NonlinearConvergenceMeasurementType numbered sequentially as the enum NonlinearCon...
double initial_auto_damping_factor
The initial (and maximum) damping coefficient.
Class that allows for attaching any method to particular parts of its functionality. Internal.
Basic vector classes and operations.
virtual bool damping_factor_condition()
Returns iff the damping factor condition is fulfilled.
General functionality for preconditioners. Contains class Precond.
Mix-in classes for one functionality, for various classes to be derived from.
virtual void deinit_solving()
Internal.
virtual NonlinearConvergenceState get_convergence_state()
Find out the convergence state.
bool jacobian_reused_okay(unsigned int &successful_steps_with_reused_jacobian)
For deciding if the reused jacobian did not bring residual increase at this point.
const int NonlinearConvergenceMeasurementTypeCount
void init_nonlinear()
Shared code for constructors.
void set_necessary_successful_steps_to_increase(unsigned int steps)
virtual void clear_tolerances()
Clear (reset) all tolerances.
void set_tolerance(double newton_tol, NonlinearConvergenceMeasurementType toleranceType, bool handleMultipleTolerancesAnd=false)
void set_max_steps_with_reused_jacobian(unsigned int steps)
virtual void solve_linear_system()
Solve the step's linear system.
void set_sufficient_improvement_factor_jacobian(double ratio)