Grid 0.7.0
MomentumFilter.h
Go to the documentation of this file.
1/*************************************************************************************
2
3Grid physics library, www.github.com/paboyle/Grid
4
5Source file: ./lib/qcd/hmc/integrators/MomentumFilter.h
6
7Copyright (C) 2015
8
9Author: Christopher Kelly <ckelly@bnl.gov>
10Author: Peter Boyle <paboyle@ph.ed.ac.uk>
11
12This program is free software; you can redistribute it and/or modify
13it under the terms of the GNU General Public License as published by
14the Free Software Foundation; either version 2 of the License, or
15(at your option) any later version.
16
17This program is distributed in the hope that it will be useful,
18but WITHOUT ANY WARRANTY; without even the implied warranty of
19MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20GNU General Public License for more details.
21
22You should have received a copy of the GNU General Public License along
23with this program; if not, write to the Free Software Foundation, Inc.,
2451 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
25
26See the full license in the file "LICENSE" in the top level distribution
27directory
28*************************************************************************************/
29/* END LEGAL */
30//--------------------------------------------------------------------
31#ifndef MOMENTUM_FILTER
32#define MOMENTUM_FILTER
33
35
36//These filter objects allow the user to manipulate the conjugate momentum as part of the update / refresh
37
38template<typename MomentaField>
40 virtual void applyFilter(MomentaField &P) const = 0;
42};
43
44//Do nothing
45template<typename MomentaField>
46struct MomentumFilterNone: public MomentumFilterBase<MomentaField>{
47 void applyFilter(MomentaField &P) const override{}
48};
49
50//Multiply each site/direction by a Lorentz vector complex number field
51//Can be used to implement a mask, zeroing out sites
52template<typename MomentaField>
53struct MomentumFilterApplyPhase: public MomentumFilterBase<MomentaField>{
54 typedef typename MomentaField::vector_type vector_type; //SIMD-vectorized complex type
55 typedef typename MomentaField::scalar_type scalar_type; //scalar complex type
56 typedef iVector<iScalar<iScalar<vector_type> >, Nd > LorentzScalarType; //complex phase for each site/direction
58
60
62
63 //Default to uniform field of (1,0)
66 for(int mu=0;mu<Nd;mu++)
67 one(mu)()() = scalar_type(1.);
68
69 phase = one;
70 }
71
72 void applyFilter(MomentaField &P) const override{
74 autoView( P_v , P, AcceleratorWrite);
75 autoView( phase_v , phase, AcceleratorRead);
76
77 accelerator_for(ss,P_v.size(),MomentaField::vector_type::Nsimd(),{
78 auto site_mom = P_v(ss);
79 auto site_phase = phase_v(ss);
80 for(int mu=0;mu<Nd;mu++)
81 site_mom(mu) = site_mom(mu) * site_phase(mu);
82 coalescedWrite(P_v[ss], site_mom);
83 });
84
85 }
86
87};
88
89
90
91
93
94#endif
#define accelerator_for(iterator, num, nsimd,...)
#define one
Definition BGQQPX.h:108
void conformable(const Lattice< obj1 > &lhs, const Lattice< obj2 > &rhs)
#define autoView(l_v, l, mode)
@ AcceleratorRead
@ AcceleratorWrite
#define NAMESPACE_BEGIN(A)
Definition Namespace.h:35
#define NAMESPACE_END(A)
Definition Namespace.h:36
static constexpr int Nd
Definition QCD.h:52
MomentaField::vector_type vector_type
MomentumFilterApplyPhase(GridBase *_grid)
iVector< iScalar< iScalar< vector_type > >, Nd > LorentzScalarType
void applyFilter(MomentaField &P) const override
MomentaField::scalar_type scalar_type
Lattice< LorentzScalarType > LatticeLorentzScalarType
MomentumFilterApplyPhase(const LatticeLorentzScalarType _phase)
LatticeLorentzScalarType phase
virtual void applyFilter(MomentaField &P) const =0
virtual ~MomentumFilterBase()
void applyFilter(MomentaField &P) const override