HermesCommon  3.0
picard_matrix_solver.h
1 // This file is part of Hermes2D
2 //
3 // Copyright (c) 2009 hp-FEM group at the University of Nevada, Reno (UNR).
4 // Email: hpfem-group@unr.edu, home page: http://www.hpfem.org/.
5 //
6 // Hermes2D is free software; you can redistribute it and/or modify
7 // it under the terms of the GNU General Public License as published
8 // by the Free Software Foundation; either version 2 of the License,
9 // or (at your option) any later version.
10 //
11 // Hermes2D is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
15 //
16 // You should have received a copy of the GNU General Public License
17 // along with Hermes2D; if not, write to the Free Software
18 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
22 #ifndef __HERMES_COMMON_PICARD_MATRIX_SOLVER_H_
23 #define __HERMES_COMMON_PICARD_MATRIX_SOLVER_H_
24 
26 
27 namespace Hermes
28 {
29  namespace Solvers
30  {
32  template<typename Scalar>
33  class HERMES_API PicardMatrixSolver : public NonlinearMatrixSolver < Scalar >
34  {
35  public:
37  virtual ~PicardMatrixSolver() {};
38 
39  void use_overloaded_damping_factor_condition(bool onOff);
40 
41 #pragma region anderson-public
42  void use_Anderson_acceleration(bool to_set);
44 
47  void set_num_last_vector_used(int num);
48 
51  void set_anderson_beta(double beta);
52 #pragma endregion
53 
54  protected:
55  virtual double update_solution_return_change_norm(Scalar* linear_system_solution);
56 
58  virtual void init_solving(Scalar*& coeff_vec);
59 
61  virtual void deinit_solving();
62 
65  virtual void solve_linear_system();
66 
68  virtual double calculate_residual_norm();
69 
70  virtual bool damping_factor_condition();
71 
74  void init_picard();
75 
77  inline std::string getClassName() const { return "PicardMatrixSolver"; }
78 
79  bool damping_factor_condition_overloaded;
80 #pragma region anderson-private
81  // Anderson.
82  int num_last_vectors_used;
83  bool anderson_is_on;
84  double anderson_beta;
86  Scalar** previous_vectors;
88  Scalar* anderson_coeffs;
89 
91  void init_anderson();
93  void deinit_anderson();
94 
96  void handle_previous_vectors();
98  void calculate_anderson_coeffs();
99 
102 
103  int vec_in_memory;
104 #pragma endregion
105  };
106  }
107 }
108 #endif
General namespace for the Hermes library.
Scalar * previous_Anderson_sln_vector
Previous solution (linear combination coming from Anderson).
Base class for defining interface for nonlinear solvers.
Scalar ** previous_vectors
To store num_last_vectors_used last coefficient vectors.
std::string getClassName() const
State querying helpers.
Scalar * anderson_coeffs
To store num_last_vectors_used - 1 Anderson coefficients.
General nonlinear solver functionality.