diff --git a/Hadrons/Modules.hpp b/Hadrons/Modules.hpp index 8d92580a..07b895bc 100644 --- a/Hadrons/Modules.hpp +++ b/Hadrons/Modules.hpp @@ -1,66 +1,68 @@ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include #include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include #include #include -#include -#include #include #include #include -#include -#include -#include -#include -#include #include +#include +#include #include #include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include #include #include -#include -#include -#include #include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include diff --git a/Hadrons/Modules/MSource/Convolution.cc b/Hadrons/Modules/MSource/Convolution.cc new file mode 100644 index 00000000..b8ffecf8 --- /dev/null +++ b/Hadrons/Modules/MSource/Convolution.cc @@ -0,0 +1,7 @@ +#include + +using namespace Grid; +using namespace Hadrons; +using namespace MSource; + +template class Grid::Hadrons::MSource::TConvolution; diff --git a/Hadrons/Modules/MSource/Convolution.hpp b/Hadrons/Modules/MSource/Convolution.hpp new file mode 100644 index 00000000..c8d06772 --- /dev/null +++ b/Hadrons/Modules/MSource/Convolution.hpp @@ -0,0 +1,110 @@ +#ifndef Hadrons_MSource_Convolution_hpp_ +#define Hadrons_MSource_Convolution_hpp_ + +#include +#include +#include + +BEGIN_HADRONS_NAMESPACE + +/****************************************************************************** + * Convolution * + ******************************************************************************/ +BEGIN_MODULE_NAMESPACE(MSource) + +class ConvolutionPar: Serializable +{ +public: + GRID_SERIALIZABLE_CLASS_MEMBERS(ConvolutionPar, + std::string, field1, + std::string, field2); +}; + +template +class TConvolution: public Module +{ +public: + BASIC_TYPE_ALIASES(FImpl,); +public: + // constructor + TConvolution(const std::string name); + // destructor + virtual ~TConvolution(void) {}; + // dependency relation + virtual std::vector getInput(void); + virtual std::vector getOutput(void); + // setup + virtual void setup(void); + // execution + virtual void execute(void); +}; + +MODULE_REGISTER_TMP(Convolution, TConvolution, MSource); + +/****************************************************************************** + * TConvolution implementation * + ******************************************************************************/ +// constructor ///////////////////////////////////////////////////////////////// +template +TConvolution::TConvolution(const std::string name) +: Module(name) +{} + +// dependencies/products /////////////////////////////////////////////////////// +template +std::vector TConvolution::getInput(void) +{ + std::vector in; + + return in; +} + +template +std::vector TConvolution::getOutput(void) +{ + std::vector out = {getName()}; + + return out; +} + +// setup /////////////////////////////////////////////////////////////////////// +template +void TConvolution::setup(void) +{ + envCreateLat(LatticeFermion, getName()); + envTmpLat(LatticeComplex, "momfield1"); + envTmp(FFT, "fft", 1, env().getGrid()); +} + +// execution /////////////////////////////////////////////////////////////////// +template +void TConvolution::execute(void) +{ + auto &field1 = envGet(LatticeComplex, par().field1); + auto &field2 = envGet(LatticeFermion, par().field2); + auto &out = envGet(LatticeFermion, getName()); + envGetTmp(LatticeComplex, momfield1); + envGetTmp(FFT, fft); + + std::vector mask(env().getNd(), 1); + mask.back()=0; //transform only the spatial dimensions + + startTimer("Fourier transform"); + fft.FFT_dim_mask(momfield1, field1, mask, FFT::forward); + fft.FFT_dim_mask(out, field2, mask, FFT::forward); + stopTimer("Fourier transform"); + + startTimer("momentum-space multiplication"); + out=momfield1*out; + stopTimer("momentum-space multiplication"); + + startTimer("Fourier transform"); + fft.FFT_dim_mask(out, out, mask, FFT::backward); + stopTimer("Fourier transform"); +} + +END_MODULE_NAMESPACE + +END_HADRONS_NAMESPACE + +#endif // Hadrons_MSource_Convolution_hpp_ diff --git a/Hadrons/Modules/MSource/Gauss.cc b/Hadrons/Modules/MSource/Gauss.cc new file mode 100644 index 00000000..89fcb8df --- /dev/null +++ b/Hadrons/Modules/MSource/Gauss.cc @@ -0,0 +1,7 @@ +#include + +using namespace Grid; +using namespace Hadrons; +using namespace MSource; + +template class Grid::Hadrons::MSource::TGauss; diff --git a/Hadrons/Modules/MSource/Gauss.hpp b/Hadrons/Modules/MSource/Gauss.hpp new file mode 100644 index 00000000..0a8c2c1a --- /dev/null +++ b/Hadrons/Modules/MSource/Gauss.hpp @@ -0,0 +1,111 @@ +#ifndef Hadrons_MSource_Gauss_hpp_ +#define Hadrons_MSource_Gauss_hpp_ + +#include +#include +#include + +BEGIN_HADRONS_NAMESPACE + +/****************************************************************************** + * Gauss * + * result[n] = 1/(sqrt(2*pi)*width)^dim*exp(-|n|^2/(2*width^2)) * + * where: * + * n=(n[0],n[1],...,n[dim-1]) (lattice coordinate) * + * dim=Nd-1 * + ******************************************************************************/ +BEGIN_MODULE_NAMESPACE(MSource) + +class GaussPar: Serializable +{ +public: + GRID_SERIALIZABLE_CLASS_MEMBERS(GaussPar, + std::string, position, + double, width); +}; + +template +class TGauss: public Module +{ +public: + // constructor + TGauss(const std::string name); + // destructor + virtual ~TGauss(void) {}; + // dependency relation + virtual std::vector getInput(void); + virtual std::vector getOutput(void); + // setup + virtual void setup(void); + // execution + virtual void execute(void); +private: + std::vector position_; +}; + +MODULE_REGISTER_TMP(Gauss, TGauss, MSource); + +/****************************************************************************** + * TGauss implementation * + ******************************************************************************/ +// constructor ///////////////////////////////////////////////////////////////// +template +TGauss::TGauss(const std::string name) +: Module(name) +{} + +// dependencies/products /////////////////////////////////////////////////////// +template +std::vector TGauss::getInput(void) +{ + std::vector in; + + return in; +} + +template +std::vector TGauss::getOutput(void) +{ + std::vector out = {getName()}; + + return out; +} + +// setup /////////////////////////////////////////////////////////////////////// +template +void TGauss::setup(void) +{ + +} + +// execution /////////////////////////////////////////////////////////////////// +template +void TGauss::execute(void) +{ + auto &rho = envGet(LatticeComplex, getName()); + envGetTmp(LatticeComplex, component); + const int dim=env().getNd()-1; + const double fact=-0.5/std::pow(par().width,2); + const std::vector latt_size { env().getGrid()->FullDimensions() }; + + //exp(fact*|n|^2) + rho=zero; + for(int mu=0; mu(std::pow(sqrt(2*M_PI)*par().width,dim)); +} + +END_MODULE_NAMESPACE + +END_HADRONS_NAMESPACE + +#endif // Hadrons_MSource_Gauss_hpp_ diff --git a/Hadrons/modules.inc b/Hadrons/modules.inc index 44bd4311..cd72b74b 100644 --- a/Hadrons/modules.inc +++ b/Hadrons/modules.inc @@ -1,133 +1,137 @@ modules_cc =\ - Modules/MContraction/Baryon.cc \ - Modules/MContraction/Meson.cc \ - Modules/MContraction/WeakEye3pt.cc \ - Modules/MContraction/A2ALoop.cc \ - Modules/MContraction/WeakNonEye3pt.cc \ - Modules/MContraction/A2AAslashField.cc \ - Modules/MContraction/A2AMesonField.cc \ - Modules/MContraction/DiscLoop.cc \ - Modules/MContraction/Gamma3pt.cc \ - Modules/MFermion/FreeProp.cc \ - Modules/MFermion/GaugeProp.cc \ - Modules/MSource/Momentum.cc \ - Modules/MSource/Point.cc \ - Modules/MSource/Wall.cc \ Modules/MSource/SeqConserved.cc \ - Modules/MSource/SeqGamma.cc \ + Modules/MSource/Convolution.cc \ + Modules/MSource/Wall.cc \ + Modules/MSource/Point.cc \ Modules/MSource/Z2.cc \ - Modules/MSink/Point.cc \ - Modules/MSink/Smear.cc \ - Modules/MSolver/A2AVectors.cc \ - Modules/MSolver/A2AAslashVectors.cc \ - Modules/MSolver/RBPrecCG.cc \ - Modules/MSolver/MixedPrecisionRBPrecCG.cc \ - Modules/MSolver/LocalCoherenceLanczos.cc \ - Modules/MGauge/StoutSmearing.cc \ - Modules/MGauge/Unit.cc \ - Modules/MGauge/UnitEm.cc \ - Modules/MGauge/StochEm.cc \ - Modules/MGauge/Random.cc \ - Modules/MGauge/Electrify.cc \ - Modules/MGauge/FundtoHirep.cc \ - Modules/MGauge/GaugeFix.cc \ + Modules/MSource/Gauss.cc \ + Modules/MSource/SeqGamma.cc \ + Modules/MSource/Momentum.cc \ + Modules/MScalarSUN/TwoPoint.cc \ + Modules/MScalarSUN/TransProj.cc \ + Modules/MScalarSUN/TwoPointNPR.cc \ + Modules/MScalarSUN/EMT.cc \ + Modules/MScalarSUN/TrKinetic.cc \ + Modules/MScalarSUN/TrPhi.cc \ + Modules/MScalarSUN/Div.cc \ + Modules/MScalarSUN/Grad.cc \ + Modules/MScalarSUN/StochFreeField.cc \ + Modules/MScalarSUN/TrMag.cc \ Modules/MNoise/FullVolumeSpinColorDiagonal.cc \ Modules/MNoise/TimeDilutedSpinColorDiagonal.cc \ - Modules/MUtilities/RandomVectors.cc \ - Modules/MUtilities/PrecisionCast.cc \ Modules/MScalar/FreeProp.cc \ Modules/MScalar/ChargedProp.cc \ - Modules/MNPR/Amputate.cc \ + Modules/MAction/Wilson.cc \ + Modules/MAction/DWF.cc \ + Modules/MAction/MobiusDWF.cc \ + Modules/MAction/ScaledDWF.cc \ + Modules/MAction/WilsonClover.cc \ + Modules/MAction/ZMobiusDWF.cc \ + Modules/MGauge/FundtoHirep.cc \ + Modules/MGauge/StochEm.cc \ + Modules/MGauge/Unit.cc \ + Modules/MGauge/StoutSmearing.cc \ + Modules/MGauge/Electrify.cc \ + Modules/MGauge/Random.cc \ + Modules/MGauge/UnitEm.cc \ + Modules/MGauge/GaugeFix.cc \ + Modules/MUtilities/PrecisionCast.cc \ + Modules/MUtilities/RandomVectors.cc \ + Modules/MIO/LoadA2AVectors.cc \ + Modules/MIO/LoadNersc.cc \ + Modules/MIO/LoadBinary.cc \ + Modules/MIO/LoadCoarseEigenPack.cc \ + Modules/MIO/LoadEigenPack.cc \ + Modules/MIO/LoadCosmHol.cc \ + Modules/MContraction/A2ALoop.cc \ + Modules/MContraction/WeakNonEye3pt.cc \ + Modules/MContraction/A2AMesonField.cc \ + Modules/MContraction/Gamma3pt.cc \ + Modules/MContraction/Baryon.cc \ + Modules/MContraction/A2AAslashField.cc \ + Modules/MContraction/DiscLoop.cc \ + Modules/MContraction/Meson.cc \ + Modules/MContraction/WeakEye3pt.cc \ Modules/MNPR/Bilinear.cc \ Modules/MNPR/FourQuark.cc \ - Modules/MAction/Wilson.cc \ - Modules/MAction/MobiusDWF.cc \ - Modules/MAction/ZMobiusDWF.cc \ - Modules/MAction/WilsonClover.cc \ - Modules/MAction/DWF.cc \ - Modules/MAction/ScaledDWF.cc \ - Modules/MScalarSUN/TrPhi.cc \ - Modules/MScalarSUN/Grad.cc \ - Modules/MScalarSUN/TrMag.cc \ - Modules/MScalarSUN/TrKinetic.cc \ - Modules/MScalarSUN/EMT.cc \ - Modules/MScalarSUN/TransProj.cc \ - Modules/MScalarSUN/StochFreeField.cc \ - Modules/MScalarSUN/TwoPoint.cc \ - Modules/MScalarSUN/TwoPointNPR.cc \ - Modules/MScalarSUN/Div.cc \ - Modules/MIO/LoadEigenPack.cc \ - Modules/MIO/LoadBinary.cc \ - Modules/MIO/LoadNersc.cc \ - Modules/MIO/LoadCoarseEigenPack.cc \ - Modules/MIO/LoadCosmHol.cc \ - Modules/MIO/LoadA2AVectors.cc + Modules/MNPR/Amputate.cc \ + Modules/MSolver/A2AAslashVectors.cc \ + Modules/MSolver/MixedPrecisionRBPrecCG.cc \ + Modules/MSolver/RBPrecCG.cc \ + Modules/MSolver/LocalCoherenceLanczos.cc \ + Modules/MSolver/A2AVectors.cc \ + Modules/MFermion/FreeProp.cc \ + Modules/MFermion/GaugeProp.cc \ + Modules/MSink/Smear.cc \ + Modules/MSink/Point.cc modules_hpp =\ - Modules/MContraction/WeakEye3pt.hpp \ - Modules/MContraction/Baryon.hpp \ - Modules/MContraction/A2AAslashField.hpp \ - Modules/MContraction/A2ALoop.hpp \ - Modules/MContraction/A2AMesonField.hpp \ - Modules/MContraction/Meson.hpp \ - Modules/MContraction/DiscLoop.hpp \ - Modules/MContraction/Gamma3pt.hpp \ - Modules/MContraction/WeakNonEye3pt.hpp \ - Modules/MFermion/FreeProp.hpp \ - Modules/MFermion/GaugeProp.hpp \ - Modules/MSource/SeqGamma.hpp \ - Modules/MSource/Point.hpp \ - Modules/MSource/Wall.hpp \ - Modules/MSource/Z2.hpp \ - Modules/MSource/SeqConserved.hpp \ + Modules/MSource/Gauss.hpp \ Modules/MSource/Momentum.hpp \ - Modules/MSink/Smear.hpp \ - Modules/MSink/Point.hpp \ - Modules/MSolver/MixedPrecisionRBPrecCG.hpp \ - Modules/MSolver/LocalCoherenceLanczos.hpp \ - Modules/MSolver/A2AAslashVectors.hpp \ - Modules/MSolver/Guesser.hpp \ - Modules/MSolver/RBPrecCG.hpp \ - Modules/MSolver/A2AVectors.hpp \ - Modules/MGauge/UnitEm.hpp \ - Modules/MGauge/StoutSmearing.hpp \ - Modules/MGauge/Unit.hpp \ - Modules/MGauge/Random.hpp \ - Modules/MGauge/GaugeFix.hpp \ - Modules/MGauge/FundtoHirep.hpp \ - Modules/MGauge/StochEm.hpp \ - Modules/MGauge/Electrify.hpp \ + Modules/MSource/Z2.hpp \ + Modules/MSource/Point.hpp \ + Modules/MSource/SeqGamma.hpp \ + Modules/MSource/Convolution.hpp \ + Modules/MSource/Wall.hpp \ + Modules/MSource/SeqConserved.hpp \ + Modules/MScalarSUN/Div.hpp \ + Modules/MScalarSUN/TrKinetic.hpp \ + Modules/MScalarSUN/TrPhi.hpp \ + Modules/MScalarSUN/TwoPoint.hpp \ + Modules/MScalarSUN/Grad.hpp \ + Modules/MScalarSUN/Utils.hpp \ + Modules/MScalarSUN/StochFreeField.hpp \ + Modules/MScalarSUN/EMT.hpp \ + Modules/MScalarSUN/TrMag.hpp \ + Modules/MScalarSUN/TwoPointNPR.hpp \ + Modules/MScalarSUN/TransProj.hpp \ Modules/MNoise/TimeDilutedSpinColorDiagonal.hpp \ Modules/MNoise/FullVolumeSpinColorDiagonal.hpp \ - Modules/MUtilities/PrecisionCast.hpp \ - Modules/MUtilities/RandomVectors.hpp \ Modules/MScalar/FreeProp.hpp \ Modules/MScalar/Scalar.hpp \ Modules/MScalar/ChargedProp.hpp \ - Modules/MNPR/Bilinear.hpp \ - Modules/MNPR/Amputate.hpp \ - Modules/MNPR/FourQuark.hpp \ - Modules/MAction/DWF.hpp \ - Modules/MAction/MobiusDWF.hpp \ Modules/MAction/Wilson.hpp \ + Modules/MAction/ScaledDWF.hpp \ + Modules/MAction/MobiusDWF.hpp \ Modules/MAction/WilsonClover.hpp \ Modules/MAction/ZMobiusDWF.hpp \ - Modules/MAction/ScaledDWF.hpp \ - Modules/MScalarSUN/StochFreeField.hpp \ - Modules/MScalarSUN/TwoPointNPR.hpp \ - Modules/MScalarSUN/Div.hpp \ - Modules/MScalarSUN/TrMag.hpp \ - Modules/MScalarSUN/EMT.hpp \ - Modules/MScalarSUN/TwoPoint.hpp \ - Modules/MScalarSUN/TrPhi.hpp \ - Modules/MScalarSUN/Utils.hpp \ - Modules/MScalarSUN/TransProj.hpp \ - Modules/MScalarSUN/Grad.hpp \ - Modules/MScalarSUN/TrKinetic.hpp \ + Modules/MAction/DWF.hpp \ + Modules/MGauge/UnitEm.hpp \ + Modules/MGauge/Electrify.hpp \ + Modules/MGauge/StoutSmearing.hpp \ + Modules/MGauge/Random.hpp \ + Modules/MGauge/FundtoHirep.hpp \ + Modules/MGauge/GaugeFix.hpp \ + Modules/MGauge/Unit.hpp \ + Modules/MGauge/StochEm.hpp \ + Modules/MUtilities/RandomVectors.hpp \ + Modules/MUtilities/PrecisionCast.hpp \ + Modules/MIO/LoadCosmHol.hpp \ + Modules/MIO/LoadA2AVectors.hpp \ Modules/MIO/LoadEigenPack.hpp \ Modules/MIO/LoadNersc.hpp \ - Modules/MIO/LoadA2AVectors.hpp \ - Modules/MIO/LoadCosmHol.hpp \ + Modules/MIO/LoadBinary.hpp \ Modules/MIO/LoadCoarseEigenPack.hpp \ - Modules/MIO/LoadBinary.hpp + Modules/MContraction/WeakEye3pt.hpp \ + Modules/MContraction/Gamma3pt.hpp \ + Modules/MContraction/A2AMesonField.hpp \ + Modules/MContraction/A2ALoop.hpp \ + Modules/MContraction/WeakNonEye3pt.hpp \ + Modules/MContraction/DiscLoop.hpp \ + Modules/MContraction/A2AAslashField.hpp \ + Modules/MContraction/Baryon.hpp \ + Modules/MContraction/Meson.hpp \ + Modules/MNPR/FourQuark.hpp \ + Modules/MNPR/Bilinear.hpp \ + Modules/MNPR/Amputate.hpp \ + Modules/MSolver/A2AAslashVectors.hpp \ + Modules/MSolver/RBPrecCG.hpp \ + Modules/MSolver/Guesser.hpp \ + Modules/MSolver/LocalCoherenceLanczos.hpp \ + Modules/MSolver/A2AVectors.hpp \ + Modules/MSolver/MixedPrecisionRBPrecCG.hpp \ + Modules/MFermion/FreeProp.hpp \ + Modules/MFermion/GaugeProp.hpp \ + Modules/MSink/Smear.hpp \ + Modules/MSink/Point.hpp