CHROMA
syssolver_linop_ibicgstab.h
Go to the documentation of this file.
1 // -*- C++ -*-
2 /*! \file
3  * \brief Solve a M*psi=chi linear system by BICGSTAB
4  */
5 
6 #ifndef __syssolver_linop_ibicgstab_h__
7 #define __syssolver_linop_ibicgstab_h__
8 
9 #include "chroma_config.h"
10 #include "handle.h"
11 #include "syssolver.h"
12 #include "linearop.h"
16 
17 namespace Chroma
18 {
19 
20  //! IBICGSTAB system solver namespace
21  namespace LinOpSysSolverIBiCGStabEnv
22  {
23  //! Register the syssolver
24  bool registerAll();
25  }
26 
27 
28  //! Solve a M*psi=chi linear system by IBICGSTAB
29  /*! \ingroup invert
30  */
31  template<typename T>
33  {
34  public:
35  //! Constructor
36  /*!
37  * \param A_ Linear operator ( Read )
38  * \param invParam inverter parameters ( Read )
39  */
41  const SysSolverBiCGStabParams& invParam_) :
42  A(A_), invParam(invParam_)
43  {}
44 
45  //! Destructor is automatic
47 
48  //! Return the subset on which the operator acts
49  const Subset& subset() const {return A->subset();}
50 
51  //! Solver the linear system
52  /*!
53  * \param psi solution ( Modify )
54  * \param chi source ( Read )
55  * \return syssolver results
56  */
58  {
59  START_CODE();
60 
61  StopWatch swatch;
62 
63  SystemSolverResults_t res; // initialized by a constructor
64 
65  // For now solve with PLUS until we add a way to explicitly
66  // ask for MINUS
67  swatch.start();
68 
69  res = InvIBiCGStab(*A,
70  chi,
71  psi,
74  PLUS);
75 
76 
77  swatch.stop();
78  double time = swatch.getTimeInSeconds();
79 
80  {
81  T r;
82  r[A->subset()]=chi;
83  T tmp;
84  (*A)(tmp, psi, PLUS);
85  r[A->subset()] -= tmp;
86  res.resid = sqrt(norm2(r, A->subset()));
87  }
88  QDPIO::cout << "IBICGSTAB_SOLVER: " << res.n_count << " iterations. Rsd = " << res.resid << " Relative Rsd = " << res.resid/sqrt(norm2(chi,A->subset())) << std::endl;
89  QDPIO::cout << "IBICGSTAB_SOLVER_TIME: "<<time<< " sec" << std::endl;
90 
91  END_CODE();
92 
93  return res;
94  }
95 
96 
97  private:
98  // Hide default constructor
100 
103  };
104 
105 } // End namespace
106 
107 #endif
108 
Class for counted reference semantics.
Definition: handle.h:33
Solve a M*psi=chi linear system by IBICGSTAB.
LinOpSysSolverIBiCGStab(Handle< LinearOperator< T > > A_, const SysSolverBiCGStabParams &invParam_)
Constructor.
const Subset & subset() const
Return the subset on which the operator acts.
~LinOpSysSolverIBiCGStab()
Destructor is automatic.
SystemSolverResults_t operator()(T &psi, const T &chi) const
Solver the linear system.
SystemSolver disambiguator.
Linear Operator.
Definition: linearop.h:27
Class for counted reference semantics.
Conjugate-Gradient algorithm for a generic Linear Operator.
Linear Operators.
bool registerAll()
Register all the factories.
Asqtad Staggered-Dirac operator.
Definition: klein_gord.cc:10
SystemSolverResults_t InvIBiCGStab(const LinearOperator< LatticeFermionF > &A, const LatticeFermionF &chi, LatticeFermionF &psi, const Real &RsdBiCGStab, int MaxBiCGStab, enum PlusMinus isign)
LatticeFermion tmp
Definition: mespbg5p_w.cc:36
LinOpSysSolverMGProtoClover::T T
@ PLUS
Definition: chromabase.h:45
multi1d< LatticeFermion > chi(Ncb)
LatticeFermion psi
Definition: mespbg5p_w.cc:35
START_CODE()
Params for BiCGStab inverter.
Holds return info from SystemSolver call.
Definition: syssolver.h:17
Linear system solvers.
Solve a BICGSTAB system.
Disambiguator for LinOp system solvers.