Grid 0.7.0
GaugeImplementations.h
Go to the documentation of this file.
1/*************************************************************************************
2
3Grid physics library, www.github.com/paboyle/Grid
4
5Source file: ./lib/qcd/action/gauge/GaugeImplementations.h
6
7Copyright (C) 2015
8
9Author: paboyle <paboyle@ph.ed.ac.uk>
10
11This program is free software; you can redistribute it and/or modify
12it under the terms of the GNU General Public License as published by
13the Free Software Foundation; either version 2 of the License, or
14(at your option) any later version.
15
16This program is distributed in the hope that it will be useful,
17but WITHOUT ANY WARRANTY; without even the implied warranty of
18MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19GNU General Public License for more details.
20
21You should have received a copy of the GNU General Public License along
22with this program; if not, write to the Free Software Foundation, Inc.,
2351 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
24
25See the full license in the file "LICENSE" in the top level distribution
26directory
27*************************************************************************************/
28 /* END LEGAL */
29#ifndef GRID_QCD_GAUGE_IMPLEMENTATIONS_H
30#define GRID_QCD_GAUGE_IMPLEMENTATIONS_H
31
32#include "GaugeImplTypes.h"
33
35
36// Composition with smeared link, bc's etc.. probably need multiple inheritance
37// Variable precision "S" and variable Nc
38template <class GimplTypes> class PeriodicGaugeImpl : public GimplTypes {
39public:
41
43 // Support needed for the assembly of loops including all boundary condition
44 // effects such as Conjugate bcs
46
47 template <class covariant>
48 static inline Lattice<covariant>
49 CovShiftForward(const GaugeLinkField &Link, int mu,
50 const Lattice<covariant> &field) {
51 return PeriodicBC::CovShiftForward(Link, mu, field);
52 }
53
54 template <class covariant>
55 static inline Lattice<covariant>
56 CovShiftBackward(const GaugeLinkField &Link, int mu,
57 const Lattice<covariant> &field) {
58 return PeriodicBC::CovShiftBackward(Link, mu, field);
59 }
60 static inline GaugeLinkField
61 CovShiftIdentityBackward(const GaugeLinkField &Link, int mu) {
63 }
64 static inline GaugeLinkField
65 CovShiftIdentityForward(const GaugeLinkField &Link, int mu) {
67 }
68 static inline GaugeLinkField ShiftStaple(const GaugeLinkField &Link, int mu) {
69 return PeriodicBC::ShiftStaple(Link,mu);
70 }
71
72 //Same as Cshift for periodic BCs
73 static inline GaugeLinkField CshiftLink(const GaugeLinkField &Link, int mu, int shift){
74 return PeriodicBC::CshiftLink(Link,mu,shift);
75 }
76
77 static inline bool isPeriodicGaugeField(void) { return true; }
78};
79
80// Composition with smeared link, bc's etc.. probably need multiple inheritance
81// Variable precision "S" and variable Nc
83protected:
84 static std::vector<int> _conjDirs;
85};
86
87 template <class GimplTypes> class ConjugateGaugeImpl : public GimplTypes, ConjugateGaugeImplBase {
88private:
89public:
91
93 // Support needed for the assembly of loops including all boundary condition
94 // effects such as Gparity.
96 template <class covariant>
97 static Lattice<covariant> CovShiftForward(const GaugeLinkField &Link, int mu,
98 const Lattice<covariant> &field)
99 {
100 assert(_conjDirs.size() == Nd);
101 if(_conjDirs[mu])
102 return ConjugateBC::CovShiftForward(Link, mu, field);
103 else
104 return PeriodicBC::CovShiftForward(Link, mu, field);
105 }
106
107 template <class covariant>
108 static Lattice<covariant> CovShiftBackward(const GaugeLinkField &Link, int mu,
109 const Lattice<covariant> &field)
110 {
111 assert(_conjDirs.size() == Nd);
112 if(_conjDirs[mu])
113 return ConjugateBC::CovShiftBackward(Link, mu, field);
114 else
115 return PeriodicBC::CovShiftBackward(Link, mu, field);
116 }
117
118 //If mu is a conjugate BC direction
119 //Out(x) = U^dag_\mu(x-mu) | x_\mu != 0
120 // = U^T_\mu(L-1) | x_\mu == 0
121 //else
122 //Out(x) = U^dag_\mu(x-mu mod L)
123 static inline GaugeLinkField
124 CovShiftIdentityBackward(const GaugeLinkField &Link, int mu)
125 {
126 assert(_conjDirs.size() == Nd);
127 if(_conjDirs[mu])
129 else
131 }
132 static inline GaugeLinkField
133 CovShiftIdentityForward(const GaugeLinkField &Link, int mu)
134 {
135 assert(_conjDirs.size() == Nd);
136 if(_conjDirs[mu])
138 else
140 }
141
142
143 //If mu is a conjugate BC direction
144 //Out(x) = S_\mu(x+mu) | x_\mu != L-1
145 // = S*_\mu(x+mu) | x_\mu == L-1
146 //else
147 //Out(x) = S_\mu(x+mu mod L)
148 //Note: While this is used for Staples it is also applicable for shifting gauge links or gauge transformation matrices
149 static inline GaugeLinkField ShiftStaple(const GaugeLinkField &Link, int mu)
150 {
151 assert(_conjDirs.size() == Nd);
152 if(_conjDirs[mu])
153 return ConjugateBC::ShiftStaple(Link,mu);
154 else
155 return PeriodicBC::ShiftStaple(Link,mu);
156 }
157
158 //Boundary-aware C-shift of gauge links / gauge transformation matrices
159 //For conjugate BC direction
160 //shift = 1
161 //Out(x) = U_\mu(x+\hat\mu) | x_\mu != L-1
162 // = U*_\mu(0) | x_\mu == L-1
163 //shift = -1
164 //Out(x) = U_\mu(x-mu) | x_\mu != 0
165 // = U*_\mu(L-1) | x_\mu == 0
166 //else
167 //shift = 1
168 //Out(x) = U_\mu(x+\hat\mu mod L)
169 //shift = -1
170 //Out(x) = U_\mu(x-\hat\mu mod L)
171 static inline GaugeLinkField CshiftLink(const GaugeLinkField &Link, int mu, int shift){
172 assert(_conjDirs.size() == Nd);
173 if(_conjDirs[mu])
174 return ConjugateBC::CshiftLink(Link,mu,shift);
175 else
176 return PeriodicBC::CshiftLink(Link,mu,shift);
177 }
178
179 static inline void setDirections(const std::vector<int> &conjDirs) { _conjDirs=conjDirs; }
180 static inline std::vector<int> getDirections(void) { return _conjDirs; }
181 static inline bool isPeriodicGaugeField(void) { return false; }
182};
183
184typedef PeriodicGaugeImpl<GimplTypesR> PeriodicGimplR; // Real.. whichever prec
187
191
192typedef ConjugateGaugeImpl<GimplTypesR> ConjugateGimplR; // Real.. whichever prec
195
196typedef PeriodicGaugeImpl<SpGimplTypesR> SpPeriodicGimplR; // Real.. whichever prec
199
200
202
203#endif
PeriodicGaugeImpl< GimplTypesF > PeriodicGimplF
PeriodicGaugeImpl< SpGimplTypesF > SpPeriodicGimplF
PeriodicGaugeImpl< GimplAdjointTypesR > PeriodicGimplAdjR
ConjugateGaugeImpl< GimplTypesF > ConjugateGimplF
ConjugateGaugeImpl< GimplTypesD > ConjugateGimplD
PeriodicGaugeImpl< GimplAdjointTypesF > PeriodicGimplAdjF
PeriodicGaugeImpl< SpGimplTypesR > SpPeriodicGimplR
PeriodicGaugeImpl< SpGimplTypesD > SpPeriodicGimplD
PeriodicGaugeImpl< GimplTypesR > PeriodicGimplR
PeriodicGaugeImpl< GimplAdjointTypesD > PeriodicGimplAdjD
ConjugateGaugeImpl< GimplTypesR > ConjugateGimplR
PeriodicGaugeImpl< GimplTypesD > PeriodicGimplD
#define NAMESPACE_BEGIN(A)
Definition Namespace.h:35
#define NAMESPACE_END(A)
Definition Namespace.h:36
static constexpr int Nd
Definition QCD.h:52
static std::vector< int > _conjDirs
static std::vector< int > getDirections(void)
static void setDirections(const std::vector< int > &conjDirs)
static bool isPeriodicGaugeField(void)
static GaugeLinkField CshiftLink(const GaugeLinkField &Link, int mu, int shift)
INHERIT_GIMPL_TYPES(GimplTypes)
static Lattice< covariant > CovShiftBackward(const GaugeLinkField &Link, int mu, const Lattice< covariant > &field)
static Lattice< covariant > CovShiftForward(const GaugeLinkField &Link, int mu, const Lattice< covariant > &field)
static GaugeLinkField ShiftStaple(const GaugeLinkField &Link, int mu)
static GaugeLinkField CovShiftIdentityForward(const GaugeLinkField &Link, int mu)
static GaugeLinkField CovShiftIdentityBackward(const GaugeLinkField &Link, int mu)
static GaugeLinkField CshiftLink(const GaugeLinkField &Link, int mu, int shift)
static GaugeLinkField ShiftStaple(const GaugeLinkField &Link, int mu)
static bool isPeriodicGaugeField(void)
INHERIT_GIMPL_TYPES(GimplTypes)
static Lattice< covariant > CovShiftForward(const GaugeLinkField &Link, int mu, const Lattice< covariant > &field)
static GaugeLinkField CovShiftIdentityBackward(const GaugeLinkField &Link, int mu)
static GaugeLinkField CovShiftIdentityForward(const GaugeLinkField &Link, int mu)
static Lattice< covariant > CovShiftBackward(const GaugeLinkField &Link, int mu, const Lattice< covariant > &field)
Lattice< gauge > CovShiftIdentityBackward(const Lattice< gauge > &Link, int mu)
Lattice< gauge > CshiftLink(const Lattice< gauge > &Link, int mu, int shift)
Lattice< covariant > CovShiftForward(const Lattice< gauge > &Link, int mu, const Lattice< covariant > &field)
Lattice< gauge > ShiftStaple(const Lattice< gauge > &Link, int mu)
Lattice< covariant > CovShiftBackward(const Lattice< gauge > &Link, int mu, const Lattice< covariant > &field)
Lattice< gauge > CovShiftIdentityForward(const Lattice< gauge > &Link, int mu)
Lattice< gauge > CovShiftIdentityForward(const Lattice< gauge > &Link, int mu)
Lattice< covariant > CovShiftForward(const Lattice< gauge > &Link, int mu, const Lattice< covariant > &field)
Lattice< gauge > ShiftStaple(const Lattice< gauge > &Link, int mu)
Lattice< gauge > CovShiftIdentityBackward(const Lattice< gauge > &Link, int mu)
Lattice< covariant > CovShiftBackward(const Lattice< gauge > &Link, int mu, const Lattice< covariant > &field)
Lattice< gauge > CshiftLink(const Lattice< gauge > &Link, int mu, int shift)