From dd6fb140c58bbc5c080e141510cea774798987ff Mon Sep 17 00:00:00 2001 From: Antonin Portelli Date: Mon, 5 Dec 2016 13:53:31 +0900 Subject: [PATCH] Hadrons: big module reorganisation --- extras/Hadrons/Global.hpp | 2 +- extras/Hadrons/Module.hpp | 17 ++++- extras/Hadrons/Modules.hpp | 18 ++--- .../Modules/{ADWF.cc => MAction/DWF.cc} | 19 +++--- .../Modules/{ADWF.hpp => MAction/DWF.hpp} | 61 ++++++++--------- .../Modules/{AWilson.cc => MAction/Wilson.cc} | 19 +++--- .../{AWilson.hpp => MAction/Wilson.hpp} | 55 ++++++++-------- .../{CMeson.cc => MContraction/Meson.cc} | 17 ++--- .../{CMeson.hpp => MContraction/Meson.hpp} | 65 ++++++++++--------- .../Modules/{GLoad.cc => MGauge/Load.cc} | 19 +++--- .../Modules/{GLoad.hpp => MGauge/Load.hpp} | 53 ++++++++------- .../Modules/{GRandom.cc => MGauge/Random.cc} | 17 ++--- .../{GRandom.hpp => MGauge/Random.hpp} | 41 ++++++------ .../Modules/{GUnit.cc => MGauge/Unit.cc} | 17 ++--- .../Modules/{GUnit.hpp => MGauge/Unit.hpp} | 41 ++++++------ extras/Hadrons/Modules/MQuark.cc | 2 +- extras/Hadrons/Modules/MQuark.hpp | 2 +- .../{SolRBPrecCG.cc => MSolver/RBPrecCG.cc} | 19 +++--- .../{SolRBPrecCG.hpp => MSolver/RBPrecCG.hpp} | 57 ++++++++-------- .../Modules/{SrcPoint.cc => MSource/Point.cc} | 19 +++--- .../{SrcPoint.hpp => MSource/Point.hpp} | 57 ++++++++-------- .../Modules/{SrcZ2.cc => MSource/Z2.cc} | 19 +++--- .../Modules/{SrcZ2.hpp => MSource/Z2.hpp} | 57 ++++++++-------- .../templates}/Module.cc.template | 2 +- .../templates}/Module.hpp.template | 6 +- .../templates/Module_in_NS.cc.template | 40 ++++++++++++ .../templates/Module_in_NS.hpp.template | 43 ++++++++++++ extras/Hadrons/add_module.sh | 30 +++++++-- extras/Hadrons/modules.inc | 36 +++++----- tests/hadrons/Test_hadrons_mesons.cc | 27 ++++---- 30 files changed, 514 insertions(+), 363 deletions(-) rename extras/Hadrons/Modules/{ADWF.cc => MAction/DWF.cc} (87%) rename extras/Hadrons/Modules/{ADWF.hpp => MAction/DWF.hpp} (60%) rename extras/Hadrons/Modules/{AWilson.cc => MAction/Wilson.cc} (85%) rename extras/Hadrons/Modules/{AWilson.hpp => MAction/Wilson.hpp} (62%) rename extras/Hadrons/Modules/{CMeson.cc => MContraction/Meson.cc} (88%) rename extras/Hadrons/Modules/{CMeson.hpp => MContraction/Meson.hpp} (55%) rename extras/Hadrons/Modules/{GLoad.cc => MGauge/Load.cc} (85%) rename extras/Hadrons/Modules/{GLoad.hpp => MGauge/Load.hpp} (65%) rename extras/Hadrons/Modules/{GRandom.cc => MGauge/Random.cc} (83%) rename extras/Hadrons/Modules/{GRandom.hpp => MGauge/Random.hpp} (70%) rename extras/Hadrons/Modules/{GUnit.cc => MGauge/Unit.cc} (84%) rename extras/Hadrons/Modules/{GUnit.hpp => MGauge/Unit.hpp} (70%) rename extras/Hadrons/Modules/{SolRBPrecCG.cc => MSolver/RBPrecCG.cc} (85%) rename extras/Hadrons/Modules/{SolRBPrecCG.hpp => MSolver/RBPrecCG.hpp} (61%) rename extras/Hadrons/Modules/{SrcPoint.cc => MSource/Point.cc} (84%) rename extras/Hadrons/Modules/{SrcPoint.hpp => MSource/Point.hpp} (64%) rename extras/Hadrons/Modules/{SrcZ2.cc => MSource/Z2.cc} (87%) rename extras/Hadrons/Modules/{SrcZ2.hpp => MSource/Z2.hpp} (64%) rename extras/Hadrons/{ => Modules/templates}/Module.cc.template (95%) rename extras/Hadrons/{ => Modules/templates}/Module.hpp.template (90%) create mode 100644 extras/Hadrons/Modules/templates/Module_in_NS.cc.template create mode 100644 extras/Hadrons/Modules/templates/Module_in_NS.hpp.template diff --git a/extras/Hadrons/Global.hpp b/extras/Hadrons/Global.hpp index 0936f3ba..5f102328 100644 --- a/extras/Hadrons/Global.hpp +++ b/extras/Hadrons/Global.hpp @@ -54,7 +54,7 @@ BEGIN_HADRONS_NAMESPACE typedef FermionOperator FMat; typedef FIMPL::FermionField FermionField; typedef FIMPL::PropagatorField PropagatorField; -typedef std::function Solver; +typedef std::function SolverFn; // logger class HadronsLogger: public Logger diff --git a/extras/Hadrons/Module.hpp b/extras/Hadrons/Module.hpp index 60dcc936..d7065650 100644 --- a/extras/Hadrons/Module.hpp +++ b/extras/Hadrons/Module.hpp @@ -33,7 +33,7 @@ directory. BEGIN_HADRONS_NAMESPACE -// module registration macro +// module registration macros #define MODULE_REGISTER(mod)\ class mod##ModuleRegistrar\ {\ @@ -49,6 +49,21 @@ public:\ };\ static mod##ModuleRegistrar mod##ModuleRegistrarInstance; +#define MODULE_REGISTER_NS(mod, ns)\ +class ns##mod##ModuleRegistrar\ +{\ +public:\ + ns##mod##ModuleRegistrar(void)\ + {\ + ModuleFactory &modFac = ModuleFactory::getInstance();\ + modFac.registerBuilder(#ns "::" #mod, [&](const std::string name)\ + {\ + return std::unique_ptr(new ns::mod(name));\ + });\ + }\ +};\ +static ns##mod##ModuleRegistrar ns##mod##ModuleRegistrarInstance; + /****************************************************************************** * Module class * ******************************************************************************/ diff --git a/extras/Hadrons/Modules.hpp b/extras/Hadrons/Modules.hpp index a7a88710..998c609f 100644 --- a/extras/Hadrons/Modules.hpp +++ b/extras/Hadrons/Modules.hpp @@ -1,10 +1,10 @@ -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include #include -#include -#include -#include +#include +#include +#include diff --git a/extras/Hadrons/Modules/ADWF.cc b/extras/Hadrons/Modules/MAction/DWF.cc similarity index 87% rename from extras/Hadrons/Modules/ADWF.cc rename to extras/Hadrons/Modules/MAction/DWF.cc index 8f83f93f..626ac69b 100644 --- a/extras/Hadrons/Modules/ADWF.cc +++ b/extras/Hadrons/Modules/MAction/DWF.cc @@ -1,7 +1,7 @@ /******************************************************************************* Grid physics library, www.github.com/paboyle/Grid -Source file: programs/Hadrons/ADWF.cc +Source file: programs/Hadrons/DWF.cc Copyright (C) 2016 @@ -25,28 +25,29 @@ See the full license in the file "LICENSE" in the top level distribution directory. *******************************************************************************/ -#include +#include using namespace Grid; using namespace Hadrons; +using namespace MAction; /****************************************************************************** -* ADWF implementation * +* DWF implementation * ******************************************************************************/ // constructor ///////////////////////////////////////////////////////////////// -ADWF::ADWF(const std::string name) -: Module(name) +DWF::DWF(const std::string name) +: Module(name) {} // dependencies/products /////////////////////////////////////////////////////// -std::vector ADWF::getInput(void) +std::vector DWF::getInput(void) { std::vector in = {par().gauge}; return in; } -std::vector ADWF::getOutput(void) +std::vector DWF::getOutput(void) { std::vector out = {getName()}; @@ -54,7 +55,7 @@ std::vector ADWF::getOutput(void) } // setup /////////////////////////////////////////////////////////////////////// -void ADWF::setup(void) +void DWF::setup(void) { unsigned int size; @@ -63,7 +64,7 @@ void ADWF::setup(void) } // execution /////////////////////////////////////////////////////////////////// -void ADWF::execute(void) +void DWF::execute(void) { LOG(Message) << "Setting up domain wall fermion matrix with m= " << par().mass << ", M5= " << par().M5 << " and Ls= " diff --git a/extras/Hadrons/Modules/ADWF.hpp b/extras/Hadrons/Modules/MAction/DWF.hpp similarity index 60% rename from extras/Hadrons/Modules/ADWF.hpp rename to extras/Hadrons/Modules/MAction/DWF.hpp index 159d5b20..15d3a0dc 100644 --- a/extras/Hadrons/Modules/ADWF.hpp +++ b/extras/Hadrons/Modules/MAction/DWF.hpp @@ -1,7 +1,7 @@ /******************************************************************************* Grid physics library, www.github.com/paboyle/Grid -Source file: programs/Hadrons/ADWF.hpp +Source file: programs/Hadrons/DWF.hpp Copyright (C) 2016 @@ -25,8 +25,8 @@ See the full license in the file "LICENSE" in the top level distribution directory. *******************************************************************************/ -#ifndef Hadrons_ADWF_hpp_ -#define Hadrons_ADWF_hpp_ +#ifndef Hadrons_DWF_hpp_ +#define Hadrons_DWF_hpp_ #include #include @@ -37,34 +37,37 @@ BEGIN_HADRONS_NAMESPACE /****************************************************************************** * Domain wall quark action * ******************************************************************************/ -class ADWFPar: Serializable +namespace MAction { -public: - GRID_SERIALIZABLE_CLASS_MEMBERS(ADWFPar, - std::string, gauge, - unsigned int, Ls, - double , mass, - double , M5); -}; + class DWFPar: Serializable + { + public: + GRID_SERIALIZABLE_CLASS_MEMBERS(DWFPar, + std::string, gauge, + unsigned int, Ls, + double , mass, + double , M5); + }; + + class DWF: public Module + { + public: + // constructor + DWF(const std::string name); + // destructor + virtual ~DWF(void) = default; + // dependency relation + virtual std::vector getInput(void); + virtual std::vector getOutput(void); + // setup + virtual void setup(void); + // execution + virtual void execute(void); + }; +} -class ADWF: public Module -{ -public: - // constructor - ADWF(const std::string name); - // destructor - virtual ~ADWF(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(ADWF); +MODULE_REGISTER_NS(DWF, MAction); END_HADRONS_NAMESPACE -#endif // Hadrons_ADWF_hpp_ +#endif // Hadrons_DWF_hpp_ diff --git a/extras/Hadrons/Modules/AWilson.cc b/extras/Hadrons/Modules/MAction/Wilson.cc similarity index 85% rename from extras/Hadrons/Modules/AWilson.cc rename to extras/Hadrons/Modules/MAction/Wilson.cc index e55fe988..a07669e2 100644 --- a/extras/Hadrons/Modules/AWilson.cc +++ b/extras/Hadrons/Modules/MAction/Wilson.cc @@ -1,7 +1,7 @@ /******************************************************************************* Grid physics library, www.github.com/paboyle/Grid -Source file: programs/Hadrons/AWilson.cc +Source file: programs/Hadrons/Wilson.cc Copyright (C) 2016 @@ -25,28 +25,29 @@ See the full license in the file "LICENSE" in the top level distribution directory. *******************************************************************************/ -#include +#include using namespace Grid; using namespace Hadrons; +using namespace MAction; /****************************************************************************** -* AWilson implementation * +* Wilson implementation * ******************************************************************************/ // constructor ///////////////////////////////////////////////////////////////// -AWilson::AWilson(const std::string name) -: Module(name) +Wilson::Wilson(const std::string name) +: Module(name) {} // dependencies/products /////////////////////////////////////////////////////// -std::vector AWilson::getInput(void) +std::vector Wilson::getInput(void) { std::vector in = {par().gauge}; return in; } -std::vector AWilson::getOutput(void) +std::vector Wilson::getOutput(void) { std::vector out = {getName()}; @@ -54,7 +55,7 @@ std::vector AWilson::getOutput(void) } // setup /////////////////////////////////////////////////////////////////////// -void AWilson::setup(void) +void Wilson::setup(void) { unsigned int size; @@ -63,7 +64,7 @@ void AWilson::setup(void) } // execution /////////////////////////////////////////////////////////////////// -void AWilson::execute() +void Wilson::execute() { LOG(Message) << "Setting up Wilson fermion matrix with m= " << par().mass << " using gauge field '" << par().gauge << "'" << std::endl; diff --git a/extras/Hadrons/Modules/AWilson.hpp b/extras/Hadrons/Modules/MAction/Wilson.hpp similarity index 62% rename from extras/Hadrons/Modules/AWilson.hpp rename to extras/Hadrons/Modules/MAction/Wilson.hpp index 93986315..d6644ea4 100644 --- a/extras/Hadrons/Modules/AWilson.hpp +++ b/extras/Hadrons/Modules/MAction/Wilson.hpp @@ -1,7 +1,7 @@ /******************************************************************************* Grid physics library, www.github.com/paboyle/Grid -Source file: programs/Hadrons/AWilson.hpp +Source file: programs/Hadrons/Wilson.hpp Copyright (C) 2016 @@ -25,8 +25,8 @@ See the full license in the file "LICENSE" in the top level distribution directory. *******************************************************************************/ -#ifndef Hadrons_AWilson_hpp_ -#define Hadrons_AWilson_hpp_ +#ifndef Hadrons_Wilson_hpp_ +#define Hadrons_Wilson_hpp_ #include #include @@ -37,32 +37,35 @@ BEGIN_HADRONS_NAMESPACE /****************************************************************************** * Wilson quark action * ******************************************************************************/ -class AWilsonPar: Serializable +namespace MAction { -public: - GRID_SERIALIZABLE_CLASS_MEMBERS(AWilsonPar, - std::string, gauge, - double , mass); -}; + class WilsonPar: Serializable + { + public: + GRID_SERIALIZABLE_CLASS_MEMBERS(WilsonPar, + std::string, gauge, + double , mass); + }; -class AWilson: public Module -{ -public: - // constructor - AWilson(const std::string name); - // destructor - virtual ~AWilson(void) = default; - // dependencies/products - virtual std::vector getInput(void); - virtual std::vector getOutput(void); - // setup - virtual void setup(void); - // execution - virtual void execute(void); -}; + class Wilson: public Module + { + public: + // constructor + Wilson(const std::string name); + // destructor + virtual ~Wilson(void) = default; + // dependencies/products + virtual std::vector getInput(void); + virtual std::vector getOutput(void); + // setup + virtual void setup(void); + // execution + virtual void execute(void); + }; +} -MODULE_REGISTER(AWilson); +MODULE_REGISTER_NS(Wilson, MAction); END_HADRONS_NAMESPACE -#endif // Hadrons_AWilson_hpp_ +#endif // Hadrons_Wilson_hpp_ diff --git a/extras/Hadrons/Modules/CMeson.cc b/extras/Hadrons/Modules/MContraction/Meson.cc similarity index 88% rename from extras/Hadrons/Modules/CMeson.cc rename to extras/Hadrons/Modules/MContraction/Meson.cc index fef8179d..1707f00d 100644 --- a/extras/Hadrons/Modules/CMeson.cc +++ b/extras/Hadrons/Modules/MContraction/Meson.cc @@ -1,7 +1,7 @@ /******************************************************************************* Grid physics library, www.github.com/paboyle/Grid -Source file: programs/Hadrons/CMeson.cc +Source file: programs/Hadrons/Meson.cc Copyright (C) 2015 @@ -25,29 +25,30 @@ See the full license in the file "LICENSE" in the top level distribution directory. *******************************************************************************/ -#include +#include using namespace Grid; using namespace QCD; using namespace Hadrons; +using namespace MContraction; /****************************************************************************** - * CMeson implementation * + * Meson implementation * ******************************************************************************/ // constructor ///////////////////////////////////////////////////////////////// -CMeson::CMeson(const std::string name) -: Module(name) +Meson::Meson(const std::string name) +: Module(name) {} // dependencies/products /////////////////////////////////////////////////////// -std::vector CMeson::getInput(void) +std::vector Meson::getInput(void) { std::vector input = {par().q1, par().q2}; return input; } -std::vector CMeson::getOutput(void) +std::vector Meson::getOutput(void) { std::vector output = {getName()}; @@ -55,7 +56,7 @@ std::vector CMeson::getOutput(void) } // execution /////////////////////////////////////////////////////////////////// -void CMeson::execute(void) +void Meson::execute(void) { LOG(Message) << "Computing meson contraction '" << getName() << "' using" << " quarks '" << par().q1 << "' and '" << par().q2 << "'" diff --git a/extras/Hadrons/Modules/CMeson.hpp b/extras/Hadrons/Modules/MContraction/Meson.hpp similarity index 55% rename from extras/Hadrons/Modules/CMeson.hpp rename to extras/Hadrons/Modules/MContraction/Meson.hpp index 2e9daa6d..a2cdf3db 100644 --- a/extras/Hadrons/Modules/CMeson.hpp +++ b/extras/Hadrons/Modules/MContraction/Meson.hpp @@ -1,7 +1,7 @@ /******************************************************************************* Grid physics library, www.github.com/paboyle/Grid -Source file: programs/Hadrons/CMeson.hpp +Source file: programs/Hadrons/Meson.hpp Copyright (C) 2015 @@ -25,8 +25,8 @@ See the full license in the file "LICENSE" in the top level distribution directory. *******************************************************************************/ -#ifndef Hadrons_CMeson_hpp_ -#define Hadrons_CMeson_hpp_ +#ifndef Hadrons_Meson_hpp_ +#define Hadrons_Meson_hpp_ #include #include @@ -35,40 +35,43 @@ directory. BEGIN_HADRONS_NAMESPACE /****************************************************************************** - * CMeson * + * Meson * ******************************************************************************/ -class CMesonPar: Serializable +namespace MContraction { -public: - GRID_SERIALIZABLE_CLASS_MEMBERS(CMesonPar, - std::string, q1, - std::string, q2, - std::string, output); -}; - -class CMeson: public Module -{ -public: - class Result: Serializable + class MesonPar: Serializable { public: - GRID_SERIALIZABLE_CLASS_MEMBERS(Result, - std::vector>>, corr); + GRID_SERIALIZABLE_CLASS_MEMBERS(MesonPar, + std::string, q1, + std::string, q2, + std::string, output); }; -public: - // constructor - CMeson(const std::string name); - // destructor - virtual ~CMeson(void) = default; - // dependencies/products - virtual std::vector getInput(void); - virtual std::vector getOutput(void); - // execution - virtual void execute(void); -}; + + class Meson: public Module + { + public: + class Result: Serializable + { + public: + GRID_SERIALIZABLE_CLASS_MEMBERS(Result, + std::vector>>, corr); + }; + public: + // constructor + Meson(const std::string name); + // destructor + virtual ~Meson(void) = default; + // dependencies/products + virtual std::vector getInput(void); + virtual std::vector getOutput(void); + // execution + virtual void execute(void); + }; +} -MODULE_REGISTER(CMeson); +MODULE_REGISTER_NS(Meson, MContraction); END_HADRONS_NAMESPACE -#endif // Hadrons_CMeson_hpp_ +#endif // Hadrons_Meson_hpp_ diff --git a/extras/Hadrons/Modules/GLoad.cc b/extras/Hadrons/Modules/MGauge/Load.cc similarity index 85% rename from extras/Hadrons/Modules/GLoad.cc rename to extras/Hadrons/Modules/MGauge/Load.cc index b81307cd..276c08b2 100644 --- a/extras/Hadrons/Modules/GLoad.cc +++ b/extras/Hadrons/Modules/MGauge/Load.cc @@ -1,7 +1,7 @@ /******************************************************************************* Grid physics library, www.github.com/paboyle/Grid -Source file: programs/Hadrons/GLoad.cc +Source file: programs/Hadrons/Load.cc Copyright (C) 2016 @@ -25,28 +25,29 @@ See the full license in the file "LICENSE" in the top level distribution directory. *******************************************************************************/ -#include +#include using namespace Grid; using namespace Hadrons; +using namespace MGauge; /****************************************************************************** -* GLoad implementation * +* Load implementation * ******************************************************************************/ // constructor ///////////////////////////////////////////////////////////////// -GLoad::GLoad(const std::string name) -: Module(name) +Load::Load(const std::string name) +: Module(name) {} // dependencies/products /////////////////////////////////////////////////////// -std::vector GLoad::getInput(void) +std::vector Load::getInput(void) { std::vector in; return in; } -std::vector GLoad::getOutput(void) +std::vector Load::getOutput(void) { std::vector out = {getName()}; @@ -54,13 +55,13 @@ std::vector GLoad::getOutput(void) } // setup /////////////////////////////////////////////////////////////////////// -void GLoad::setup(void) +void Load::setup(void) { env().registerLattice(getName()); } // execution /////////////////////////////////////////////////////////////////// -void GLoad::execute(void) +void Load::execute(void) { NerscField header; std::string fileName = par().file + "." diff --git a/extras/Hadrons/Modules/GLoad.hpp b/extras/Hadrons/Modules/MGauge/Load.hpp similarity index 65% rename from extras/Hadrons/Modules/GLoad.hpp rename to extras/Hadrons/Modules/MGauge/Load.hpp index 9a089b61..5cd98f0c 100644 --- a/extras/Hadrons/Modules/GLoad.hpp +++ b/extras/Hadrons/Modules/MGauge/Load.hpp @@ -1,7 +1,7 @@ /******************************************************************************* Grid physics library, www.github.com/paboyle/Grid -Source file: programs/Hadrons/GLoad.hpp +Source file: programs/Hadrons/Load.hpp Copyright (C) 2016 @@ -25,8 +25,8 @@ See the full license in the file "LICENSE" in the top level distribution directory. *******************************************************************************/ -#ifndef Hadrons_GLoad_hpp_ -#define Hadrons_GLoad_hpp_ +#ifndef Hadrons_Load_hpp_ +#define Hadrons_Load_hpp_ #include #include @@ -37,31 +37,34 @@ BEGIN_HADRONS_NAMESPACE /****************************************************************************** * Load a NERSC configuration * ******************************************************************************/ -class GLoadPar: Serializable +namespace MGauge { -public: - GRID_SERIALIZABLE_CLASS_MEMBERS(GLoadPar, - std::string, file); -}; + class LoadPar: Serializable + { + public: + GRID_SERIALIZABLE_CLASS_MEMBERS(LoadPar, + std::string, file); + }; -class GLoad: public Module -{ -public: - // constructor - GLoad(const std::string name); - // destructor - virtual ~GLoad(void) = default; - // dependency relation - virtual std::vector getInput(void); - virtual std::vector getOutput(void); - // setup - virtual void setup(void); - // execution - virtual void execute(void); -}; + class Load: public Module + { + public: + // constructor + Load(const std::string name); + // destructor + virtual ~Load(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(GLoad); +MODULE_REGISTER_NS(Load, MGauge); END_HADRONS_NAMESPACE -#endif // Hadrons_GLoad_hpp_ +#endif // Hadrons_Load_hpp_ diff --git a/extras/Hadrons/Modules/GRandom.cc b/extras/Hadrons/Modules/MGauge/Random.cc similarity index 83% rename from extras/Hadrons/Modules/GRandom.cc rename to extras/Hadrons/Modules/MGauge/Random.cc index 7f5af2c2..587c5c25 100644 --- a/extras/Hadrons/Modules/GRandom.cc +++ b/extras/Hadrons/Modules/MGauge/Random.cc @@ -1,7 +1,7 @@ /******************************************************************************* Grid physics library, www.github.com/paboyle/Grid -Source file: programs/Hadrons/GRandom.cc +Source file: programs/Hadrons/Random.cc Copyright (C) 2016 @@ -25,26 +25,27 @@ See the full license in the file "LICENSE" in the top level distribution directory. *******************************************************************************/ -#include +#include using namespace Grid; using namespace Hadrons; +using namespace MGauge; /****************************************************************************** -* GRandom implementation * +* Random implementation * ******************************************************************************/ // constructor ///////////////////////////////////////////////////////////////// -GRandom::GRandom(const std::string name) +Random::Random(const std::string name) : Module(name) {} // dependencies/products /////////////////////////////////////////////////////// -std::vector GRandom::getInput(void) +std::vector Random::getInput(void) { return std::vector(); } -std::vector GRandom::getOutput(void) +std::vector Random::getOutput(void) { std::vector out = {getName()}; @@ -52,13 +53,13 @@ std::vector GRandom::getOutput(void) } // setup /////////////////////////////////////////////////////////////////////// -void GRandom::setup(void) +void Random::setup(void) { env().registerLattice(getName()); } // execution /////////////////////////////////////////////////////////////////// -void GRandom::execute(void) +void Random::execute(void) { LOG(Message) << "Generating random gauge configuration" << std::endl; LatticeGaugeField &U = *env().createLattice(getName()); diff --git a/extras/Hadrons/Modules/GRandom.hpp b/extras/Hadrons/Modules/MGauge/Random.hpp similarity index 70% rename from extras/Hadrons/Modules/GRandom.hpp rename to extras/Hadrons/Modules/MGauge/Random.hpp index 6c42372e..285357e3 100644 --- a/extras/Hadrons/Modules/GRandom.hpp +++ b/extras/Hadrons/Modules/MGauge/Random.hpp @@ -1,7 +1,7 @@ /******************************************************************************* Grid physics library, www.github.com/paboyle/Grid -Source file: programs/Hadrons/GRandom.hpp +Source file: programs/Hadrons/Random.hpp Copyright (C) 2016 @@ -25,8 +25,8 @@ See the full license in the file "LICENSE" in the top level distribution directory. *******************************************************************************/ -#ifndef Hadrons_GRandom_hpp_ -#define Hadrons_GRandom_hpp_ +#ifndef Hadrons_Random_hpp_ +#define Hadrons_Random_hpp_ #include #include @@ -37,24 +37,27 @@ BEGIN_HADRONS_NAMESPACE /****************************************************************************** * Random gauge * ******************************************************************************/ -class GRandom: public Module +namespace MGauge { -public: - // constructor - GRandom(const std::string name); - // destructor - virtual ~GRandom(void) = default; - // dependency relation - virtual std::vector getInput(void); - virtual std::vector getOutput(void); - // setup - virtual void setup(void); - // execution - virtual void execute(void); -}; + class Random: public Module + { + public: + // constructor + Random(const std::string name); + // destructor + virtual ~Random(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(GRandom); +MODULE_REGISTER_NS(Random, MGauge); END_HADRONS_NAMESPACE -#endif // Hadrons_GRandom_hpp_ +#endif // Hadrons_Random_hpp_ diff --git a/extras/Hadrons/Modules/GUnit.cc b/extras/Hadrons/Modules/MGauge/Unit.cc similarity index 84% rename from extras/Hadrons/Modules/GUnit.cc rename to extras/Hadrons/Modules/MGauge/Unit.cc index 34f134fe..232bd835 100644 --- a/extras/Hadrons/Modules/GUnit.cc +++ b/extras/Hadrons/Modules/MGauge/Unit.cc @@ -1,7 +1,7 @@ /******************************************************************************* Grid physics library, www.github.com/paboyle/Grid -Source file: programs/Hadrons/GUnit.cc +Source file: programs/Hadrons/Unit.cc Copyright (C) 2016 @@ -25,26 +25,27 @@ See the full license in the file "LICENSE" in the top level distribution directory. *******************************************************************************/ -#include +#include using namespace Grid; using namespace Hadrons; +using namespace MGauge; /****************************************************************************** -* GUnit implementation * +* Unit implementation * ******************************************************************************/ // constructor ///////////////////////////////////////////////////////////////// -GUnit::GUnit(const std::string name) +Unit::Unit(const std::string name) : Module(name) {} // dependencies/products /////////////////////////////////////////////////////// -std::vector GUnit::getInput(void) +std::vector Unit::getInput(void) { return std::vector(); } -std::vector GUnit::getOutput(void) +std::vector Unit::getOutput(void) { std::vector out = {getName()}; @@ -52,13 +53,13 @@ std::vector GUnit::getOutput(void) } // setup /////////////////////////////////////////////////////////////////////// -void GUnit::setup(void) +void Unit::setup(void) { env().registerLattice(getName()); } // execution /////////////////////////////////////////////////////////////////// -void GUnit::execute(void) +void Unit::execute(void) { LOG(Message) << "Creating unit gauge configuration" << std::endl; LatticeGaugeField &U = *env().createLattice(getName()); diff --git a/extras/Hadrons/Modules/GUnit.hpp b/extras/Hadrons/Modules/MGauge/Unit.hpp similarity index 70% rename from extras/Hadrons/Modules/GUnit.hpp rename to extras/Hadrons/Modules/MGauge/Unit.hpp index 31b53a35..4fa03f54 100644 --- a/extras/Hadrons/Modules/GUnit.hpp +++ b/extras/Hadrons/Modules/MGauge/Unit.hpp @@ -1,7 +1,7 @@ /******************************************************************************* Grid physics library, www.github.com/paboyle/Grid -Source file: programs/Hadrons/GUnit.hpp +Source file: programs/Hadrons/Unit.hpp Copyright (C) 2016 @@ -25,8 +25,8 @@ See the full license in the file "LICENSE" in the top level distribution directory. *******************************************************************************/ -#ifndef Hadrons_GUnit_hpp_ -#define Hadrons_GUnit_hpp_ +#ifndef Hadrons_Unit_hpp_ +#define Hadrons_Unit_hpp_ #include #include @@ -37,24 +37,27 @@ BEGIN_HADRONS_NAMESPACE /****************************************************************************** * Unit gauge * ******************************************************************************/ -class GUnit: public Module +namespace MGauge { -public: - // constructor - GUnit(const std::string name); - // destructor - virtual ~GUnit(void) = default; - // dependencies/products - virtual std::vector getInput(void); - virtual std::vector getOutput(void); - // setup - virtual void setup(void); - // execution - virtual void execute(void); -}; + class Unit: public Module + { + public: + // constructor + Unit(const std::string name); + // destructor + virtual ~Unit(void) = default; + // dependencies/products + virtual std::vector getInput(void); + virtual std::vector getOutput(void); + // setup + virtual void setup(void); + // execution + virtual void execute(void); + }; +} -MODULE_REGISTER(GUnit); +MODULE_REGISTER_NS(Unit, MGauge); END_HADRONS_NAMESPACE -#endif // Hadrons_GUnit_hpp_ +#endif // Hadrons_Unit_hpp_ diff --git a/extras/Hadrons/Modules/MQuark.cc b/extras/Hadrons/Modules/MQuark.cc index 8f730b58..07f25e1c 100644 --- a/extras/Hadrons/Modules/MQuark.cc +++ b/extras/Hadrons/Modules/MQuark.cc @@ -76,7 +76,7 @@ void MQuark::execute(void) << std::endl; LatticePropagator &prop = *env().createLattice(propName); LatticePropagator &fullSrc = *env().getObject(par().source); - Solver &solver = *env().getObject(par().solver); + SolverFn &solver = *env().getObject(par().solver); if (Ls_ > 1) { env().createLattice(getName()); diff --git a/extras/Hadrons/Modules/MQuark.hpp b/extras/Hadrons/Modules/MQuark.hpp index f217e338..ed6dfb0c 100644 --- a/extras/Hadrons/Modules/MQuark.hpp +++ b/extras/Hadrons/Modules/MQuark.hpp @@ -61,7 +61,7 @@ public: virtual void execute(void); private: unsigned int Ls_; - Solver *solver_{nullptr}; + SolverFn *solver_{nullptr}; }; MODULE_REGISTER(MQuark); diff --git a/extras/Hadrons/Modules/SolRBPrecCG.cc b/extras/Hadrons/Modules/MSolver/RBPrecCG.cc similarity index 85% rename from extras/Hadrons/Modules/SolRBPrecCG.cc rename to extras/Hadrons/Modules/MSolver/RBPrecCG.cc index 7a7aa69d..2c3d9f67 100644 --- a/extras/Hadrons/Modules/SolRBPrecCG.cc +++ b/extras/Hadrons/Modules/MSolver/RBPrecCG.cc @@ -1,7 +1,7 @@ /******************************************************************************* Grid physics library, www.github.com/paboyle/Grid -Source file: programs/Hadrons/SolRBPrecCG.cc +Source file: programs/Hadrons/RBPrecCG.cc Copyright (C) 2016 @@ -25,29 +25,30 @@ See the full license in the file "LICENSE" in the top level distribution directory. *******************************************************************************/ -#include +#include using namespace Grid; using namespace QCD; using namespace Hadrons; +using namespace MSolver; /****************************************************************************** -* SolRBPrecCG implementation * +* RBPrecCG implementation * ******************************************************************************/ // constructor ///////////////////////////////////////////////////////////////// -SolRBPrecCG::SolRBPrecCG(const std::string name) +RBPrecCG::RBPrecCG(const std::string name) : Module(name) {} // dependencies/products /////////////////////////////////////////////////////// -std::vector SolRBPrecCG::getInput(void) +std::vector RBPrecCG::getInput(void) { std::vector in = {par().action}; return in; } -std::vector SolRBPrecCG::getOutput(void) +std::vector RBPrecCG::getOutput(void) { std::vector out = {getName()}; @@ -55,7 +56,7 @@ std::vector SolRBPrecCG::getOutput(void) } // setup /////////////////////////////////////////////////////////////////////// -void SolRBPrecCG::setup(void) +void RBPrecCG::setup(void) { auto Ls = env().getObjectLs(par().action); @@ -64,7 +65,7 @@ void SolRBPrecCG::setup(void) } // execution /////////////////////////////////////////////////////////////////// -void SolRBPrecCG::execute(void) +void RBPrecCG::execute(void) { auto &mat = *(env().getObject(par().action)); auto solver = [&mat, this](LatticeFermion &sol, @@ -79,5 +80,5 @@ void SolRBPrecCG::execute(void) LOG(Message) << "setting up Schur red-black preconditioned CG for" << " action '" << par().action << "' with residual " << par().residual << std::endl; - env().setObject(getName(), new Solver(solver)); + env().setObject(getName(), new SolverFn(solver)); } diff --git a/extras/Hadrons/Modules/SolRBPrecCG.hpp b/extras/Hadrons/Modules/MSolver/RBPrecCG.hpp similarity index 61% rename from extras/Hadrons/Modules/SolRBPrecCG.hpp rename to extras/Hadrons/Modules/MSolver/RBPrecCG.hpp index 7482a70c..3d36c4c7 100644 --- a/extras/Hadrons/Modules/SolRBPrecCG.hpp +++ b/extras/Hadrons/Modules/MSolver/RBPrecCG.hpp @@ -1,7 +1,7 @@ /******************************************************************************* Grid physics library, www.github.com/paboyle/Grid -Source file: programs/Hadrons/SolRBPrecCG.hpp +Source file: programs/Hadrons/RBPrecCG.hpp Copyright (C) 2016 @@ -25,8 +25,8 @@ See the full license in the file "LICENSE" in the top level distribution directory. *******************************************************************************/ -#ifndef Hadrons_SolRBPrecCG_hpp_ -#define Hadrons_SolRBPrecCG_hpp_ +#ifndef Hadrons_RBPrecCG_hpp_ +#define Hadrons_RBPrecCG_hpp_ #include #include @@ -37,32 +37,35 @@ BEGIN_HADRONS_NAMESPACE /****************************************************************************** * Schur red-black preconditioned CG * ******************************************************************************/ -class SolRBPrecCGPar: Serializable +namespace MSolver { -public: - GRID_SERIALIZABLE_CLASS_MEMBERS(SolRBPrecCGPar, - std::string, action, - double , residual); -}; + class RBPrecCGPar: Serializable + { + public: + GRID_SERIALIZABLE_CLASS_MEMBERS(RBPrecCGPar, + std::string, action, + double , residual); + }; + + class RBPrecCG: public Module + { + public: + // constructor + RBPrecCG(const std::string name); + // destructor + virtual ~RBPrecCG(void) = default; + // dependencies/products + virtual std::vector getInput(void); + virtual std::vector getOutput(void); + // setup + virtual void setup(void); + // execution + virtual void execute(void); + }; +} -class SolRBPrecCG: public Module -{ -public: - // constructor - SolRBPrecCG(const std::string name); - // destructor - virtual ~SolRBPrecCG(void) = default; - // dependencies/products - virtual std::vector getInput(void); - virtual std::vector getOutput(void); - // setup - virtual void setup(void); - // execution - virtual void execute(void); -}; - -MODULE_REGISTER(SolRBPrecCG); +MODULE_REGISTER_NS(RBPrecCG, MSolver); END_HADRONS_NAMESPACE -#endif // Hadrons_SolRBPrecCG_hpp_ +#endif // Hadrons_RBPrecCG_hpp_ diff --git a/extras/Hadrons/Modules/SrcPoint.cc b/extras/Hadrons/Modules/MSource/Point.cc similarity index 84% rename from extras/Hadrons/Modules/SrcPoint.cc rename to extras/Hadrons/Modules/MSource/Point.cc index a060b5d7..f22f41d9 100644 --- a/extras/Hadrons/Modules/SrcPoint.cc +++ b/extras/Hadrons/Modules/MSource/Point.cc @@ -1,7 +1,7 @@ /******************************************************************************* Grid physics library, www.github.com/paboyle/Grid -Source file: programs/Hadrons/SrcPoint.cc +Source file: programs/Hadrons/Point.cc Copyright (C) 2016 @@ -25,28 +25,29 @@ See the full license in the file "LICENSE" in the top level distribution directory. *******************************************************************************/ -#include +#include using namespace Grid; using namespace Hadrons; +using namespace MSource; /****************************************************************************** -* SrcPoint implementation * +* Point implementation * ******************************************************************************/ // constructor ///////////////////////////////////////////////////////////////// -SrcPoint::SrcPoint(const std::string name) -: Module(name) +Point::Point(const std::string name) +: Module(name) {} // dependencies/products /////////////////////////////////////////////////////// -std::vector SrcPoint::getInput(void) +std::vector Point::getInput(void) { std::vector in; return in; } -std::vector SrcPoint::getOutput(void) +std::vector Point::getOutput(void) { std::vector out = {getName()}; @@ -54,13 +55,13 @@ std::vector SrcPoint::getOutput(void) } // setup /////////////////////////////////////////////////////////////////////// -void SrcPoint::setup(void) +void Point::setup(void) { env().registerLattice(getName()); } // execution /////////////////////////////////////////////////////////////////// -void SrcPoint::execute(void) +void Point::execute(void) { std::vector position = strToVec(par().position); SpinColourMatrix id; diff --git a/extras/Hadrons/Modules/SrcPoint.hpp b/extras/Hadrons/Modules/MSource/Point.hpp similarity index 64% rename from extras/Hadrons/Modules/SrcPoint.hpp rename to extras/Hadrons/Modules/MSource/Point.hpp index 8c1efce0..4bebdfe0 100644 --- a/extras/Hadrons/Modules/SrcPoint.hpp +++ b/extras/Hadrons/Modules/MSource/Point.hpp @@ -1,7 +1,7 @@ /******************************************************************************* Grid physics library, www.github.com/paboyle/Grid -Source file: programs/Hadrons/SrcPoint.hpp +Source file: programs/Hadrons/Point.hpp Copyright (C) 2016 @@ -25,8 +25,8 @@ See the full license in the file "LICENSE" in the top level distribution directory. *******************************************************************************/ -#ifndef Hadrons_SrcPoint_hpp_ -#define Hadrons_SrcPoint_hpp_ +#ifndef Hadrons_Point_hpp_ +#define Hadrons_Point_hpp_ #include #include @@ -46,33 +46,36 @@ BEGIN_HADRONS_NAMESPACE */ /****************************************************************************** - * SrcPoint * + * Point * ******************************************************************************/ -class SrcPointPar: Serializable +namespace MSource { -public: - GRID_SERIALIZABLE_CLASS_MEMBERS(SrcPointPar, - std::string, position); -}; + class PointPar: Serializable + { + public: + GRID_SERIALIZABLE_CLASS_MEMBERS(PointPar, + std::string, position); + }; + + class Point: public Module + { + public: + // constructor + Point(const std::string name); + // destructor + virtual ~Point(void) = default; + // dependency relation + virtual std::vector getInput(void); + virtual std::vector getOutput(void); + // setup + virtual void setup(void); + // execution + virtual void execute(void); + }; +} -class SrcPoint: public Module -{ -public: - // constructor - SrcPoint(const std::string name); - // destructor - virtual ~SrcPoint(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(SrcPoint); +MODULE_REGISTER_NS(Point, MSource); END_HADRONS_NAMESPACE -#endif // Hadrons_SrcPoint_hpp_ +#endif // Hadrons_Point_hpp_ diff --git a/extras/Hadrons/Modules/SrcZ2.cc b/extras/Hadrons/Modules/MSource/Z2.cc similarity index 87% rename from extras/Hadrons/Modules/SrcZ2.cc rename to extras/Hadrons/Modules/MSource/Z2.cc index ec555a08..90f9f274 100644 --- a/extras/Hadrons/Modules/SrcZ2.cc +++ b/extras/Hadrons/Modules/MSource/Z2.cc @@ -1,7 +1,7 @@ /******************************************************************************* Grid physics library, www.github.com/paboyle/Grid -Source file: programs/Hadrons/SrcZ2.cc +Source file: programs/Hadrons/Z2.cc Copyright (C) 2016 @@ -25,28 +25,29 @@ See the full license in the file "LICENSE" in the top level distribution directory. *******************************************************************************/ -#include +#include using namespace Grid; using namespace Hadrons; +using namespace MSource; /****************************************************************************** -* SrcZ2 implementation * +* Z2 implementation * ******************************************************************************/ // constructor ///////////////////////////////////////////////////////////////// -SrcZ2::SrcZ2(const std::string name) -: Module(name) +Z2::Z2(const std::string name) +: Module(name) {} // dependencies/products /////////////////////////////////////////////////////// -std::vector SrcZ2::getInput(void) +std::vector Z2::getInput(void) { std::vector in; return in; } -std::vector SrcZ2::getOutput(void) +std::vector Z2::getOutput(void) { std::vector out = {getName()}; @@ -54,13 +55,13 @@ std::vector SrcZ2::getOutput(void) } // setup /////////////////////////////////////////////////////////////////////// -void SrcZ2::setup(void) +void Z2::setup(void) { env().registerLattice(getName()); } // execution /////////////////////////////////////////////////////////////////// -void SrcZ2::execute(void) +void Z2::execute(void) { Lattice> t(env().getGrid()); LatticeComplex eta(env().getGrid()); diff --git a/extras/Hadrons/Modules/SrcZ2.hpp b/extras/Hadrons/Modules/MSource/Z2.hpp similarity index 64% rename from extras/Hadrons/Modules/SrcZ2.hpp rename to extras/Hadrons/Modules/MSource/Z2.hpp index bf0aebc0..0ff24b0c 100644 --- a/extras/Hadrons/Modules/SrcZ2.hpp +++ b/extras/Hadrons/Modules/MSource/Z2.hpp @@ -1,7 +1,7 @@ /******************************************************************************* Grid physics library, www.github.com/paboyle/Grid -Source file: programs/Hadrons/SrcZ2.hpp +Source file: programs/Hadrons/Z2.hpp Copyright (C) 2016 @@ -25,8 +25,8 @@ See the full license in the file "LICENSE" in the top level distribution directory. *******************************************************************************/ -#ifndef Hadrons_SrcZ2_hpp_ -#define Hadrons_SrcZ2_hpp_ +#ifndef Hadrons_Z2_hpp_ +#define Hadrons_Z2_hpp_ #include #include @@ -47,34 +47,37 @@ BEGIN_HADRONS_NAMESPACE */ /****************************************************************************** - * SrcZ2 * + * Z2 * ******************************************************************************/ -class SrcZ2Par: Serializable +namespace MSource { -public: - GRID_SERIALIZABLE_CLASS_MEMBERS(SrcZ2Par, - unsigned int, tA, - unsigned int, tB); -}; + class Z2Par: Serializable + { + public: + GRID_SERIALIZABLE_CLASS_MEMBERS(Z2Par, + unsigned int, tA, + unsigned int, tB); + }; -class SrcZ2: public Module -{ -public: - // constructor - SrcZ2(const std::string name); - // destructor - virtual ~SrcZ2(void) = default; - // dependency relation - virtual std::vector getInput(void); - virtual std::vector getOutput(void); - // setup - virtual void setup(void); - // execution - virtual void execute(void); -}; + class Z2: public Module + { + public: + // constructor + Z2(const std::string name); + // destructor + virtual ~Z2(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(SrcZ2); +MODULE_REGISTER_NS(Z2, MSource); END_HADRONS_NAMESPACE -#endif // Hadrons_SrcZ2_hpp_ +#endif // Hadrons_Z2_hpp_ diff --git a/extras/Hadrons/Module.cc.template b/extras/Hadrons/Modules/templates/Module.cc.template similarity index 95% rename from extras/Hadrons/Module.cc.template rename to extras/Hadrons/Modules/templates/Module.cc.template index 1bcf53ca..5cd7664d 100644 --- a/extras/Hadrons/Module.cc.template +++ b/extras/Hadrons/Modules/templates/Module.cc.template @@ -1,4 +1,4 @@ -#include +#include using namespace Grid; using namespace Hadrons; diff --git a/extras/Hadrons/Module.hpp.template b/extras/Hadrons/Modules/templates/Module.hpp.template similarity index 90% rename from extras/Hadrons/Module.hpp.template rename to extras/Hadrons/Modules/templates/Module.hpp.template index e8e6c4de..bee4e618 100644 --- a/extras/Hadrons/Module.hpp.template +++ b/extras/Hadrons/Modules/templates/Module.hpp.template @@ -1,9 +1,9 @@ #ifndef Hadrons____FILEBASENAME____hpp_ #define Hadrons____FILEBASENAME____hpp_ -#include -#include -#include +#include +#include +#include BEGIN_HADRONS_NAMESPACE diff --git a/extras/Hadrons/Modules/templates/Module_in_NS.cc.template b/extras/Hadrons/Modules/templates/Module_in_NS.cc.template new file mode 100644 index 00000000..64bc7aa9 --- /dev/null +++ b/extras/Hadrons/Modules/templates/Module_in_NS.cc.template @@ -0,0 +1,40 @@ +#include + +using namespace Grid; +using namespace Hadrons; +using namespace ___NAMESPACE___; + +/****************************************************************************** +* ___FILEBASENAME___ implementation * +******************************************************************************/ +// constructor ///////////////////////////////////////////////////////////////// +___FILEBASENAME___::___FILEBASENAME___(const std::string name) +: Module<___FILEBASENAME___Par>(name) +{} + +// dependencies/products /////////////////////////////////////////////////////// +std::vector ___FILEBASENAME___::getInput(void) +{ + std::vector in; + + return in; +} + +std::vector ___FILEBASENAME___::getOutput(void) +{ + std::vector out = {getName()}; + + return out; +} + +// setup /////////////////////////////////////////////////////////////////////// +void ___FILEBASENAME___::setup(void) +{ + +} + +// execution /////////////////////////////////////////////////////////////////// +void ___FILEBASENAME___::execute(void) +{ + +} diff --git a/extras/Hadrons/Modules/templates/Module_in_NS.hpp.template b/extras/Hadrons/Modules/templates/Module_in_NS.hpp.template new file mode 100644 index 00000000..bc43649b --- /dev/null +++ b/extras/Hadrons/Modules/templates/Module_in_NS.hpp.template @@ -0,0 +1,43 @@ +#ifndef Hadrons____FILEBASENAME____hpp_ +#define Hadrons____FILEBASENAME____hpp_ + +#include +#include +#include + +BEGIN_HADRONS_NAMESPACE + +/****************************************************************************** + * ___FILEBASENAME___ * + ******************************************************************************/ +namespace ___NAMESPACE___ +{ + class ___FILEBASENAME___Par: Serializable + { + public: + GRID_SERIALIZABLE_CLASS_MEMBERS(___FILEBASENAME___Par, + unsigned int, i); + }; + + class ___FILEBASENAME___: public Module<___FILEBASENAME___Par> + { + public: + // constructor + ___FILEBASENAME___(const std::string name); + // destructor + virtual ~___FILEBASENAME___(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(___FILEBASENAME___, ___NAMESPACE___); + +END_HADRONS_NAMESPACE + +#endif // Hadrons____FILEBASENAME____hpp_ diff --git a/extras/Hadrons/add_module.sh b/extras/Hadrons/add_module.sh index e412e0e7..d5d23ea4 100755 --- a/extras/Hadrons/add_module.sh +++ b/extras/Hadrons/add_module.sh @@ -1,15 +1,31 @@ #!/usr/bin/env bash -if (( $# != 1 )); then - echo "usage: `basename $0` " 1>&2 +if (( $# != 1 && $# != 2)); then + echo "usage: `basename $0` []" 1>&2 exit 1 fi NAME=$1 +NS=$2 -if [ -e "Modules/${NAME}.cc" ] || [ -e "Modules/${NAME}.hpp" ]; then - echo "error: files Modules/${NAME}.* already exists" 1>&2 - exit 1 +if (( $# == 1 )); then + if [ -e "Modules/${NAME}.cc" ] || [ -e "Modules/${NAME}.hpp" ]; then + echo "error: files Modules/${NAME}.* already exists" 1>&2 + exit 1 + fi + sed "s/___FILEBASENAME___/${NAME}/g" Modules/templates/Module.cc.template > Modules/${NAME}.cc + sed "s/___FILEBASENAME___/${NAME}/g" Modules/templates/Module.hpp.template > Modules/${NAME}.hpp +elif (( $# == 2 )); then + mkdir -p Modules/${NS} + if [ -e "Modules/${NS}/${NAME}.cc" ] || [ -e "Modules/${NS}/${NAME}.hpp" ]; then + echo "error: files Modules/${NS}/${NAME}.* already exists" 1>&2 + exit 1 + fi + TMPCC=".${NS}.${NAME}.tmp.cc" + TMPHPP=".${NS}.${NAME}.tmp.hpp" + sed "s/___FILEBASENAME___/${NAME}/g" Modules/templates/Module_in_NS.cc.template > ${TMPCC} + sed "s/___FILEBASENAME___/${NAME}/g" Modules/templates/Module_in_NS.hpp.template > ${TMPHPP} + sed "s/___NAMESPACE___/${NS}/g" ${TMPCC} > Modules/${NS}/${NAME}.cc + sed "s/___NAMESPACE___/${NS}/g" ${TMPHPP} > Modules/${NS}/${NAME}.hpp + rm -f ${TMPCC} ${TMPHPP} fi -sed "s/___FILEBASENAME___/${NAME}/g" Module.cc.template > Modules/${NAME}.cc -sed "s/___FILEBASENAME___/${NAME}/g" Module.hpp.template > Modules/${NAME}.hpp ./make_module_list.sh diff --git a/extras/Hadrons/modules.inc b/extras/Hadrons/modules.inc index 9040c406..a460ae86 100644 --- a/extras/Hadrons/modules.inc +++ b/extras/Hadrons/modules.inc @@ -1,24 +1,24 @@ modules_cc =\ - Modules/ADWF.cc \ - Modules/AWilson.cc \ - Modules/CMeson.cc \ - Modules/GLoad.cc \ - Modules/GRandom.cc \ - Modules/GUnit.cc \ + Modules/MAction/DWF.cc \ + Modules/MAction/Wilson.cc \ + Modules/MContraction/Meson.cc \ + Modules/MGauge/Load.cc \ + Modules/MGauge/Random.cc \ + Modules/MGauge/Unit.cc \ Modules/MQuark.cc \ - Modules/SolRBPrecCG.cc \ - Modules/SrcPoint.cc \ - Modules/SrcZ2.cc + Modules/MSolver/RBPrecCG.cc \ + Modules/MSource/Point.cc \ + Modules/MSource/Z2.cc modules_hpp =\ - Modules/ADWF.hpp \ - Modules/AWilson.hpp \ - Modules/CMeson.hpp \ - Modules/GLoad.hpp \ - Modules/GRandom.hpp \ - Modules/GUnit.hpp \ + Modules/MAction/DWF.hpp \ + Modules/MAction/Wilson.hpp \ + Modules/MContraction/Meson.hpp \ + Modules/MGauge/Load.hpp \ + Modules/MGauge/Random.hpp \ + Modules/MGauge/Unit.hpp \ Modules/MQuark.hpp \ - Modules/SolRBPrecCG.hpp \ - Modules/SrcPoint.hpp \ - Modules/SrcZ2.hpp + Modules/MSolver/RBPrecCG.hpp \ + Modules/MSource/Point.hpp \ + Modules/MSource/Z2.hpp diff --git a/tests/hadrons/Test_hadrons_mesons.cc b/tests/hadrons/Test_hadrons_mesons.cc index 9c062b39..b9561694 100644 --- a/tests/hadrons/Test_hadrons_mesons.cc +++ b/tests/hadrons/Test_hadrons_mesons.cc @@ -28,7 +28,6 @@ #include using namespace Grid; -using namespace QCD; using namespace Hadrons; int main(int argc, char *argv[]) @@ -56,30 +55,31 @@ int main(int argc, char *argv[]) globalPar.seed = "1 2 3 4"; application.setPar(globalPar); // gauge field - application.createModule("gauge"); + application.createModule("gauge"); // sources - SrcZ2::Par z2Par; + MSource::Z2::Par z2Par; z2Par.tA = 0; z2Par.tB = 0; - application.createModule("z2", z2Par); - SrcPoint::Par ptPar; + application.createModule("z2", z2Par); + MSource::Point::Par ptPar; ptPar.position = "0 0 0 0"; - application.createModule("pt", ptPar); + application.createModule("pt", ptPar); for (unsigned int i = 0; i < flavour.size(); ++i) { // actions - ADWF::Par actionPar; + MAction::DWF::Par actionPar; actionPar.gauge = "gauge"; actionPar.Ls = 12; actionPar.M5 = 1.8; actionPar.mass = mass[i]; - application.createModule("DWF_" + flavour[i], actionPar); + application.createModule("DWF_" + flavour[i], actionPar); // solvers - SolRBPrecCG::Par solverPar; + MSolver::RBPrecCG::Par solverPar; solverPar.action = "DWF_" + flavour[i]; solverPar.residual = 1.0e-8; - application.createModule("CG_" + flavour[i], solverPar); + application.createModule("CG_" + flavour[i], + solverPar); // propagators MQuark::Par quarkPar; @@ -90,13 +90,14 @@ int main(int argc, char *argv[]) for (unsigned int i = 0; i < flavour.size(); ++i) for (unsigned int j = i + 1; j < flavour.size(); ++j) { - CMeson::Par mesPar; + MContraction::Meson::Par mesPar; mesPar.output = "mesons/" + flavour[i] + flavour[j]; mesPar.q1 = "Q_" + flavour[i]; mesPar.q2 = "Q_" + flavour[j]; - application.createModule("meson_" + flavour[i] + flavour[j], - mesPar); + application.createModule("meson_" + + flavour[i] + flavour[j], + mesPar); } // execution