Bridge++  Version 1.5.4
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
solver_CG.h
Go to the documentation of this file.
1 
14 #ifndef SOLVER_CG_INCLUDED
15 #define SOLVER_CG_INCLUDED
16 
17 #include "solver.h"
18 
19 #include "IO/bridgeIO.h"
20 using Bridge::vout;
21 
23 
38 class Solver_CG : public Solver
39 {
40  public:
41  static const std::string class_name;
42 
43  private:
45 
46  int m_Niter;
48  double m_Stop_cond;
50 
51  //- working area
53 
56 
57  public:
58  Solver_CG(Fopr *fopr)
59  : Solver(), m_fopr(fopr)
60  {
61  m_use_init_guess = false;
62  m_Nrestart_count = 0;
63  m_Nconv_count = 0;
64  }
65 
67  : Solver(), m_fopr(fopr.get())
68  {
69  m_use_init_guess = false;
70  m_Nrestart_count = 0;
71  m_Nconv_count = 0;
72  }
73 
75 
76  void set_parameters(const Parameters& params);
77  void set_parameters(const int Niter, const int Nrestart, const double Stop_cond);
78  void set_parameters(const int Niter, const int Nrestart, const double Stop_cond, const bool use_init_guess);
79 
80  void solve(Field& solution, const Field& source,
81  int& Nconv, double& diff);
82 
83  Fopr *get_fopr() { return m_fopr; }
84 
85  double flop_count();
86 
87  private:
88  void reset_field(const Field&);
89 
90  void solve_init(const Field&, double&);
91  void solve_step(double&);
92 
93 #ifdef USE_FACTORY
94  private:
95  static Solver *create_object(Fopr *fopr)
96  {
97  return new Solver_CG(fopr);
98  }
99 
100  public:
101  static bool register_factory()
102  {
103  return Solver::Factory::Register("CG", create_object);
104  }
105 #endif
106 };
107 #endif
BridgeIO vout
Definition: bridgeIO.cpp:503
Fopr * get_fopr()
Definition: solver_CG.h:83
void solve_init(const Field &, double &)
Definition: solver_CG.cpp:223
int m_Nrestart_count
Definition: solver_CG.h:54
~Solver_CG()
Definition: solver_CG.h:74
double m_Stop_cond
Definition: solver_CG.h:48
void reset_field(const Field &)
Definition: solver_CG.cpp:200
Solver_CG(Fopr *fopr)
Definition: solver_CG.h:58
void solve(Field &solution, const Field &source, int &Nconv, double &diff)
Definition: solver_CG.cpp:112
Container of Field-type object.
Definition: field.h:45
static const std::string class_name
Definition: solver_CG.h:41
void solve_step(double &)
Definition: solver_CG.cpp:238
bool m_use_init_guess
Definition: solver_CG.h:49
Class for parameters.
Definition: parameters.h:46
Solver_CG(unique_ptr< Fopr > &fopr)
Definition: solver_CG.h:66
Standard Conjugate Gradient solver algorithm.
Definition: solver_CG.h:38
int m_Nrestart
Definition: solver_CG.h:47
void set_parameters(const Parameters &params)
Definition: solver_CG.cpp:25
Field m_s
Definition: solver_CG.h:52
Field m_x
Definition: solver_CG.h:52
Fopr * m_fopr
Definition: solver_CG.h:44
Base class for linear solver class family.
Definition: solver.h:36
Field m_p
Definition: solver_CG.h:52
Field m_r
Definition: solver_CG.h:52
Base class of fermion operator family.
Definition: fopr.h:46
double flop_count()
Definition: solver_CG.cpp:258
int m_Niter
Definition: solver_CG.h:46
int m_Nconv_count
Definition: solver_CG.h:55