HermesCommon  3.0
Hermes::Solvers::PicardMatrixSolver< Scalar > Class Template Reference

See H2D: PicardSolver. More...

#include <picard_matrix_solver.h>

+ Inheritance diagram for Hermes::Solvers::PicardMatrixSolver< Scalar >:

Public Member Functions

void use_overloaded_damping_factor_condition (bool onOff)
 
void use_Anderson_acceleration (bool to_set)
 Turn on / off the Anderson acceleration. By default it is off.
 
void set_num_last_vector_used (int num)
 
void set_anderson_beta (double beta)
 
- Public Member Functions inherited from Hermes::Solvers::NonlinearMatrixSolver< Scalar >
virtual void solve (Scalar *coeff_vec)
 
void set_max_allowed_iterations (int max_allowed_iterations)
 Set the maximum number of iterations, thus co-determine when to stop iterations.
 
virtual void clear_tolerances ()
 Clear (reset) all tolerances.
 
void set_max_allowed_residual_norm (double max_allowed_residual_norm_to_set)
 
void set_tolerance (double newton_tol, NonlinearConvergenceMeasurementType toleranceType, bool handleMultipleTolerancesAnd=false)
 
int get_num_iters () const
 Get the number of iterations.
 
void set_min_allowed_damping_coeff (double min_allowed_damping_coeff_to_set)
 
void set_manual_damping_coeff (bool onOff, double coeff)
 
void set_initial_auto_damping_coeff (double coeff)
 
void set_auto_damping_ratio (double ratio)
 
void set_sufficient_improvement_factor (double ratio)
 
void set_necessary_successful_steps_to_increase (unsigned int steps)
 
void set_sufficient_improvement_factor_jacobian (double ratio)
 
void set_max_steps_with_reused_jacobian (unsigned int steps)
 
virtual void free ()
 Frees the instances.
 
- Public Member Functions inherited from Hermes::Solvers::MatrixSolver< Scalar >
 MatrixSolver (bool force_use_direct_solver=false)
 
virtual Scalar * get_sln_vector ()
 Return the solution vector.
 
void set_jacobian_constant (bool to_set=true)
 Sets the jacobian to be constant, i.e. reused whenever possible.
 
virtual LinearMatrixSolver
< Scalar > * 
get_linear_matrix_solver ()
 
virtual void set_UMFPACK_output (bool to_set=true, bool with_output=false)
 
virtual double get_UMFPACK_reporting_data (UMFPACK_reporting_data_value data_value)
 
SparseMatrix< Scalar > * get_jacobian ()
 Only a shortcut for algebraic solver (->) get_matrix().
 
Vector< Scalar > * get_residual ()
 Only a shortcut for algebraic solver (->) get_rhs().
 
virtual void set_verbose_output (bool to_set)
 Verbose output.
 
- Public Member Functions inherited from Hermes::Mixins::Loggable
 Loggable (bool verbose_output=false, callbackFn verbose_callback=NULL, bool add_newline=true)
 
void set_file_output_only (bool onOff)
 
void set_timestamps (bool onOff)
 Sets the addition of a time stamp on each line in the log file. By default it is on.
 
void set_erase_on_beginning (bool onOff)
 Sets the logFile being always erased before logging.
 
void set_logFile_name (const char *filename)
 
void set_logFile_name (std::string filename)
 
void info (const char *msg,...) const
 
void info_if (bool cond, const char *msg,...) const
 
void warn (const char *msg,...) const
 
void warn_if (bool cond, const char *msg,...) const
 
void error (const char *msg,...) const
 
void error_if (bool cond, const char *msg,...) const
 
bool get_verbose_output () const
 Returns the current value of verbose_output;.
 
virtual void set_verbose_callback (callbackFn callback)
 
callbackFn get_verbose_callback () const
 Returns the current value of verbose_callback;.
 
- Public Member Functions inherited from Hermes::Mixins::OutputAttachable
virtual bool on_initialization ()
 
virtual bool on_step_begin ()
 
virtual bool on_initial_step_end ()
 
virtual bool on_step_end ()
 
virtual bool on_finish ()
 
template<typename T >
const T & get_parameter_value (const Parameter< T > &parameter)
 
template<typename T >
T & get_parameter_value (Parameter< T > &parameter)
 
- Public Member Functions inherited from Hermes::Mixins::StateQueryable
void check () const
 Method to handle the state.
 
- Public Member Functions inherited from Hermes::Mixins::TimeMeasurable
 TimeMeasurable (const char *name=nullptr)
 Constructs internal structures and starts measuring.
 
const TimeMeasurablereset ()
 Resets accumulated time.
 
const TimeMeasurabletick_reset ()
 Starts a new_ period and resets accumulated time.
 
const TimeMeasurabletick (TimeMeasurable::TimerPeriodTickType type=HERMES_ACCUMULATE)
 Starts/ends a new_ period.
 
const std::string & name () const
 Returns a name of the time period if any.
 
double accumulated () const
 Returns accumulated time (in seconds).
 
std::string accumulated_str () const
 Returns accumulated time in human readable form.
 
double last () const
 Returns last measured period (in seconds). More...
 
std::string last_str () const
 Returns last measured period in human readable form.
 

Protected Member Functions

virtual double update_solution_return_change_norm (Scalar *linear_system_solution)
 
virtual void init_solving (Scalar *&coeff_vec)
 Initialization - called at the beginning of solving.
 
virtual void deinit_solving ()
 Internal.
 
virtual void solve_linear_system ()
 
virtual double calculate_residual_norm ()
 Norm for convergence.
 
virtual bool damping_factor_condition ()
 Returns iff the damping factor condition is fulfilled.
 
void init_picard ()
 
std::string getClassName () const
 State querying helpers.
 
void init_anderson ()
 Initialization.
 
void deinit_anderson ()
 Deinitialization.
 
void handle_previous_vectors ()
 Handle the previous vectors.
 
void calculate_anderson_coeffs ()
 Calcualte the coefficients.
 
- Protected Member Functions inherited from Hermes::Solvers::NonlinearMatrixSolver< Scalar >
bool force_reuse_jacobian_values (unsigned int &successful_steps_with_reused_jacobian)
 For deciding if the jacobian is reused at this point.
 
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.
 
virtual void assemble_residual (bool store_previous_residual)=0
 
virtual bool assemble_jacobian (bool store_previous_jacobian)=0
 
virtual bool assemble (bool store_previous_jacobian, bool store_previous_residual)=0
 
virtual void on_damping_factor_updated ()
 
virtual void on_reused_jacobian_step_begin ()
 
virtual void on_reused_jacobian_step_end ()
 
virtual bool handle_convergence_state_return_finished (NonlinearConvergenceState state)
 
virtual void init_solving (Scalar *coeff_vec)
 
virtual NonlinearConvergenceState get_convergence_state ()
 Find out the convergence state.
 
bool do_initial_step_return_finished ()
 Initial step.
 
void finalize_solving ()
 Internal.
 
bool calculate_damping_factor (unsigned int &successful_steps)
 Calculates the new_ damping coefficient.
 
int get_current_iteration_number ()
 Shortcut method for getting the current iteration.
 
void step_info ()
 Output info about the step.
 
virtual bool isOkay () const
 State querying helpers.
 
void init_nonlinear ()
 Shared code for constructors.
 
const OutputParameterUnsignedIntiteration () const
 
const OutputParameterDoubleVectorresidual_norms () const
 
const OutputParameterDoubleVectorsolution_norms () const
 
const OutputParameterDoubleVectorsolution_change_norms () const
 
const OutputParameterUnsignedIntsuccessful_steps_damping () const
 
const OutputParameterUnsignedIntsuccessful_steps_jacobian () const
 
const OutputParameterDoubleVectordamping_factors () const
 
const OutputParameterBoolresidual_norm_drop () const
 
const OutputParameterBoolVectoriterations_with_recalculated_jacobian () const
 
- Protected Member Functions inherited from Hermes::Solvers::MatrixSolver< Scalar >
void handle_UMFPACK_reports ()
 This is not used now.
 
- Protected Member Functions inherited from Hermes::Mixins::Loggable
void hermes_fwrite (const void *ptr, size_t size, size_t nitems, FILE *stream) const
 
void hermes_fread (void *ptr, size_t size, size_t nitems, FILE *stream) const
 
- Protected Member Functions inherited from Hermes::Mixins::OutputAttachable
template<typename T >
void set_parameter_value (Parameter< T > &parameter, T *value)
 

Protected Attributes

bool damping_factor_condition_overloaded
 
int num_last_vectors_used
 
bool anderson_is_on
 
double anderson_beta
 
Scalar ** previous_vectors
 To store num_last_vectors_used last coefficient vectors.
 
Scalar * anderson_coeffs
 To store num_last_vectors_used - 1 Anderson coefficients.
 
Scalar * previous_Anderson_sln_vector
 Previous solution (linear combination coming from Anderson).
 
int vec_in_memory
 
- Protected Attributes inherited from Hermes::Solvers::NonlinearMatrixSolver< Scalar >
bool manual_damping
 Manual / auto.
 
double manual_damping_factor
 Manual.
 
double auto_damping_ratio
 
double initial_auto_damping_factor
 The initial (and maximum) damping coefficient.
 
double sufficient_improvement_factor
 Sufficient improvement for continuing.
 
unsigned int necessary_successful_steps_to_increase
 necessary number of steps to increase back the damping coeff.
 
double min_allowed_damping_coeff
 Minimum allowed damping coeff.
 
double sufficient_improvement_factor_jacobian
 
unsigned int max_steps_with_reused_jacobian
 
Vector< Scalar > * residual_back
 Backup vector for unsuccessful reuse of Jacobian.
 
double max_allowed_residual_norm
 
int max_allowed_iterations
 Maximum number of iterations allowed.
 
double tolerance [NonlinearConvergenceMeasurementTypeCount]
 Tolerances for all NonlinearConvergenceMeasurementType numbered sequentially as the enum NonlinearConvergenceMeasurementType is.
 
bool tolerance_set [NonlinearConvergenceMeasurementTypeCount]
 info about set tolerances.
 
bool handleMultipleTolerancesAnd
 
int num_iters
 To be filled and returned on demand.
 
SparseMatrix< Scalar > * previous_jacobian
 Previous structures (e.g. in Picard's residual calculation)
 
Vector< Scalar > * previous_residual
 
OutputParameterDoubleVector p_residual_norms
 
OutputParameterDoubleVector p_solution_norms
 
OutputParameterDoubleVector p_solution_change_norms
 
OutputParameterBoolVector p_iterations_with_recalculated_jacobian
 
OutputParameterUnsignedInt p_successful_steps_damping
 
OutputParameterUnsignedInt p_successful_steps_jacobian
 
OutputParameterDoubleVector p_damping_factors
 
OutputParameterBool p_residual_norm_drop
 
OutputParameterUnsignedInt p_iteration
 
Scalar * previous_sln_vector
 
bool use_initial_guess_for_iterative_solvers
 
- Protected Attributes inherited from Hermes::Solvers::MatrixSolver< Scalar >
Hermes::Solvers::LinearMatrixSolver
< Scalar > * 
linear_matrix_solver
 Linear solver.
 
bool constant_jacobian
 Jacobian can be reused if possible.
 
bool jacobian_reusable
 Jacobian is ready to be reused if desirable.
 
int problem_size
 Number of equations.
 
bool do_UMFPACK_reporting
 
double UMFPACK_reporting_data [3]
 

Additional Inherited Members

- Public Types inherited from Hermes::Solvers::MatrixSolver< Scalar >
enum  UMFPACK_reporting_data_value { FactorizationSize = 0, PeakMemoryUsage = 1, Flops = 2 }
 Data values (types) for UMFPACK reporting.
 
- Public Types inherited from Hermes::Mixins::TimeMeasurable
enum  TimerPeriodTickType { HERMES_ACCUMULATE, HERMES_SKIP }
 Tick type. Used by the class Hermes::TimePeriod. More...
 
- Static Public Member Functions inherited from Hermes::Mixins::Loggable
static void set_static_logFile_name (const char *filename)
 
static void set_static_logFile_name (std::string filename)
 
- Public Attributes inherited from Hermes::Solvers::MatrixSolver< Scalar >
Scalar * sln_vector
 The solution vector.
 
- Public Attributes inherited from Hermes::Mixins::Loggable
char * logFileName
 Logfile name.
 
- Static Public Attributes inherited from Hermes::Mixins::Loggable
static char * staticLogFileName = nullptr
 

Detailed Description

template<typename Scalar>
class Hermes::Solvers::PicardMatrixSolver< Scalar >

See H2D: PicardSolver.

Definition at line 33 of file picard_matrix_solver.h.

Member Function Documentation

template<typename Scalar >
void Hermes::Solvers::PicardMatrixSolver< Scalar >::init_picard ( )
protected

Common constructors code. Internal setting of default values (see individual set methods).

Definition at line 38 of file picard_matrix_solver.cpp.

template<typename Scalar >
void Hermes::Solvers::PicardMatrixSolver< Scalar >::set_anderson_beta ( double  beta)

Set the Anderson beta coefficient. See the details about the Anderson acceleration for explanation of this parameter.

Definition at line 145 of file picard_matrix_solver.cpp.

template<typename Scalar >
void Hermes::Solvers::PicardMatrixSolver< Scalar >::set_num_last_vector_used ( int  num)

Set how many last vectors will be used for Anderson acceleration. See the details about the Anderson acceleration for explanation of this parameter.

Definition at line 139 of file picard_matrix_solver.cpp.

template<typename Scalar >
void Hermes::Solvers::PicardMatrixSolver< Scalar >::solve_linear_system ( )
protectedvirtual

Solve the step's linear system. Overriden because of Anderson.

Reimplemented from Hermes::Solvers::NonlinearMatrixSolver< Scalar >.

Definition at line 102 of file picard_matrix_solver.cpp.

template<typename Scalar >
double Hermes::Solvers::PicardMatrixSolver< Scalar >::update_solution_return_change_norm ( Scalar *  linear_system_solution)
protectedvirtual

Update the solution. This is a method that serves the purpose of distinguishing methods that solve for increment (Newton), or for solution (Picard).

Implements Hermes::Solvers::NonlinearMatrixSolver< Scalar >.

Definition at line 69 of file picard_matrix_solver.cpp.


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