Bridge++  Ver. 2.0.2
solver_GMRES_m_Cmplx.h
Go to the documentation of this file.
1 
14 #ifndef SOLVER_GMRES_m_CMPLX_INCLUDED
15 #define SOLVER_GMRES_m_CMPLX_INCLUDED
16 
17 #include "solver.h"
18 
19 #include "IO/bridgeIO.h"
20 using Bridge::vout;
21 
23 
42 {
43  public:
44  static const std::string class_name;
45 
46  private:
48 
50 
51  int m_Niter;
53  double m_Stop_cond;
55 
56  int m_N_M;
57 
58  //- working area
59  double m_beta_prev;
60 
61  std::vector<Field> m_v;
63 
66 
67  public:
69  : m_vl(CommonParameters::Vlevel()), m_fopr(fopr)
70  {
71  m_use_init_guess = false;
72  m_Nrestart_count = 0;
73  m_Nconv_count = 0;
74  }
75 
76  Solver_GMRES_m_Cmplx(Fopr *fopr, const Parameters& params)
77  : m_vl(CommonParameters::Vlevel()), m_fopr(fopr)
78  {
79  m_use_init_guess = false;
80  m_Nrestart_count = 0;
81  m_Nconv_count = 0;
82 
83  set_parameters(params);
84  }
85 
87 
88  void set_parameters(const Parameters& params);
89 
90  void set_parameters(const int Niter, const int Nrestart, const double Stop_cond);
92  void set_parameters(const int Niter, const int Nrestart, const double Stop_cond, const bool use_init_guess);
94  void set_parameters_GMRES_m(const int N_M);
95 
96  void set_parameters(const int Niter, const int Nrestart, const double Stop_cond, const bool use_init_guess, const int N_M);
97 
98  void get_parameters(Parameters& params) const;
99 
100  void solve(Field& solution, const Field& source, int& Nconv, double& diff);
101 
102  Fopr *get_fopr() { return m_fopr; }
103 
104  double flop_count();
105 
106  private:
107  void reset_field(const Field&);
108 
109  void solve_init(const Field&, double&);
110  void solve_step(const Field&, double&);
111 
112  void innerprod_c(double& prod_r, double& prod_i,
113  const Field& v, const Field& w);
114 
115  void min_J(std::valarray<dcomplex>& y,
116  std::valarray<dcomplex>& h);
117 
118  int index_ij(const int i, const int j)
119  {
120  return i + (m_N_M + 1) * j;
121  }
122 
123 #ifdef USE_FACTORY
124  private:
125  static Solver *create_object(Fopr *fopr)
126  {
127  return new Solver_GMRES_m_Cmplx(fopr);
128  }
129 
130  static Solver *create_object_with_params(Fopr *fopr, const Parameters& params)
131  {
132  return new Solver_GMRES_m_Cmplx(fopr, params);
133  }
134 
135  public:
136  static bool register_factory()
137  {
138  bool init = true;
139  init &= Solver::Factory::Register("GMRES_m_Cmplx", create_object);
140  init &= Solver::Factory_params::Register("GMRES_m_Cmplx", create_object_with_params);
141  return init;
142  }
143 #endif
144 };
145 #endif
Solver_GMRES_m_Cmplx::solve_step
void solve_step(const Field &, double &)
Definition: solver_GMRES_m_Cmplx.cpp:335
solver.h
Solver_GMRES_m_Cmplx::class_name
static const std::string class_name
Definition: solver_GMRES_m_Cmplx.h:44
Solver_GMRES_m_Cmplx::m_v_tmp
Field m_v_tmp
Definition: solver_GMRES_m_Cmplx.h:62
bridgeIO.h
Solver_GMRES_m_Cmplx::set_parameters_GMRES_m
DEPRECATED void set_parameters_GMRES_m(const int N_M)
Definition: solver_GMRES_m_Cmplx.cpp:129
CommonParameters
Common parameter class: provides parameters as singleton.
Definition: commonParameters.h:42
AFopr< Field >
Solver_GMRES_m_Cmplx::m_v
std::vector< Field > m_v
Definition: solver_GMRES_m_Cmplx.h:61
Parameters
Class for parameters.
Definition: parameters.h:46
Solver_GMRES_m_Cmplx
GMRES(m) algorithm with complex variables.
Definition: solver_GMRES_m_Cmplx.h:41
Solver_GMRES_m_Cmplx::get_fopr
Fopr * get_fopr()
Definition: solver_GMRES_m_Cmplx.h:102
Solver_GMRES_m_Cmplx::m_s
Field m_s
Definition: solver_GMRES_m_Cmplx.h:62
Solver_GMRES_m_Cmplx::flop_count
double flop_count()
Definition: solver_GMRES_m_Cmplx.cpp:439
Solver_GMRES_m_Cmplx::m_N_M
int m_N_M
Definition: solver_GMRES_m_Cmplx.h:56
Solver_GMRES_m_Cmplx::m_Stop_cond
double m_Stop_cond
Definition: solver_GMRES_m_Cmplx.h:53
Solver_GMRES_m_Cmplx::m_beta_prev
double m_beta_prev
Definition: solver_GMRES_m_Cmplx.h:59
Solver_GMRES_m_Cmplx::solve_init
void solve_init(const Field &, double &)
Definition: solver_GMRES_m_Cmplx.cpp:308
Solver_GMRES_m_Cmplx::m_Nrestart_count
int m_Nrestart_count
Definition: solver_GMRES_m_Cmplx.h:64
Solver_GMRES_m_Cmplx::innerprod_c
void innerprod_c(double &prod_r, double &prod_i, const Field &v, const Field &w)
Solver_GMRES_m_Cmplx::m_Nrestart
int m_Nrestart
Definition: solver_GMRES_m_Cmplx.h:52
Solver_GMRES_m_Cmplx::m_fopr
Fopr * m_fopr
Definition: solver_GMRES_m_Cmplx.h:49
Solver_GMRES_m_Cmplx::index_ij
int index_ij(const int i, const int j)
Definition: solver_GMRES_m_Cmplx.h:118
Solver_GMRES_m_Cmplx::Solver_GMRES_m_Cmplx
Solver_GMRES_m_Cmplx(Fopr *fopr, const Parameters &params)
Definition: solver_GMRES_m_Cmplx.h:76
Solver_GMRES_m_Cmplx::get_parameters
void get_parameters(Parameters &params) const
Definition: solver_GMRES_m_Cmplx.cpp:56
Solver_GMRES_m_Cmplx::m_r
Field m_r
Definition: solver_GMRES_m_Cmplx.h:62
Solver
Base class for linear solver class family.
Definition: solver.h:36
Solver_GMRES_m_Cmplx::m_Niter
int m_Niter
Definition: solver_GMRES_m_Cmplx.h:51
Solver_GMRES_m_Cmplx::reset_field
void reset_field(const Field &)
Definition: solver_GMRES_m_Cmplx.cpp:278
Solver_GMRES_m_Cmplx::min_J
void min_J(std::valarray< dcomplex > &y, std::valarray< dcomplex > &h)
Definition: solver_GMRES_m_Cmplx.cpp:385
Solver_GMRES_m_Cmplx::m_x
Field m_x
Definition: solver_GMRES_m_Cmplx.h:62
Solver_GMRES_m_Cmplx::m_Nconv_count
int m_Nconv_count
Definition: solver_GMRES_m_Cmplx.h:65
Solver_GMRES_m_Cmplx::solve
void solve(Field &solution, const Field &source, int &Nconv, double &diff)
Definition: solver_GMRES_m_Cmplx.cpp:190
Solver_GMRES_m_Cmplx::m_vl
Bridge::VerboseLevel m_vl
Definition: solver_GMRES_m_Cmplx.h:47
Solver_GMRES_m_Cmplx::~Solver_GMRES_m_Cmplx
~Solver_GMRES_m_Cmplx()
Definition: solver_GMRES_m_Cmplx.h:86
Solver_GMRES_m_Cmplx::m_use_init_guess
bool m_use_init_guess
Definition: solver_GMRES_m_Cmplx.h:54
Field
Container of Field-type object.
Definition: field.h:46
Bridge::VerboseLevel
VerboseLevel
Definition: bridgeIO.h:42
Solver_GMRES_m_Cmplx::set_parameters
void set_parameters(const Parameters &params)
Definition: solver_GMRES_m_Cmplx.cpp:25
DEPRECATED
#define DEPRECATED
Definition: configure.h:28
Solver_GMRES_m_Cmplx::Solver_GMRES_m_Cmplx
Solver_GMRES_m_Cmplx(Fopr *fopr)
Definition: solver_GMRES_m_Cmplx.h:68
Bridge::vout
BridgeIO vout
Definition: bridgeIO.cpp:512