Bridge++  Ver. 2.0.2
asolver_MG_double.h
Go to the documentation of this file.
1 
10 //====================================================================
11 #ifndef ASOLVER_MG_H
12 #define ASOLVER_MG_H
13 
14 #include <cstdio>
15 #include <cstdlib>
16 #include <vector>
17 using std::vector;
18 #include <string>
19 using std::string;
20 
21 #include "lib_alt/Solver/asolver.h"
22 #include "lib/Fopr/afopr.h"
23 #include "lib_alt/Fopr/afopr_dd.h"
27 
28 //====================================================================
29 template<typename AFIELD>
30 class ASolver_MG_double : public ASolver<AFIELD>
31 {
32  public:
33  typedef typename AFIELD::real_t real_t;
35  // fopr types: should be given in the .cpp file
36  //using FoprD_t = AFopr_Clover<AFIELD>;
37  //using FoprF_t = AFopr_Clover_dd<AFIELD2>;
38  //using FoprCoarse_t = AFopr_Clover_coarse<AFIELD2 >;
39 
40  // solver types: should be given in the .cpp file
41  //using OuterSolver_t = ASolver_FBiCGStab<AFIELD>;
42  //using CoarseSolver_t = ASolver_BiCGStab_Cmplx< AFIELD2>;
43  //using Smoother_t = ASolver_SAP<AFIELD2>;
44 
45 
46  // index
47  // using MultiGrid_t = MultiGrid_Clover<AFIELD2, AFIELD2>;
48 
50  static const std::string class_name;
51 
52  protected:
53 
54  // preconditinor: I am the owener
55  unique_ptr<APrecond_MG<AFIELD, AFIELD2> > m_prec_mg;
56  std::vector<int> m_sap_block_size;
57 
58  // fine grid fermion operators: only references
59  AFopr<AFIELD> *m_afopr_fineD; // assumes double prec.
60  AFopr_dd<AFIELD2> *m_afopr_fineF; // a block version is required
61 
62  // coarse grid fermion operator: I am the owner
63  unique_ptr<AFopr<AFIELD2> > m_afopr_coarse;
64 
65  // solvers: I am the owner
66  unique_ptr<ASolver<AFIELD2> > m_asolver_coarse;
67  unique_ptr<ASolver<AFIELD2> > m_asolver_smoother;
68  unique_ptr<ASolver<AFIELD> > m_outer_solver;
69 
70  // multigrid converter: I am the owner
71  unique_ptr<MultiGrid<AFIELD2, AFIELD2> > m_multigrid;
72 
73  int m_Niter;
75  int m_Nconv;
76 
77  int m_nvec;
78  int m_nsetup;
79 
80  static constexpr int m_min_res_iter = 6;
83 
86  // Parameters m_params_fopr_dd; //!< parameters for fopr, used to generated dd op.
87 
88  std::string m_mode;
89 
91  int m_nconv;
92 
94  //ASolver_MG_double(){ };
95 
98 
99 
100  public:
103  : m_Niter(0), m_Stop_cond(0.0L)
104  {
105  this->init();
106  }
107 
109  ~ASolver_MG_double() { this->tidyup(); }
110 
112  void set_parameters(const Parameters& params);
113 
115  void set_parameters_level0(const Parameters& params);
116 
118  void set_parameters_level1(const Parameters& params);
119 
121  void set_parameters(const int Niter, const real_t Stop_cond, const std::vector<int>& sap_block_size, const int nvec);
122 
123  void set_parameters(const int Niter, const real_t Stop_cond, const std::string& outer_vlevel,
124  const std::vector<int>& sap_block_size, const int nvec, const int nsetup,
125  const int coarse_niter, const real_t coarse_stop_cond, const std::string& coarse_vlevel,
126  const int smoother_niter, const real_t smoother_stop_cond);
127 
129  void run_setup();
130  void run_setup_initial(std::vector<AFIELD2>& testvec_work);
131  void run_setup_iterative(int niter, std::vector<AFIELD2>& testvec_work);
132 
133 
135  void solve(AFIELD& xq, const AFIELD& b, int& nconv, real_t& diff);
136 
141 
143 
144  // ! set fopr
145  void set_foprD(AFopr<AFIELD> *foprD);
146 
147  void set_foprF(AFopr_dd<AFIELD2> *foprF);
148 
149  void set_lattice(const vector<int>& sap_block_size);
150 
151  // ! initialize internal solvers
152  void init_solver(std::string mode);
153 
154  // ! initialize internal solvers
155  void init_solver()
156  {
157  init_solver("D");
158  }
159 
161  double flop_count();
162 
164  double flop_count_setup();
165 
166  void reset_flop_count();
167 
168  protected:
169 
170  void init_coarse_grid();
171 
172  void init(void);
173 
174  void tidyup(void);
175 
176  void solve_MG_init(real_t& rrp, real_t& rr);
177 
178  void solve_MG_step(real_t& rrp, real_t& rr);
179 
180  std::vector<int> m_coarse_lattice;
181 
182  unique_ptr<Timer> m_timer_gramschmidt;
183  unique_ptr<Timer> m_timer_generate_coarse_op;
184 };
185 
186 #endif // include gurad
187 //============================================================END=====
ASolver_MG_double::m_smoother_stop_cond
int m_smoother_stop_cond
Definition: asolver_MG_double.h:82
ASolver_MG_double::get_fopr_coarse
AFopr< AFIELD2 > * get_fopr_coarse()
Definition: asolver_MG_double.h:142
ASolver_MG_double::m_nvec
int m_nvec
number of testvectors
Definition: asolver_MG_double.h:77
ASolver_MG_double::set_lattice
void set_lattice(const vector< int > &sap_block_size)
Definition: asolver_MG_double-tmpl.h:297
aprecond_MG.h
Multigrid preconditionor (SIMD version)
AFopr
Definition: afopr.h:48
ASolver
Definition: asolver.h:23
ASolver_MG_double::m_min_res_iter
static constexpr int m_min_res_iter
Definition: asolver_MG_double.h:80
ASolver_MG_double::get_fopr
AFopr< AFIELD > * get_fopr()
returns the pointer to the fermion operator.
Definition: asolver_MG_double.h:138
Parameters
Class for parameters.
Definition: parameters.h:46
ASolver_MG_double::m_Niter
int m_Niter
maximum iteration number.
Definition: asolver_MG_double.h:73
ASolver_MG_double::solve_MG_init
void solve_MG_init(real_t &rrp, real_t &rr)
afield_base.h
ASolver_MG_double::set_parameters_level0
void set_parameters_level0(const Parameters &params)
setting parameters by a Parameter object.
Definition: asolver_MG_double-tmpl.h:103
ASolver_MG_double::run_setup
void run_setup()
setup
Definition: asolver_MG_double-tmpl.h:336
AField
Definition: afield_base.h:16
ASolver_MG_double::m_coarse_lattice
std::vector< int > m_coarse_lattice
Definition: asolver_MG_double.h:180
ASolver_MG_double::set_parameters
void set_parameters(const Parameters &params)
setting parameters by a Parameter object.
Definition: asolver_MG_double-tmpl.h:67
ASolver_MG_double::m_mode
std::string m_mode
Definition: asolver_MG_double.h:88
ASolver_MG_double::flop_count_setup
double flop_count_setup()
returns the floating point operation count [setup].
ASolver_MG_double::set_parameters_level1
void set_parameters_level1(const Parameters &params)
setting parameters by a Parameter object.
Definition: asolver_MG_double-tmpl.h:111
ASolver_MG_double::m_afopr_fineD
AFopr< AFIELD > * m_afopr_fineD
Definition: asolver_MG_double.h:59
ASolver_MG_double::real_t
AFIELD::real_t real_t
Definition: asolver_MG_double.h:33
ASolver_MG_double::init_solver
void init_solver()
Definition: asolver_MG_double.h:155
ASolver_MG_double::m_params_asolver_coarse
Parameters m_params_asolver_coarse
parameters for coarse grid solver
Definition: asolver_MG_double.h:84
real_t
double real_t
Definition: bridgeQXS_Clover_coarse_double.cpp:16
ASolver_MG_double::reset_flop_count
void reset_flop_count()
Definition: asolver_MG_double-tmpl.h:508
AFopr_dd
Base class of fermion operator family.
Definition: afopr_dd.h:24
ASolver_MG_double::m_r
AFIELD m_r
Definition: asolver_MG_double.h:97
ASolver_MG_double::m_multigrid
unique_ptr< MultiGrid< AFIELD2, AFIELD2 > > m_multigrid
Definition: asolver_MG_double.h:71
MultiGrid.h
Field::real_t
double real_t
Definition: field.h:51
ASolver_MG_double::run_setup_iterative
void run_setup_iterative(int niter, std::vector< AFIELD2 > &testvec_work)
Definition: asolver_MG_double-tmpl.h:442
afopr_dd.h
ASolver_MG_double::set_foprD
void set_foprD(AFopr< AFIELD > *foprD)
Definition: asolver_MG_double-tmpl.h:178
ASolver_MG_double::solve_MG_step
void solve_MG_step(real_t &rrp, real_t &rr)
ASolver_MG_double::m_asolver_coarse
unique_ptr< ASolver< AFIELD2 > > m_asolver_coarse
Definition: asolver_MG_double.h:66
ASolver_MG_double::tidyup
void tidyup(void)
Definition: asolver_MG_double-tmpl.h:60
ASolver_MG_double::m_p
AFIELD m_p
Definition: asolver_MG_double.h:97
ASolver_MG_double::m_prec_mg
unique_ptr< APrecond_MG< AFIELD, AFIELD2 > > m_prec_mg
Definition: asolver_MG_double.h:55
ASolver_MG_double::flop_count
double flop_count()
returns the floating point operation count.
Definition: asolver_MG_double-tmpl.h:517
ASolver_MG_double::class_name
static const std::string class_name
Definition: asolver_MG_double.h:50
ASolver_MG_double::m_nsetup
int m_nsetup
setup iterations
Definition: asolver_MG_double.h:78
ASolver_MG_double::m_smoother_niter
int m_smoother_niter
Definition: asolver_MG_double.h:81
ASolver_MG_double::m_outer_solver
unique_ptr< ASolver< AFIELD > > m_outer_solver
Definition: asolver_MG_double.h:68
ASolver_MG_double::run_setup_initial
void run_setup_initial(std::vector< AFIELD2 > &testvec_work)
Definition: asolver_MG_double-tmpl.h:375
ASolver_MG_double::set_foprF
void set_foprF(AFopr_dd< AFIELD2 > *foprF)
Definition: asolver_MG_double-tmpl.h:191
ASolver_MG_double::m_Nconv
int m_Nconv
iteratoin number to calculate flop
Definition: asolver_MG_double.h:75
ASolver_MG_double::m_Stop_cond
real_t m_Stop_cond
stopping criterion (squared).
Definition: asolver_MG_double.h:74
ASolver_MG_double::solve
void solve(AFIELD &xq, const AFIELD &b, int &nconv, real_t &diff)
solver main.
Definition: asolver_MG_double-tmpl.h:499
ASolver_MG_double::m_sap_block_size
std::vector< int > m_sap_block_size
Definition: asolver_MG_double.h:56
ASolver_MG_double::m_asolver_smoother
unique_ptr< ASolver< AFIELD2 > > m_asolver_smoother
Definition: asolver_MG_double.h:67
ASolver_MG_double::ASolver_MG_double
ASolver_MG_double()
constructor.
Definition: asolver_MG_double.h:102
ASolver_MG_double::m_afopr_coarse
unique_ptr< AFopr< AFIELD2 > > m_afopr_coarse
Definition: asolver_MG_double.h:63
ASolver_MG_double::m_x
AFIELD m_x
calling constructor without fermion operator is forbidden.
Definition: asolver_MG_double.h:97
ASolver_MG_double
Definition: asolver_MG_double.h:30
ASolver_MG_double::m_params_asolver_outer
Parameters m_params_asolver_outer
parameters for outer solver
Definition: asolver_MG_double.h:85
ASolver_MG_double::get_foprF
AFopr_dd< AFIELD2 > * get_foprF()
Definition: asolver_MG_double.h:140
ASolver_MG_double::m_timer_generate_coarse_op
unique_ptr< Timer > m_timer_generate_coarse_op
Definition: asolver_MG_double.h:183
ASolver_MG_double::init_coarse_grid
void init_coarse_grid()
Definition: asolver_MG_double-tmpl.h:237
Field
Container of Field-type object.
Definition: field.h:46
afopr.h
asolver.h
ASolver_MG_double::m_timer_gramschmidt
unique_ptr< Timer > m_timer_gramschmidt
Definition: asolver_MG_double.h:182
ASolver_MG_double::~ASolver_MG_double
~ASolver_MG_double()
destructor.
Definition: asolver_MG_double.h:109
ASolver_MG_double::m_nconv
int m_nconv
set "D" for colver (default), "DdagD" for domainwall
Definition: asolver_MG_double.h:91
ASolver_MG_double::init
void init(void)
Definition: asolver_MG_double-tmpl.h:47
ASolver::real_t
AFIELD::real_t real_t
Definition: asolver.h:29
ASolver_MG_double::get_foprD
AFopr< AFIELD > * get_foprD()
Definition: asolver_MG_double.h:139
ASolver_MG_double::m_afopr_fineF
AFopr_dd< AFIELD2 > * m_afopr_fineF
Definition: asolver_MG_double.h:60