1
0
mirror of https://github.com/paboyle/Grid.git synced 2025-04-27 22:25:56 +01:00

Namespace, clean up

This commit is contained in:
paboyle 2018-01-14 23:26:41 +00:00
parent 901e359d28
commit 70c5b781e5

View File

@ -28,17 +28,16 @@ with this program; if not, write to the Free Software Foundation, Inc.,
See the full license in the file "LICENSE" in the top level distribution directory See the full license in the file "LICENSE" in the top level distribution directory
*************************************************************************************/ *************************************************************************************/
/* END LEGAL */ /* END LEGAL */
#include <Grid/Grid_Eigen_Dense.h> #include <Grid/Grid_Eigen_Dense.h>
#include <Grid/qcd/action/fermion/FermionCore.h> #include <Grid/qcd/action/fermion/FermionCore.h>
#include <Grid/qcd/action/fermion/MobiusEOFAFermion.h> #include <Grid/qcd/action/fermion/MobiusEOFAFermion.h>
namespace Grid { NAMESPACE_BEGIN(Grid);
namespace QCD {
template<class Impl> template<class Impl>
MobiusEOFAFermion<Impl>::MobiusEOFAFermion( MobiusEOFAFermion<Impl>::MobiusEOFAFermion(
GaugeField &_Umu, GaugeField &_Umu,
GridCartesian &FiveDimGrid, GridCartesian &FiveDimGrid,
GridRedBlackCartesian &FiveDimRedBlackGrid, GridRedBlackCartesian &FiveDimRedBlackGrid,
@ -50,7 +49,7 @@ namespace QCD {
AbstractEOFAFermion<Impl>(_Umu, FiveDimGrid, FiveDimRedBlackGrid, AbstractEOFAFermion<Impl>(_Umu, FiveDimGrid, FiveDimRedBlackGrid,
FourDimGrid, FourDimRedBlackGrid, _mq1, _mq2, _mq3, FourDimGrid, FourDimRedBlackGrid, _mq1, _mq2, _mq3,
_shift, _pm, _M5, _b, _c, p) _shift, _pm, _M5, _b, _c, p)
{ {
int Ls = this->Ls; int Ls = this->Ls;
RealD eps = 1.0; RealD eps = 1.0;
@ -75,16 +74,16 @@ namespace QCD {
MooeeInvDag_shift_lc.resize(Ls, 0.0); MooeeInvDag_shift_lc.resize(Ls, 0.0);
MooeeInvDag_shift_norm.resize(Ls, 0.0); MooeeInvDag_shift_norm.resize(Ls, 0.0);
} }
} }
/**************************************************************** /****************************************************************
* Additional EOFA operators only called outside the inverter. * Additional EOFA operators only called outside the inverter.
* Since speed is not essential, simple axpby-style * Since speed is not essential, simple axpby-style
* implementations should be fine. * implementations should be fine.
***************************************************************/ ***************************************************************/
template<class Impl> template<class Impl>
void MobiusEOFAFermion<Impl>::Omega(const FermionField& psi, FermionField& Din, int sign, int dag) void MobiusEOFAFermion<Impl>::Omega(const FermionField& psi, FermionField& Din, int sign, int dag)
{ {
int Ls = this->Ls; int Ls = this->Ls;
RealD alpha = this->alpha; RealD alpha = this->alpha;
@ -106,13 +105,13 @@ namespace QCD {
axpby_ssp(Din, 1.0, Din, 2.0*std::pow(1.0-alpha,sp)/std::pow(1.0+alpha,sp+1), psi, 0, sp); axpby_ssp(Din, 1.0, Din, 2.0*std::pow(1.0-alpha,sp)/std::pow(1.0+alpha,sp+1), psi, 0, sp);
} }
} }
} }
// This is the operator relating the usual Ddwf to TWQCD's EOFA Dirac operator (arXiv:1706.05843, Eqn. 6). // This is the operator relating the usual Ddwf to TWQCD's EOFA Dirac operator (arXiv:1706.05843, Eqn. 6).
// It also relates the preconditioned and unpreconditioned systems described in Appendix B.2. // It also relates the preconditioned and unpreconditioned systems described in Appendix B.2.
template<class Impl> template<class Impl>
void MobiusEOFAFermion<Impl>::Dtilde(const FermionField& psi, FermionField& chi) void MobiusEOFAFermion<Impl>::Dtilde(const FermionField& psi, FermionField& chi)
{ {
int Ls = this->Ls; int Ls = this->Ls;
RealD b = 0.5 * ( 1.0 + this->alpha ); RealD b = 0.5 * ( 1.0 + this->alpha );
RealD c = 0.5 * ( 1.0 - this->alpha ); RealD c = 0.5 * ( 1.0 - this->alpha );
@ -130,11 +129,11 @@ namespace QCD {
axpby_ssp_pplus (chi, 1.0, chi, -c, psi, s, s-1); axpby_ssp_pplus (chi, 1.0, chi, -c, psi, s, s-1);
} }
} }
} }
template<class Impl> template<class Impl>
void MobiusEOFAFermion<Impl>::DtildeInv(const FermionField& psi, FermionField& chi) void MobiusEOFAFermion<Impl>::DtildeInv(const FermionField& psi, FermionField& chi)
{ {
int Ls = this->Ls; int Ls = this->Ls;
RealD m = this->mq1; RealD m = this->mq1;
RealD c = 0.5 * this->alpha; RealD c = 0.5 * this->alpha;
@ -161,13 +160,13 @@ namespace QCD {
} }
}} }}
} }
/*****************************************************************************************************/ /*****************************************************************************************************/
template<class Impl> template<class Impl>
RealD MobiusEOFAFermion<Impl>::M(const FermionField& psi, FermionField& chi) RealD MobiusEOFAFermion<Impl>::M(const FermionField& psi, FermionField& chi)
{ {
int Ls = this->Ls; int Ls = this->Ls;
FermionField Din(psi._grid); FermionField Din(psi._grid);
@ -177,11 +176,11 @@ namespace QCD {
axpby(chi, 1.0, 1.0, chi, psi); axpby(chi, 1.0, 1.0, chi, psi);
this->M5D(psi, chi); this->M5D(psi, chi);
return(norm2(chi)); return(norm2(chi));
} }
template<class Impl> template<class Impl>
RealD MobiusEOFAFermion<Impl>::Mdag(const FermionField& psi, FermionField& chi) RealD MobiusEOFAFermion<Impl>::Mdag(const FermionField& psi, FermionField& chi)
{ {
int Ls = this->Ls; int Ls = this->Ls;
FermionField Din(psi._grid); FermionField Din(psi._grid);
@ -191,15 +190,15 @@ namespace QCD {
this->M5Ddag(psi, chi); this->M5Ddag(psi, chi);
axpby(chi, 1.0, 1.0, chi, psi); axpby(chi, 1.0, 1.0, chi, psi);
return(norm2(chi)); return(norm2(chi));
} }
/******************************************************************** /********************************************************************
* Performance critical fermion operators called inside the inverter * Performance critical fermion operators called inside the inverter
********************************************************************/ ********************************************************************/
template<class Impl> template<class Impl>
void MobiusEOFAFermion<Impl>::M5D(const FermionField& psi, FermionField& chi) void MobiusEOFAFermion<Impl>::M5D(const FermionField& psi, FermionField& chi)
{ {
int Ls = this->Ls; int Ls = this->Ls;
std::vector<Coeff_t> diag(Ls,1.0); std::vector<Coeff_t> diag(Ls,1.0);
@ -211,11 +210,11 @@ namespace QCD {
// fused M + shift operation // fused M + shift operation
else{ this->M5D_shift(psi, chi, chi, lower, diag, upper, Mooee_shift); } else{ this->M5D_shift(psi, chi, chi, lower, diag, upper, Mooee_shift); }
} }
template<class Impl> template<class Impl>
void MobiusEOFAFermion<Impl>::M5Ddag(const FermionField& psi, FermionField& chi) void MobiusEOFAFermion<Impl>::M5Ddag(const FermionField& psi, FermionField& chi)
{ {
int Ls = this->Ls; int Ls = this->Ls;
std::vector<Coeff_t> diag(Ls,1.0); std::vector<Coeff_t> diag(Ls,1.0);
@ -227,12 +226,12 @@ namespace QCD {
// fused M + shift operation // fused M + shift operation
else{ this->M5Ddag_shift(psi, chi, chi, lower, diag, upper, Mooee_shift); } else{ this->M5Ddag_shift(psi, chi, chi, lower, diag, upper, Mooee_shift); }
} }
// half checkerboard operations // half checkerboard operations
template<class Impl> template<class Impl>
void MobiusEOFAFermion<Impl>::Mooee(const FermionField& psi, FermionField& chi) void MobiusEOFAFermion<Impl>::Mooee(const FermionField& psi, FermionField& chi)
{ {
int Ls = this->Ls; int Ls = this->Ls;
// coefficients of Mooee // coefficients of Mooee
@ -251,11 +250,11 @@ namespace QCD {
// fused M + shift operation // fused M + shift operation
else { this->M5D_shift(psi, psi, chi, lower, diag, upper, Mooee_shift); } else { this->M5D_shift(psi, psi, chi, lower, diag, upper, Mooee_shift); }
} }
template<class Impl> template<class Impl>
void MobiusEOFAFermion<Impl>::MooeeDag(const FermionField& psi, FermionField& chi) void MobiusEOFAFermion<Impl>::MooeeDag(const FermionField& psi, FermionField& chi)
{ {
int Ls = this->Ls; int Ls = this->Ls;
// coefficients of MooeeDag // coefficients of MooeeDag
@ -280,20 +279,20 @@ namespace QCD {
// fused M + shift operation // fused M + shift operation
else{ this->M5Ddag_shift(psi, psi, chi, lower, diag, upper, Mooee_shift); } else{ this->M5Ddag_shift(psi, psi, chi, lower, diag, upper, Mooee_shift); }
} }
/****************************************************************************************/ /****************************************************************************************/
// Computes coefficients for applying Cayley preconditioned shift operators // Computes coefficients for applying Cayley preconditioned shift operators
// (Mooee + \Delta) --> Mooee_shift // (Mooee + \Delta) --> Mooee_shift
// (Mooee + \Delta)^{-1} --> MooeeInv_shift_lc, MooeeInv_shift_norm // (Mooee + \Delta)^{-1} --> MooeeInv_shift_lc, MooeeInv_shift_norm
// (Mooee + \Delta)^{-dag} --> MooeeInvDag_shift_lc, MooeeInvDag_shift_norm // (Mooee + \Delta)^{-dag} --> MooeeInvDag_shift_lc, MooeeInvDag_shift_norm
// For the latter two cases, the operation takes the form // For the latter two cases, the operation takes the form
// [ (Mooee + \Delta)^{-1} \psi ]_{i} = Mooee_{ij} \psi_{j} + // [ (Mooee + \Delta)^{-1} \psi ]_{i} = Mooee_{ij} \psi_{j} +
// ( MooeeInv_shift_norm )_{i} ( \sum_{j} [ MooeeInv_shift_lc ]_{j} P_{pm} \psi_{j} ) // ( MooeeInv_shift_norm )_{i} ( \sum_{j} [ MooeeInv_shift_lc ]_{j} P_{pm} \psi_{j} )
template<class Impl> template<class Impl>
void MobiusEOFAFermion<Impl>::SetCoefficientsPrecondShiftOps() void MobiusEOFAFermion<Impl>::SetCoefficientsPrecondShiftOps()
{ {
int Ls = this->Ls; int Ls = this->Ls;
int pm = this->pm; int pm = this->pm;
RealD alpha = this->alpha; RealD alpha = this->alpha;
@ -388,12 +387,12 @@ namespace QCD {
( std::pow(this->bee[s],Ls) + mq1*std::pow(this->cee[s],Ls) ) / N; } ( std::pow(this->bee[s],Ls) + mq1*std::pow(this->cee[s],Ls) ) / N; }
} }
} }
} }
// Recompute coefficients for a different value of shift constant // Recompute coefficients for a different value of shift constant
template<class Impl> template<class Impl>
void MobiusEOFAFermion<Impl>::RefreshShiftCoefficients(RealD new_shift) void MobiusEOFAFermion<Impl>::RefreshShiftCoefficients(RealD new_shift)
{ {
this->shift = new_shift; this->shift = new_shift;
if(new_shift != 0.0){ if(new_shift != 0.0){
SetCoefficientsPrecondShiftOps(); SetCoefficientsPrecondShiftOps();
@ -405,12 +404,12 @@ namespace QCD {
MooeeInvDag_shift_lc.resize(Ls,0.0); MooeeInvDag_shift_lc.resize(Ls,0.0);
MooeeInvDag_shift_norm.resize(Ls,0.0); MooeeInvDag_shift_norm.resize(Ls,0.0);
} }
} }
template<class Impl> template<class Impl>
void MobiusEOFAFermion<Impl>::MooeeInternalCompute(int dag, int inv, void MobiusEOFAFermion<Impl>::MooeeInternalCompute(int dag, int inv,
Vector<iSinglet<Simd> >& Matp, Vector<iSinglet<Simd> >& Matm) Vector<iSinglet<Simd> >& Matp, Vector<iSinglet<Simd> >& Matm)
{ {
int Ls = this->Ls; int Ls = this->Ls;
GridBase* grid = this->FermionRedBlackGrid(); GridBase* grid = this->FermionRedBlackGrid();
@ -494,9 +493,9 @@ namespace QCD {
Matp[LLs*s2+s1] = Vp; Matp[LLs*s2+s1] = Vp;
Matm[LLs*s2+s1] = Vm; Matm[LLs*s2+s1] = Vm;
}} }}
} }
FermOpTemplateInstantiate(MobiusEOFAFermion); FermOpTemplateInstantiate(MobiusEOFAFermion);
GparityFermOpTemplateInstantiate(MobiusEOFAFermion); GparityFermOpTemplateInstantiate(MobiusEOFAFermion);
}} NAMESPACE_END(Grid);