20 #if BASE_PRECISION == 32
21 #define QDP_Precision 'F'
22 #define QLA_Precision 'F'
23 #define toReal toFloat
24 #elif BASE_PRECISION == 64
25 #define QDP_Precision 'D'
26 #define QLA_Precision 'D'
27 #define toReal toDouble
32 #include "wilsonmg-interface.h"
39 namespace MGMdagMInternal {
63 Handle<
FermState<LatticeFermion,multi1d<LatticeColorMatrix>,multi1d<LatticeColorMatrix > > > state_,
70 QDPIO::cout<<
"MdagM multigrid initialized"<<std::endl;
89 typedef LatticeFermion
T;
90 typedef multi1d<LatticeColorMatrix>
P;
91 typedef multi1d<LatticeColorMatrix>
Q;
112 g5chi[
A->subset()] = Gamma(
Nd*
Nd-1)*
chi ;
113 Double g5chi_norm = sqrt(norm2(g5chi,
A->subset()));
126 tmpsol_tmp[
A->subset() ] =
chi;
129 two_step_predictor.
predictY(tmpferm, A_unprec, tmpsol_tmp);
132 tmpsol_tmp = Gamma(
Nd*
Nd -1 )*tmpferm;
133 Double init_norm = norm2(tmpsol_tmp, all);
134 QDPIO::cout <<
"Initial guess norm_sq = " << init_norm <<
" norm = " << sqrt(init_norm) << std::endl;
137 individual_res = (*Dinv)(tmpsol_tmp,g5chi);
141 tmpsol[
A->subset() ] = tmpsol_tmp;
144 Double rel_resid = individual_res.
resid / g5chi_norm;
151 <<
" reached in first LinopSolver call."
156 (*Dinv).eraseSubspace();
160 QDPIO::cout <<
"QOPMG_MDAGM_SOLVER: First solve failed with RelResid = " << rel_resid
161 <<
" Re-trying with refreshed subspace " << std::endl;
164 individual_res = (*Dinv)(tmpsol_tmp,g5chi);
166 tmpsol[
A->subset() ] = tmpsol_tmp;
169 rel_resid = individual_res.
resid / g5chi_norm;
171 QDPIO::cout <<
"QOP_MG_MDAGM_SOLVER: Re-solving of first solve with refreshed space failed with RelResid = " << rel_resid
172 <<
" Giving Up! " << std::endl;
188 tmpsol2[
A->subset()] = Gamma(
Nd*
Nd-1)*tmpsol ;
189 Double tmpsol2_norm = sqrt(norm2(tmpsol2,
A->subset()));
194 two_step_predictor.
predictX(tmpsol_tmp, A_unprec, tmpsol2);
196 init_norm = norm2(tmpsol_tmp, all);
197 QDPIO::cout <<
"Initial guess norm_sq = " << init_norm <<
" norm = " << sqrt(init_norm) << std::endl;
199 individual_res = (*Dinv)(tmpsol_tmp,tmpsol2);
202 psi[
A->subset() ] = tmpsol_tmp;
205 rel_resid = individual_res.
resid / tmpsol2_norm;
211 <<
" reached in second LinopSolver call."
216 (*Dinv).eraseSubspace();
222 QDPIO::cout <<
"QOPMG_MDAGM_SOLVER: Second solve failed with RelResid = " << rel_resid
223 <<
" Re-trying with refreshed subspace " << std::endl;
226 individual_res = (*Dinv)(tmpsol_tmp,tmpsol2);
228 psi[
A->subset() ] = tmpsol_tmp;
231 rel_resid = individual_res.
resid / tmpsol2_norm;
233 QDPIO::cout <<
"QOP_MG_MDAGM_SOLVER: Re-solving of second solve with refreshed space failed with RelResid = " << rel_resid
234 <<
" Giving Up! " << std::endl;
250 double time = swatch.getTimeInSeconds();
253 r[
A->subset()] =
chi;
259 r[
A->subset()] -=
tmp;
260 res.
resid = sqrt(norm2(
r,
A->subset()));
261 rel_resid = res.
resid / sqrt(norm2(
chi,
A->subset()));
264 QDPIO::cout <<
"QOPMG_MDAGM_SOLVER: "
266 <<
" iterations: " << res.
n_count
267 <<
" time: " << time <<
" sec."
268 <<
" Rsd: " << res.
resid
269 <<
" Relative Rsd: " << rel_resid
274 QDPIO::cout <<
"***** !!! ERROR !!! NONCONVERGENCE !!! Mass="<<
invParam.
Mass <<
" Aborting !!! *******" << std::endl;
278 QDPIO::cout <<
"***** !!! WARNING!!! NONCONVERGENCE !!! Mass="<<
invParam.
Mass <<
" !!! *******" << std::endl;
282 catch(std::bad_cast&
bc) {
283 QDPIO::cout <<
"Couldnt cast predictor to two step predictor" << std::endl;
312 namespace MdagMSysSolverQOPMGEnv
330 multi1d<LatticeColorMatrix>,
331 multi1d<LatticeColorMatrix> > >
state,
Abstract interface for a Chronological Solution predictor.
virtual void predictY(T &Y, const T &chi, const Subset &s) const
virtual void newYVector(const T &Y)=0
virtual void predictX(T &X, const T &chi, const Subset &s) const
virtual void newXVector(const T &X)=0
Support class for fermion actions and linear operators.
Class for counted reference semantics.
Solve a M*psi=chi linear system using the external QDP multigrid inverter.
Gamma(5) hermitian linear operator.
Solve a M*psi=chi linear system using the external QDP multigrid inverter.
SysSolverQOPMGParams invParam
multi1d< LatticeColorMatrix > Q
SystemSolverResults_t operator()(T &psi, const T &chi) const
Solver the linear system.
~MdagMSysSolverQOPMG()
Destructor finalizes the QDP environment.
Handle< LinearOperator< T > > A
Zero initial guess predictor.
Named object function std::map.
static bool registered
Local registration flag.
const std::string name
Name to be used.
multi1d< LatticeColorMatrix > P
SysSolverQOPMGParams remapParams(const SysSolverQOPMGParams &invParam_)
bool registerAll()
Register all the factories.
MdagMSystemSolver< LatticeFermion > * createFerm(XMLReader &xml_in, const std::string &path, Handle< FermState< LatticeFermion, multi1d< LatticeColorMatrix >, multi1d< LatticeColorMatrix > > > state, Handle< LinearOperator< LatticeFermion > > A)
Callback function for standard precision.
Asqtad Staggered-Dirac operator.
multi1d< LatticeFermion > chi(Ncb)
const WilsonTypeFermAct< multi1d< LatticeFermion > > Handle< const ConnectState > state
FloatingPoint< double > Double
Null predictor: Leaves input x0 unchanged.
Support class for fermion actions and linear operators.
Parameters for the external QDP multigrid inverter.
Holds return info from SystemSolver call.
Make contact with the QDP clover multigrid solver, transfer the gauge field, generate the coarse grid...
Register MdagM system solvers.
Factory for producing system solvers for MdagM*psi = chi.
Make contact with the QDP clover multigrid solver, transfer the gauge field, generate the coarse grid...