Bridge++  Ver. 2.0.2
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  protected:
45 
46  private:
48 
49  int m_Niter;
51  double m_Stop_cond;
53 
54  //- working area
56 
59 
60  public:
61  Solver_CG(Fopr *fopr)
62  : m_vl(CommonParameters::Vlevel()), m_fopr(fopr)
63  {
64  m_use_init_guess = false;
65  m_Nrestart_count = 0;
66  m_Nconv_count = 0;
67  }
68 
69  Solver_CG(Fopr *fopr, const Parameters& params)
70  : m_vl(CommonParameters::Vlevel()), m_fopr(fopr)
71  {
72  m_use_init_guess = false;
73  m_Nrestart_count = 0;
74  m_Nconv_count = 0;
75 
76  set_parameters(params);
77  }
78 
80 
81  void set_parameters(const Parameters& params);
82 
83  void set_parameters(const int Niter, const int Nrestart, const double Stop_cond);
84 
85  void set_parameters(const int Niter, const int Nrestart, const double Stop_cond, const bool use_init_guess);
86 
87  void get_parameters(Parameters& params) const;
88 
89  void solve(Field& solution, const Field& source, int& Nconv, double& diff);
90 
91  Fopr *get_fopr() { return m_fopr; }
92 
93  double flop_count();
94 
95  private:
96  void reset_field(const Field&);
97 
98  void solve_init(const Field&, double&);
99  void solve_step(double&);
100 
101 #ifdef USE_FACTORY
102  private:
103  static Solver *create_object(Fopr *fopr)
104  {
105  return new Solver_CG(fopr);
106  }
107 
108  static Solver *create_object_with_params(Fopr *fopr, const Parameters& params)
109  {
110  return new Solver_CG(fopr, params);
111  }
112 
113  public:
114  static bool register_factory()
115  {
116  bool init = true;
117  init &= Solver::Factory::Register("CG", create_object);
118  init &= Solver::Factory_params::Register("CG", create_object_with_params);
119  return init;
120  }
121 #endif
122 };
123 #endif
Solver_CG::m_fopr
Fopr * m_fopr
Definition: solver_CG.h:47
solver.h
bridgeIO.h
Solver_CG::Solver_CG
Solver_CG(Fopr *fopr)
Definition: solver_CG.h:61
CommonParameters
Common parameter class: provides parameters as singleton.
Definition: commonParameters.h:42
AFopr< Field >
Solver_CG::m_Nrestart
int m_Nrestart
Definition: solver_CG.h:50
Solver_CG::m_vl
Bridge::VerboseLevel m_vl
Definition: solver_CG.h:44
Parameters
Class for parameters.
Definition: parameters.h:46
Solver_CG::~Solver_CG
~Solver_CG()
Definition: solver_CG.h:79
Solver_CG::Solver_CG
Solver_CG(Fopr *fopr, const Parameters &params)
Definition: solver_CG.h:69
Solver_CG::reset_field
void reset_field(const Field &)
Definition: solver_CG.cpp:213
Solver_CG::get_parameters
void get_parameters(Parameters &params) const
Definition: solver_CG.cpp:53
Solver_CG::solve
void solve(Field &solution, const Field &source, int &Nconv, double &diff)
Definition: solver_CG.cpp:125
Solver_CG::m_Nrestart_count
int m_Nrestart_count
Definition: solver_CG.h:57
Solver_CG::m_s
Field m_s
Definition: solver_CG.h:55
Solver
Base class for linear solver class family.
Definition: solver.h:36
Solver_CG::class_name
static const std::string class_name
Definition: solver_CG.h:41
Solver_CG::m_x
Field m_x
Definition: solver_CG.h:55
Solver_CG::get_fopr
Fopr * get_fopr()
Definition: solver_CG.h:91
Solver_CG::m_p
Field m_p
Definition: solver_CG.h:55
Solver_CG::m_Niter
int m_Niter
Definition: solver_CG.h:49
Solver_CG::m_Stop_cond
double m_Stop_cond
Definition: solver_CG.h:51
Solver_CG::solve_init
void solve_init(const Field &, double &)
Definition: solver_CG.cpp:236
Solver_CG::set_parameters
void set_parameters(const Parameters &params)
Definition: solver_CG.cpp:25
Solver_CG::solve_step
void solve_step(double &)
Definition: solver_CG.cpp:251
Solver_CG
Standard Conjugate Gradient solver algorithm.
Definition: solver_CG.h:38
Field
Container of Field-type object.
Definition: field.h:46
Bridge::VerboseLevel
VerboseLevel
Definition: bridgeIO.h:42
Solver_CG::flop_count
double flop_count()
Definition: solver_CG.cpp:271
Solver_CG::m_Nconv_count
int m_Nconv_count
Definition: solver_CG.h:58
Bridge::vout
BridgeIO vout
Definition: bridgeIO.cpp:512
Solver_CG::m_use_init_guess
bool m_use_init_guess
Definition: solver_CG.h:52
Solver_CG::m_r
Field m_r
Definition: solver_CG.h:55