Bridge++  Ver. 2.0.2
asolver_BiCGStab_Cmplx.h
Go to the documentation of this file.
1 
14 #ifndef ASOLVER_BICGSTAB_Cmplx_H
15 #define ASOLVER_BICGSTAB_Cmplx_H
16 
17 
18 #include <string>
19 using std::string;
20 
21 #include "lib_alt/Solver/asolver.h"
22 #include "lib/Fopr/afopr.h"
23 
24 
45 /*
46  Uses a prescription to improve stability of BiCGStab.
47  See G.L.G.Sleijpen and H.A.van der Vorst,
48  Numerical Algorithms 10(1995)203-22.
49  */
50 
51 template<typename AFIELD>
52 class ASolver_BiCGStab_Cmplx : public ASolver<AFIELD>
53 {
54  public:
55  typedef typename AFIELD::real_t real_t;
57  static const std::string class_name;
59  private:
60 
62 
63  int m_Niter;
65 
67 
69 
74 
75  struct coeff_t
76  {
77  std::complex<real_t> rho;
78  std::complex<real_t> alpha;
79  std::complex<real_t> omega;
80  };
81 
82  protected:
83 
85  int m_nconv;
86 
89 
92 
95 
96  public:
100  {
101  vout.paranoiac("setting fopr to ASolver_BiCGStab_Cmplx: fopr=%p\n", fopr);
102  this->init();
103  }
104 
107 
109  void set_parameters(const Parameters& params);
110 
112  void set_parameters(const int Niter, const real_t Stop_cond);
113 
115  void set_parameters(const int Niter, const real_t Stop_cond, const InitialGuess init_guess);
116 
117  void set_init_mode(const InitialGuess init_guess)
118  {
119  m_initial_mode = init_guess;
120  }
121 
123  void set_parameters_BiCGStab_series(const real_t Omega_tolerance);
124 
126  void solve(AFIELD& xq, const AFIELD& b, int& nconv, real_t& diff);
127 
130 
132  double flop_count();
133 
134 
135  protected:
136 
137  void init(void);
138 
139  void tidyup(void);
140 
141  void solve_init(const AFIELD& b, real_t& rr, coeff_t&, const real_t scale, const InitialGuess);
142  void solve_init_RHS(const AFIELD& b, real_t& rr, coeff_t&);
143  void solve_init_ZERO(const AFIELD& b, real_t& rr, coeff_t&);
144  void solve_init_GIVEN(const AFIELD& b, real_t& rr, coeff_t&, const real_t);
145 
146  void solve_step(real_t& rr, int& iflg, coeff_t&);
147 
148 #ifdef USE_FACTORY
149  private:
150  static ASolver<AFIELD> *create_object_with_fopr(AFopr<AFIELD> *fopr)
151  {
152  return new ASolver_BiCGStab_Cmplx<AFIELD>(fopr);
153  }
154 
155  public:
156  static bool register_factory()
157  {
158  return ASolver<AFIELD>::Factory_fopr::Register("BiCGStab_Cmplx", create_object_with_fopr);
159  }
160 #endif
161 };
162 
163 #endif // ASOLVER_BICGSTAB_Cmplx_H
ASolver_BiCGStab_Cmplx::m_p
AFIELD m_p
Definition: asolver_BiCGStab_Cmplx.h:73
ASolver_BiCGStab_Cmplx::solve_init_ZERO
void solve_init_ZERO(const AFIELD &b, real_t &rr, coeff_t &)
Definition: asolver_BiCGStab_Cmplx-tmpl.h:355
ASolver_BiCGStab_Cmplx::m_rh
AFIELD m_rh
Definition: asolver_BiCGStab_Cmplx.h:73
ASolver_BiCGStab_Cmplx::ASolver_BiCGStab_Cmplx
ASolver_BiCGStab_Cmplx(AFopr< AFIELD > *fopr)
constructor.
Definition: asolver_BiCGStab_Cmplx.h:98
ASolver_BiCGStab_Cmplx::m_Stop_cond
real_t m_Stop_cond
stopping criterion (squared).
Definition: asolver_BiCGStab_Cmplx.h:64
ASolver_BiCGStab_Cmplx::coeff_t::omega
std::complex< real_t > omega
Definition: asolver_BiCGStab_Cmplx.h:79
ASolver::RHS
@ RHS
Definition: asolver.h:31
AFopr
Definition: afopr.h:48
ASolver
Definition: asolver.h:23
ASolver_BiCGStab_Cmplx::set_init_mode
void set_init_mode(const InitialGuess init_guess)
Definition: asolver_BiCGStab_Cmplx.h:117
ASolver_BiCGStab_Cmplx::m_initial_mode
InitialGuess m_initial_mode
mode switch for initial guess
Definition: asolver_BiCGStab_Cmplx.h:91
Parameters
Class for parameters.
Definition: parameters.h:46
ASolver_BiCGStab_Cmplx::real_t
AFIELD::real_t real_t
Definition: asolver_BiCGStab_Cmplx.h:55
ASolver_BiCGStab_Cmplx::m_Omega_tolerance
real_t m_Omega_tolerance
tolerance for the stability
Definition: asolver_BiCGStab_Cmplx.h:66
ASolver_BiCGStab_Cmplx::m_r
AFIELD m_r
Definition: asolver_BiCGStab_Cmplx.h:73
ASolver_BiCGStab_Cmplx::m_t
AFIELD m_t
Definition: asolver_BiCGStab_Cmplx.h:73
real_t
double real_t
Definition: bridgeQXS_Clover_coarse_double.cpp:16
ASolver_BiCGStab_Cmplx::m_nconv
int m_nconv
to remember convergence iteration to provide flop count.
Definition: asolver_BiCGStab_Cmplx.h:85
ASolver_BiCGStab_Cmplx::solve_init_RHS
void solve_init_RHS(const AFIELD &b, real_t &rr, coeff_t &)
Definition: asolver_BiCGStab_Cmplx-tmpl.h:281
Field::real_t
double real_t
Definition: field.h:51
Bridge::BridgeIO::paranoiac
void paranoiac(const char *format,...)
Definition: bridgeIO.cpp:238
ASolver_BiCGStab_Cmplx::solve
void solve(AFIELD &xq, const AFIELD &b, int &nconv, real_t &diff)
solver main.
Definition: asolver_BiCGStab_Cmplx-tmpl.h:178
ASolver_BiCGStab_Cmplx::solve_step
void solve_step(real_t &rr, int &iflg, coeff_t &)
Definition: asolver_BiCGStab_Cmplx-tmpl.h:377
ASolver_BiCGStab_Cmplx::coeff_t
Definition: asolver_BiCGStab_Cmplx.h:75
ASolver_BiCGStab_Cmplx::set_parameters_BiCGStab_series
void set_parameters_BiCGStab_series(const real_t Omega_tolerance)
setting BiCGStab specific parameters.
Definition: asolver_BiCGStab_Cmplx-tmpl.h:161
ASolver_BiCGStab_Cmplx::init
void init(void)
Definition: asolver_BiCGStab_Cmplx-tmpl.h:39
ASolver_BiCGStab_Cmplx::~ASolver_BiCGStab_Cmplx
~ASolver_BiCGStab_Cmplx()
destructor.
Definition: asolver_BiCGStab_Cmplx.h:106
ASolver_BiCGStab_Cmplx::m_ecrit
real_t m_ecrit
to avoid too small denominator denominator.
Definition: asolver_BiCGStab_Cmplx.h:68
ASolver_BiCGStab_Cmplx
Definition: asolver_BiCGStab_Cmplx.h:52
ASolver_BiCGStab_Cmplx::get_fopr
AFopr< AFIELD > * get_fopr()
returns the pointer to the fermion operator.
Definition: asolver_BiCGStab_Cmplx.h:129
ASolver_BiCGStab_Cmplx::class_name
static const std::string class_name
Definition: asolver_BiCGStab_Cmplx.h:57
ASolver_BiCGStab_Cmplx::tidyup
void tidyup(void)
Definition: asolver_BiCGStab_Cmplx-tmpl.h:65
ASolver_BiCGStab_Cmplx::m_init_mult
int m_init_mult
to remember convergence iteration to provide flop count.
Definition: asolver_BiCGStab_Cmplx.h:88
ASolver_BiCGStab_Cmplx::m_Niter
int m_Niter
maximum iteration number.
Definition: asolver_BiCGStab_Cmplx.h:63
ASolver_BiCGStab_Cmplx::solve_init_GIVEN
void solve_init_GIVEN(const AFIELD &b, real_t &rr, coeff_t &, const real_t)
Definition: asolver_BiCGStab_Cmplx-tmpl.h:323
ASolver_BiCGStab_Cmplx::m_v
AFIELD m_v
Definition: asolver_BiCGStab_Cmplx.h:73
ASolver_BiCGStab_Cmplx::solve_init
void solve_init(const AFIELD &b, real_t &rr, coeff_t &, const real_t scale, const InitialGuess)
Definition: asolver_BiCGStab_Cmplx-tmpl.h:260
ASolver_BiCGStab_Cmplx::m_fopr
AFopr< AFIELD > * m_fopr
fermion operator.
Definition: asolver_BiCGStab_Cmplx.h:61
ASolver::InitialGuess
InitialGuess
Definition: asolver.h:31
ASolver_BiCGStab_Cmplx::InitialGuess
typename ASolver< AFIELD >::InitialGuess InitialGuess
Definition: asolver_BiCGStab_Cmplx.h:58
Field
Container of Field-type object.
Definition: field.h:46
afopr.h
ASolver_BiCGStab_Cmplx::coeff_t::rho
std::complex< real_t > rho
Definition: asolver_BiCGStab_Cmplx.h:77
ASolver_BiCGStab_Cmplx::coeff_t::alpha
std::complex< real_t > alpha
Definition: asolver_BiCGStab_Cmplx.h:78
asolver.h
ASolver_BiCGStab_Cmplx::set_parameters
void set_parameters(const Parameters &params)
setting parameters by a Parameter object.
Definition: asolver_BiCGStab_Cmplx-tmpl.h:74
ASolver_BiCGStab_Cmplx::ASolver_BiCGStab_Cmplx
ASolver_BiCGStab_Cmplx()
calling constructor without fermion operator is forbidden.
Definition: asolver_BiCGStab_Cmplx.h:94
ASolver::real_t
AFIELD::real_t real_t
Definition: asolver.h:29
ASolver_BiCGStab_Cmplx::m_px
AFIELD * m_px
Definition: asolver_BiCGStab_Cmplx.h:72
ASolver_BiCGStab_Cmplx::flop_count
double flop_count()
returns the floating point operation count.
Definition: asolver_BiCGStab_Cmplx-tmpl.h:468
Bridge::vout
BridgeIO vout
Definition: bridgeIO.cpp:512