diff --git a/Grid/algorithms/iterative/Reconstruct5Dprop.h b/Grid/algorithms/iterative/Reconstruct5Dprop.h index 303202af..9d73ec14 100644 --- a/Grid/algorithms/iterative/Reconstruct5Dprop.h +++ b/Grid/algorithms/iterative/Reconstruct5Dprop.h @@ -31,80 +31,125 @@ namespace Grid { namespace QCD { -template class Reconstruct5DfromPhysical { +template +class PauliVillarsSolverUnprec +{ + public: + ConjugateGradient & CG; + PauliVillarsSolverUnprec( ConjugateGradient &_CG) : CG(_CG){}; + + template + void operator() (Matrix &_Matrix,const Field &src,Field &sol) + { + RealD m = _Matrix.Mass(); + Field A (_Matrix.FermionGrid()); + + MdagMLinearOperator HermOp(_Matrix); + + _Matrix.SetMass(1.0); + _Matrix.Mdag(src,A); + CG(HermOp,A,sol); + _Matrix.SetMass(m); + }; +}; + +template +class PauliVillarsSolverRBprec +{ + public: + ConjugateGradient & CG; + PauliVillarsSolverRBprec( ConjugateGradient &_CG) : CG(_CG){}; + + template + void operator() (Matrix &_Matrix,const Field &src,Field &sol) + { + RealD m = _Matrix.Mass(); + Field A (_Matrix.FermionGrid()); + + _Matrix.SetMass(1.0); + SchurRedBlackDiagMooeeSolve SchurSolver(CG); + SchurSolver(_Matrix,src,sol); + _Matrix.SetMass(m); + }; +}; + +template class Reconstruct5DfromPhysical { private: - OperatorFunction & _PauliVillarsSolver; + PVinverter & PauliVillarsSolver; public: ///////////////////////////////////////////////////// - // Wrap the usual normal equations Schur trick + // First cut works, 10 Oct 2018. + // + // Must form a plan to get this into production for Zmobius acceleration + // of the Mobius exact AMA corrections. + // + // TODO : understand absence of contact term in eqns in Hantao's thesis + // sol4 is contact term subtracted. + // + // Options + // a) Defect correction approach: + // 1) Compute defect from current soln (initially guess). + // This is ...... outerToInner check !!!! + // 2) Deflated Zmobius solve to get 4d soln + // Ensure deflation is working + // 3) Refine 5d Outer using the inner 4d delta soln + // + // Step 1: localise PV inverse in a routine. [DONE] + // Step 2: Schur based PV inverse [DONE] + // Step 3: Fourier accelerated PV inverse + // Step 4: ///////////////////////////////////////////////////// - Reconstruct5DfromPhysical(OperatorFunction &PauliVillarsSolver) : - _PauliVillarsSolver(PauliVillarsSolver) - { }; - /* - void SliceDump(const Field &f) - { - std::vector C1; - Field ff(f._grid); - Gamma G5 ( Gamma::Algebra::Gamma5); - ff= f+ G5*f; - ff=ff*0.5; - { - auto ip = localInnerProduct(ff,ff); - sliceSum(ip,C1,0); - for(int s=0;s class Reconstruct5DfromPhysical { ExtractSlice(psi4,c,s,0); InsertSlice(psi4,psi,s,0); } - + + ///////////////////////////// // Pdag PV^-1 Dm P + ///////////////////////////// _Matrix.P(psi,B); _Matrix.M(B,A); + PauliVillarsSolver(_Matrix,A,B); + _Matrix.Pdag(B,A); - // PauliVillars invert - _Matrix.SetMass(1.0); - _Matrix.Mdag(A,B); _PauliVillarsSolver(HermOp,B,A); - _Matrix.SetMass(m); + ////////////////////////////// + // Reinsert surface prop + ////////////////////////////// + InsertSlice(sol4,A,0,0); - _Matrix.Pdag(A,B); - - InsertSlice(sol4,B,0,0); - - // Convert from y back to x with P+ circular shift - _Matrix.P(B,sol5); + ////////////////////////////// + // Convert from y back to x + ////////////////////////////// + _Matrix.P(A,sol5); } }; diff --git a/tests/debug/Test_cayley_cg.cc b/tests/debug/Test_cayley_cg.cc index 3f001f28..c22ab51a 100644 --- a/tests/debug/Test_cayley_cg.cc +++ b/tests/debug/Test_cayley_cg.cc @@ -229,16 +229,14 @@ void TestReconstruct5D(What & Ddwf, Ddwf.M(result,src_NE); src_NE = src_NE - src; std::cout < reconstructor(CG); - - std::cout < PVinverter; + typedef PauliVillarsSolverRBprec PVinverter; + PVinverter PVinverse(CG); + Reconstruct5DfromPhysical reconstructor(PVinverse); + reconstructor(Ddwf,res4,src4,result_rec); std::cout <