mirror of
https://github.com/paboyle/Grid.git
synced 2025-04-09 05:30:46 +01:00
move momentum phase from MSource::Gauss to MSource::Convolution
This commit is contained in:
parent
6064f96fde
commit
6fdf93d695
@ -17,14 +17,16 @@ class ConvolutionPar: Serializable
|
|||||||
public:
|
public:
|
||||||
GRID_SERIALIZABLE_CLASS_MEMBERS(ConvolutionPar,
|
GRID_SERIALIZABLE_CLASS_MEMBERS(ConvolutionPar,
|
||||||
std::string, field1,
|
std::string, field1,
|
||||||
std::string, field2);
|
std::string, field2,
|
||||||
|
std::string, mom);
|
||||||
};
|
};
|
||||||
|
|
||||||
template <typename FImpl>
|
template <typename FImpl>
|
||||||
class TConvolution: public Module<ConvolutionPar>
|
class TConvolution: public Module<ConvolutionPar>
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
BASIC_TYPE_ALIASES(FImpl,);
|
//BASIC_TYPE_ALIASES(FImpl,);
|
||||||
|
FERM_TYPE_ALIASES(FImpl,);
|
||||||
public:
|
public:
|
||||||
// constructor
|
// constructor
|
||||||
TConvolution(const std::string name);
|
TConvolution(const std::string name);
|
||||||
@ -37,9 +39,12 @@ public:
|
|||||||
virtual void setup(void);
|
virtual void setup(void);
|
||||||
// execution
|
// execution
|
||||||
virtual void execute(void);
|
virtual void execute(void);
|
||||||
|
private:
|
||||||
|
std::vector<int> mom_;
|
||||||
};
|
};
|
||||||
|
|
||||||
MODULE_REGISTER_TMP(Convolution, TConvolution<FIMPL>, MSource);
|
MODULE_REGISTER_TMP(Convolution, TConvolution<FIMPL>, MSource);
|
||||||
|
//MODULE_REGISTER_TMP(ScalarConvolution, TConvolution<ScalarImplCR>, MSource);
|
||||||
|
|
||||||
/******************************************************************************
|
/******************************************************************************
|
||||||
* TConvolution implementation *
|
* TConvolution implementation *
|
||||||
@ -71,6 +76,13 @@ std::vector<std::string> TConvolution<FImpl>::getOutput(void)
|
|||||||
template <typename FImpl>
|
template <typename FImpl>
|
||||||
void TConvolution<FImpl>::setup(void)
|
void TConvolution<FImpl>::setup(void)
|
||||||
{
|
{
|
||||||
|
mom_ = strToVec<int>(par().mom);
|
||||||
|
if(mom_.size() != env().getNd()-1) {
|
||||||
|
HADRONS_ERROR(Size, std::string("momentum has ")
|
||||||
|
+ std::to_string(mom_.size()) + " instead of "
|
||||||
|
+ std::to_string(env().getNd()-1) + " components");
|
||||||
|
}
|
||||||
|
|
||||||
envCreateLat(PropagatorField, getName());
|
envCreateLat(PropagatorField, getName());
|
||||||
envTmpLat(LatticeComplex, "momfield1");
|
envTmpLat(LatticeComplex, "momfield1");
|
||||||
envTmp(FFT, "fft", 1, env().getGrid());
|
envTmp(FFT, "fft", 1, env().getGrid());
|
||||||
@ -98,6 +110,12 @@ void TConvolution<FImpl>::execute(void)
|
|||||||
out=momfield1*out;
|
out=momfield1*out;
|
||||||
stopTimer("momentum-space multiplication");
|
stopTimer("momentum-space multiplication");
|
||||||
|
|
||||||
|
startTimer("adding momentum");
|
||||||
|
for(int mu=0; mu<env().getNd()-1; mu++) {
|
||||||
|
out=Cshift(out, mu, mom_[mu]);
|
||||||
|
}
|
||||||
|
stopTimer("adding momentum");
|
||||||
|
|
||||||
startTimer("Fourier transform");
|
startTimer("Fourier transform");
|
||||||
fft.FFT_dim_mask(out, out, mask, FFT::backward);
|
fft.FFT_dim_mask(out, out, mask, FFT::backward);
|
||||||
stopTimer("Fourier transform");
|
stopTimer("Fourier transform");
|
||||||
|
@ -10,10 +10,9 @@ BEGIN_HADRONS_NAMESPACE
|
|||||||
/******************************************************************************
|
/******************************************************************************
|
||||||
* Gauss *
|
* Gauss *
|
||||||
* result[n] = 1/(sqrt(2*pi)*width)^dim *
|
* result[n] = 1/(sqrt(2*pi)*width)^dim *
|
||||||
* * exp(-|n-position|^2/(2*width^2) + i p.n) *
|
* * exp(-|n-position|^2/(2*width^2)) *
|
||||||
* where: *
|
* where: *
|
||||||
* n=(n[0],n[1],...,n[dim-1]) (lattice coordinate) *
|
* n=(n[0],n[1],...,n[dim-1]) (lattice coordinate) *
|
||||||
* p[i]=2*pi/L[i]*mom[i] *
|
|
||||||
* dim=Nd-1 *
|
* dim=Nd-1 *
|
||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
BEGIN_MODULE_NAMESPACE(MSource)
|
BEGIN_MODULE_NAMESPACE(MSource)
|
||||||
@ -23,7 +22,6 @@ class GaussPar: Serializable
|
|||||||
public:
|
public:
|
||||||
GRID_SERIALIZABLE_CLASS_MEMBERS(GaussPar,
|
GRID_SERIALIZABLE_CLASS_MEMBERS(GaussPar,
|
||||||
std::string, position,
|
std::string, position,
|
||||||
std::string, mom,
|
|
||||||
double, width);
|
double, width);
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -44,7 +42,6 @@ public:
|
|||||||
virtual void execute(void);
|
virtual void execute(void);
|
||||||
private:
|
private:
|
||||||
std::vector<int> position_;
|
std::vector<int> position_;
|
||||||
std::vector<int> mom_;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
MODULE_REGISTER_TMP(Gauss, TGauss<FIMPL>, MSource);
|
MODULE_REGISTER_TMP(Gauss, TGauss<FIMPL>, MSource);
|
||||||
@ -79,18 +76,12 @@ std::vector<std::string> TGauss<FImpl>::getOutput(void)
|
|||||||
template <typename FImpl>
|
template <typename FImpl>
|
||||||
void TGauss<FImpl>::setup(void)
|
void TGauss<FImpl>::setup(void)
|
||||||
{
|
{
|
||||||
auto parse_vector = [](const std::string &momentum, int dim,
|
position_ = strToVec<int>(par().position);
|
||||||
const std::string &desc)
|
if(position_.size() != env().getNd()-1) {
|
||||||
{
|
HADRONS_ERROR(Size, std::string("position has ")
|
||||||
std::vector<int> res = strToVec<int>(momentum);
|
+ std::to_string(position_.size()) + " instead of "
|
||||||
if(res.size() != dim) {
|
+ std::to_string(env().getNd()-1) + " components");
|
||||||
HADRONS_ERROR(Size, desc + " has " + std::to_string(res.size())
|
}
|
||||||
+ " instead of " + std::to_string(dim) + " components");
|
|
||||||
}
|
|
||||||
return res;
|
|
||||||
};
|
|
||||||
position_ = parse_vector(par().position, env().getNd()-1, "position");
|
|
||||||
mom_ = parse_vector(par().mom, env().getNd()-1, "momentum");
|
|
||||||
|
|
||||||
envCreateLat(LatticeComplex, getName());
|
envCreateLat(LatticeComplex, getName());
|
||||||
envTmpLat(LatticeComplex, "component");
|
envTmpLat(LatticeComplex, "component");
|
||||||
@ -109,7 +100,6 @@ void TGauss<FImpl>::execute(void)
|
|||||||
rho=zero;
|
rho=zero;
|
||||||
for(int mu=0; mu<dim; mu++) {
|
for(int mu=0; mu<dim; mu++) {
|
||||||
LatticeCoordinate(component, mu);
|
LatticeCoordinate(component, mu);
|
||||||
rho+=(i*(mom_[mu]*2*M_PI/env().getDim(mu)))*component;
|
|
||||||
//FIXME: the next three lines are very inefficient...
|
//FIXME: the next three lines are very inefficient...
|
||||||
// should not need any communication (Cshift) here
|
// should not need any communication (Cshift) here
|
||||||
assert(env().getDim(mu)%2==0);
|
assert(env().getDim(mu)%2==0);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user