mirror of
https://github.com/paboyle/Grid.git
synced 2025-07-07 17:07:05 +01:00
Big updates with progress towards wilson matrix
This commit is contained in:
@ -1,157 +1,220 @@
|
||||
#ifnfdef GRID_QCD_WILSON_DOP_H
|
||||
#define GRID_QCD_WILSON_DOP_H
|
||||
|
||||
#include <Grid.h>
|
||||
|
||||
namespace Grid {
|
||||
namespace QCD {
|
||||
|
||||
|
||||
const std::vector<int> WilsonMatrix::directions ({0,1,2,3, 0, 1, 2, 3,0});
|
||||
const std::vector<int> WilsonMatrix::displacements({1,1,1,1,-1,-1,-1,-1,0});
|
||||
|
||||
// Should be in header?
|
||||
static const int WilsonMatrix::Xp = 0;
|
||||
static const int WilsonMatrix::Yp = 1;
|
||||
static const int WilsonMatrix::Zp = 2;
|
||||
static const int WilsonMatrix::Tp = 3;
|
||||
static const int WilsonMatrix::Xm = 4;
|
||||
static const int WilsonMatrix::Ym = 5;
|
||||
static const int WilsonMatrix::Zm = 6;
|
||||
static const int WilsonMatrix::Tm = 7;
|
||||
static const int WilsonMatrix::X0 = 8;
|
||||
static const int WilsonMatrix::npoint=9;
|
||||
const int WilsonMatrix::Xp = 0;
|
||||
const int WilsonMatrix::Yp = 1;
|
||||
const int WilsonMatrix::Zp = 2;
|
||||
const int WilsonMatrix::Tp = 3;
|
||||
const int WilsonMatrix::Xm = 4;
|
||||
const int WilsonMatrix::Ym = 5;
|
||||
const int WilsonMatrix::Zm = 6;
|
||||
const int WilsonMatrix::Tm = 7;
|
||||
//const int WilsonMatrix::X0 = 8;
|
||||
|
||||
class WilsonCompressor {
|
||||
public:
|
||||
int mu;
|
||||
|
||||
void Point(int p) { mu=p;};
|
||||
vHalfSpinColourVector operator () (vSpinColourVector &in)
|
||||
{
|
||||
vHalfSpinColourVector ret;
|
||||
switch(mu) {
|
||||
case WilsonMatrix::Xp:
|
||||
spProjXp(ret,in);
|
||||
break;
|
||||
case WilsonMatrix::Yp:
|
||||
spProjYp(ret,in);
|
||||
break;
|
||||
case WilsonMatrix::Zp:
|
||||
spProjZp(ret,in);
|
||||
break;
|
||||
case WilsonMatrix::Tp:
|
||||
spProjTp(ret,in);
|
||||
break;
|
||||
case WilsonMatrix::Xm:
|
||||
spProjXm(ret,in);
|
||||
break;
|
||||
case WilsonMatrix::Ym:
|
||||
spProjYm(ret,in);
|
||||
break;
|
||||
case WilsonMatrix::Zm:
|
||||
spProjZm(ret,in);
|
||||
break;
|
||||
case WilsonMatrix::Tm:
|
||||
spProjTm(ret,in);
|
||||
break;
|
||||
default:
|
||||
assert(0);
|
||||
break;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
};
|
||||
|
||||
WilsonMatrix::WilsonMatrix(LatticeGaugeField &_Umu,int _mass)
|
||||
: Stencil((&Umu._grid,npoint,0,directions,displacements),
|
||||
WilsonMatrix::WilsonMatrix(LatticeGaugeField &_Umu,double _mass)
|
||||
: Stencil(Umu._grid,npoint,0,directions,displacements),
|
||||
mass(_mass),
|
||||
Umu(_Umu)
|
||||
Umu(_Umu._grid)
|
||||
{
|
||||
// Allocate the required comms buffer
|
||||
grid = _Umu._grid;
|
||||
comm_buf.resize(Stencil._unified_buffer_size);
|
||||
DoubleStore(Umu,_Umu);
|
||||
}
|
||||
|
||||
void WilsonMatrix::DoubleStore(LatticeDoubledGaugeField &Uds,const LatticeGaugeField &Umu)
|
||||
{
|
||||
LatticeColourMatrix U(grid);
|
||||
|
||||
for(int mu=0;mu<Nd;mu++){
|
||||
U = peekIndex<LorentzIndex>(Umu,mu);
|
||||
pokeIndex<LorentzIndex>(Uds,U,mu);
|
||||
U = adj(Cshift(U,mu,-1));
|
||||
pokeIndex<LorentzIndex>(Uds,U,mu+4);
|
||||
}
|
||||
}
|
||||
|
||||
void WilsonMatrix::multiply(const LatticeFermion &in, LatticeFermion &out)
|
||||
{
|
||||
|
||||
Dhop(in,out);
|
||||
return;
|
||||
}
|
||||
|
||||
void WilsonMatrix::Dhop(const LatticeFermion &in, LatticeFermion &out)
|
||||
{
|
||||
Stencil.HaloExchange(in,comm_buf);
|
||||
// Stencil.HaloExchange(in,comm_buf);
|
||||
|
||||
for(int ss=0;ss<_grid->oSites();ss++){
|
||||
for(int ss=0;ss<grid->oSites();ss++){
|
||||
|
||||
int offset,local;
|
||||
|
||||
vSpinColourVector result;
|
||||
vHalfSpinColourVector UChi;
|
||||
|
||||
vHalfSpinColourVector chi;
|
||||
vHalfSpinColourVector Uchi;
|
||||
vHalfSpinColourVector *chi_p;
|
||||
// Xp
|
||||
offset = Stencil._offsets [Xp][ss];
|
||||
local = Stencil._is_local[Xp][ss];
|
||||
if ( local ) {
|
||||
Uchi = U[]*spProjXp(in._odata[offset]);
|
||||
} else {
|
||||
Uchi = U[]*comm_buf._odata[offset]
|
||||
}
|
||||
result = ReconXp(Uchi);
|
||||
|
||||
chi_p = &comm_buf[offset];
|
||||
if ( local ) {
|
||||
spProjXp(chi,in._odata[offset]);
|
||||
chi_p = χ
|
||||
}
|
||||
mult(&(Uchi()),&(Umu._odata[ss](Xp)),&(*chi_p)());
|
||||
spReconXp(result,Uchi);
|
||||
|
||||
#if 0
|
||||
// Yp
|
||||
offset = Stencil._offsets [Yp][ss];
|
||||
local = Stencil._is_local[Yp][ss];
|
||||
chi_p = &comm_buf[offset];
|
||||
if ( local ) {
|
||||
Uchi = U[]*spProjYp(in._odata[offset]);
|
||||
} else {
|
||||
Uchi = U[]*comm_buf._odata[offset]
|
||||
}
|
||||
result+= ReconYp(Uchi);
|
||||
spProjYp(chi,in._odata[offset]);
|
||||
chi_p = χ
|
||||
}
|
||||
mult(&(Uchi()),&(Umu._odata[ss](Yp)),&(*chi_p)());
|
||||
accumReconYp(result,Uchi);
|
||||
|
||||
// Zp
|
||||
offset = Stencil._offsets [Zp][ss];
|
||||
local = Stencil._is_local[Zp][ss];
|
||||
chi_p = &comm_buf[offset];
|
||||
if ( local ) {
|
||||
Uchi = U[]*spProjZp(in._odata[offset]);
|
||||
} else {
|
||||
Uchi = U[]*comm_buf._odata[offset]
|
||||
}
|
||||
result+= ReconZp(Uchi);
|
||||
spProjZp(chi,in._odata[offset]);
|
||||
chi_p = χ
|
||||
}
|
||||
mult(&(Uchi()),&(Umu._odata[ss](Zp)),&(*chi_p)() );
|
||||
accumReconZp(result,Uchi);
|
||||
|
||||
// Tp
|
||||
offset = Stencil._offsets [Tp][ss];
|
||||
local = Stencil._is_local[Tp][ss];
|
||||
chi_p = &comm_buf[offset];
|
||||
if ( local ) {
|
||||
Uchi = U[]*spProjTp(in._odata[offset]);
|
||||
} else {
|
||||
Uchi = U[]*comm_buf._odata[offset]
|
||||
}
|
||||
result+= ReconTp(Uchi);
|
||||
spProjTp(chi,in._odata[offset]);
|
||||
chi_p = χ
|
||||
}
|
||||
mult(&(Uchi()),&(Umu._odata[ss](Tp)),&(*chi_p)());
|
||||
accumReconTp(result,Uchi);
|
||||
|
||||
// Xm
|
||||
offset = Stencil._offsets [Xm][ss];
|
||||
local = Stencil._is_local[Xm][ss];
|
||||
chi_p = &comm_buf[offset];
|
||||
if ( local ) {
|
||||
Uchi = U[]*spProjXm(in._odata[offset]);
|
||||
} else {
|
||||
Uchi = U[]*comm_buf._odata[offset]
|
||||
}
|
||||
result+= ReconXm(Uchi);
|
||||
spProjXm(chi,in._odata[offset]);
|
||||
chi_p = χ
|
||||
}
|
||||
mult(&(Uchi()),&(Umu._odata[ss](Xm)),&(*chi_p)());
|
||||
accumReconXm(result,Uchi);
|
||||
|
||||
// Ym
|
||||
offset = Stencil._offsets [Ym][ss];
|
||||
local = Stencil._is_local[Ym][ss];
|
||||
chi_p = &comm_buf[offset];
|
||||
if ( local ) {
|
||||
Uchi = U[]*spProjYm(in._odata[offset]);
|
||||
} else {
|
||||
Uchi = U[]*comm_buf._odata[offset]
|
||||
}
|
||||
result+= ReconYm(Uchi);
|
||||
spProjYm(chi,in._odata[offset]);
|
||||
chi_p = χ
|
||||
}
|
||||
mult(&(Uchi()),&(Umu._odata[ss](Ym)),&(*chi_p)());
|
||||
accumReconYm(result,Uchi);
|
||||
|
||||
// Zm
|
||||
offset = Stencil._offsets [Zm][ss];
|
||||
local = Stencil._is_local[Zm][ss];
|
||||
chi_p = &comm_buf[offset];
|
||||
if ( local ) {
|
||||
Uchi = U[]*spProjZm(in._odata[offset]);
|
||||
} else {
|
||||
Uchi = U[]*comm_buf._odata[offset]
|
||||
}
|
||||
result+= ReconZm(Uchi);
|
||||
spProjZm(chi,in._odata[offset]);
|
||||
chi_p = χ
|
||||
}
|
||||
mult(&(Uchi()),&(Umu._odata[ss](Zm)),&(*chi_p)());
|
||||
accumReconZm(result,Uchi);
|
||||
|
||||
// Tm
|
||||
offset = Stencil._offsets [Tm][ss];
|
||||
local = Stencil._is_local[Tm][ss];
|
||||
chi_p = &comm_buf[offset];
|
||||
if ( local ) {
|
||||
Uchi = U[]*spProjTm(in._odata[offset]);
|
||||
} else {
|
||||
Uchi = U[]*comm_buf._odata[offset]
|
||||
}
|
||||
result+= ReconTm(Uchi);
|
||||
|
||||
spProjTm(chi,in._odata[offset]);
|
||||
chi_p = χ
|
||||
}
|
||||
mult(&(Uchi()),&(Umu._odata[ss](Tm)),&(*chi_p)());
|
||||
accumReconTm(result,Uchi);
|
||||
#endif
|
||||
out._odata[ss] = result;
|
||||
}
|
||||
|
||||
}
|
||||
void WilsonMatrix::Dw(const LatticeFermion &in, LatticeFermion &out)
|
||||
{
|
||||
|
||||
return;
|
||||
}
|
||||
void WilsonMatrix::MpcDag (const LatticeFermion &in, LatticeFermion &out)
|
||||
{
|
||||
|
||||
return;
|
||||
}
|
||||
void WilsonMatrix::Mpc (const LatticeFermion &in, LatticeFermion &out)
|
||||
{
|
||||
|
||||
return;
|
||||
}
|
||||
void WilsonMatrix::MpcDagMpc(const LatticeFermion &in, LatticeFermion &out)
|
||||
{
|
||||
|
||||
return;
|
||||
}
|
||||
void WilsonMatrix::MDagM (const LatticeFermion &in, LatticeFermion &out)
|
||||
{
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
}}
|
||||
#endif
|
||||
|
||||
|
Reference in New Issue
Block a user