Grid 0.7.0
DirichletFilter.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/DirichletFilter.h
6
7Copyright (C) 2015
8
9Author: Peter Boyle <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//--------------------------------------------------------------------
30#pragma once
31
33
34template<typename MomentaField>
35struct DirichletFilter: public MomentumFilterBase<MomentaField>
36{
37 typedef typename MomentaField::vector_type vector_type; //SIMD-vectorized complex type
38 typedef typename MomentaField::scalar_type scalar_type; //scalar complex type
39
40 typedef iScalar<iScalar<iScalar<vector_type> > > ScalarType; //complex phase for each site
41
43
44 DirichletFilter(const Coordinate &_Block): Block(_Block){}
45
46 void applyFilter(MomentaField &P) const override
47 {
48 GridBase *grid = P.Grid();
49 typedef decltype(PeekIndex<LorentzIndex>(P, 0)) LatCM;
51 // Zero strictly links crossing between domains
53 LatticeInteger coor(grid);
54 LatCM zz(grid); zz = Zero();
55 for(int mu=0;mu<Nd;mu++) {
56 if ( (Block[mu]) && (Block[mu] <= grid->GlobalDimensions()[mu] ) ) {
57 // If costly could provide Grid earlier and precompute masks
58 std::cout << GridLogMessage << " Dirichlet in mu="<<mu<<std::endl;
59 LatticeCoordinate(coor,mu);
60 auto P_mu = PeekIndex<LorentzIndex>(P, mu);
61 P_mu = where(mod(coor,Block[mu])==Integer(Block[mu]-1),zz,P_mu);
62 PokeIndex<LorentzIndex>(P, P_mu, mu);
63 }
64 }
65 }
66};
67
68
69
71
AcceleratorVector< int, MaxDims > Coordinate
Definition Coordinate.h:95
void LatticeCoordinate(Lattice< iobj > &l, int mu)
void PokeIndex(Lattice< vobj > &lhs, const Lattice< decltype(peekIndex< Index >(vobj(), 0))> &rhs, int i)
auto PeekIndex(const Lattice< vobj > &lhs, int i) -> Lattice< decltype(peekIndex< Index >(vobj(), i))>
Lattice< obj > mod(const Lattice< obj > &rhs_i, Integer y)
GridLogger GridLogMessage(1, "Message", GridLogColours, "NORMAL")
#define NAMESPACE_BEGIN(A)
Definition Namespace.h:35
#define NAMESPACE_END(A)
Definition Namespace.h:36
Lattice< vTInteger > LatticeInteger
Definition QCD.h:364
static constexpr int Nd
Definition QCD.h:52
uint32_t Integer
Definition Simd.h:58
const Coordinate & GlobalDimensions(void)
Definition Simd.h:194
void applyFilter(MomentaField &P) const override
DirichletFilter(const Coordinate &_Block)
MomentaField::vector_type vector_type
MomentaField::scalar_type scalar_type
iScalar< iScalar< iScalar< vector_type > > > ScalarType