From 22749699a30da633f58a4d47642721c639048f31 Mon Sep 17 00:00:00 2001 From: Antonin Portelli Date: Tue, 6 Jun 2017 11:45:30 -0500 Subject: [PATCH] Fixes after merge and point sink module --- extras/Hadrons/Environment.cc | 56 ++++++++- extras/Hadrons/Environment.hpp | 44 ++++++- extras/Hadrons/Global.hpp | 9 +- extras/Hadrons/Modules.hpp | 1 + extras/Hadrons/Modules/MAction/DWF.hpp | 8 +- extras/Hadrons/Modules/MAction/Wilson.hpp | 6 +- .../Hadrons/Modules/MContraction/Baryon.hpp | 14 +-- .../Hadrons/Modules/MContraction/DiscLoop.hpp | 8 +- .../Hadrons/Modules/MContraction/Gamma3pt.hpp | 12 +- extras/Hadrons/Modules/MContraction/Meson.hpp | 102 ++++++++++------ .../Modules/MContraction/WeakHamiltonian.hpp | 8 +- .../MContraction/WeakHamiltonianEye.hpp | 6 +- .../MContraction/WeakHamiltonianNonEye.hpp | 6 +- .../MContraction/WeakNeutral4ptDisc.hpp | 6 +- extras/Hadrons/Modules/MGauge/Load.hpp | 6 +- extras/Hadrons/Modules/MGauge/Random.hpp | 6 +- extras/Hadrons/Modules/MGauge/StochEm.hpp | 6 +- extras/Hadrons/Modules/MGauge/Unit.hpp | 6 +- extras/Hadrons/Modules/MLoop/NoiseLoop.hpp | 8 +- .../Hadrons/Modules/MScalar/ChargedProp.hpp | 6 +- extras/Hadrons/Modules/MScalar/FreeProp.hpp | 6 +- extras/Hadrons/Modules/MSink/Point.hpp | 114 ++++++++++++++++++ extras/Hadrons/Modules/MSolver/RBPrecCG.hpp | 8 +- extras/Hadrons/Modules/MSource/Point.hpp | 6 +- extras/Hadrons/Modules/MSource/SeqGamma.hpp | 8 +- extras/Hadrons/Modules/MSource/Wall.hpp | 8 +- extras/Hadrons/Modules/MSource/Z2.hpp | 6 +- extras/Hadrons/Modules/Quark.hpp | 2 +- .../templates/Module_in_NS.hpp.template | 6 +- .../templates/Module_tmp_in_NS.hpp.template | 6 +- extras/Hadrons/modules.inc | 1 + tests/hadrons/Test_hadrons_spectrum.cc | 24 ++-- 32 files changed, 385 insertions(+), 134 deletions(-) create mode 100644 extras/Hadrons/Modules/MSink/Point.hpp diff --git a/extras/Hadrons/Environment.cc b/extras/Hadrons/Environment.cc index 37f2a3d7..0e7a4326 100644 --- a/extras/Hadrons/Environment.cc +++ b/extras/Hadrons/Environment.cc @@ -41,9 +41,10 @@ using namespace Hadrons; // constructor ///////////////////////////////////////////////////////////////// Environment::Environment(void) { - nd_ = GridDefaultLatt().size(); + dim_ = GridDefaultLatt(); + nd_ = dim_.size(); grid4d_.reset(SpaceTimeGrid::makeFourDimGrid( - GridDefaultLatt(), GridDefaultSimd(nd_, vComplex::Nsimd()), + dim_, GridDefaultSimd(nd_, vComplex::Nsimd()), GridDefaultMpi())); gridRb4d_.reset(SpaceTimeGrid::makeFourDimRedBlackGrid(grid4d_.get())); auto loc = getGrid()->LocalDimensions(); @@ -132,6 +133,16 @@ unsigned int Environment::getNd(void) const return nd_; } +std::vector Environment::getDim(void) const +{ + return dim_; +} + +int Environment::getDim(const unsigned int mu) const +{ + return dim_[mu]; +} + // random number generator ///////////////////////////////////////////////////// void Environment::setSeed(const std::vector &seed) { @@ -271,6 +282,21 @@ std::string Environment::getModuleType(const std::string name) const return getModuleType(getModuleAddress(name)); } +std::string Environment::getModuleNamespace(const unsigned int address) const +{ + std::string type = getModuleType(address), ns; + + auto pos2 = type.rfind("::"); + auto pos1 = type.rfind("::", pos2 - 2); + + return type.substr(pos1 + 2, pos2 - pos1 - 2); +} + +std::string Environment::getModuleNamespace(const std::string name) const +{ + return getModuleNamespace(getModuleAddress(name)); +} + bool Environment::hasModule(const unsigned int address) const { return (address < module_.size()); @@ -492,7 +518,14 @@ std::string Environment::getObjectType(const unsigned int address) const { if (hasRegisteredObject(address)) { - return typeName(object_[address].type); + if (object_[address].type) + { + return typeName(object_[address].type); + } + else + { + return ""; + } } else if (hasObject(address)) { @@ -532,6 +565,23 @@ Environment::Size Environment::getObjectSize(const std::string name) const return getObjectSize(getObjectAddress(name)); } +unsigned int Environment::getObjectModule(const unsigned int address) const +{ + if (hasObject(address)) + { + return object_[address].module; + } + else + { + HADRON_ERROR("no object with address " + std::to_string(address)); + } +} + +unsigned int Environment::getObjectModule(const std::string name) const +{ + return getObjectModule(getObjectAddress(name)); +} + unsigned int Environment::getObjectLs(const unsigned int address) const { if (hasRegisteredObject(address)) diff --git a/extras/Hadrons/Environment.hpp b/extras/Hadrons/Environment.hpp index 2628e5a0..13264bd5 100644 --- a/extras/Hadrons/Environment.hpp +++ b/extras/Hadrons/Environment.hpp @@ -106,6 +106,8 @@ public: void createGrid(const unsigned int Ls); GridCartesian * getGrid(const unsigned int Ls = 1) const; GridRedBlackCartesian * getRbGrid(const unsigned int Ls = 1) const; + std::vector getDim(void) const; + int getDim(const unsigned int mu) const; unsigned int getNd(void) const; // random number generator void setSeed(const std::vector &seed); @@ -131,6 +133,8 @@ public: std::string getModuleName(const unsigned int address) const; std::string getModuleType(const unsigned int address) const; std::string getModuleType(const std::string name) const; + std::string getModuleNamespace(const unsigned int address) const; + std::string getModuleNamespace(const std::string name) const; bool hasModule(const unsigned int address) const; bool hasModule(const std::string name) const; Graph makeModuleGraph(void) const; @@ -171,6 +175,8 @@ public: std::string getObjectType(const std::string name) const; Size getObjectSize(const unsigned int address) const; Size getObjectSize(const std::string name) const; + unsigned int getObjectModule(const unsigned int address) const; + unsigned int getObjectModule(const std::string name) const; unsigned int getObjectLs(const unsigned int address) const; unsigned int getObjectLs(const std::string name) const; bool hasObject(const unsigned int address) const; @@ -181,6 +187,10 @@ public: bool hasCreatedObject(const std::string name) const; bool isObject5d(const unsigned int address) const; bool isObject5d(const std::string name) const; + template + bool isObjectOfType(const unsigned int address) const; + template + bool isObjectOfType(const std::string name) const; Environment::Size getTotalSize(void) const; void addOwnership(const unsigned int owner, const unsigned int property); @@ -197,6 +207,7 @@ private: bool dryRun_{false}; unsigned int traj_, locVol_; // grids + std::vector dim_; GridPt grid4d_; std::map grid5d_; GridRbPt gridRb4d_; @@ -343,7 +354,7 @@ T * Environment::getObject(const unsigned int address) const else { HADRON_ERROR("object with address " + std::to_string(address) + - " does not have type '" + typeid(T).name() + + " does not have type '" + typeName(&typeid(T)) + "' (has type '" + getObjectType(address) + "')"); } } @@ -380,6 +391,37 @@ T * Environment::createLattice(const std::string name) return createLattice(getObjectAddress(name)); } +template +bool Environment::isObjectOfType(const unsigned int address) const +{ + if (hasRegisteredObject(address)) + { + if (auto h = dynamic_cast *>(object_[address].data.get())) + { + return true; + } + else + { + return false; + } + } + else if (hasObject(address)) + { + HADRON_ERROR("object with address " + std::to_string(address) + + " exists but is not registered"); + } + else + { + HADRON_ERROR("no object with address " + std::to_string(address)); + } +} + +template +bool Environment::isObjectOfType(const std::string name) const +{ + return isObjectOfType(getObjectAddress(name)); +} + END_HADRONS_NAMESPACE #endif // Hadrons_Environment_hpp_ diff --git a/extras/Hadrons/Global.hpp b/extras/Hadrons/Global.hpp index 3ff79ea3..9de01623 100644 --- a/extras/Hadrons/Global.hpp +++ b/extras/Hadrons/Global.hpp @@ -65,7 +65,9 @@ BEGIN_HADRONS_NAMESPACE typedef FermionOperator FMat##suffix; \ typedef typename FImpl::FermionField FermionField##suffix; \ typedef typename FImpl::PropagatorField PropagatorField##suffix; \ -typedef typename FImpl::SitePropagator SitePropagator##suffix; +typedef typename FImpl::SitePropagator SitePropagator##suffix; \ +typedef std::vector \ + SlicedPropagator##suffix; #define GAUGE_TYPE_ALIASES(FImpl, suffix)\ typedef typename FImpl::DoubledGaugeField DoubledGaugeField##suffix; @@ -78,7 +80,10 @@ typedef typename SImpl::Field PropagatorField##suffix; typedef std::function SolverFn##suffix; -#define TYPE_ALIASES(FImpl, suffix)\ +#define SINK_TYPE_ALIASES(suffix)\ +typedef std::function SinkFn##suffix; + +#define FGS_TYPE_ALIASES(FImpl, suffix)\ FERM_TYPE_ALIASES(FImpl, suffix)\ GAUGE_TYPE_ALIASES(FImpl, suffix)\ SOLVER_TYPE_ALIASES(FImpl, suffix) diff --git a/extras/Hadrons/Modules.hpp b/extras/Hadrons/Modules.hpp index 7155c02a..42a1f651 100644 --- a/extras/Hadrons/Modules.hpp +++ b/extras/Hadrons/Modules.hpp @@ -16,6 +16,7 @@ #include #include #include +#include #include #include #include diff --git a/extras/Hadrons/Modules/MAction/DWF.hpp b/extras/Hadrons/Modules/MAction/DWF.hpp index 880fe7b9..78e0916c 100644 --- a/extras/Hadrons/Modules/MAction/DWF.hpp +++ b/extras/Hadrons/Modules/MAction/DWF.hpp @@ -27,8 +27,8 @@ See the full license in the file "LICENSE" in the top level distribution directo *************************************************************************************/ /* END LEGAL */ -#ifndef Hadrons_DWF_hpp_ -#define Hadrons_DWF_hpp_ +#ifndef Hadrons_MAction_DWF_hpp_ +#define Hadrons_MAction_DWF_hpp_ #include #include @@ -56,7 +56,7 @@ template class TDWF: public Module { public: - TYPE_ALIASES(FImpl,); + FGS_TYPE_ALIASES(FImpl,); public: // constructor TDWF(const std::string name); @@ -137,4 +137,4 @@ END_MODULE_NAMESPACE END_HADRONS_NAMESPACE -#endif // Hadrons_DWF_hpp_ +#endif // Hadrons_MAction_DWF_hpp_ diff --git a/extras/Hadrons/Modules/MAction/Wilson.hpp b/extras/Hadrons/Modules/MAction/Wilson.hpp index 4b84bda5..aab54245 100644 --- a/extras/Hadrons/Modules/MAction/Wilson.hpp +++ b/extras/Hadrons/Modules/MAction/Wilson.hpp @@ -27,8 +27,8 @@ See the full license in the file "LICENSE" in the top level distribution directo *************************************************************************************/ /* END LEGAL */ -#ifndef Hadrons_Wilson_hpp_ -#define Hadrons_Wilson_hpp_ +#ifndef Hadrons_MAction_Wilson_hpp_ +#define Hadrons_MAction_Wilson_hpp_ #include #include @@ -54,7 +54,7 @@ template class TWilson: public Module { public: - TYPE_ALIASES(FImpl,); + FGS_TYPE_ALIASES(FImpl,); public: // constructor TWilson(const std::string name); diff --git a/extras/Hadrons/Modules/MContraction/Baryon.hpp b/extras/Hadrons/Modules/MContraction/Baryon.hpp index be7d919c..78bde5a2 100644 --- a/extras/Hadrons/Modules/MContraction/Baryon.hpp +++ b/extras/Hadrons/Modules/MContraction/Baryon.hpp @@ -27,8 +27,8 @@ See the full license in the file "LICENSE" in the top level distribution directo *************************************************************************************/ /* END LEGAL */ -#ifndef Hadrons_Baryon_hpp_ -#define Hadrons_Baryon_hpp_ +#ifndef Hadrons_MContraction_Baryon_hpp_ +#define Hadrons_MContraction_Baryon_hpp_ #include #include @@ -55,9 +55,9 @@ template class TBaryon: public Module { public: - TYPE_ALIASES(FImpl1, 1); - TYPE_ALIASES(FImpl2, 2); - TYPE_ALIASES(FImpl3, 3); + FERM_TYPE_ALIASES(FImpl1, 1); + FERM_TYPE_ALIASES(FImpl2, 2); + FERM_TYPE_ALIASES(FImpl3, 3); class Result: Serializable { public: @@ -121,11 +121,11 @@ void TBaryon::execute(void) // FIXME: do contractions - write(writer, "meson", result); + // write(writer, "meson", result); } END_MODULE_NAMESPACE END_HADRONS_NAMESPACE -#endif // Hadrons_Baryon_hpp_ +#endif // Hadrons_MContraction_Baryon_hpp_ diff --git a/extras/Hadrons/Modules/MContraction/DiscLoop.hpp b/extras/Hadrons/Modules/MContraction/DiscLoop.hpp index 4ad12e90..4f782cd3 100644 --- a/extras/Hadrons/Modules/MContraction/DiscLoop.hpp +++ b/extras/Hadrons/Modules/MContraction/DiscLoop.hpp @@ -26,8 +26,8 @@ See the full license in the file "LICENSE" in the top level distribution directo *************************************************************************************/ /* END LEGAL */ -#ifndef Hadrons_DiscLoop_hpp_ -#define Hadrons_DiscLoop_hpp_ +#ifndef Hadrons_MContraction_DiscLoop_hpp_ +#define Hadrons_MContraction_DiscLoop_hpp_ #include #include @@ -52,7 +52,7 @@ public: template class TDiscLoop: public Module { - TYPE_ALIASES(FImpl,); + FERM_TYPE_ALIASES(FImpl,); class Result: Serializable { public: @@ -141,4 +141,4 @@ END_MODULE_NAMESPACE END_HADRONS_NAMESPACE -#endif // Hadrons_DiscLoop_hpp_ +#endif // Hadrons_MContraction_DiscLoop_hpp_ diff --git a/extras/Hadrons/Modules/MContraction/Gamma3pt.hpp b/extras/Hadrons/Modules/MContraction/Gamma3pt.hpp index e5e73fa6..7f643d49 100644 --- a/extras/Hadrons/Modules/MContraction/Gamma3pt.hpp +++ b/extras/Hadrons/Modules/MContraction/Gamma3pt.hpp @@ -26,8 +26,8 @@ See the full license in the file "LICENSE" in the top level distribution directo *************************************************************************************/ /* END LEGAL */ -#ifndef Hadrons_Gamma3pt_hpp_ -#define Hadrons_Gamma3pt_hpp_ +#ifndef Hadrons_MContraction_Gamma3pt_hpp_ +#define Hadrons_MContraction_Gamma3pt_hpp_ #include #include @@ -72,9 +72,9 @@ public: template class TGamma3pt: public Module { - TYPE_ALIASES(FImpl1, 1); - TYPE_ALIASES(FImpl2, 2); - TYPE_ALIASES(FImpl3, 3); + FERM_TYPE_ALIASES(FImpl1, 1); + FERM_TYPE_ALIASES(FImpl2, 2); + FERM_TYPE_ALIASES(FImpl3, 3); class Result: Serializable { public: @@ -167,4 +167,4 @@ END_MODULE_NAMESPACE END_HADRONS_NAMESPACE -#endif // Hadrons_Gamma3pt_hpp_ +#endif // Hadrons_MContraction_Gamma3pt_hpp_ diff --git a/extras/Hadrons/Modules/MContraction/Meson.hpp b/extras/Hadrons/Modules/MContraction/Meson.hpp index 09c2a6e1..7810326a 100644 --- a/extras/Hadrons/Modules/MContraction/Meson.hpp +++ b/extras/Hadrons/Modules/MContraction/Meson.hpp @@ -29,8 +29,8 @@ See the full license in the file "LICENSE" in the top level distribution directo *************************************************************************************/ /* END LEGAL */ -#ifndef Hadrons_Meson_hpp_ -#define Hadrons_Meson_hpp_ +#ifndef Hadrons_MContraction_Meson_hpp_ +#define Hadrons_MContraction_Meson_hpp_ #include #include @@ -69,7 +69,7 @@ public: std::string, q1, std::string, q2, std::string, gammas, - std::string, mom, + std::string, sink, std::string, output); }; @@ -77,8 +77,10 @@ template class TMeson: public Module { public: - TYPE_ALIASES(FImpl1, 1); - TYPE_ALIASES(FImpl2, 2); + FERM_TYPE_ALIASES(FImpl1, 1); + FERM_TYPE_ALIASES(FImpl2, 2); + FERM_TYPE_ALIASES(ScalarImplCR, Scalar); + SINK_TYPE_ALIASES(Scalar); class Result: Serializable { public: @@ -115,7 +117,7 @@ TMeson::TMeson(const std::string name) template std::vector TMeson::getInput(void) { - std::vector input = {par().q1, par().q2}; + std::vector input = {par().q1, par().q2, par().sink}; return input; } @@ -154,6 +156,9 @@ void TMeson::parseGammaString(std::vector &gammaList) // execution /////////////////////////////////////////////////////////////////// +#define mesonConnected(q1, q2, gSnk, gSrc) \ +(g5*(gSnk))*(q1)*(adj(gSrc)*g5)*adj(q2) + template void TMeson::execute(void) { @@ -161,43 +166,72 @@ void TMeson::execute(void) << " quarks '" << par().q1 << "' and '" << par().q2 << "'" << std::endl; - CorrWriter writer(par().output); - PropagatorField1 &q1 = *env().template getObject(par().q1); - PropagatorField2 &q2 = *env().template getObject(par().q2); - LatticeComplex c(env().getGrid()); - Gamma g5(Gamma::Algebra::Gamma5); - std::vector gammaList; + CorrWriter writer(par().output); std::vector buf; std::vector result; - std::vector p; - - p = strToVec(par().mom); - LatticeComplex ph(env().getGrid()), coor(env().getGrid()); - Complex i(0.0,1.0); - ph = zero; - for(unsigned int mu = 0; mu < env().getNd(); mu++) - { - LatticeCoordinate(coor, mu); - ph = ph + p[mu]*coor*((1./(env().getGrid()->_fdimensions[mu]))); - } - ph = exp((Real)(2*M_PI)*i*ph); + Gamma g5(Gamma::Algebra::Gamma5); + std::vector gammaList; + int nt = env().getDim(Tp); parseGammaString(gammaList); - result.resize(gammaList.size()); for (unsigned int i = 0; i < result.size(); ++i) { - Gamma gSnk(gammaList[i].first); - Gamma gSrc(gammaList[i].second); - c = trace((g5*gSnk)*q1*(adj(gSrc)*g5)*adj(q2))*ph; - sliceSum(c, buf, Tp); - result[i].gamma_snk = gammaList[i].first; result[i].gamma_src = gammaList[i].second; - result[i].corr.resize(buf.size()); - for (unsigned int t = 0; t < buf.size(); ++t) + result[i].corr.resize(nt); + } + if (env().template isObjectOfType(par().q1) and + env().template isObjectOfType(par().q2)) + { + SlicedPropagator1 &q1 = *env().template getObject(par().q1); + SlicedPropagator2 &q2 = *env().template getObject(par().q2); + + LOG(Message) << "(propagator already sinked)" << std::endl; + for (unsigned int i = 0; i < result.size(); ++i) { - result[i].corr[t] = TensorRemove(buf[t]); + Gamma gSnk(gammaList[i].first); + Gamma gSrc(gammaList[i].second); + + for (unsigned int t = 0; t < buf.size(); ++t) + { + result[i].corr[t] = TensorRemove(trace(mesonConnected(q1[t], q2[t], gSnk, gSrc))); + } + } + } + else + { + PropagatorField1 &q1 = *env().template getObject(par().q1); + PropagatorField2 &q2 = *env().template getObject(par().q2); + LatticeComplex c(env().getGrid()); + + LOG(Message) << "(using sink '" << par().sink << "')" << std::endl; + for (unsigned int i = 0; i < result.size(); ++i) + { + Gamma gSnk(gammaList[i].first); + Gamma gSrc(gammaList[i].second); + std::string ns; + + ns = env().getModuleNamespace(env().getObjectModule(par().sink)); + if (ns == "MSource") + { + PropagatorField1 &sink = + *env().template getObject(par().sink); + + c = trace(mesonConnected(q1, q2, gSnk, gSrc)*sink); + sliceSum(c, buf, Tp); + } + else if (ns == "MSink") + { + SinkFnScalar &sink = *env().template getObject(par().sink); + + c = trace(mesonConnected(q1, q2, gSnk, gSrc)); + buf = sink(c); + } + for (unsigned int t = 0; t < buf.size(); ++t) + { + result[i].corr[t] = TensorRemove(buf[t]); + } } } write(writer, "meson", result); @@ -207,4 +241,4 @@ END_MODULE_NAMESPACE END_HADRONS_NAMESPACE -#endif // Hadrons_Meson_hpp_ +#endif // Hadrons_MContraction_Meson_hpp_ diff --git a/extras/Hadrons/Modules/MContraction/WeakHamiltonian.hpp b/extras/Hadrons/Modules/MContraction/WeakHamiltonian.hpp index 23482feb..0a3c2e31 100644 --- a/extras/Hadrons/Modules/MContraction/WeakHamiltonian.hpp +++ b/extras/Hadrons/Modules/MContraction/WeakHamiltonian.hpp @@ -26,8 +26,8 @@ See the full license in the file "LICENSE" in the top level distribution directo *************************************************************************************/ /* END LEGAL */ -#ifndef Hadrons_WeakHamiltonian_hpp_ -#define Hadrons_WeakHamiltonian_hpp_ +#ifndef Hadrons_MContraction_WeakHamiltonian_hpp_ +#define Hadrons_MContraction_WeakHamiltonian_hpp_ #include #include @@ -83,7 +83,7 @@ public: class T##modname: public Module\ {\ public:\ - TYPE_ALIASES(FIMPL,)\ + FERM_TYPE_ALIASES(FIMPL,)\ class Result: Serializable\ {\ public:\ @@ -111,4 +111,4 @@ END_MODULE_NAMESPACE END_HADRONS_NAMESPACE -#endif // Hadrons_WeakHamiltonian_hpp_ +#endif // Hadrons_MContraction_WeakHamiltonian_hpp_ diff --git a/extras/Hadrons/Modules/MContraction/WeakHamiltonianEye.hpp b/extras/Hadrons/Modules/MContraction/WeakHamiltonianEye.hpp index 2ee87895..3a2b9309 100644 --- a/extras/Hadrons/Modules/MContraction/WeakHamiltonianEye.hpp +++ b/extras/Hadrons/Modules/MContraction/WeakHamiltonianEye.hpp @@ -26,8 +26,8 @@ See the full license in the file "LICENSE" in the top level distribution directo *************************************************************************************/ /* END LEGAL */ -#ifndef Hadrons_WeakHamiltonianEye_hpp_ -#define Hadrons_WeakHamiltonianEye_hpp_ +#ifndef Hadrons_MContraction_WeakHamiltonianEye_hpp_ +#define Hadrons_MContraction_WeakHamiltonianEye_hpp_ #include @@ -55,4 +55,4 @@ END_MODULE_NAMESPACE END_HADRONS_NAMESPACE -#endif // Hadrons_WeakHamiltonianEye_hpp_ +#endif // Hadrons_MContraction_WeakHamiltonianEye_hpp_ diff --git a/extras/Hadrons/Modules/MContraction/WeakHamiltonianNonEye.hpp b/extras/Hadrons/Modules/MContraction/WeakHamiltonianNonEye.hpp index 69bb8005..eb5abe3c 100644 --- a/extras/Hadrons/Modules/MContraction/WeakHamiltonianNonEye.hpp +++ b/extras/Hadrons/Modules/MContraction/WeakHamiltonianNonEye.hpp @@ -26,8 +26,8 @@ See the full license in the file "LICENSE" in the top level distribution directo *************************************************************************************/ /* END LEGAL */ -#ifndef Hadrons_WeakHamiltonianNonEye_hpp_ -#define Hadrons_WeakHamiltonianNonEye_hpp_ +#ifndef Hadrons_MContraction_WeakHamiltonianNonEye_hpp_ +#define Hadrons_MContraction_WeakHamiltonianNonEye_hpp_ #include @@ -54,4 +54,4 @@ END_MODULE_NAMESPACE END_HADRONS_NAMESPACE -#endif // Hadrons_WeakHamiltonianNonEye_hpp_ +#endif // Hadrons_MContraction_WeakHamiltonianNonEye_hpp_ diff --git a/extras/Hadrons/Modules/MContraction/WeakNeutral4ptDisc.hpp b/extras/Hadrons/Modules/MContraction/WeakNeutral4ptDisc.hpp index c0d8f829..f26d4636 100644 --- a/extras/Hadrons/Modules/MContraction/WeakNeutral4ptDisc.hpp +++ b/extras/Hadrons/Modules/MContraction/WeakNeutral4ptDisc.hpp @@ -26,8 +26,8 @@ See the full license in the file "LICENSE" in the top level distribution directo *************************************************************************************/ /* END LEGAL */ -#ifndef Hadrons_WeakNeutral4ptDisc_hpp_ -#define Hadrons_WeakNeutral4ptDisc_hpp_ +#ifndef Hadrons_MContraction_WeakNeutral4ptDisc_hpp_ +#define Hadrons_MContraction_WeakNeutral4ptDisc_hpp_ #include @@ -56,4 +56,4 @@ END_MODULE_NAMESPACE END_HADRONS_NAMESPACE -#endif // Hadrons_WeakNeutral4ptDisc_hpp_ +#endif // Hadrons_MContraction_WeakNeutral4ptDisc_hpp_ diff --git a/extras/Hadrons/Modules/MGauge/Load.hpp b/extras/Hadrons/Modules/MGauge/Load.hpp index c41f9b8c..5ff6da0f 100644 --- a/extras/Hadrons/Modules/MGauge/Load.hpp +++ b/extras/Hadrons/Modules/MGauge/Load.hpp @@ -27,8 +27,8 @@ See the full license in the file "LICENSE" in the top level distribution directo *************************************************************************************/ /* END LEGAL */ -#ifndef Hadrons_Load_hpp_ -#define Hadrons_Load_hpp_ +#ifndef Hadrons_MGauge_Load_hpp_ +#define Hadrons_MGauge_Load_hpp_ #include #include @@ -70,4 +70,4 @@ END_MODULE_NAMESPACE END_HADRONS_NAMESPACE -#endif // Hadrons_Load_hpp_ +#endif // Hadrons_MGauge_Load_hpp_ diff --git a/extras/Hadrons/Modules/MGauge/Random.hpp b/extras/Hadrons/Modules/MGauge/Random.hpp index e3fbcf1a..a97d25cf 100644 --- a/extras/Hadrons/Modules/MGauge/Random.hpp +++ b/extras/Hadrons/Modules/MGauge/Random.hpp @@ -27,8 +27,8 @@ See the full license in the file "LICENSE" in the top level distribution directo *************************************************************************************/ /* END LEGAL */ -#ifndef Hadrons_Random_hpp_ -#define Hadrons_Random_hpp_ +#ifndef Hadrons_MGauge_Random_hpp_ +#define Hadrons_MGauge_Random_hpp_ #include #include @@ -63,4 +63,4 @@ END_MODULE_NAMESPACE END_HADRONS_NAMESPACE -#endif // Hadrons_Random_hpp_ +#endif // Hadrons_MGauge_Random_hpp_ diff --git a/extras/Hadrons/Modules/MGauge/StochEm.hpp b/extras/Hadrons/Modules/MGauge/StochEm.hpp index 50a77435..12ce9fdc 100644 --- a/extras/Hadrons/Modules/MGauge/StochEm.hpp +++ b/extras/Hadrons/Modules/MGauge/StochEm.hpp @@ -25,8 +25,8 @@ with this program; if not, write to the Free Software Foundation, Inc., See the full license in the file "LICENSE" in the top level distribution directory *************************************************************************************/ /* END LEGAL */ -#ifndef Hadrons_StochEm_hpp_ -#define Hadrons_StochEm_hpp_ +#ifndef Hadrons_MGauge_StochEm_hpp_ +#define Hadrons_MGauge_StochEm_hpp_ #include #include @@ -72,4 +72,4 @@ END_MODULE_NAMESPACE END_HADRONS_NAMESPACE -#endif // Hadrons_StochEm_hpp_ +#endif // Hadrons_MGauge_StochEm_hpp_ diff --git a/extras/Hadrons/Modules/MGauge/Unit.hpp b/extras/Hadrons/Modules/MGauge/Unit.hpp index 2ff10bfd..7cd15ef7 100644 --- a/extras/Hadrons/Modules/MGauge/Unit.hpp +++ b/extras/Hadrons/Modules/MGauge/Unit.hpp @@ -27,8 +27,8 @@ See the full license in the file "LICENSE" in the top level distribution directo *************************************************************************************/ /* END LEGAL */ -#ifndef Hadrons_Unit_hpp_ -#define Hadrons_Unit_hpp_ +#ifndef Hadrons_MGauge_Unit_hpp_ +#define Hadrons_MGauge_Unit_hpp_ #include #include @@ -63,4 +63,4 @@ END_MODULE_NAMESPACE END_HADRONS_NAMESPACE -#endif // Hadrons_Unit_hpp_ +#endif // Hadrons_MGauge_Unit_hpp_ diff --git a/extras/Hadrons/Modules/MLoop/NoiseLoop.hpp b/extras/Hadrons/Modules/MLoop/NoiseLoop.hpp index 3d2850d1..5d2c4a13 100644 --- a/extras/Hadrons/Modules/MLoop/NoiseLoop.hpp +++ b/extras/Hadrons/Modules/MLoop/NoiseLoop.hpp @@ -26,8 +26,8 @@ See the full license in the file "LICENSE" in the top level distribution directo *************************************************************************************/ /* END LEGAL */ -#ifndef Hadrons_NoiseLoop_hpp_ -#define Hadrons_NoiseLoop_hpp_ +#ifndef Hadrons_MLoop_NoiseLoop_hpp_ +#define Hadrons_MLoop_NoiseLoop_hpp_ #include #include @@ -65,7 +65,7 @@ template class TNoiseLoop: public Module { public: - TYPE_ALIASES(FImpl,); + FERM_TYPE_ALIASES(FImpl,); public: // constructor TNoiseLoop(const std::string name); @@ -129,4 +129,4 @@ END_MODULE_NAMESPACE END_HADRONS_NAMESPACE -#endif // Hadrons_NoiseLoop_hpp_ +#endif // Hadrons_MLoop_NoiseLoop_hpp_ diff --git a/extras/Hadrons/Modules/MScalar/ChargedProp.hpp b/extras/Hadrons/Modules/MScalar/ChargedProp.hpp index 8bb5faa0..fbe75c05 100644 --- a/extras/Hadrons/Modules/MScalar/ChargedProp.hpp +++ b/extras/Hadrons/Modules/MScalar/ChargedProp.hpp @@ -1,5 +1,5 @@ -#ifndef Hadrons_ChargedProp_hpp_ -#define Hadrons_ChargedProp_hpp_ +#ifndef Hadrons_MScalar_ChargedProp_hpp_ +#define Hadrons_MScalar_ChargedProp_hpp_ #include #include @@ -58,4 +58,4 @@ END_MODULE_NAMESPACE END_HADRONS_NAMESPACE -#endif // Hadrons_ChargedProp_hpp_ +#endif // Hadrons_MScalar_ChargedProp_hpp_ diff --git a/extras/Hadrons/Modules/MScalar/FreeProp.hpp b/extras/Hadrons/Modules/MScalar/FreeProp.hpp index 29f15eda..97cf288a 100644 --- a/extras/Hadrons/Modules/MScalar/FreeProp.hpp +++ b/extras/Hadrons/Modules/MScalar/FreeProp.hpp @@ -1,5 +1,5 @@ -#ifndef Hadrons_FreeProp_hpp_ -#define Hadrons_FreeProp_hpp_ +#ifndef Hadrons_MScalar_FreeProp_hpp_ +#define Hadrons_MScalar_FreeProp_hpp_ #include #include @@ -47,4 +47,4 @@ END_MODULE_NAMESPACE END_HADRONS_NAMESPACE -#endif // Hadrons_FreeProp_hpp_ +#endif // Hadrons_MScalar_FreeProp_hpp_ diff --git a/extras/Hadrons/Modules/MSink/Point.hpp b/extras/Hadrons/Modules/MSink/Point.hpp new file mode 100644 index 00000000..7b3aa9de --- /dev/null +++ b/extras/Hadrons/Modules/MSink/Point.hpp @@ -0,0 +1,114 @@ +#ifndef Hadrons_MSink_Point_hpp_ +#define Hadrons_MSink_Point_hpp_ + +#include +#include +#include + +BEGIN_HADRONS_NAMESPACE + +/****************************************************************************** + * Point * + ******************************************************************************/ +BEGIN_MODULE_NAMESPACE(MSink) + +class PointPar: Serializable +{ +public: + GRID_SERIALIZABLE_CLASS_MEMBERS(PointPar, + std::string, mom); +}; + +template +class TPoint: public Module +{ +public: + FERM_TYPE_ALIASES(FImpl,); + SINK_TYPE_ALIASES(); +public: + // constructor + TPoint(const std::string name); + // destructor + virtual ~TPoint(void) = default; + // dependency relation + virtual std::vector getInput(void); + virtual std::vector getOutput(void); + // setup + virtual void setup(void); + // execution + virtual void execute(void); +}; + +MODULE_REGISTER_NS(Point, TPoint, MSink); +MODULE_REGISTER_NS(ScalarPoint, TPoint, MSink); + +/****************************************************************************** + * TPoint implementation * + ******************************************************************************/ +// constructor ///////////////////////////////////////////////////////////////// +template +TPoint::TPoint(const std::string name) +: Module(name) +{} + +// dependencies/products /////////////////////////////////////////////////////// +template +std::vector TPoint::getInput(void) +{ + std::vector in; + + return in; +} + +template +std::vector TPoint::getOutput(void) +{ + std::vector out = {getName()}; + + return out; +} + +// setup /////////////////////////////////////////////////////////////////////// +template +void TPoint::setup(void) +{ + unsigned int size; + + size = env().template lattice4dSize(); + env().registerObject(getName(), size); +} + +// execution /////////////////////////////////////////////////////////////////// +template +void TPoint::execute(void) +{ + std::vector p = strToVec(par().mom); + LatticeComplex ph(env().getGrid()), coor(env().getGrid()); + Complex i(0.0,1.0); + + LOG(Message) << "Setting up point sink function for momentum [" + << par().mom << "]" << std::endl; + ph = zero; + for(unsigned int mu = 0; mu < env().getNd(); mu++) + { + LatticeCoordinate(coor, mu); + ph = ph + (p[mu]/env().getGrid()->_fdimensions[mu])*coor; + } + ph = exp((Real)(2*M_PI)*i*ph); + auto sink = [ph](const PropagatorField &field) + { + SlicedPropagator res; + PropagatorField tmp = ph*field; + + sliceSum(tmp, res, Tp); + + return res; + }; + env().setObject(getName(), new SinkFn(sink)); +} + +END_MODULE_NAMESPACE + +END_HADRONS_NAMESPACE + +#endif // Hadrons_MSink_Point_hpp_ diff --git a/extras/Hadrons/Modules/MSolver/RBPrecCG.hpp b/extras/Hadrons/Modules/MSolver/RBPrecCG.hpp index d7220271..b1f63a5d 100644 --- a/extras/Hadrons/Modules/MSolver/RBPrecCG.hpp +++ b/extras/Hadrons/Modules/MSolver/RBPrecCG.hpp @@ -27,8 +27,8 @@ See the full license in the file "LICENSE" in the top level distribution directo *************************************************************************************/ /* END LEGAL */ -#ifndef Hadrons_RBPrecCG_hpp_ -#define Hadrons_RBPrecCG_hpp_ +#ifndef Hadrons_MSolver_RBPrecCG_hpp_ +#define Hadrons_MSolver_RBPrecCG_hpp_ #include #include @@ -53,7 +53,7 @@ template class TRBPrecCG: public Module { public: - TYPE_ALIASES(FImpl,); + FGS_TYPE_ALIASES(FImpl,); public: // constructor TRBPrecCG(const std::string name); @@ -129,4 +129,4 @@ END_MODULE_NAMESPACE END_HADRONS_NAMESPACE -#endif // Hadrons_RBPrecCG_hpp_ +#endif // Hadrons_MSolver_RBPrecCG_hpp_ diff --git a/extras/Hadrons/Modules/MSource/Point.hpp b/extras/Hadrons/Modules/MSource/Point.hpp index 3c0fc9a1..0c415807 100644 --- a/extras/Hadrons/Modules/MSource/Point.hpp +++ b/extras/Hadrons/Modules/MSource/Point.hpp @@ -27,8 +27,8 @@ See the full license in the file "LICENSE" in the top level distribution directo *************************************************************************************/ /* END LEGAL */ -#ifndef Hadrons_Point_hpp_ -#define Hadrons_Point_hpp_ +#ifndef Hadrons_MSource_Point_hpp_ +#define Hadrons_MSource_Point_hpp_ #include #include @@ -133,4 +133,4 @@ END_MODULE_NAMESPACE END_HADRONS_NAMESPACE -#endif // Hadrons_Point_hpp_ +#endif // Hadrons_MSource_Point_hpp_ diff --git a/extras/Hadrons/Modules/MSource/SeqGamma.hpp b/extras/Hadrons/Modules/MSource/SeqGamma.hpp index 366ebee7..e2129a46 100644 --- a/extras/Hadrons/Modules/MSource/SeqGamma.hpp +++ b/extras/Hadrons/Modules/MSource/SeqGamma.hpp @@ -28,8 +28,8 @@ See the full license in the file "LICENSE" in the top level distribution directo *************************************************************************************/ /* END LEGAL */ -#ifndef Hadrons_SeqGamma_hpp_ -#define Hadrons_SeqGamma_hpp_ +#ifndef Hadrons_MSource_SeqGamma_hpp_ +#define Hadrons_MSource_SeqGamma_hpp_ #include #include @@ -72,7 +72,7 @@ template class TSeqGamma: public Module { public: - TYPE_ALIASES(FImpl,); + FGS_TYPE_ALIASES(FImpl,); public: // constructor TSeqGamma(const std::string name); @@ -161,4 +161,4 @@ END_MODULE_NAMESPACE END_HADRONS_NAMESPACE -#endif // Hadrons_SeqGamma_hpp_ +#endif // Hadrons_MSource_SeqGamma_hpp_ diff --git a/extras/Hadrons/Modules/MSource/Wall.hpp b/extras/Hadrons/Modules/MSource/Wall.hpp index 8722876f..4de37e4d 100644 --- a/extras/Hadrons/Modules/MSource/Wall.hpp +++ b/extras/Hadrons/Modules/MSource/Wall.hpp @@ -26,8 +26,8 @@ See the full license in the file "LICENSE" in the top level distribution directo *************************************************************************************/ /* END LEGAL */ -#ifndef Hadrons_WallSource_hpp_ -#define Hadrons_WallSource_hpp_ +#ifndef Hadrons_MSource_WallSource_hpp_ +#define Hadrons_MSource_WallSource_hpp_ #include #include @@ -64,7 +64,7 @@ template class TWall: public Module { public: - TYPE_ALIASES(FImpl,); + FERM_TYPE_ALIASES(FImpl,); public: // constructor TWall(const std::string name); @@ -144,4 +144,4 @@ END_MODULE_NAMESPACE END_HADRONS_NAMESPACE -#endif // Hadrons_WallSource_hpp_ +#endif // Hadrons_MSource_WallSource_hpp_ diff --git a/extras/Hadrons/Modules/MSource/Z2.hpp b/extras/Hadrons/Modules/MSource/Z2.hpp index 761ae139..a7f7a3e6 100644 --- a/extras/Hadrons/Modules/MSource/Z2.hpp +++ b/extras/Hadrons/Modules/MSource/Z2.hpp @@ -27,8 +27,8 @@ See the full license in the file "LICENSE" in the top level distribution directo *************************************************************************************/ /* END LEGAL */ -#ifndef Hadrons_Z2_hpp_ -#define Hadrons_Z2_hpp_ +#ifndef Hadrons_MSource_Z2_hpp_ +#define Hadrons_MSource_Z2_hpp_ #include #include @@ -149,4 +149,4 @@ END_MODULE_NAMESPACE END_HADRONS_NAMESPACE -#endif // Hadrons_Z2_hpp_ +#endif // Hadrons_MSource_Z2_hpp_ diff --git a/extras/Hadrons/Modules/Quark.hpp b/extras/Hadrons/Modules/Quark.hpp index c0d1f65a..cf7d4c28 100644 --- a/extras/Hadrons/Modules/Quark.hpp +++ b/extras/Hadrons/Modules/Quark.hpp @@ -51,7 +51,7 @@ template class TQuark: public Module { public: - TYPE_ALIASES(FImpl,); + FGS_TYPE_ALIASES(FImpl,); public: // constructor TQuark(const std::string name); diff --git a/extras/Hadrons/Modules/templates/Module_in_NS.hpp.template b/extras/Hadrons/Modules/templates/Module_in_NS.hpp.template index ece2bb58..ea77b12a 100644 --- a/extras/Hadrons/Modules/templates/Module_in_NS.hpp.template +++ b/extras/Hadrons/Modules/templates/Module_in_NS.hpp.template @@ -1,5 +1,5 @@ -#ifndef Hadrons____FILEBASENAME____hpp_ -#define Hadrons____FILEBASENAME____hpp_ +#ifndef Hadrons____NAMESPACE_______FILEBASENAME____hpp_ +#define Hadrons____NAMESPACE_______FILEBASENAME____hpp_ #include #include @@ -41,4 +41,4 @@ END_MODULE_NAMESPACE END_HADRONS_NAMESPACE -#endif // Hadrons____FILEBASENAME____hpp_ +#endif // Hadrons____NAMESPACE_______FILEBASENAME____hpp_ diff --git a/extras/Hadrons/Modules/templates/Module_tmp_in_NS.hpp.template b/extras/Hadrons/Modules/templates/Module_tmp_in_NS.hpp.template index a330652d..b79c0ad3 100644 --- a/extras/Hadrons/Modules/templates/Module_tmp_in_NS.hpp.template +++ b/extras/Hadrons/Modules/templates/Module_tmp_in_NS.hpp.template @@ -1,5 +1,5 @@ -#ifndef Hadrons____FILEBASENAME____hpp_ -#define Hadrons____FILEBASENAME____hpp_ +#ifndef Hadrons____NAMESPACE_______FILEBASENAME____hpp_ +#define Hadrons____NAMESPACE_______FILEBASENAME____hpp_ #include #include @@ -82,4 +82,4 @@ END_MODULE_NAMESPACE END_HADRONS_NAMESPACE -#endif // Hadrons____FILEBASENAME____hpp_ +#endif // Hadrons____NAMESPACE_______FILEBASENAME____hpp_ diff --git a/extras/Hadrons/modules.inc b/extras/Hadrons/modules.inc index 3cf69144..f51ede5a 100644 --- a/extras/Hadrons/modules.inc +++ b/extras/Hadrons/modules.inc @@ -28,6 +28,7 @@ modules_hpp =\ Modules/MScalar/ChargedProp.hpp \ Modules/MScalar/FreeProp.hpp \ Modules/MScalar/Scalar.hpp \ + Modules/MSink/Point.hpp \ Modules/MSolver/RBPrecCG.hpp \ Modules/MSource/Point.hpp \ Modules/MSource/SeqGamma.hpp \ diff --git a/tests/hadrons/Test_hadrons_spectrum.cc b/tests/hadrons/Test_hadrons_spectrum.cc index 55f3346e..8f7b30c8 100644 --- a/tests/hadrons/Test_hadrons_spectrum.cc +++ b/tests/hadrons/Test_hadrons_spectrum.cc @@ -63,6 +63,10 @@ int main(int argc, char *argv[]) MSource::Point::Par ptPar; ptPar.position = "0 0 0 0"; application.createModule("pt", ptPar); + // sink + MSink::Point::Par sinkPar; + sinkPar.mom = "0 0 0"; + application.createModule("sink", sinkPar); // set fermion boundary conditions to be periodic space, antiperiodic time. std::string boundary = "1 1 1 -1"; @@ -98,19 +102,19 @@ int main(int argc, char *argv[]) { MContraction::Meson::Par mesPar; - mesPar.output = "mesons/pt_" + flavour[i] + flavour[j]; - mesPar.q1 = "Qpt_" + flavour[i]; - mesPar.q2 = "Qpt_" + flavour[j]; - mesPar.gammas = "all"; - mesPar.mom = "0. 0. 0. 0."; + mesPar.output = "mesons/pt_" + flavour[i] + flavour[j]; + mesPar.q1 = "Qpt_" + flavour[i]; + mesPar.q2 = "Qpt_" + flavour[j]; + mesPar.gammas = "all"; + mesPar.sink = "sink"; application.createModule("meson_pt_" + flavour[i] + flavour[j], mesPar); - mesPar.output = "mesons/Z2_" + flavour[i] + flavour[j]; - mesPar.q1 = "QZ2_" + flavour[i]; - mesPar.q2 = "QZ2_" + flavour[j]; - mesPar.gammas = "all"; - mesPar.mom = "0. 0. 0. 0."; + mesPar.output = "mesons/Z2_" + flavour[i] + flavour[j]; + mesPar.q1 = "QZ2_" + flavour[i]; + mesPar.q2 = "QZ2_" + flavour[j]; + mesPar.gammas = "all"; + mesPar.sink = "sink"; application.createModule("meson_Z2_" + flavour[i] + flavour[j], mesPar);