Grid 0.7.0
FermionOperatorImpl.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/FermionOperatorImpl.h
6
7Copyright (C) 2015
8
9Author: Peter Boyle <pabobyle@ph.ed.ac.uk>
10Author: Peter Boyle <paboyle@ph.ed.ac.uk>
11Author: Peter Boyle <peterboyle@Peters-MacBook-Pro-2.local>
12Author: paboyle <paboyle@ph.ed.ac.uk>
13
14This program is free software; you can redistribute it and/or modify
15it under the terms of the GNU General Public License as published by
16the Free Software Foundation; either version 2 of the License, or
17(at your option) any later version.
18
19This program is distributed in the hope that it will be useful,
20but WITHOUT ANY WARRANTY; without even the implied warranty of
21MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22GNU General Public License for more details.
23
24You should have received a copy of the GNU General Public License along
25with this program; if not, write to the Free Software Foundation, Inc.,
2651 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
27
28See the full license in the file "LICENSE" in the top level distribution
29directory
30*************************************************************************************/
31 /* END LEGAL */
32
33#pragma once
34
36
38// Template parameter class constructs to package
39// externally control Fermion implementations
40// in orthogonal directions
41//
42// Ultimately need Impl to always define types where XXX is opaque
43//
44// typedef typename XXX Simd;
45// typedef typename XXX GaugeLinkField;
46// typedef typename XXX GaugeField;
47// typedef typename XXX GaugeActField;
48// typedef typename XXX FermionField;
49// typedef typename XXX PropagatorField;
50// typedef typename XXX DoubledGaugeField;
51// typedef typename XXX SiteSpinor;
52// typedef typename XXX SitePropagator;
53// typedef typename XXX SiteHalfSpinor;
54// typedef typename XXX Compressor;
55//
56// and Methods:
57// void ImportGauge(GridBase *GaugeGrid,DoubledGaugeField &Uds,const GaugeField &Umu)
58// void DoubleStore(GridBase *GaugeGrid,DoubledGaugeField &Uds,const GaugeField &Umu)
59// void multLink(SiteHalfSpinor &phi,const SiteDoubledGaugeField &U,const SiteHalfSpinor &chi,int mu,StencilEntry *SE,StencilImpl::View_type &St)
60// void InsertForce4D(GaugeField &mat,const FermionField &Btilde,const FermionField &A,int mu)
61// void InsertForce5D(GaugeField &mat,const FermionField &Btilde,const FermionField &A,int mu)
62//
63//
64// To acquire the typedefs from "Base" (either a base class or template param) use:
65//
66// INHERIT_GIMPL_TYPES(Base)
67// INHERIT_FIMPL_TYPES(Base)
68// INHERIT_IMPL_TYPES(Base)
69//
70// The Fermion operators will do the following:
71//
72// struct MyOpParams {
73// RealD mass;
74// };
75//
76//
77// template<class Impl>
78// class MyOp : public<Impl> {
79// public:
80//
81// INHERIT_ALL_IMPL_TYPES(Impl);
82//
83// MyOp(MyOpParams Myparm, ImplParams &ImplParam) : Impl(ImplParam)
84// {
85//
86// };
87//
88// }
90
91template <class T> struct SamePrecisionMapper {
92 typedef T HigherPrecVector ;
93 typedef T LowerPrecVector ;
94};
95template <class T> struct LowerPrecisionMapper { };
96template <> struct LowerPrecisionMapper<vRealF> {
99};
100template <> struct LowerPrecisionMapper<vRealD> {
103};
112
113struct CoeffReal {
114public:
116 static const int Nhcs = 2;
117 template<class Simd> using PrecisionMapper = SamePrecisionMapper<Simd>;
118};
120public:
122 static const int Nhcs = 1;
123 template<class Simd> using PrecisionMapper = LowerPrecisionMapper<Simd>;
124};
126public:
128 static const int Nhcs = 2;
129 template<class Simd> using PrecisionMapper = SamePrecisionMapper<Simd>;
130};
132public:
134 static const int Nhcs = 1;
135 template<class Simd> using PrecisionMapper = LowerPrecisionMapper<Simd>;
136};
137
139// Implementation dependent fermion types
141
142#define INHERIT_FIMPL_TYPES(Impl)\
143 typedef typename Impl::Coeff_t Coeff_t; \
144 typedef Impl Impl_t; \
145 typedef typename Impl::FermionField FermionField; \
146 typedef typename Impl::PropagatorField PropagatorField; \
147 typedef typename Impl::DoubledGaugeField DoubledGaugeField; \
148 typedef typename Impl::SiteDoubledGaugeField SiteDoubledGaugeField; \
149 typedef typename Impl::SiteSpinor SiteSpinor; \
150 typedef typename Impl::SitePropagator SitePropagator; \
151 typedef typename Impl::SiteHalfSpinor SiteHalfSpinor; \
152 typedef typename Impl::Compressor Compressor; \
153 typedef typename Impl::StencilImpl StencilImpl; \
154 typedef typename Impl::ImplParams ImplParams; \
155 typedef typename Impl::StencilImpl::View_type StencilView; \
156 typedef const typename ViewMap<FermionField>::Type FermionFieldView; \
157 typedef const typename ViewMap<DoubledGaugeField>::Type DoubledGaugeFieldView;
158
159#define INHERIT_IMPL_TYPES(Base) \
160 INHERIT_GIMPL_TYPES(Base) \
161 INHERIT_FIMPL_TYPES(Base)
162
166// Single flavour four spinors with colour index
169NAMESPACE_CHECK(ImplWilson);
170
172// Flavour doubled spinors; is Gparity the only? what about C*?
175NAMESPACE_CHECK(ImplGparityWilson);
176
178// Single flavour one component spinors with colour index
181NAMESPACE_CHECK(ImplStaggered);
182
184// Single flavour one component spinors with colour index. 5d vec
186// Deprecate Vec5d
187//#include <Grid/qcd/action/fermion/StaggeredVec5dImpl.h>
188//NAMESPACE_CHECK(ImplStaggered5dVec);
189
190
Grid_simd< complex< float >, SIMD_Ftype > vComplexF
Grid_simd< uint16_t, SIMD_Htype > vRealH
Grid_simd< complex< uint16_t >, SIMD_Htype > vComplexH
Grid_simd< float, SIMD_Ftype > vRealF
Grid_simd< complex< double >, SIMD_Dtype > vComplexD
Grid_simd< double, SIMD_Dtype > vRealD
#define NAMESPACE_CHECK(x)
Definition Namespace.h:39
#define NAMESPACE_BEGIN(A)
Definition Namespace.h:35
#define NAMESPACE_END(A)
Definition Namespace.h:36
std::complex< RealD > ComplexD
Definition Simd.h:79
double RealD
Definition Simd.h:61
LowerPrecisionMapper< Simd > PrecisionMapper
SamePrecisionMapper< Simd > PrecisionMapper
static const int Nhcs
LowerPrecisionMapper< Simd > PrecisionMapper
SamePrecisionMapper< Simd > PrecisionMapper
static const int Nhcs