1
0
mirror of https://github.com/paboyle/Grid.git synced 2024-11-10 07:55:35 +00:00

Fix naming conventions to be consistent with Peter

This commit is contained in:
David Murphy 2019-12-11 11:46:18 -05:00
parent 4180a4a8a7
commit 843ca9350a
8 changed files with 37 additions and 42 deletions

View File

@ -322,7 +322,7 @@ public:
}; };
template<class Field> template<class Field>
class HermitianSchurOperatorBase : public LinearOperatorBase<Field> class NonHermitianSchurOperatorBase : public LinearOperatorBase<Field>
{ {
public: public:
virtual RealD Mpc (const Field& in, Field& out) = 0; virtual RealD Mpc (const Field& in, Field& out) = 0;
@ -334,16 +334,10 @@ public:
no = MpcDag(tmp,out); no = MpcDag(tmp,out);
} }
virtual void HermOpAndNorm(const Field& in, Field& out, RealD& n1, RealD& n2) { virtual void HermOpAndNorm(const Field& in, Field& out, RealD& n1, RealD& n2) {
out.Checkerboard() = in.Checkerboard(); assert(0);
Mpc(in, out);
ComplexD dot = innerProduct(in,out); n1 = real(dot);
n2 = norm2(out);
} }
virtual void HermOp(const Field& in, Field& out) { virtual void HermOp(const Field& in, Field& out) {
RealD n1, n2; assert(0);
HermOpAndNorm(in, out, n1, n2);
} }
void Op(const Field& in, Field& out) { void Op(const Field& in, Field& out) {
Mpc(in, out); Mpc(in, out);
@ -361,11 +355,11 @@ public:
}; };
template<class Matrix, class Field> template<class Matrix, class Field>
class HermitianSchurDiagMooeeOperator : public HermitianSchurOperatorBase<Field> class NonHermitianSchurDiagMooeeOperator : public NonHermitianSchurOperatorBase<Field>
{ {
public: public:
Matrix& _Mat; Matrix& _Mat;
HermitianSchurDiagMooeeOperator(Matrix& Mat): _Mat(Mat){}; NonHermitianSchurDiagMooeeOperator(Matrix& Mat): _Mat(Mat){};
virtual RealD Mpc(const Field& in, Field& out) { virtual RealD Mpc(const Field& in, Field& out) {
Field tmp(in.Grid()); Field tmp(in.Grid());
tmp.Checkerboard() = !in.Checkerboard(); tmp.Checkerboard() = !in.Checkerboard();
@ -392,13 +386,13 @@ public:
}; };
template<class Matrix,class Field> template<class Matrix,class Field>
class HermitianSchurDiagOneOperator : public HermitianSchurOperatorBase<Field> class NonHermitianSchurDiagOneOperator : public NonHermitianSchurOperatorBase<Field>
{ {
protected: protected:
Matrix &_Mat; Matrix &_Mat;
public: public:
HermitianSchurDiagOneOperator (Matrix& Mat): _Mat(Mat){}; NonHermitianSchurDiagOneOperator (Matrix& Mat): _Mat(Mat){};
virtual RealD Mpc(const Field& in, Field& out) { virtual RealD Mpc(const Field& in, Field& out) {
Field tmp(in.Grid()); Field tmp(in.Grid());
@ -422,13 +416,13 @@ public:
}; };
template<class Matrix, class Field> template<class Matrix, class Field>
class HermitianSchurDiagTwoOperator : public HermitianSchurOperatorBase<Field> class NonHermitianSchurDiagTwoOperator : public NonHermitianSchurOperatorBase<Field>
{ {
protected: protected:
Matrix& _Mat; Matrix& _Mat;
public: public:
HermitianSchurDiagTwoOperator(Matrix& Mat): _Mat(Mat){}; NonHermitianSchurDiagTwoOperator(Matrix& Mat): _Mat(Mat){};
virtual RealD Mpc(const Field& in, Field& out) { virtual RealD Mpc(const Field& in, Field& out) {
Field tmp(in.Grid()); Field tmp(in.Grid());

View File

@ -62,7 +62,7 @@ class BiCGSTAB : public OperatorFunction<Field>
conformable(psi, src); conformable(psi, src);
RealD cp(0), rho(1), rho_prev(0), alpha(1), beta(0), omega(1); RealD cp(0), rho(1), rho_prev(0), alpha(1), beta(0), omega(1);
RealD a(0), bo(0), d(0), b(0), ssq(0), qq(0); RealD a(0), bo(0), b(0), ssq(0);
Field p(src); Field p(src);
Field r(src); Field r(src);
@ -79,7 +79,8 @@ class BiCGSTAB : public OperatorFunction<Field>
RealD guess = norm2(psi); RealD guess = norm2(psi);
assert(std::isnan(guess) == 0); assert(std::isnan(guess) == 0);
Linop.HermOpAndNorm(psi, v, d, b); Linop.Op(psi, v);
b = norm2(v);
r = src - v; r = src - v;
rhat = r; rhat = r;
@ -131,7 +132,7 @@ class BiCGSTAB : public OperatorFunction<Field>
LinalgTimer.Stop(); LinalgTimer.Stop();
MatrixTimer.Start(); MatrixTimer.Start();
Linop.HermOp(p,v); Linop.Op(p,v);
MatrixTimer.Stop(); MatrixTimer.Stop();
LinalgTimer.Start(); LinalgTimer.Start();
@ -155,7 +156,7 @@ class BiCGSTAB : public OperatorFunction<Field>
LinalgTimer.Stop(); LinalgTimer.Stop();
MatrixTimer.Start(); MatrixTimer.Start();
Linop.HermOp(s,t); Linop.Op(s,t);
MatrixTimer.Stop(); MatrixTimer.Stop();
LinalgTimer.Start(); LinalgTimer.Start();
@ -181,7 +182,7 @@ class BiCGSTAB : public OperatorFunction<Field>
if(cp <= rsq) if(cp <= rsq)
{ {
SolverTimer.Stop(); SolverTimer.Stop();
Linop.HermOpAndNorm(psi, v, d, qq); Linop.Op(psi, v);
p = v - src; p = v - src;
RealD srcnorm = sqrt(norm2(src)); RealD srcnorm = sqrt(norm2(src));

View File

@ -105,7 +105,7 @@ class MixedPrecisionBiCGSTAB : public LinearFunction<FieldD>
for(outer_iter = 0; outer_iter < MaxOuterIterations; outer_iter++) for(outer_iter = 0; outer_iter < MaxOuterIterations; outer_iter++)
{ {
// Compute double precision rsd and also new RHS vector. // Compute double precision rsd and also new RHS vector.
Linop_d.HermOp(sol_d, tmp_d); Linop_d.Op(sol_d, tmp_d);
RealD norm = axpy_norm(src_d, -1., tmp_d, src_d_in); //src_d is residual vector RealD norm = axpy_norm(src_d, -1., tmp_d, src_d_in); //src_d is residual vector
std::cout << GridLogMessage << "MixedPrecisionBiCGSTAB: Outer iteration " << outer_iter << " residual " << norm << " target " << stop << std::endl; std::cout << GridLogMessage << "MixedPrecisionBiCGSTAB: Outer iteration " << outer_iter << " residual " << norm << " target " << stop << std::endl;

View File

@ -405,14 +405,14 @@ namespace Grid {
} }
}; };
template<class Field> class HermitianSchurRedBlackDiagMooeeSolve : public SchurRedBlackBase<Field> template<class Field> class NonHermitianSchurRedBlackDiagMooeeSolve : public SchurRedBlackBase<Field>
{ {
public: public:
typedef CheckerBoardedSparseMatrixBase<Field> Matrix; typedef CheckerBoardedSparseMatrixBase<Field> Matrix;
HermitianSchurRedBlackDiagMooeeSolve(OperatorFunction<Field>& HermitianRBSolver, const bool initSubGuess = false, NonHermitianSchurRedBlackDiagMooeeSolve(OperatorFunction<Field>& RBSolver, const bool initSubGuess = false,
const bool _solnAsInitGuess = false) const bool _solnAsInitGuess = false)
: SchurRedBlackBase<Field>(HermitianRBSolver, initSubGuess, _solnAsInitGuess) {}; : SchurRedBlackBase<Field>(RBSolver, initSubGuess, _solnAsInitGuess) {};
////////////////////////////////////////////////////// //////////////////////////////////////////////////////
// Override RedBlack specialisation // Override RedBlack specialisation
@ -458,14 +458,14 @@ namespace Grid {
virtual void RedBlackSolve(Matrix& _Matrix, const Field& src_o, Field& sol_o) virtual void RedBlackSolve(Matrix& _Matrix, const Field& src_o, Field& sol_o)
{ {
HermitianSchurDiagMooeeOperator<Matrix,Field> _HermOpEO(_Matrix); NonHermitianSchurDiagMooeeOperator<Matrix,Field> _OpEO(_Matrix);
this->_HermitianRBSolver(_HermOpEO, src_o, sol_o); assert(sol_o.Checkerboard() == Odd); this->_HermitianRBSolver(_OpEO, src_o, sol_o); assert(sol_o.Checkerboard() == Odd);
} }
virtual void RedBlackSolve(Matrix& _Matrix, const std::vector<Field>& src_o, std::vector<Field>& sol_o) virtual void RedBlackSolve(Matrix& _Matrix, const std::vector<Field>& src_o, std::vector<Field>& sol_o)
{ {
HermitianSchurDiagMooeeOperator<Matrix,Field> _HermOpEO(_Matrix); NonHermitianSchurDiagMooeeOperator<Matrix,Field> _OpEO(_Matrix);
this->_HermitianRBSolver(_HermOpEO, src_o, sol_o); this->_HermitianRBSolver(_OpEO, src_o, sol_o);
} }
}; };
@ -547,7 +547,7 @@ namespace Grid {
} }
}; };
template<class Field> class HermitianSchurRedBlackDiagTwoSolve : public SchurRedBlackBase<Field> template<class Field> class NonHermitianSchurRedBlackDiagTwoSolve : public SchurRedBlackBase<Field>
{ {
public: public:
typedef CheckerBoardedSparseMatrixBase<Field> Matrix; typedef CheckerBoardedSparseMatrixBase<Field> Matrix;
@ -555,9 +555,9 @@ namespace Grid {
///////////////////////////////////////////////////// /////////////////////////////////////////////////////
// Wrap the usual normal equations Schur trick // Wrap the usual normal equations Schur trick
///////////////////////////////////////////////////// /////////////////////////////////////////////////////
HermitianSchurRedBlackDiagTwoSolve(OperatorFunction<Field>& HermitianRBSolver, const bool initSubGuess = false, NonHermitianSchurRedBlackDiagTwoSolve(OperatorFunction<Field>& RBSolver, const bool initSubGuess = false,
const bool _solnAsInitGuess = false) const bool _solnAsInitGuess = false)
: SchurRedBlackBase<Field>(HermitianRBSolver, initSubGuess, _solnAsInitGuess) {}; : SchurRedBlackBase<Field>(RBSolver, initSubGuess, _solnAsInitGuess) {};
virtual void RedBlackSource(Matrix& _Matrix, const Field& src, Field& src_e, Field& src_o) virtual void RedBlackSource(Matrix& _Matrix, const Field& src, Field& src_e, Field& src_o)
{ {
@ -606,14 +606,14 @@ namespace Grid {
virtual void RedBlackSolve(Matrix& _Matrix, const Field& src_o, Field& sol_o) virtual void RedBlackSolve(Matrix& _Matrix, const Field& src_o, Field& sol_o)
{ {
HermitianSchurDiagTwoOperator<Matrix,Field> _HermOpEO(_Matrix); NonHermitianSchurDiagTwoOperator<Matrix,Field> _OpEO(_Matrix);
this->_HermitianRBSolver(_HermOpEO, src_o, sol_o); this->_HermitianRBSolver(_OpEO, src_o, sol_o);
}; };
virtual void RedBlackSolve(Matrix& _Matrix, const std::vector<Field>& src_o, std::vector<Field>& sol_o) virtual void RedBlackSolve(Matrix& _Matrix, const std::vector<Field>& src_o, std::vector<Field>& sol_o)
{ {
SchurDiagTwoOperator<Matrix,Field> _HermOpEO(_Matrix); NonHermitianSchurDiagTwoOperator<Matrix,Field> _OpEO(_Matrix);
this->_HermitianRBSolver(_HermOpEO, src_o, sol_o); this->_HermitianRBSolver(_OpEO, src_o, sol_o);
} }
}; };
} }

View File

@ -77,7 +77,7 @@ int main (int argc, char ** argv)
pickCheckerboard(Odd, src_o, src); pickCheckerboard(Odd, src_o, src);
result_o = Zero(); result_o = Zero();
HermitianSchurDiagMooeeOperator<WilsonCloverFermionR,LatticeFermion> HermOp(Dw); NonHermitianSchurDiagMooeeOperator<WilsonCloverFermionR,LatticeFermion> HermOp(Dw);
BiCGSTAB<LatticeFermion> CG(1.0e-8,10000); BiCGSTAB<LatticeFermion> CG(1.0e-8,10000);
CG(HermOp, src_o, result_o); CG(HermOp, src_o, result_o);

View File

@ -73,7 +73,7 @@ int main (int argc, char ** argv)
WilsonCloverFermionR Dw(Umu, Grid, RBGrid, mass, csw_r, csw_t); WilsonCloverFermionR Dw(Umu, Grid, RBGrid, mass, csw_r, csw_t);
BiCGSTAB<LatticeFermion> CG(1.0e-8,10000); BiCGSTAB<LatticeFermion> CG(1.0e-8,10000);
HermitianSchurRedBlackDiagMooeeSolve<LatticeFermion> SchurSolver(CG); NonHermitianSchurRedBlackDiagMooeeSolve<LatticeFermion> SchurSolver(CG);
SchurSolver(Dw, src, result); SchurSolver(Dw, src, result);

View File

@ -72,7 +72,7 @@ int main (int argc, char ** argv)
RealD csw_t = 1.0; RealD csw_t = 1.0;
WilsonCloverFermionR Dw(Umu, Grid, RBGrid, mass, csw_r, csw_t); WilsonCloverFermionR Dw(Umu, Grid, RBGrid, mass, csw_r, csw_t);
HermitianLinearOperator<WilsonCloverFermionR,LatticeFermion> HermOp(Dw); NonHermitianLinearOperator<WilsonCloverFermionR,LatticeFermion> HermOp(Dw);
BiCGSTAB<LatticeFermion> CG(1.0e-8,10000); BiCGSTAB<LatticeFermion> CG(1.0e-8,10000);
CG(HermOp,src,result); CG(HermOp,src,result);

View File

@ -80,16 +80,16 @@ int main (int argc, char ** argv)
result_o_2.Checkerboard() = Odd; result_o_2.Checkerboard() = Odd;
result_o_2 = Zero(); result_o_2 = Zero();
HermitianSchurDiagMooeeOperator<WilsonCloverFermionD, LatticeFermionD> HermOpEO_d(Dw_d); NonHermitianSchurDiagMooeeOperator<WilsonCloverFermionD, LatticeFermionD> NonHermOpEO_d(Dw_d);
HermitianSchurDiagMooeeOperator<WilsonCloverFermionF, LatticeFermionF> HermOpEO_f(Dw_f); NonHermitianSchurDiagMooeeOperator<WilsonCloverFermionF, LatticeFermionF> NonHermOpEO_f(Dw_f);
std::cout << GridLogMessage << "::::::::::::: Starting mixed CG" << std::endl; std::cout << GridLogMessage << "::::::::::::: Starting mixed CG" << std::endl;
MixedPrecisionBiCGSTAB<LatticeFermionD, LatticeFermionF> mCG(1.0e-8, 10000, 50, FrbGrid_f, HermOpEO_f, HermOpEO_d); MixedPrecisionBiCGSTAB<LatticeFermionD, LatticeFermionF> mCG(1.0e-8, 10000, 50, FrbGrid_f, NonHermOpEO_f, NonHermOpEO_d);
mCG(src_o, result_o); mCG(src_o, result_o);
std::cout << GridLogMessage << "::::::::::::: Starting regular CG" << std::endl; std::cout << GridLogMessage << "::::::::::::: Starting regular CG" << std::endl;
BiCGSTAB<LatticeFermionD> CG(1.0e-8, 10000); BiCGSTAB<LatticeFermionD> CG(1.0e-8, 10000);
CG(HermOpEO_d, src_o, result_o_2); CG(NonHermOpEO_d, src_o, result_o_2);
LatticeFermionD diff_o(FrbGrid_d); LatticeFermionD diff_o(FrbGrid_d);
RealD diff = axpy_norm(diff_o, -1.0, result_o, result_o_2); RealD diff = axpy_norm(diff_o, -1.0, result_o, result_o_2);