Bridge++  Ver. 2.0.2
asolver_BiCGStab.h
Go to the documentation of this file.
1 #ifndef ASOLVER_BICGSTAB_H
2 #define ASOLVER_BICGSTAB_H
3 
4 #include <cstdio>
5 #include <cstdlib>
6 #include <vector>
7 using std::vector;
8 #include <string>
9 using std::string;
10 
11 #include "asolver.h"
12 #include "lib/Fopr/afopr.h"
13 
14 template<typename AFIELD>
15 class ASolver_BiCGStab : public ASolver<AFIELD>
16 {
17  public:
18  typedef typename AFIELD::real_t real_t;
20  static const std::string class_name;
22 
23  private:
24 
26 
27  int m_Niter;
29 
31 
33 
34 
37  // real_t m_rho_prev, m_alpha_prev, m_omega_prev;
38 
39  protected:
40 
42  int m_nconv;
43 
46 
49 
52 
53  public:
56  : m_Niter(0), m_Stop_cond(0.0L)
57  {
58  m_fopr = fopr;
59  this->init();
60  }
61 
63  ~ASolver_BiCGStab() { this->tidyup(); }
64 
66  void set_parameters(const Parameters& params);
67 
69  void set_parameters(const int Niter, const real_t Stop_cond);
70 
72  void set_parameters(const int Niter, const real_t Stop_cond, const InitialGuess init_mode);
73 
75  void set_init_mode(const InitialGuess init_guess)
76  {
77  m_initial_mode = init_guess;
78  }
79 
81  void set_parameters_BiCGStab_series(const real_t Omega_tolerance);
82 
84  void solve(AFIELD& xq, const AFIELD& b, int& nconv, real_t& diff);
85 
87  AFopr<AFIELD> *get_fopr() { return m_fopr; }
88 
90  double flop_count();
91 
92 
93  protected:
94 
95  void init(void);
96 
97  void tidyup(void);
98 
99  void solve_init(const AFIELD& b, real_t& rr, real_t& alpha_prev, real_t& rho_prev, real_t& omega_prev, const InitialGuess init_mode);
100 
101  void solve_step(real_t& rr, int& iflg, real_t& alpha_prev, real_t& rho_prev, real_t& omega_prev);
102 
103 
104 #ifdef USE_FACTORY
105  private:
106  static ASolver<AFIELD> *create_object_with_fopr(AFopr<AFIELD> *fopr)
107  { return new ASolver_BiCGStab<AFIELD>(fopr); }
108 
109  public:
110  static bool register_factory()
111  {
113  create_object_with_fopr);
114  return init;
115  }
116 #endif
117 };
118 
119 #endif // ASOLVER_BICGSTAB_H
ASolver_BiCGStab::tidyup
void tidyup(void)
Definition: asolver_BiCGStab-tmpl.h:48
ASolver_BiCGStab::m_x
AFIELD m_x
Matsufuru added: new AField_dev implementation.
Definition: asolver_BiCGStab.h:36
AFopr
Definition: afopr.h:48
ASolver
Definition: asolver.h:23
Parameters
Class for parameters.
Definition: parameters.h:46
ASolver_BiCGStab::m_v
AFIELD m_v
Definition: asolver_BiCGStab.h:36
ASolver_BiCGStab::m_s
AFIELD m_s
Definition: asolver_BiCGStab.h:36
ASolver_BiCGStab::m_Stop_cond
real_t m_Stop_cond
stopping criterion (squared).
Definition: asolver_BiCGStab.h:28
ASolver_BiCGStab::set_init_mode
void set_init_mode(const InitialGuess init_guess)
setting the initial guess mode
Definition: asolver_BiCGStab.h:75
ASolver_BiCGStab::get_fopr
AFopr< AFIELD > * get_fopr()
returns the pointer to the fermion operator.
Definition: asolver_BiCGStab.h:87
ASolver_BiCGStab::ASolver_BiCGStab
ASolver_BiCGStab(AFopr< AFIELD > *fopr)
constructor.
Definition: asolver_BiCGStab.h:55
ASolver_BiCGStab::m_init_mult
int m_init_mult
to remember convergence iteration to provide flop count.
Definition: asolver_BiCGStab.h:45
ASolver_BiCGStab
Definition: asolver_BiCGStab.h:15
real_t
double real_t
Definition: bridgeQXS_Clover_coarse_double.cpp:16
ASolver_BiCGStab::set_parameters_BiCGStab_series
void set_parameters_BiCGStab_series(const real_t Omega_tolerance)
setting BiCGStab specific parameters.
Definition: asolver_BiCGStab-tmpl.h:125
ASolver_BiCGStab::m_rh
AFIELD m_rh
Definition: asolver_BiCGStab.h:36
ASolver_BiCGStab::~ASolver_BiCGStab
~ASolver_BiCGStab()
destructor.
Definition: asolver_BiCGStab.h:63
Field::real_t
double real_t
Definition: field.h:51
ASolver_BiCGStab::solve
void solve(AFIELD &xq, const AFIELD &b, int &nconv, real_t &diff)
solver main.
Definition: asolver_BiCGStab-tmpl.h:142
ASolver_BiCGStab::init
void init(void)
Definition: asolver_BiCGStab-tmpl.h:16
ASolver_BiCGStab::m_t
AFIELD m_t
Definition: asolver_BiCGStab.h:36
ASolver_BiCGStab::real_t
AFIELD::real_t real_t
Definition: asolver_BiCGStab.h:18
ASolver_BiCGStab::m_r
AFIELD m_r
Definition: asolver_BiCGStab.h:36
ASolver_BiCGStab::m_p
AFIELD m_p
Definition: asolver_BiCGStab.h:36
ASolver_BiCGStab::solve_init
void solve_init(const AFIELD &b, real_t &rr, real_t &alpha_prev, real_t &rho_prev, real_t &omega_prev, const InitialGuess init_mode)
Definition: asolver_BiCGStab-tmpl.h:252
ASolver_BiCGStab::class_name
static const std::string class_name
Definition: asolver_BiCGStab.h:20
ASolver_BiCGStab::m_initial_mode
InitialGuess m_initial_mode
mode switch for initial guess
Definition: asolver_BiCGStab.h:48
ASolver_BiCGStab::flop_count
double flop_count()
returns the floating point operation count.
Definition: asolver_BiCGStab-tmpl.h:387
ASolver_BiCGStab::m_Omega_tolerance
real_t m_Omega_tolerance
tolerance for the stability
Definition: asolver_BiCGStab.h:30
ASolver_BiCGStab::set_parameters
void set_parameters(const Parameters &params)
setting parameters by a Parameter object.
Definition: asolver_BiCGStab-tmpl.h:57
ASolver_BiCGStab::m_fopr
AFopr< AFIELD > * m_fopr
fermion operator.
Definition: asolver_BiCGStab.h:25
ASolver::InitialGuess
InitialGuess
Definition: asolver.h:31
ASolver_BiCGStab::InitialGuess
typename ASolver< AFIELD >::InitialGuess InitialGuess
Definition: asolver_BiCGStab.h:21
ASolver_BiCGStab::ASolver_BiCGStab
ASolver_BiCGStab()
calling constructor without fermion operator is forbidden.
Definition: asolver_BiCGStab.h:51
Field
Container of Field-type object.
Definition: field.h:46
afopr.h
ASolver_BiCGStab::m_ecrit
real_t m_ecrit
to avoid too small denominator denominator.
Definition: asolver_BiCGStab.h:32
asolver.h
ASolver_BiCGStab::m_nconv
int m_nconv
to remember convergence iteration to provide flop count.
Definition: asolver_BiCGStab.h:42
ASolver_BiCGStab::m_Niter
int m_Niter
maximum iteration number.
Definition: asolver_BiCGStab.h:27
ASolver_BiCGStab::solve_step
void solve_step(real_t &rr, int &iflg, real_t &alpha_prev, real_t &rho_prev, real_t &omega_prev)
Definition: asolver_BiCGStab-tmpl.h:294
ASolver::real_t
AFIELD::real_t real_t
Definition: asolver.h:29