From 3ce68a751aaced0652a8e1aa023d81ba37d5e177 Mon Sep 17 00:00:00 2001 From: Antonin Portelli Date: Mon, 2 Jul 2018 17:52:04 +0100 Subject: [PATCH] Hadrons: stout smearing module --- extras/Hadrons/Global.hpp | 2 +- extras/Hadrons/Modules.hpp | 1 + .../Hadrons/Modules/MGauge/StoutSmearing.cc | 7 ++ .../Hadrons/Modules/MGauge/StoutSmearing.hpp | 103 ++++++++++++++++++ extras/Hadrons/modules.inc | 2 + 5 files changed, 114 insertions(+), 1 deletion(-) create mode 100644 extras/Hadrons/Modules/MGauge/StoutSmearing.cc create mode 100644 extras/Hadrons/Modules/MGauge/StoutSmearing.hpp diff --git a/extras/Hadrons/Global.hpp b/extras/Hadrons/Global.hpp index fdacb799..cf96ad9b 100644 --- a/extras/Hadrons/Global.hpp +++ b/extras/Hadrons/Global.hpp @@ -72,7 +72,7 @@ using Grid::operator>>; #define SIMPL ScalarImplCR #endif #ifndef GIMPL -#define GIMPL GimplTypesR +#define GIMPL PeriodicGimplR #endif BEGIN_HADRONS_NAMESPACE diff --git a/extras/Hadrons/Modules.hpp b/extras/Hadrons/Modules.hpp index f882d86c..6bf5d3ed 100644 --- a/extras/Hadrons/Modules.hpp +++ b/extras/Hadrons/Modules.hpp @@ -19,6 +19,7 @@ #include #include #include +#include #include #include #include diff --git a/extras/Hadrons/Modules/MGauge/StoutSmearing.cc b/extras/Hadrons/Modules/MGauge/StoutSmearing.cc new file mode 100644 index 00000000..161e74aa --- /dev/null +++ b/extras/Hadrons/Modules/MGauge/StoutSmearing.cc @@ -0,0 +1,7 @@ +#include + +using namespace Grid; +using namespace Hadrons; +using namespace MGauge; + +template class Grid::Hadrons::MGauge::TStoutSmearing; diff --git a/extras/Hadrons/Modules/MGauge/StoutSmearing.hpp b/extras/Hadrons/Modules/MGauge/StoutSmearing.hpp new file mode 100644 index 00000000..d84b1c6f --- /dev/null +++ b/extras/Hadrons/Modules/MGauge/StoutSmearing.hpp @@ -0,0 +1,103 @@ +#ifndef Hadrons_MGauge_StoutSmearing_hpp_ +#define Hadrons_MGauge_StoutSmearing_hpp_ + +#include +#include +#include + +BEGIN_HADRONS_NAMESPACE + +/****************************************************************************** + * Stout smearing * + ******************************************************************************/ +BEGIN_MODULE_NAMESPACE(MGauge) + +class StoutSmearingPar: Serializable +{ +public: + GRID_SERIALIZABLE_CLASS_MEMBERS(StoutSmearingPar, + std::string, gauge, + unsigned int, steps, + double, rho); +}; + +template +class TStoutSmearing: public Module +{ +public: + typedef typename GImpl::Field GaugeField; +public: + // constructor + TStoutSmearing(const std::string name); + // destructor + virtual ~TStoutSmearing(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(StoutSmearing, TStoutSmearing, MGauge); + +/****************************************************************************** + * TStoutSmearing implementation * + ******************************************************************************/ +// constructor ///////////////////////////////////////////////////////////////// +template +TStoutSmearing::TStoutSmearing(const std::string name) +: Module(name) +{} + +// dependencies/products /////////////////////////////////////////////////////// +template +std::vector TStoutSmearing::getInput(void) +{ + std::vector in = {par().gauge}; + + return in; +} + +template +std::vector TStoutSmearing::getOutput(void) +{ + std::vector out = {getName()}; + + return out; +} + +// setup /////////////////////////////////////////////////////////////////////// +template +void TStoutSmearing::setup(void) +{ + envCreateLat(GaugeField, getName()); + envTmpLat(GaugeField, "buf"); +} + +// execution /////////////////////////////////////////////////////////////////// +template +void TStoutSmearing::execute(void) +{ + LOG(Message) << "Smearing '" << par().gauge << "' with " << par().steps + << " of stout smearing and rho= " << par().rho << std::endl; + + Smear_Stout smearer(par().rho); + auto &U = envGet(GaugeField, par().gauge); + auto &Usmr = envGet(GaugeField, getName()); + + envGetTmp(GaugeField, buf); + buf = U; + for (unsigned int n = 0; n < par().steps; ++n) + { + smearer.smear(Usmr, buf); + buf = Usmr; + } +} + +END_MODULE_NAMESPACE + +END_HADRONS_NAMESPACE + +#endif // Hadrons_MGauge_StoutSmearing_hpp_ diff --git a/extras/Hadrons/modules.inc b/extras/Hadrons/modules.inc index 37477d79..58b082d0 100644 --- a/extras/Hadrons/modules.inc +++ b/extras/Hadrons/modules.inc @@ -18,6 +18,7 @@ modules_cc =\ Modules/MSink/Smear.cc \ Modules/MSolver/RBPrecCG.cc \ Modules/MSolver/LocalCoherenceLanczos.cc \ + Modules/MGauge/StoutSmearing.cc \ Modules/MGauge/Unit.cc \ Modules/MGauge/UnitEm.cc \ Modules/MGauge/StochEm.cc \ @@ -75,6 +76,7 @@ modules_hpp =\ Modules/MSolver/LocalCoherenceLanczos.hpp \ Modules/MSolver/RBPrecCG.hpp \ Modules/MGauge/UnitEm.hpp \ + Modules/MGauge/StoutSmearing.hpp \ Modules/MGauge/Unit.hpp \ Modules/MGauge/Random.hpp \ Modules/MGauge/FundtoHirep.hpp \