2016-01-02 14:51:32 +00:00
|
|
|
/*************************************************************************************
|
|
|
|
|
|
|
|
Grid physics library, www.github.com/paboyle/Grid
|
|
|
|
|
|
|
|
Source file: ./tests/Test_dwf_hdcr.cc
|
|
|
|
|
|
|
|
Copyright (C) 2015
|
|
|
|
|
|
|
|
Author: Antonin Portelli <antonin.portelli@me.com>
|
|
|
|
Author: Peter Boyle <paboyle@ph.ed.ac.uk>
|
|
|
|
Author: paboyle <paboyle@ph.ed.ac.uk>
|
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation; either version 2 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License along
|
|
|
|
with this program; if not, write to the Free Software Foundation, Inc.,
|
|
|
|
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
|
|
|
|
|
|
See the full license in the file "LICENSE" in the top level distribution directory
|
|
|
|
*************************************************************************************/
|
|
|
|
/* END LEGAL */
|
2016-07-07 22:31:07 +01:00
|
|
|
#include <Grid/Grid.h>
|
|
|
|
#include <Grid/algorithms/iterative/PrecGeneralisedConjugateResidual.h>
|
2015-07-01 13:04:02 +01:00
|
|
|
//#include <algorithms/iterative/PrecConjugateResidual.h>
|
2015-06-22 12:49:44 +01:00
|
|
|
|
|
|
|
using namespace std;
|
|
|
|
using namespace Grid;
|
|
|
|
using namespace Grid::QCD;
|
|
|
|
|
2015-11-29 10:59:11 +00:00
|
|
|
class myclass: Serializable {
|
2015-11-29 01:01:51 +00:00
|
|
|
public:
|
|
|
|
|
2015-12-08 13:54:00 +00:00
|
|
|
GRID_SERIALIZABLE_CLASS_MEMBERS(myclass,
|
2015-11-29 01:01:51 +00:00
|
|
|
int, domaindecompose,
|
|
|
|
int, domainsize,
|
|
|
|
int, order,
|
2016-03-16 09:31:04 +00:00
|
|
|
int, Ls,
|
|
|
|
double, mq,
|
2015-11-29 01:01:51 +00:00
|
|
|
double, lo,
|
|
|
|
double, hi,
|
|
|
|
int, steps);
|
|
|
|
|
|
|
|
myclass(){};
|
|
|
|
|
|
|
|
};
|
|
|
|
myclass params;
|
|
|
|
|
2015-07-21 05:52:23 +01:00
|
|
|
RealD InverseApproximation(RealD x){
|
|
|
|
return 1.0/x;
|
|
|
|
}
|
|
|
|
|
2015-06-30 15:01:26 +01:00
|
|
|
template<class Fobj,class CComplex,int nbasis, class Matrix>
|
2015-06-22 12:49:44 +01:00
|
|
|
class MultiGridPreconditioner : public LinearFunction< Lattice<Fobj> > {
|
|
|
|
public:
|
|
|
|
|
|
|
|
typedef Aggregation<Fobj,CComplex,nbasis> Aggregates;
|
|
|
|
typedef CoarsenedMatrix<Fobj,CComplex,nbasis> CoarseOperator;
|
|
|
|
|
|
|
|
typedef typename Aggregation<Fobj,CComplex,nbasis>::siteVector siteVector;
|
|
|
|
typedef typename Aggregation<Fobj,CComplex,nbasis>::CoarseScalar CoarseScalar;
|
|
|
|
typedef typename Aggregation<Fobj,CComplex,nbasis>::CoarseVector CoarseVector;
|
|
|
|
typedef typename Aggregation<Fobj,CComplex,nbasis>::CoarseMatrix CoarseMatrix;
|
|
|
|
typedef typename Aggregation<Fobj,CComplex,nbasis>::FineField FineField;
|
|
|
|
typedef LinearOperatorBase<FineField> FineOperator;
|
|
|
|
|
|
|
|
Aggregates & _Aggregates;
|
|
|
|
CoarseOperator & _CoarseOperator;
|
2015-11-29 01:01:51 +00:00
|
|
|
Matrix & _FineMatrix;
|
2015-06-22 12:49:44 +01:00
|
|
|
FineOperator & _FineOperator;
|
2015-11-29 01:01:51 +00:00
|
|
|
Matrix & _SmootherMatrix;
|
|
|
|
FineOperator & _SmootherOperator;
|
2015-06-22 12:49:44 +01:00
|
|
|
|
|
|
|
// Constructor
|
2015-11-29 01:01:51 +00:00
|
|
|
MultiGridPreconditioner(Aggregates &Agg, CoarseOperator &Coarse,
|
|
|
|
FineOperator &Fine,Matrix &FineMatrix,
|
|
|
|
FineOperator &Smooth,Matrix &SmootherMatrix)
|
2015-06-22 12:49:44 +01:00
|
|
|
: _Aggregates(Agg),
|
|
|
|
_CoarseOperator(Coarse),
|
2015-06-30 15:01:26 +01:00
|
|
|
_FineOperator(Fine),
|
2015-11-29 01:01:51 +00:00
|
|
|
_FineMatrix(FineMatrix),
|
|
|
|
_SmootherOperator(Smooth),
|
|
|
|
_SmootherMatrix(SmootherMatrix)
|
2015-06-22 12:49:44 +01:00
|
|
|
{
|
|
|
|
}
|
2015-07-21 05:52:23 +01:00
|
|
|
|
|
|
|
void PowerMethod(const FineField &in) {
|
|
|
|
|
|
|
|
FineField p1(in._grid);
|
|
|
|
FineField p2(in._grid);
|
|
|
|
|
2015-11-29 01:01:51 +00:00
|
|
|
MdagMLinearOperator<Matrix,FineField> fMdagMOp(_FineMatrix);
|
2015-07-21 05:52:23 +01:00
|
|
|
|
|
|
|
p1=in;
|
|
|
|
RealD absp2;
|
|
|
|
for(int i=0;i<20;i++){
|
|
|
|
RealD absp1=std::sqrt(norm2(p1));
|
|
|
|
fMdagMOp.HermOp(p1,p2);// this is the G5 herm bit
|
|
|
|
// _FineOperator.Op(p1,p2);// this is the G5 herm bit
|
|
|
|
RealD absp2=std::sqrt(norm2(p2));
|
|
|
|
if(i%10==9)
|
2015-07-23 17:31:13 +01:00
|
|
|
std::cout<<GridLogMessage << "Power method on mdagm "<<i<<" " << absp2/absp1<<std::endl;
|
2015-07-21 05:52:23 +01:00
|
|
|
p1=p2*(1.0/std::sqrt(absp2));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-06-22 12:49:44 +01:00
|
|
|
void operator()(const FineField &in, FineField & out) {
|
2015-11-29 01:01:51 +00:00
|
|
|
if ( params.domaindecompose ) {
|
|
|
|
operatorSAP(in,out);
|
|
|
|
} else {
|
|
|
|
operatorCheby(in,out);
|
|
|
|
}
|
2015-06-30 15:01:26 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////////
|
|
|
|
// ADEF2: [PTM+Q] in = [1 - Q A] M in + Q in = Min + Q [ in -A Min]
|
|
|
|
// ADEF1: [MP+Q ] in =M [1 - A Q] in + Q in
|
|
|
|
////////////////////////////////////////////////////////////////////////
|
2015-11-29 01:01:51 +00:00
|
|
|
#if 1
|
|
|
|
void operatorADEF2(const FineField &in, FineField & out) {
|
2015-06-30 15:01:26 +01:00
|
|
|
|
|
|
|
CoarseVector Csrc(_CoarseOperator.Grid());
|
|
|
|
CoarseVector Ctmp(_CoarseOperator.Grid());
|
|
|
|
CoarseVector Csol(_CoarseOperator.Grid());
|
|
|
|
|
|
|
|
ConjugateGradient<CoarseVector> CG(1.0e-10,100000);
|
|
|
|
ConjugateGradient<FineField> fCG(3.0e-2,1000);
|
|
|
|
|
|
|
|
HermitianLinearOperator<CoarseOperator,CoarseVector> HermOp(_CoarseOperator);
|
|
|
|
MdagMLinearOperator<CoarseOperator,CoarseVector> MdagMOp(_CoarseOperator);
|
2015-11-29 01:01:51 +00:00
|
|
|
MdagMLinearOperator<Matrix,FineField> fMdagMOp(_FineMatrix);
|
2015-06-30 15:01:26 +01:00
|
|
|
|
|
|
|
FineField tmp(in._grid);
|
|
|
|
FineField res(in._grid);
|
|
|
|
FineField Min(in._grid);
|
|
|
|
|
|
|
|
// Monitor completeness of low mode space
|
|
|
|
_Aggregates.ProjectToSubspace (Csrc,in);
|
|
|
|
_Aggregates.PromoteFromSubspace(Csrc,out);
|
2015-07-23 17:31:13 +01:00
|
|
|
std::cout<<GridLogMessage<<"Coarse Grid Preconditioner\nCompleteness in: "<<std::sqrt(norm2(out)/norm2(in))<<std::endl;
|
2015-06-30 15:01:26 +01:00
|
|
|
|
|
|
|
// [PTM+Q] in = [1 - Q A] M in + Q in = Min + Q [ in -A Min]
|
|
|
|
_FineOperator.Op(in,tmp);// this is the G5 herm bit
|
|
|
|
fCG(fMdagMOp,tmp,Min); // solves MdagM = g5 M g5M
|
|
|
|
|
|
|
|
// Monitor completeness of low mode space
|
|
|
|
_Aggregates.ProjectToSubspace (Csrc,Min);
|
|
|
|
_Aggregates.PromoteFromSubspace(Csrc,out);
|
2015-07-23 17:31:13 +01:00
|
|
|
std::cout<<GridLogMessage<<"Completeness Min: "<<std::sqrt(norm2(out)/norm2(Min))<<std::endl;
|
2015-06-30 15:01:26 +01:00
|
|
|
|
|
|
|
_FineOperator.Op(Min,tmp);
|
|
|
|
tmp = in - tmp; // in - A Min
|
|
|
|
|
|
|
|
Csol=zero;
|
|
|
|
_Aggregates.ProjectToSubspace (Csrc,tmp);
|
|
|
|
HermOp.AdjOp(Csrc,Ctmp);// Normal equations
|
|
|
|
CG(MdagMOp,Ctmp,Csol);
|
|
|
|
|
|
|
|
HermOp.Op(Csol,Ctmp);
|
|
|
|
Ctmp=Ctmp-Csrc;
|
2015-07-23 17:31:13 +01:00
|
|
|
std::cout<<GridLogMessage<<"coarse space true residual "<<std::sqrt(norm2(Ctmp)/norm2(Csrc))<<std::endl;
|
2015-06-30 15:01:26 +01:00
|
|
|
_Aggregates.PromoteFromSubspace(Csol,out);
|
|
|
|
|
|
|
|
_FineOperator.Op(out,res);
|
|
|
|
res=res-tmp;
|
2015-07-23 17:31:13 +01:00
|
|
|
std::cout<<GridLogMessage<<"promoted sol residual "<<std::sqrt(norm2(res)/norm2(tmp))<<std::endl;
|
2015-06-30 15:01:26 +01:00
|
|
|
_Aggregates.ProjectToSubspace (Csrc,res);
|
2015-07-23 17:31:13 +01:00
|
|
|
std::cout<<GridLogMessage<<"coarse space proj of residual "<<norm2(Csrc)<<std::endl;
|
2015-06-30 15:01:26 +01:00
|
|
|
|
|
|
|
|
|
|
|
out = out+Min; // additive coarse space correction
|
|
|
|
// out = Min; // no additive coarse space correction
|
|
|
|
|
|
|
|
_FineOperator.Op(out,tmp);
|
|
|
|
tmp=tmp-in; // tmp is new residual
|
|
|
|
|
2015-07-23 17:31:13 +01:00
|
|
|
std::cout<<GridLogMessage<< " Preconditioner in " << norm2(in)<<std::endl;
|
|
|
|
std::cout<<GridLogMessage<< " Preconditioner out " << norm2(out)<<std::endl;
|
|
|
|
std::cout<<GridLogMessage<<"preconditioner thinks residual is "<<std::sqrt(norm2(tmp)/norm2(in))<<std::endl;
|
2015-06-30 15:01:26 +01:00
|
|
|
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
// ADEF1: [MP+Q ] in =M [1 - A Q] in + Q in
|
2015-11-29 01:01:51 +00:00
|
|
|
#if 1
|
|
|
|
void operatorADEF1(const FineField &in, FineField & out) {
|
2015-06-30 15:01:26 +01:00
|
|
|
|
|
|
|
CoarseVector Csrc(_CoarseOperator.Grid());
|
|
|
|
CoarseVector Ctmp(_CoarseOperator.Grid());
|
|
|
|
CoarseVector Csol(_CoarseOperator.Grid()); Csol=zero;
|
|
|
|
|
|
|
|
ConjugateGradient<CoarseVector> CG(1.0e-10,100000);
|
2015-07-21 05:52:23 +01:00
|
|
|
ConjugateGradient<FineField> fCG(3.0e-2,1000);
|
2015-06-30 15:01:26 +01:00
|
|
|
|
|
|
|
HermitianLinearOperator<CoarseOperator,CoarseVector> HermOp(_CoarseOperator);
|
|
|
|
MdagMLinearOperator<CoarseOperator,CoarseVector> MdagMOp(_CoarseOperator);
|
2015-11-29 01:01:51 +00:00
|
|
|
ShiftedMdagMLinearOperator<Matrix,FineField> fMdagMOp(_FineMatrix,0.1);
|
2015-06-30 15:01:26 +01:00
|
|
|
|
|
|
|
FineField tmp(in._grid);
|
|
|
|
FineField res(in._grid);
|
|
|
|
FineField Qin(in._grid);
|
|
|
|
|
|
|
|
// Monitor completeness of low mode space
|
|
|
|
// _Aggregates.ProjectToSubspace (Csrc,in);
|
|
|
|
// _Aggregates.PromoteFromSubspace(Csrc,out);
|
2015-07-23 17:31:13 +01:00
|
|
|
// std::cout<<GridLogMessage<<"Coarse Grid Preconditioner\nCompleteness in: "<<std::sqrt(norm2(out)/norm2(in))<<std::endl;
|
2015-06-30 15:01:26 +01:00
|
|
|
|
|
|
|
_Aggregates.ProjectToSubspace (Csrc,in);
|
|
|
|
HermOp.AdjOp(Csrc,Ctmp);// Normal equations
|
|
|
|
CG(MdagMOp,Ctmp,Csol);
|
|
|
|
_Aggregates.PromoteFromSubspace(Csol,Qin);
|
|
|
|
|
2015-07-21 05:52:23 +01:00
|
|
|
// Qin=0;
|
2015-06-30 15:01:26 +01:00
|
|
|
_FineOperator.Op(Qin,tmp);// A Q in
|
|
|
|
tmp = in - tmp; // in - A Q in
|
|
|
|
|
|
|
|
_FineOperator.Op(tmp,res);// this is the G5 herm bit
|
|
|
|
fCG(fMdagMOp,res,out); // solves MdagM = g5 M g5M
|
|
|
|
|
|
|
|
out = out + Qin;
|
|
|
|
|
|
|
|
_FineOperator.Op(out,tmp);
|
|
|
|
tmp=tmp-in; // tmp is new residual
|
|
|
|
|
2015-07-23 17:31:13 +01:00
|
|
|
std::cout<<GridLogMessage<<"preconditioner thinks residual is "<<std::sqrt(norm2(tmp)/norm2(in))<<std::endl;
|
2015-06-30 15:01:26 +01:00
|
|
|
|
2015-06-22 12:49:44 +01:00
|
|
|
}
|
2015-07-21 05:52:23 +01:00
|
|
|
#endif
|
|
|
|
|
2015-11-29 01:01:51 +00:00
|
|
|
void SAP (const FineField & src,FineField & psi){
|
|
|
|
|
|
|
|
Lattice<iScalar<vInteger> > coor(src._grid);
|
|
|
|
Lattice<iScalar<vInteger> > subset(src._grid);
|
|
|
|
|
|
|
|
FineField r(src._grid);
|
|
|
|
FineField zz(src._grid); zz=zero;
|
|
|
|
FineField vec1(src._grid);
|
|
|
|
FineField vec2(src._grid);
|
|
|
|
|
|
|
|
const Integer block=params.domainsize;
|
|
|
|
|
|
|
|
subset=zero;
|
|
|
|
for(int mu=0;mu<Nd;mu++){
|
|
|
|
LatticeCoordinate(coor,mu+1);
|
|
|
|
coor = div(coor,block);
|
|
|
|
subset = subset+coor;
|
|
|
|
}
|
|
|
|
subset = mod(subset,(Integer)2);
|
|
|
|
|
|
|
|
ShiftedMdagMLinearOperator<Matrix,FineField> fMdagMOp(_SmootherMatrix,0.0);
|
|
|
|
Chebyshev<FineField> Cheby (params.lo,params.hi,params.order,InverseApproximation);
|
|
|
|
|
|
|
|
RealD resid;
|
|
|
|
for(int i=0;i<params.steps;i++){
|
|
|
|
|
|
|
|
// Even domain residual
|
|
|
|
_FineOperator.Op(psi,vec1);// this is the G5 herm bit
|
|
|
|
r= src - vec1 ;
|
|
|
|
resid = norm2(r) /norm2(src);
|
|
|
|
std::cout << "SAP "<<i<<" resid "<<resid<<std::endl;
|
|
|
|
|
|
|
|
// Even domain solve
|
|
|
|
r= where(subset==(Integer)0,r,zz);
|
|
|
|
_SmootherOperator.AdjOp(r,vec1);
|
|
|
|
Cheby(fMdagMOp,vec1,vec2); // solves MdagM = g5 M g5M
|
|
|
|
psi = psi + vec2;
|
|
|
|
|
|
|
|
// Odd domain residual
|
|
|
|
_FineOperator.Op(psi,vec1);// this is the G5 herm bit
|
|
|
|
r= src - vec1 ;
|
|
|
|
r= where(subset==(Integer)1,r,zz);
|
|
|
|
|
|
|
|
resid = norm2(r) /norm2(src);
|
|
|
|
std::cout << "SAP "<<i<<" resid "<<resid<<std::endl;
|
|
|
|
|
|
|
|
// Odd domain solve
|
|
|
|
_SmootherOperator.AdjOp(r,vec1);
|
|
|
|
Cheby(fMdagMOp,vec1,vec2); // solves MdagM = g5 M g5M
|
|
|
|
psi = psi + vec2;
|
|
|
|
|
|
|
|
_FineOperator.Op(psi,vec1);// this is the G5 herm bit
|
|
|
|
r= src - vec1 ;
|
|
|
|
resid = norm2(r) /norm2(src);
|
|
|
|
std::cout << "SAP "<<i<<" resid "<<resid<<std::endl;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
};
|
|
|
|
|
2015-07-21 05:52:23 +01:00
|
|
|
void SmootherTest (const FineField & in){
|
|
|
|
|
|
|
|
FineField vec1(in._grid);
|
|
|
|
FineField vec2(in._grid);
|
|
|
|
RealD lo[3] = { 0.5, 1.0, 2.0};
|
|
|
|
|
2015-11-29 01:01:51 +00:00
|
|
|
// MdagMLinearOperator<Matrix,FineField> fMdagMOp(_FineMatrix);
|
|
|
|
ShiftedMdagMLinearOperator<Matrix,FineField> fMdagMOp(_SmootherMatrix,0.0);
|
2015-07-21 05:52:23 +01:00
|
|
|
|
|
|
|
RealD Ni,r;
|
|
|
|
|
|
|
|
Ni = norm2(in);
|
|
|
|
|
2015-07-23 17:31:13 +01:00
|
|
|
for(int ilo=0;ilo<3;ilo++){
|
|
|
|
for(int ord=5;ord<50;ord*=2){
|
2015-07-21 05:52:23 +01:00
|
|
|
|
2015-11-29 01:01:51 +00:00
|
|
|
_SmootherOperator.AdjOp(in,vec1);
|
2015-07-21 05:52:23 +01:00
|
|
|
|
|
|
|
Chebyshev<FineField> Cheby (lo[ilo],70.0,ord,InverseApproximation);
|
|
|
|
Cheby(fMdagMOp,vec1,vec2); // solves MdagM = g5 M g5M
|
|
|
|
|
|
|
|
_FineOperator.Op(vec2,vec1);// this is the G5 herm bit
|
|
|
|
vec1 = in - vec1; // tmp = in - A Min
|
|
|
|
r=norm2(vec1);
|
2015-07-23 17:31:13 +01:00
|
|
|
std::cout<<GridLogMessage << "Smoother resid "<<std::sqrt(r/Ni)<<std::endl;
|
2015-07-21 05:52:23 +01:00
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-11-29 01:01:51 +00:00
|
|
|
void operatorCheby(const FineField &in, FineField & out) {
|
2015-07-21 05:52:23 +01:00
|
|
|
|
|
|
|
CoarseVector Csrc(_CoarseOperator.Grid());
|
|
|
|
CoarseVector Ctmp(_CoarseOperator.Grid());
|
|
|
|
CoarseVector Csol(_CoarseOperator.Grid()); Csol=zero;
|
|
|
|
|
2016-03-30 08:16:02 +01:00
|
|
|
ConjugateGradient<CoarseVector> CG(3.0e-3,100000);
|
2015-07-23 17:31:13 +01:00
|
|
|
// ConjugateGradient<FineField> fCG(3.0e-2,1000);
|
2015-07-21 05:52:23 +01:00
|
|
|
|
|
|
|
HermitianLinearOperator<CoarseOperator,CoarseVector> HermOp(_CoarseOperator);
|
|
|
|
MdagMLinearOperator<CoarseOperator,CoarseVector> MdagMOp(_CoarseOperator);
|
2015-11-29 01:01:51 +00:00
|
|
|
// MdagMLinearOperator<Matrix,FineField> fMdagMOp(_FineMatrix);
|
|
|
|
ShiftedMdagMLinearOperator<Matrix,FineField> fMdagMOp(_SmootherMatrix,0.0);
|
2015-07-21 05:52:23 +01:00
|
|
|
|
|
|
|
FineField vec1(in._grid);
|
|
|
|
FineField vec2(in._grid);
|
|
|
|
|
|
|
|
// Chebyshev<FineField> Cheby (0.5,70.0,30,InverseApproximation);
|
|
|
|
// Chebyshev<FineField> ChebyAccu(0.5,70.0,30,InverseApproximation);
|
2016-03-08 09:01:50 +00:00
|
|
|
Chebyshev<FineField> Cheby (params.lo,params.hi,params.order,InverseApproximation);
|
|
|
|
Chebyshev<FineField> ChebyAccu(params.lo,params.hi,params.order,InverseApproximation);
|
2015-11-29 01:01:51 +00:00
|
|
|
// Cheby.JacksonSmooth();
|
|
|
|
// ChebyAccu.JacksonSmooth();
|
2015-07-21 05:52:23 +01:00
|
|
|
|
2016-03-08 09:01:50 +00:00
|
|
|
// _Aggregates.ProjectToSubspace (Csrc,in);
|
|
|
|
// _Aggregates.PromoteFromSubspace(Csrc,out);
|
|
|
|
// std::cout<<GridLogMessage<<"Completeness: "<<std::sqrt(norm2(out)/norm2(in))<<std::endl;
|
2015-07-21 05:52:23 +01:00
|
|
|
|
|
|
|
// ofstream fout("smoother");
|
|
|
|
// Cheby.csv(fout);
|
|
|
|
|
|
|
|
// V11 multigrid.
|
|
|
|
// Use a fixed chebyshev and hope hermiticity helps.
|
|
|
|
|
|
|
|
// To make a working smoother for indefinite operator
|
|
|
|
// must multiply by "Mdag" (ouch loses all low mode content)
|
|
|
|
// and apply to poly approx of (mdagm)^-1.
|
|
|
|
// so that we end up with an odd polynomial.
|
|
|
|
|
|
|
|
RealD Ni = norm2(in);
|
|
|
|
|
2015-11-29 01:01:51 +00:00
|
|
|
_SmootherOperator.AdjOp(in,vec1);// this is the G5 herm bit
|
2015-07-21 05:52:23 +01:00
|
|
|
ChebyAccu(fMdagMOp,vec1,out); // solves MdagM = g5 M g5M
|
|
|
|
|
2015-07-23 17:31:13 +01:00
|
|
|
std::cout<<GridLogMessage << "Smoother norm "<<norm2(out)<<std::endl;
|
2015-07-21 05:52:23 +01:00
|
|
|
|
|
|
|
// Update with residual for out
|
|
|
|
_FineOperator.Op(out,vec1);// this is the G5 herm bit
|
|
|
|
vec1 = in - vec1; // tmp = in - A Min
|
|
|
|
|
|
|
|
RealD r = norm2(vec1);
|
|
|
|
|
2015-07-23 17:31:13 +01:00
|
|
|
std::cout<<GridLogMessage << "Smoother resid "<<std::sqrt(r/Ni)<< " " << r << " " << Ni <<std::endl;
|
2015-07-21 05:52:23 +01:00
|
|
|
|
|
|
|
_Aggregates.ProjectToSubspace (Csrc,vec1);
|
|
|
|
HermOp.AdjOp(Csrc,Ctmp);// Normal equations
|
|
|
|
CG(MdagMOp,Ctmp,Csol);
|
|
|
|
_Aggregates.PromoteFromSubspace(Csol,vec1); // Ass^{-1} [in - A Min]_s
|
|
|
|
// Q = Q[in - A Min]
|
|
|
|
out = out+vec1;
|
|
|
|
|
|
|
|
// Three preconditioner smoothing -- hermitian if C3 = C1
|
|
|
|
// Recompute error
|
|
|
|
_FineOperator.Op(out,vec1);// this is the G5 herm bit
|
|
|
|
vec1 = in - vec1; // tmp = in - A Min
|
|
|
|
r=norm2(vec1);
|
|
|
|
|
2015-07-23 17:31:13 +01:00
|
|
|
std::cout<<GridLogMessage << "Coarse resid "<<std::sqrt(r/Ni)<<std::endl;
|
2015-07-21 05:52:23 +01:00
|
|
|
|
|
|
|
// Reapply smoother
|
2015-11-29 01:01:51 +00:00
|
|
|
_SmootherOperator.Op(vec1,vec2); // this is the G5 herm bit
|
2015-07-21 05:52:23 +01:00
|
|
|
ChebyAccu(fMdagMOp,vec2,vec1); // solves MdagM = g5 M g5M
|
|
|
|
|
|
|
|
out =out+vec1;
|
|
|
|
vec1 = in - vec1; // tmp = in - A Min
|
|
|
|
r=norm2(vec1);
|
2015-07-23 17:31:13 +01:00
|
|
|
std::cout<<GridLogMessage << "Smoother resid "<<std::sqrt(r/Ni)<<std::endl;
|
2015-07-21 05:52:23 +01:00
|
|
|
|
|
|
|
}
|
2015-06-22 12:49:44 +01:00
|
|
|
|
2015-11-29 01:01:51 +00:00
|
|
|
void operatorSAP(const FineField &in, FineField & out) {
|
|
|
|
|
|
|
|
CoarseVector Csrc(_CoarseOperator.Grid());
|
|
|
|
CoarseVector Ctmp(_CoarseOperator.Grid());
|
|
|
|
CoarseVector Csol(_CoarseOperator.Grid()); Csol=zero;
|
|
|
|
|
|
|
|
ConjugateGradient<CoarseVector> CG(1.0e-3,100000);
|
|
|
|
|
|
|
|
HermitianLinearOperator<CoarseOperator,CoarseVector> HermOp(_CoarseOperator);
|
|
|
|
MdagMLinearOperator<CoarseOperator,CoarseVector> MdagMOp(_CoarseOperator);
|
|
|
|
|
|
|
|
FineField vec1(in._grid);
|
|
|
|
FineField vec2(in._grid);
|
|
|
|
|
|
|
|
_Aggregates.ProjectToSubspace (Csrc,in);
|
|
|
|
_Aggregates.PromoteFromSubspace(Csrc,out);
|
|
|
|
std::cout<<GridLogMessage<<"Completeness: "<<std::sqrt(norm2(out)/norm2(in))<<std::endl;
|
|
|
|
|
|
|
|
|
|
|
|
// To make a working smoother for indefinite operator
|
|
|
|
// must multiply by "Mdag" (ouch loses all low mode content)
|
|
|
|
// and apply to poly approx of (mdagm)^-1.
|
|
|
|
// so that we end up with an odd polynomial.
|
|
|
|
SAP(in,out);
|
|
|
|
|
|
|
|
// Update with residual for out
|
|
|
|
_FineOperator.Op(out,vec1);// this is the G5 herm bit
|
|
|
|
vec1 = in - vec1; // tmp = in - A Min
|
|
|
|
|
|
|
|
RealD r = norm2(vec1);
|
|
|
|
RealD Ni = norm2(in);
|
|
|
|
std::cout<<GridLogMessage << "SAP resid "<<std::sqrt(r/Ni)<< " " << r << " " << Ni <<std::endl;
|
|
|
|
|
|
|
|
_Aggregates.ProjectToSubspace (Csrc,vec1);
|
|
|
|
HermOp.AdjOp(Csrc,Ctmp);// Normal equations
|
|
|
|
CG(MdagMOp,Ctmp,Csol);
|
|
|
|
_Aggregates.PromoteFromSubspace(Csol,vec1); // Ass^{-1} [in - A Min]_s
|
|
|
|
// Q = Q[in - A Min]
|
|
|
|
out = out+vec1;
|
|
|
|
|
|
|
|
// Three preconditioner smoothing -- hermitian if C3 = C1
|
|
|
|
// Recompute error
|
|
|
|
_FineOperator.Op(out,vec1);// this is the G5 herm bit
|
|
|
|
vec1 = in - vec1; // tmp = in - A Min
|
|
|
|
r=norm2(vec1);
|
|
|
|
|
|
|
|
std::cout<<GridLogMessage << "Coarse resid "<<std::sqrt(r/Ni)<<std::endl;
|
|
|
|
|
|
|
|
// Reapply smoother
|
|
|
|
SAP(vec1,vec2);
|
|
|
|
out =out+vec2;
|
|
|
|
|
|
|
|
|
|
|
|
// Update with residual for out
|
|
|
|
_FineOperator.Op(out,vec1);// this is the G5 herm bit
|
|
|
|
vec1 = in - vec1; // tmp = in - A Min
|
|
|
|
|
|
|
|
r = norm2(vec1);
|
|
|
|
Ni = norm2(in);
|
|
|
|
std::cout<<GridLogMessage << "SAP resid(post) "<<std::sqrt(r/Ni)<< " " << r << " " << Ni <<std::endl;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2015-06-22 12:49:44 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
int main (int argc, char ** argv)
|
|
|
|
{
|
|
|
|
Grid_init(&argc,&argv);
|
|
|
|
|
2015-11-29 10:59:11 +00:00
|
|
|
XmlReader RD("params.xml");
|
2015-11-29 01:01:51 +00:00
|
|
|
read(RD,"params",params);
|
|
|
|
std::cout<<"Params: Order "<<params.order<<"["<<params.lo<<","<<params.hi<<"]"<< " steps "<<params.steps<<std::endl;
|
|
|
|
|
2016-03-16 09:31:04 +00:00
|
|
|
const int Ls=params.Ls;
|
2015-06-22 12:49:44 +01:00
|
|
|
|
2015-06-30 15:01:26 +01:00
|
|
|
GridCartesian * UGrid = SpaceTimeGrid::makeFourDimGrid(GridDefaultLatt(), GridDefaultSimd(Nd,vComplex::Nsimd()),GridDefaultMpi());
|
2015-06-22 12:49:44 +01:00
|
|
|
GridRedBlackCartesian * UrbGrid = SpaceTimeGrid::makeFourDimRedBlackGrid(UGrid);
|
|
|
|
|
|
|
|
GridCartesian * FGrid = SpaceTimeGrid::makeFiveDimGrid(Ls,UGrid);
|
|
|
|
GridRedBlackCartesian * FrbGrid = SpaceTimeGrid::makeFiveDimRedBlackGrid(Ls,UGrid);
|
|
|
|
|
|
|
|
///////////////////////////////////////////////////
|
|
|
|
// Construct a coarsened grid; utility for this?
|
|
|
|
///////////////////////////////////////////////////
|
2016-03-08 09:01:50 +00:00
|
|
|
std::vector<int> block ({2,2,2,2});
|
|
|
|
const int nbasis= 32;
|
|
|
|
|
2015-06-22 12:49:44 +01:00
|
|
|
std::vector<int> clatt = GridDefaultLatt();
|
|
|
|
for(int d=0;d<clatt.size();d++){
|
2016-03-08 09:01:50 +00:00
|
|
|
clatt[d] = clatt[d]/block[d];
|
2015-06-22 12:49:44 +01:00
|
|
|
}
|
2015-06-30 15:01:26 +01:00
|
|
|
GridCartesian *Coarse4d = SpaceTimeGrid::makeFourDimGrid(clatt, GridDefaultSimd(Nd,vComplex::Nsimd()),GridDefaultMpi());;
|
2015-06-22 12:49:44 +01:00
|
|
|
GridCartesian *Coarse5d = SpaceTimeGrid::makeFiveDimGrid(1,Coarse4d);
|
|
|
|
|
|
|
|
std::vector<int> seeds4({1,2,3,4});
|
|
|
|
std::vector<int> seeds5({5,6,7,8});
|
|
|
|
std::vector<int> cseeds({5,6,7,8});
|
|
|
|
GridParallelRNG RNG5(FGrid); RNG5.SeedFixedIntegers(seeds5);
|
|
|
|
GridParallelRNG RNG4(UGrid); RNG4.SeedFixedIntegers(seeds4);
|
|
|
|
GridParallelRNG CRNG(Coarse5d);CRNG.SeedFixedIntegers(cseeds);
|
|
|
|
|
2017-01-24 03:13:43 +00:00
|
|
|
Gamma g5(Gamma::Algebra::Gamma5);
|
2015-06-30 15:01:26 +01:00
|
|
|
|
|
|
|
LatticeFermion src(FGrid); gaussian(RNG5,src);// src=src+g5*src;
|
2015-06-22 12:49:44 +01:00
|
|
|
LatticeFermion result(FGrid); result=zero;
|
|
|
|
LatticeFermion ref(FGrid); ref=zero;
|
|
|
|
LatticeFermion tmp(FGrid);
|
|
|
|
LatticeFermion err(FGrid);
|
|
|
|
LatticeGaugeField Umu(UGrid);
|
2015-11-29 01:01:51 +00:00
|
|
|
LatticeGaugeField UmuDD(UGrid);
|
|
|
|
LatticeColourMatrix U(UGrid);
|
|
|
|
LatticeColourMatrix zz(UGrid);
|
2015-06-22 12:49:44 +01:00
|
|
|
|
2017-06-19 22:54:18 +01:00
|
|
|
FieldMetaData header;
|
2015-07-31 21:58:35 +01:00
|
|
|
std::string file("./ckpoint_lat.4000");
|
Binary IO file for generic Grid array parallel I/O.
Number of IO MPI tasks can be varied by selecting which
dimensions use parallel IO and which dimensions use Serial send to boss
I/O.
Thus can neck down from, say 1024 nodes = 4x4x8x8 to {1,8,32,64,128,256,1024} nodes
doing the I/O.
Interpolates nicely between ALL nodes write their data, a single boss per time-plane
in processor space [old UKQCD fortran code did this], and a single node doing all I/O.
Not sure I have the transfer sizes big enough and am not overly convinced fstream
is guaranteed to not give buffer inconsistencies unless I set streambuf size to zero.
Practically it has worked on 8 tasks, 2x1x2x2 writing /cloning NERSC configurations
on my MacOS + OpenMPI and Clang environment.
It is VERY easy to switch to pwrite at a later date, and also easy to send x-strips around from
each node in order to gather bigger chunks at the syscall level.
That would push us up to the circa 8x 18*4*8 == 4KB size write chunk, and by taking, say, x/y non
parallel we get to 16MB contiguous chunks written in multi 4KB transactions
per IOnode in 64^3 lattices for configuration I/O.
I suspect this is fine for system performance.
2015-08-26 13:40:29 +01:00
|
|
|
NerscIO::readConfiguration(Umu,header,file);
|
2015-06-22 12:49:44 +01:00
|
|
|
|
2015-11-29 01:01:51 +00:00
|
|
|
|
|
|
|
if ( params.domaindecompose ) {
|
|
|
|
Lattice<iScalar<vInteger> > coor(UGrid);
|
|
|
|
zz=zero;
|
|
|
|
for(int mu=0;mu<Nd;mu++){
|
|
|
|
LatticeCoordinate(coor,mu);
|
|
|
|
U = PeekIndex<LorentzIndex>(Umu,mu);
|
|
|
|
U = where(mod(coor,params.domainsize)==(Integer)0,zz,U);
|
|
|
|
PokeIndex<LorentzIndex>(UmuDD,U,mu);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
UmuDD = Umu;
|
|
|
|
}
|
2015-06-22 12:49:44 +01:00
|
|
|
// SU3::ColdConfiguration(RNG4,Umu);
|
|
|
|
// SU3::TepidConfiguration(RNG4,Umu);
|
|
|
|
// SU3::HotConfiguration(RNG4,Umu);
|
|
|
|
// Umu=zero;
|
|
|
|
|
2016-03-16 09:31:04 +00:00
|
|
|
RealD mass=params.mq;
|
2015-06-22 12:49:44 +01:00
|
|
|
RealD M5=1.8;
|
|
|
|
|
2015-07-23 17:31:13 +01:00
|
|
|
std::cout<<GridLogMessage << "**************************************************"<< std::endl;
|
|
|
|
std::cout<<GridLogMessage << "Building g5R5 hermitian DWF operator" <<std::endl;
|
|
|
|
std::cout<<GridLogMessage << "**************************************************"<< std::endl;
|
2015-08-10 20:47:44 +01:00
|
|
|
DomainWallFermionR Ddwf(Umu,*FGrid,*FrbGrid,*UGrid,*UrbGrid,mass,M5);
|
2015-11-29 01:01:51 +00:00
|
|
|
DomainWallFermionR DdwfDD(UmuDD,*FGrid,*FrbGrid,*UGrid,*UrbGrid,mass,M5);
|
2015-06-22 12:49:44 +01:00
|
|
|
|
|
|
|
typedef Aggregation<vSpinColourVector,vTComplex,nbasis> Subspace;
|
|
|
|
typedef CoarsenedMatrix<vSpinColourVector,vTComplex,nbasis> CoarseOperator;
|
|
|
|
typedef CoarseOperator::CoarseVector CoarseVector;
|
|
|
|
|
2015-07-23 17:31:13 +01:00
|
|
|
std::cout<<GridLogMessage << "**************************************************"<< std::endl;
|
|
|
|
std::cout<<GridLogMessage << "Calling Aggregation class to build subspace" <<std::endl;
|
|
|
|
std::cout<<GridLogMessage << "**************************************************"<< std::endl;
|
2015-08-10 20:47:44 +01:00
|
|
|
MdagMLinearOperator<DomainWallFermionR,LatticeFermion> HermDefOp(Ddwf);
|
2017-10-30 00:05:21 +00:00
|
|
|
Subspace Aggregates(Coarse5d,FGrid,0);
|
2015-07-21 05:52:23 +01:00
|
|
|
// Aggregates.CreateSubspace(RNG5,HermDefOp,nbasis);
|
|
|
|
assert ( (nbasis & 0x1)==0);
|
|
|
|
int nb=nbasis/2;
|
2015-07-23 17:31:13 +01:00
|
|
|
std::cout<<GridLogMessage << " nbasis/2 = "<<nb<<std::endl;
|
2017-10-30 00:05:21 +00:00
|
|
|
Aggregates.CreateSubspace(RNG5,HermDefOp,nb);
|
|
|
|
// Aggregates.CreateSubspaceLanczos(RNG5,HermDefOp,nb);
|
2015-07-21 05:52:23 +01:00
|
|
|
for(int n=0;n<nb;n++){
|
|
|
|
G5R5(Aggregates.subspace[n+nb],Aggregates.subspace[n]);
|
2015-07-23 17:31:13 +01:00
|
|
|
std::cout<<GridLogMessage<<n<<" subspace "<<norm2(Aggregates.subspace[n+nb])<<" "<<norm2(Aggregates.subspace[n]) <<std::endl;
|
2015-07-21 05:52:23 +01:00
|
|
|
}
|
|
|
|
for(int n=0;n<nbasis;n++){
|
2015-07-23 17:31:13 +01:00
|
|
|
std::cout<<GridLogMessage << "vec["<<n<<"] = "<<norm2(Aggregates.subspace[n]) <<std::endl;
|
2015-07-21 05:52:23 +01:00
|
|
|
}
|
|
|
|
|
2015-06-30 15:01:26 +01:00
|
|
|
// for(int i=0;i<nbasis;i++){
|
|
|
|
// result = Aggregates.subspace[i];
|
|
|
|
// Aggregates.subspace[i]=result+g5*result;
|
|
|
|
// }
|
|
|
|
result=zero;
|
|
|
|
|
2015-07-23 17:31:13 +01:00
|
|
|
std::cout<<GridLogMessage << "**************************************************"<< std::endl;
|
|
|
|
std::cout<<GridLogMessage << "Building coarse representation of Indef operator" <<std::endl;
|
|
|
|
std::cout<<GridLogMessage << "**************************************************"<< std::endl;
|
2015-08-10 20:47:44 +01:00
|
|
|
Gamma5R5HermitianLinearOperator<DomainWallFermionR,LatticeFermion> HermIndefOp(Ddwf);
|
2015-11-29 01:01:51 +00:00
|
|
|
Gamma5R5HermitianLinearOperator<DomainWallFermionR,LatticeFermion> HermIndefOpDD(DdwfDD);
|
2015-06-22 12:49:44 +01:00
|
|
|
CoarsenedMatrix<vSpinColourVector,vTComplex,nbasis> LDOp(*Coarse5d);
|
|
|
|
LDOp.CoarsenOperator(FGrid,HermIndefOp,Aggregates);
|
|
|
|
|
2015-07-23 17:31:13 +01:00
|
|
|
std::cout<<GridLogMessage << "**************************************************"<< std::endl;
|
|
|
|
std::cout<<GridLogMessage << "Testing some coarse space solvers " <<std::endl;
|
|
|
|
std::cout<<GridLogMessage << "**************************************************"<< std::endl;
|
2015-06-22 12:49:44 +01:00
|
|
|
CoarseVector c_src (Coarse5d);
|
|
|
|
CoarseVector c_res (Coarse5d);
|
|
|
|
gaussian(CRNG,c_src);
|
|
|
|
c_res=zero;
|
|
|
|
|
2015-07-23 17:31:13 +01:00
|
|
|
std::cout<<GridLogMessage << "**************************************************"<< std::endl;
|
|
|
|
std::cout<<GridLogMessage << "Solving posdef-CG on coarse space "<< std::endl;
|
|
|
|
std::cout<<GridLogMessage << "**************************************************"<< std::endl;
|
2015-06-22 12:49:44 +01:00
|
|
|
MdagMLinearOperator<CoarseOperator,CoarseVector> PosdefLdop(LDOp);
|
2015-06-30 15:01:26 +01:00
|
|
|
ConjugateGradient<CoarseVector> CG(1.0e-6,100000);
|
2016-03-16 09:31:04 +00:00
|
|
|
// CG(PosdefLdop,c_src,c_res);
|
2015-06-22 12:49:44 +01:00
|
|
|
|
2015-07-23 17:31:13 +01:00
|
|
|
// std::cout<<GridLogMessage << "**************************************************"<< std::endl;
|
|
|
|
// std::cout<<GridLogMessage << "Solving indef-MCR on coarse space "<< std::endl;
|
|
|
|
// std::cout<<GridLogMessage << "**************************************************"<< std::endl;
|
2015-06-30 15:01:26 +01:00
|
|
|
// HermitianLinearOperator<CoarseOperator,CoarseVector> HermIndefLdop(LDOp);
|
|
|
|
// ConjugateResidual<CoarseVector> MCR(1.0e-6,100000);
|
2015-06-22 12:49:44 +01:00
|
|
|
//MCR(HermIndefLdop,c_src,c_res);
|
|
|
|
|
2015-07-23 17:31:13 +01:00
|
|
|
std::cout<<GridLogMessage << "**************************************************"<< std::endl;
|
|
|
|
std::cout<<GridLogMessage << "Building deflation preconditioner "<< std::endl;
|
|
|
|
std::cout<<GridLogMessage << "**************************************************"<< std::endl;
|
2015-06-22 12:49:44 +01:00
|
|
|
|
2015-11-29 01:01:51 +00:00
|
|
|
MultiGridPreconditioner <vSpinColourVector,vTComplex,nbasis,DomainWallFermionR> Precon (Aggregates, LDOp,
|
|
|
|
HermIndefOp,Ddwf,
|
|
|
|
HermIndefOp,Ddwf);
|
|
|
|
|
|
|
|
MultiGridPreconditioner <vSpinColourVector,vTComplex,nbasis,DomainWallFermionR> PreconDD(Aggregates, LDOp,
|
|
|
|
HermIndefOp,Ddwf,
|
|
|
|
HermIndefOpDD,DdwfDD);
|
2015-06-30 15:01:26 +01:00
|
|
|
TrivialPrecon<LatticeFermion> simple;
|
|
|
|
|
2015-07-23 17:31:13 +01:00
|
|
|
std::cout<<GridLogMessage << "**************************************************"<< std::endl;
|
|
|
|
std::cout<<GridLogMessage << "Testing smoother efficacy"<< std::endl;
|
|
|
|
std::cout<<GridLogMessage << "**************************************************"<< std::endl;
|
2016-03-16 09:31:04 +00:00
|
|
|
// Precon.SmootherTest(src);
|
2015-07-21 05:52:23 +01:00
|
|
|
|
2015-11-29 01:01:51 +00:00
|
|
|
std::cout<<GridLogMessage << "**************************************************"<< std::endl;
|
|
|
|
std::cout<<GridLogMessage << "Testing DD smoother efficacy"<< std::endl;
|
|
|
|
std::cout<<GridLogMessage << "**************************************************"<< std::endl;
|
2016-03-16 09:31:04 +00:00
|
|
|
// PreconDD.SmootherTest(src);
|
2015-11-29 01:01:51 +00:00
|
|
|
|
|
|
|
std::cout<<GridLogMessage << "**************************************************"<< std::endl;
|
|
|
|
std::cout<<GridLogMessage << "Testing SAP smoother efficacy"<< std::endl;
|
|
|
|
std::cout<<GridLogMessage << "**************************************************"<< std::endl;
|
2016-03-16 09:31:04 +00:00
|
|
|
// PreconDD.SAP(src,result);
|
2015-11-29 01:01:51 +00:00
|
|
|
|
2015-07-23 17:31:13 +01:00
|
|
|
std::cout<<GridLogMessage << "**************************************************"<< std::endl;
|
|
|
|
std::cout<<GridLogMessage << "Unprec CG "<< std::endl;
|
|
|
|
std::cout<<GridLogMessage << "**************************************************"<< std::endl;
|
2015-11-29 01:01:51 +00:00
|
|
|
|
2015-06-30 15:01:26 +01:00
|
|
|
// TrivialPrecon<LatticeFermion> simple;
|
2015-07-21 16:30:05 +01:00
|
|
|
// ConjugateGradient<LatticeFermion> fCG(1.0e-8,100000);
|
|
|
|
// fCG(HermDefOp,src,result);
|
2015-07-21 05:52:23 +01:00
|
|
|
// exit(0);
|
2015-06-22 12:49:44 +01:00
|
|
|
|
2015-07-23 17:31:13 +01:00
|
|
|
std::cout<<GridLogMessage << "**************************************************"<< std::endl;
|
|
|
|
std::cout<<GridLogMessage << "Testing GCR on indef matrix "<< std::endl;
|
|
|
|
std::cout<<GridLogMessage << "**************************************************"<< std::endl;
|
2015-06-30 15:01:26 +01:00
|
|
|
// PrecGeneralisedConjugateResidual<LatticeFermion> UPGCR(1.0e-8,100000,simple,8,128);
|
|
|
|
// UPGCR(HermIndefOp,src,result);
|
2015-06-22 12:49:44 +01:00
|
|
|
|
2015-07-21 05:52:23 +01:00
|
|
|
|
|
|
|
/// Get themax eval
|
2015-07-23 17:31:13 +01:00
|
|
|
std::cout<<GridLogMessage << "**************************************************"<< std::endl;
|
|
|
|
std::cout<<GridLogMessage <<" Applying power method to find spectral range "<<std::endl;
|
|
|
|
std::cout<<GridLogMessage << "**************************************************"<< std::endl;
|
2015-07-21 05:52:23 +01:00
|
|
|
Precon.PowerMethod(src);
|
|
|
|
|
2015-11-29 01:01:51 +00:00
|
|
|
|
2015-07-23 17:31:13 +01:00
|
|
|
std::cout<<GridLogMessage << "**************************************************"<< std::endl;
|
2015-11-29 01:01:51 +00:00
|
|
|
std::cout<<GridLogMessage << "Building a two level DDPGCR "<< std::endl;
|
2015-07-23 17:31:13 +01:00
|
|
|
std::cout<<GridLogMessage << "**************************************************"<< std::endl;
|
2016-03-16 09:31:04 +00:00
|
|
|
// PrecGeneralisedConjugateResidual<LatticeFermion> PGCRDD(1.0e-8,100000,PreconDD,8,128);
|
|
|
|
// result=zero;
|
|
|
|
// std::cout<<GridLogMessage<<"checking norm src "<<norm2(src)<<std::endl;
|
|
|
|
// PGCRDD(HermIndefOp,src,result);
|
2015-11-29 01:01:51 +00:00
|
|
|
|
|
|
|
std::cout<<GridLogMessage << "**************************************************"<< std::endl;
|
|
|
|
std::cout<<GridLogMessage << "Building a two level PGCR "<< std::endl;
|
|
|
|
std::cout<<GridLogMessage << "**************************************************"<< std::endl;
|
2016-03-16 09:31:04 +00:00
|
|
|
PrecGeneralisedConjugateResidual<LatticeFermion> PGCR(1.0e-8,100000,Precon,8,8);
|
|
|
|
std::cout<<GridLogMessage<<"checking norm src "<<norm2(src)<<std::endl;
|
|
|
|
result=zero;
|
|
|
|
PGCR(HermIndefOp,src,result);
|
2015-06-22 12:49:44 +01:00
|
|
|
|
2015-07-23 17:31:13 +01:00
|
|
|
std::cout<<GridLogMessage << "**************************************************"<< std::endl;
|
|
|
|
std::cout<<GridLogMessage << "Red Black Prec CG "<< std::endl;
|
|
|
|
std::cout<<GridLogMessage << "**************************************************"<< std::endl;
|
2015-08-10 20:47:44 +01:00
|
|
|
SchurDiagMooeeOperator<DomainWallFermionR,LatticeFermion> HermOpEO(Ddwf);
|
2015-07-23 17:31:13 +01:00
|
|
|
ConjugateGradient<LatticeFermion> pCG(1.0e-8,10000);
|
|
|
|
|
|
|
|
LatticeFermion src_o(FrbGrid);
|
|
|
|
LatticeFermion result_o(FrbGrid);
|
|
|
|
pickCheckerboard(Odd,src_o,src);
|
|
|
|
result_o=zero;
|
|
|
|
|
|
|
|
pCG(HermOpEO,src_o,result_o);
|
|
|
|
|
2015-11-29 01:01:51 +00:00
|
|
|
|
2015-07-23 17:31:13 +01:00
|
|
|
std::cout<<GridLogMessage << "**************************************************"<< std::endl;
|
|
|
|
std::cout<<GridLogMessage << "Done "<< std::endl;
|
|
|
|
std::cout<<GridLogMessage << "**************************************************"<< std::endl;
|
2015-06-22 12:49:44 +01:00
|
|
|
Grid_finalize();
|
|
|
|
}
|