CHROMA
syssolver_linop_rel_ibicgstab_clover.h
Go to the documentation of this file.
1 // -*- C++ -*-
2 /*! \file
3  * \brief Solve a MdagM*psi=chi linear system by BiCGStab
4  */
5 
6 #ifndef __syssolver_linop_rel_ibicgstab_multiprec_h__
7 #define __syssolver_linop_rel_ibicgstab_multiprec_h__
8 #include "chroma_config.h"
9 
10 #include "handle.h"
11 #include "state.h"
12 #include "syssolver.h"
13 #include "linearop.h"
14 #include "lmdagm.h"
22 
23 #include <string>
24 
25 namespace Chroma
26 {
27 
28  //! Richardson system solver namespace
29  namespace LinOpSysSolverReliableIBiCGStabCloverEnv
30  {
31  //! Register the syssolver
32  bool registerAll();
33  }
34 
35 
36 
37  //! Solve a system using Richardson iteration.
38  /*! \ingroup invert
39  *** WARNING THIS SOLVER WORKS FOR CLOVER FERMIONS ONLY ***
40  */
41 
43  {
44  public:
45  typedef LatticeFermion T;
46  typedef LatticeColorMatrix U;
47  typedef multi1d<LatticeColorMatrix> Q;
48 
49  typedef LatticeFermionF TF;
50  typedef LatticeColorMatrixF UF;
51  typedef multi1d<LatticeColorMatrixF> QF;
52 
53  typedef LatticeFermionD TD;
54  typedef LatticeColorMatrixD UD;
55  typedef multi1d<LatticeColorMatrixD> QD;
56 
57  //! Constructor
58  /*!
59  * \param M_ Linear operator ( Read )
60  * \param invParam inverter parameters ( Read )
61  */
63  Handle< FermState<T,Q,Q> > state_,
64  const SysSolverReliableBiCGStabCloverParams& invParam_) :
65  A(A_), invParam(invParam_)
66  {
67 
68  // Get the Links out of the state and convertto single.
69  QF links_single; links_single.resize(Nd);
70  QD links_double; links_double.resize(Nd);
71 
72  const Q& links = state_->getLinks();
73  for(int mu=0; mu < Nd; mu++) {
74  links_single[mu] = links[mu];
75  links_double[mu] = links[mu];
76  }
77 
78 
79  // Links single hold the possibly stouted links
80  // with gaugeBCs applied...
81  // Now I need to create a single prec state...
82  fstate_single = new PeriodicFermState<TF,QF,QF>(links_single);
83  fstate_double = new PeriodicFermState<TD,QD,QD>(links_double);
84 
85  // Make single precision M
88 
89 
90 
91  }
92 
93  //! Destructor is automatic
95 
96  //! Return the subset on which the operator acts
97  const Subset& subset() const {return A->subset();}
98 
99  //! Solver the linear system
100  /*!
101  * \param psi solution ( Modify )
102  * \param chi source ( Read )
103  * \return syssolver results
104  */
106  {
108 
109  START_CODE();
110  StopWatch swatch;
111  swatch.start();
112 
113  // T MdagChi;
114 
115  // This is a CGNE. So create new RHS
116  // (*A)(MdagChi, chi, MINUS);
117  // Handle< LinearOperator<T> > MM(new MdagMLinOp<T>(A));
118 
119  TD psi_d = psi;
120  TD chi_d = chi;
121 
123  *M_single,
124  chi_d,
125  psi_d,
127  invParam.Delta,
129  PLUS);
130 
131  psi = psi_d;
132 
133  swatch.stop();
134  double time = swatch.getTimeInSeconds();
135 
136  {
137  T r;
138  r[A->subset()]=chi;
139  T tmp;
140  (*A)(tmp, psi, PLUS);
141  r[A->subset()] -= tmp;
142  res.resid = sqrt(norm2(r, A->subset()));
143  }
144  QDPIO::cout << "RELIABLE_IBICGSTAB_SOLVER: " << res.n_count << " iterations. Rsd = " << res.resid << " Relative Rsd = " << res.resid/sqrt(norm2(chi,A->subset())) << std::endl;
145  QDPIO::cout << "RELIABLE_IBICGSTAB_SOLVER_TIME: "<<time<< " sec" << std::endl;
146 
147 
148  END_CODE();
149  return res;
150  }
151 
152 
153  private:
154  // Hide default constructor
158 
159  // Created and initialized here.
164 
165 
166  };
167 
168 
169 } // End namespace
170 
171 #endif
172 
Even-odd preconditioned Clover-Dirac operator.
Even-odd preconditioned Clover-Dirac operator.
Support class for fermion actions and linear operators.
Definition: state.h:94
Class for counted reference semantics.
Definition: handle.h:33
LinOpSysSolverReliableIBiCGStabClover(Handle< LinearOperator< T > > A_, Handle< FermState< T, Q, Q > > state_, const SysSolverReliableBiCGStabCloverParams &invParam_)
Constructor.
SystemSolverResults_t operator()(T &psi, const T &chi) const
Solver the linear system.
const Subset & subset() const
Return the subset on which the operator acts.
SystemSolver disambiguator.
Linear Operator.
Definition: linearop.h:27
Periodic version of FermState.
Parameters for Clover fermion action.
int mu
Definition: cool.cc:24
Even-odd preconditioned Clover fermion linear operator.
SystemSolverResults_t InvIBiCGStabReliable(const LinearOperator< LatticeFermionF > &A, const LatticeFermionF &chi, LatticeFermionF &psi, const Real &RsdBiCGStab, const Real &Delta, int MaxBiCGStab, enum PlusMinus isign)
Bi-CG stabilized.
Class for counted reference semantics.
Linear Operators.
M^dag*M composition of a linear operator.
Nd
Definition: meslate.cc:74
Asqtad Staggered-Dirac operator.
Definition: klein_gord.cc:10
LatticeFermion tmp
Definition: mespbg5p_w.cc:36
@ PLUS
Definition: chromabase.h:45
multi1d< LatticeFermion > chi(Ncb)
LatticeFermion psi
Definition: mespbg5p_w.cc:35
START_CODE()
Periodic ferm state and a creator.
BiCGStab Solver with reliable updates.
Support class for fermion actions and linear operators.
Holds return info from SystemSolver call.
Definition: syssolver.h:17
Linear system solvers.
Factory for solving M*psi=chi where M is not hermitian or pos. def.
Disambiguator for MdagM system solvers.