mirror of
https://github.com/paboyle/Grid.git
synced 2025-04-24 12:45:56 +01:00
General detection for arbitrary domains.
Can simplify and make specific if performance matters
This commit is contained in:
parent
f9cda24781
commit
6dcaed621c
@ -32,8 +32,11 @@ directory
|
|||||||
////////////////////////////////////////////////////
|
////////////////////////////////////////////////////
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include <Grid/qcd/action/momentum/Domains.h>
|
||||||
|
|
||||||
NAMESPACE_BEGIN(Grid);
|
NAMESPACE_BEGIN(Grid);
|
||||||
|
|
||||||
|
|
||||||
template<typename MomentaField>
|
template<typename MomentaField>
|
||||||
struct DirichletFilter: public MomentumFilterBase<MomentaField>
|
struct DirichletFilter: public MomentumFilterBase<MomentaField>
|
||||||
{
|
{
|
||||||
@ -41,28 +44,55 @@ struct DirichletFilter: public MomentumFilterBase<MomentaField>
|
|||||||
|
|
||||||
DirichletFilter(const Coordinate &_Block): Block(_Block) {}
|
DirichletFilter(const Coordinate &_Block): Block(_Block) {}
|
||||||
|
|
||||||
void applyFilter(MomentaField &P) const override
|
// Edge detect using domain projectors
|
||||||
|
void applyFilter (MomentaField &U) const override
|
||||||
{
|
{
|
||||||
GridBase *grid = P.Grid();
|
DomainDecomposition Domains(Block);
|
||||||
|
GridBase *grid = U.Grid();
|
||||||
////////////////////////////////////////////////////
|
|
||||||
// Zero strictly links crossing between domains
|
|
||||||
////////////////////////////////////////////////////
|
|
||||||
LatticeInteger coor(grid);
|
LatticeInteger coor(grid);
|
||||||
typedef decltype(PeekIndex<LorentzIndex>(P,0)) MatrixType;
|
LatticeInteger face(grid);
|
||||||
MatrixType zz(grid); zz = Zero();
|
LatticeInteger one(grid); one = 1;
|
||||||
Coordinate Global=grid->GlobalDimensions();
|
LatticeInteger zero(grid); zero = 0;
|
||||||
for(int mu=0;mu<Nd;mu++) {
|
LatticeInteger omega(grid);
|
||||||
if ( (Block[mu] <= Global[mu]) && (Block[mu]>1) ) {
|
LatticeInteger omegabar(grid);
|
||||||
// If costly could provide Grid earlier and precompute masks
|
LatticeInteger tmp(grid);
|
||||||
LatticeCoordinate(coor,mu);
|
|
||||||
|
|
||||||
auto P_mu = PeekIndex<LorentzIndex>(P, mu);
|
omega=one; Domains.ProjectDomain(omega,0);
|
||||||
P_mu = where(mod(coor,Block[mu])==Integer(Block[mu]-1),zz,P_mu);
|
omegabar=one; Domains.ProjectDomain(omegabar,1);
|
||||||
PokeIndex<LorentzIndex>(P, P_mu, mu);
|
|
||||||
|
LatticeInteger nface(grid); nface=Zero();
|
||||||
|
|
||||||
|
MomentaField projected(grid); projected=Zero();
|
||||||
|
typedef decltype(PeekIndex<LorentzIndex>(U,0)) MomentaLinkField;
|
||||||
|
MomentaLinkField Umu(grid);
|
||||||
|
MomentaLinkField zz(grid); zz=Zero();
|
||||||
|
|
||||||
|
int dims = grid->Nd();
|
||||||
|
Coordinate Global=grid->GlobalDimensions();
|
||||||
|
assert(dims==Nd);
|
||||||
|
|
||||||
|
for(int mu=0;mu<Nd;mu++){
|
||||||
|
|
||||||
|
if ( Block[mu]!=0 ) {
|
||||||
|
|
||||||
|
Umu = PeekIndex<LorentzIndex>(U,mu);
|
||||||
|
|
||||||
|
// Upper face
|
||||||
|
tmp = Cshift(omegabar,mu,1);
|
||||||
|
tmp = tmp + omega;
|
||||||
|
face = where(tmp == Integer(2),one,zero );
|
||||||
|
|
||||||
|
tmp = Cshift(omega,mu,1);
|
||||||
|
tmp = tmp + omegabar;
|
||||||
|
face = where(tmp == Integer(2),one,face );
|
||||||
|
|
||||||
|
Umu = where(face,zz,Umu);
|
||||||
|
|
||||||
|
PokeIndex<LorentzIndex>(U, Umu, mu);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
NAMESPACE_END(Grid);
|
NAMESPACE_END(Grid);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user