Grid 0.7.0
WilsonFermion.h
Go to the documentation of this file.
1/*************************************************************************************
2
3Grid physics library, www.github.com/paboyle/Grid
4
5Source file: ./lib/qcd/action/fermion/WilsonFermion.h
6
7Copyright (C) 2015
8
9Author: Peter Boyle <pabobyle@ph.ed.ac.uk>
10Author: Peter Boyle <paboyle@ph.ed.ac.uk>
11Author: paboyle <paboyle@ph.ed.ac.uk>
12
13This program is free software; you can redistribute it and/or modify
14it under the terms of the GNU General Public License as published by
15the Free Software Foundation; either version 2 of the License, or
16(at your option) any later version.
17
18This program is distributed in the hope that it will be useful,
19but WITHOUT ANY WARRANTY; without even the implied warranty of
20MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21GNU General Public License for more details.
22
23You should have received a copy of the GNU General Public License along
24with this program; if not, write to the Free Software Foundation, Inc.,
2551 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
26
27See the full license in the file "LICENSE" in the top level distribution
28directory
29*************************************************************************************/
30 /* END LEGAL */
31#pragma once
32
34
36public:
37 static int HandOptDslash; // these are a temporary hack
38 static int MortonOrder;
39 static const std::vector<int> directions;
40 static const std::vector<int> displacements;
41 static const int npoint = 8;
42};
43
44 struct WilsonAnisotropyCoefficients: Serializable
45 {
47 bool, isAnisotropic,
48 int, t_direction,
49 double, xi_0,
50 double, nu);
51
53 isAnisotropic(false),
54 t_direction(Nd-1),
55 xi_0(1.0),
56 nu(1.0){}
57};
58
59template <class Impl>
61{
62public:
65
67 // Implement the abstract base
69 GridBase *GaugeGrid(void) { return _grid; }
71 GridBase *FermionGrid(void) { return _grid; }
73
74 FermionField _tmp;
75 FermionField &tmp(void) { return _tmp; }
76
78 // override multiply; cut number routines if pass dagger argument
79 // and also make interface more uniformly consistent
81 virtual void M(const FermionField &in, FermionField &out);
82 virtual void Mdag(const FermionField &in, FermionField &out);
83
85 // half checkerboard operations
86 // could remain virtual so we can derive Clover from Wilson base
88 void Meooe(const FermionField &in, FermionField &out);
89 void MeooeDag(const FermionField &in, FermionField &out);
90
91 // allow override for twisted mass and clover
92 virtual void Mooee(const FermionField &in, FermionField &out);
93 virtual void MooeeDag(const FermionField &in, FermionField &out);
94 virtual void MooeeInv(const FermionField &in, FermionField &out);
95 virtual void MooeeInvDag(const FermionField &in, FermionField &out);
96
97 virtual void MomentumSpacePropagator(FermionField &out,const FermionField &in,RealD _mass,std::vector<double> twist) ;
98
100 // Derivative interface
102 // Interface calls an internal routine
103 void DhopDeriv(GaugeField &mat,const FermionField &U,const FermionField &V,int dag);
104 void DhopDerivOE(GaugeField &mat,const FermionField &U,const FermionField &V,int dag);
105 void DhopDerivEO(GaugeField &mat,const FermionField &U,const FermionField &V,int dag);
106
108 // non-hermitian hopping term; half cb or both
110 void Dhop(const FermionField &in, FermionField &out, int dag);
111 void DhopOE(const FermionField &in, FermionField &out, int dag);
112 void DhopEO(const FermionField &in, FermionField &out, int dag);
113
115 // Multigrid assistance; force term uses too
117 void Mdir(const FermionField &in, FermionField &out, int dir, int disp);
118 void MdirAll(const FermionField &in, std::vector<FermionField> &out);
119 void DhopDir(const FermionField &in, FermionField &out, int dir, int disp);
120 void DhopDirAll(const FermionField &in, std::vector<FermionField> &out);
121 void DhopDirCalc(const FermionField &in, FermionField &out, int dirdisp,int gamma, int dag);
122
124 // Extra methods added by derived
126 void DerivInternal(StencilImpl &st, DoubledGaugeField &U, GaugeField &mat,
127 const FermionField &A, const FermionField &B, int dag);
128
129 void DhopInternal(StencilImpl &st,
130 DoubledGaugeField &U,
131 const FermionField &in, FermionField &out, int dag);
132
133 void DhopInternalSerial(StencilImpl &st,
134 DoubledGaugeField &U,
135 const FermionField &in, FermionField &out, int dag);
136
137 void DhopInternalOverlappedComms(StencilImpl &st,
138 DoubledGaugeField &U,
139 const FermionField &in, FermionField &out, int dag);
140
141 // Constructor
142 WilsonFermion(GaugeField &_Umu, GridCartesian &Fgrid,
143 GridRedBlackCartesian &Hgrid, RealD _mass,
144 const ImplParams &p = ImplParams(),
146
147 // DoubleStore impl dependent
148 void ImportGauge(const GaugeField &_Umu);
149
151 // Data members require to support the functionality
153
154 // protected:
155public:
156 virtual RealD Mass(void) { return mass; }
157 virtual int isTrivialEE(void) { return 1; };
160
163
164 // Defines the stencils for even and odd
165 StencilImpl Stencil;
166 StencilImpl StencilEven;
167 StencilImpl StencilOdd;
168 void SloppyComms(int sloppy)
169 {
170 Stencil.SetSloppyComms(sloppy);
171 StencilEven.SetSloppyComms(sloppy);
172 StencilOdd.SetSloppyComms(sloppy);
173 }
174
175 // Copy of the gauge field , with even and odd subsets
176 DoubledGaugeField Umu;
177 DoubledGaugeField UmuEven;
178 DoubledGaugeField UmuOdd;
179
181
183 // Conserved current utilities
185 void ContractConservedCurrent(PropagatorField &q_in_1,
186 PropagatorField &q_in_2,
187 PropagatorField &q_out,
188 PropagatorField &phys_src,
189 Current curr_type,
190 unsigned int mu);
191 void SeqConservedCurrent(PropagatorField &q_in,
192 PropagatorField &q_out,
193 PropagatorField &phys_src,
194 Current curr_type,
195 unsigned int mu,
196 unsigned int tmin,
197 unsigned int tmax,
198 ComplexField &lattice_cmplx);
199};
200
203
WilsonFermion< WilsonImplF > WilsonFermionF
Definition Fermion.h:158
WilsonFermion< WilsonImplD > WilsonFermionD
Definition Fermion.h:160
B
#define NAMESPACE_BEGIN(A)
Definition Namespace.h:35
#define NAMESPACE_END(A)
Definition Namespace.h:36
static constexpr int Nd
Definition QCD.h:52
double RealD
Definition Simd.h:61
static INTERNAL_PRECISION U
Definition Zolotarev.cc:230
static const std::vector< int > displacements
static const int npoint
static const std::vector< int > directions
static int HandOptDslash
void DhopInternalSerial(StencilImpl &st, DoubledGaugeField &U, const FermionField &in, FermionField &out, int dag)
INHERIT_IMPL_TYPES(Impl)
void SloppyComms(int sloppy)
void DhopDirCalc(const FermionField &in, FermionField &out, int dirdisp, int gamma, int dag)
void MeooeDag(const FermionField &in, FermionField &out)
void DhopOE(const FermionField &in, FermionField &out, int dag)
GridBase * GaugeRedBlackGrid(void)
void Meooe(const FermionField &in, FermionField &out)
void DhopInternal(StencilImpl &st, DoubledGaugeField &U, const FermionField &in, FermionField &out, int dag)
virtual void Mooee(const FermionField &in, FermionField &out)
void DhopDerivOE(GaugeField &mat, const FermionField &U, const FermionField &V, int dag)
WilsonFermion(GaugeField &_Umu, GridCartesian &Fgrid, GridRedBlackCartesian &Hgrid, RealD _mass, const ImplParams &p=ImplParams(), const WilsonAnisotropyCoefficients &anis=WilsonAnisotropyCoefficients())
virtual RealD Mass(void)
virtual int isTrivialEE(void)
void Dhop(const FermionField &in, FermionField &out, int dag)
WilsonKernels< WilsonImplD2 > Kernels
void SeqConservedCurrent(PropagatorField &q_in, PropagatorField &q_out, PropagatorField &phys_src, Current curr_type, unsigned int mu, unsigned int tmin, unsigned int tmax, ComplexField &lattice_cmplx)
void DhopDerivEO(GaugeField &mat, const FermionField &U, const FermionField &V, int dag)
virtual void MomentumSpacePropagator(FermionField &out, const FermionField &in, RealD _mass, std::vector< double > twist)
void ImportGauge(const GaugeField &_Umu)
GridBase * FermionGrid(void)
void DerivInternal(StencilImpl &st, DoubledGaugeField &U, GaugeField &mat, const FermionField &A, const FermionField &B, int dag)
void DhopDir(const FermionField &in, FermionField &out, int dir, int disp)
WilsonAnisotropyCoefficients anisotropyCoeff
void DhopDeriv(GaugeField &mat, const FermionField &U, const FermionField &V, int dag)
void Mdir(const FermionField &in, FermionField &out, int dir, int disp)
virtual void MooeeDag(const FermionField &in, FermionField &out)
virtual void MooeeInv(const FermionField &in, FermionField &out)
void MdirAll(const FermionField &in, std::vector< FermionField > &out)
void ContractConservedCurrent(PropagatorField &q_in_1, PropagatorField &q_in_2, PropagatorField &q_out, PropagatorField &phys_src, Current curr_type, unsigned int mu)
GridBase * GaugeGrid(void)
void DhopDirAll(const FermionField &in, std::vector< FermionField > &out)
void DhopEO(const FermionField &in, FermionField &out, int dag)
void DhopInternalOverlappedComms(StencilImpl &st, DoubledGaugeField &U, const FermionField &in, FermionField &out, int dag)
virtual void M(const FermionField &in, FermionField &out)
virtual void Mdag(const FermionField &in, FermionField &out)
GridBase * FermionRedBlackGrid(void)
FermionField & tmp(void)
virtual void MooeeInvDag(const FermionField &in, FermionField &out)
WilsonKernels(const ImplParams &p=ImplParams())
GRID_SERIALIZABLE_CLASS_MEMBERS(WilsonAnisotropyCoefficients, bool, isAnisotropic, int, t_direction, double, xi_0, double, nu)