1
0
mirror of https://github.com/paboyle/Grid.git synced 2024-11-10 07:55:35 +00:00

Hadrons: big module reorganisation

This commit is contained in:
Antonin Portelli 2016-12-05 13:53:31 +09:00
parent 0b4f680d28
commit dd6fb140c5
30 changed files with 514 additions and 363 deletions

View File

@ -54,7 +54,7 @@ BEGIN_HADRONS_NAMESPACE
typedef FermionOperator<FIMPL> FMat; typedef FermionOperator<FIMPL> FMat;
typedef FIMPL::FermionField FermionField; typedef FIMPL::FermionField FermionField;
typedef FIMPL::PropagatorField PropagatorField; typedef FIMPL::PropagatorField PropagatorField;
typedef std::function<void(FermionField &, const FermionField &)> Solver; typedef std::function<void(FermionField &, const FermionField &)> SolverFn;
// logger // logger
class HadronsLogger: public Logger class HadronsLogger: public Logger

View File

@ -33,7 +33,7 @@ directory.
BEGIN_HADRONS_NAMESPACE BEGIN_HADRONS_NAMESPACE
// module registration macro // module registration macros
#define MODULE_REGISTER(mod)\ #define MODULE_REGISTER(mod)\
class mod##ModuleRegistrar\ class mod##ModuleRegistrar\
{\ {\
@ -49,6 +49,21 @@ public:\
};\ };\
static mod##ModuleRegistrar mod##ModuleRegistrarInstance; 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<ns::mod>(new ns::mod(name));\
});\
}\
};\
static ns##mod##ModuleRegistrar ns##mod##ModuleRegistrarInstance;
/****************************************************************************** /******************************************************************************
* Module class * * Module class *
******************************************************************************/ ******************************************************************************/

View File

@ -1,10 +1,10 @@
#include <Grid/Hadrons/Modules/ADWF.hpp> #include <Grid/Hadrons/Modules/MAction/DWF.hpp>
#include <Grid/Hadrons/Modules/AWilson.hpp> #include <Grid/Hadrons/Modules/MAction/Wilson.hpp>
#include <Grid/Hadrons/Modules/CMeson.hpp> #include <Grid/Hadrons/Modules/MContraction/Meson.hpp>
#include <Grid/Hadrons/Modules/GLoad.hpp> #include <Grid/Hadrons/Modules/MGauge/Load.hpp>
#include <Grid/Hadrons/Modules/GRandom.hpp> #include <Grid/Hadrons/Modules/MGauge/Random.hpp>
#include <Grid/Hadrons/Modules/GUnit.hpp> #include <Grid/Hadrons/Modules/MGauge/Unit.hpp>
#include <Grid/Hadrons/Modules/MQuark.hpp> #include <Grid/Hadrons/Modules/MQuark.hpp>
#include <Grid/Hadrons/Modules/SolRBPrecCG.hpp> #include <Grid/Hadrons/Modules/MSolver/RBPrecCG.hpp>
#include <Grid/Hadrons/Modules/SrcPoint.hpp> #include <Grid/Hadrons/Modules/MSource/Point.hpp>
#include <Grid/Hadrons/Modules/SrcZ2.hpp> #include <Grid/Hadrons/Modules/MSource/Z2.hpp>

View File

@ -1,7 +1,7 @@
/******************************************************************************* /*******************************************************************************
Grid physics library, www.github.com/paboyle/Grid Grid physics library, www.github.com/paboyle/Grid
Source file: programs/Hadrons/ADWF.cc Source file: programs/Hadrons/DWF.cc
Copyright (C) 2016 Copyright (C) 2016
@ -25,28 +25,29 @@ See the full license in the file "LICENSE" in the top level distribution
directory. directory.
*******************************************************************************/ *******************************************************************************/
#include <Grid/Hadrons/Modules/ADWF.hpp> #include <Grid/Hadrons/Modules/MAction/DWF.hpp>
using namespace Grid; using namespace Grid;
using namespace Hadrons; using namespace Hadrons;
using namespace MAction;
/****************************************************************************** /******************************************************************************
* ADWF implementation * * DWF implementation *
******************************************************************************/ ******************************************************************************/
// constructor ///////////////////////////////////////////////////////////////// // constructor /////////////////////////////////////////////////////////////////
ADWF::ADWF(const std::string name) DWF::DWF(const std::string name)
: Module<ADWFPar>(name) : Module<DWFPar>(name)
{} {}
// dependencies/products /////////////////////////////////////////////////////// // dependencies/products ///////////////////////////////////////////////////////
std::vector<std::string> ADWF::getInput(void) std::vector<std::string> DWF::getInput(void)
{ {
std::vector<std::string> in = {par().gauge}; std::vector<std::string> in = {par().gauge};
return in; return in;
} }
std::vector<std::string> ADWF::getOutput(void) std::vector<std::string> DWF::getOutput(void)
{ {
std::vector<std::string> out = {getName()}; std::vector<std::string> out = {getName()};
@ -54,7 +55,7 @@ std::vector<std::string> ADWF::getOutput(void)
} }
// setup /////////////////////////////////////////////////////////////////////// // setup ///////////////////////////////////////////////////////////////////////
void ADWF::setup(void) void DWF::setup(void)
{ {
unsigned int size; unsigned int size;
@ -63,7 +64,7 @@ void ADWF::setup(void)
} }
// execution /////////////////////////////////////////////////////////////////// // execution ///////////////////////////////////////////////////////////////////
void ADWF::execute(void) void DWF::execute(void)
{ {
LOG(Message) << "Setting up domain wall fermion matrix with m= " LOG(Message) << "Setting up domain wall fermion matrix with m= "
<< par().mass << ", M5= " << par().M5 << " and Ls= " << par().mass << ", M5= " << par().M5 << " and Ls= "

View File

@ -1,7 +1,7 @@
/******************************************************************************* /*******************************************************************************
Grid physics library, www.github.com/paboyle/Grid Grid physics library, www.github.com/paboyle/Grid
Source file: programs/Hadrons/ADWF.hpp Source file: programs/Hadrons/DWF.hpp
Copyright (C) 2016 Copyright (C) 2016
@ -25,8 +25,8 @@ See the full license in the file "LICENSE" in the top level distribution
directory. directory.
*******************************************************************************/ *******************************************************************************/
#ifndef Hadrons_ADWF_hpp_ #ifndef Hadrons_DWF_hpp_
#define Hadrons_ADWF_hpp_ #define Hadrons_DWF_hpp_
#include <Grid/Hadrons/Global.hpp> #include <Grid/Hadrons/Global.hpp>
#include <Grid/Hadrons/Module.hpp> #include <Grid/Hadrons/Module.hpp>
@ -37,34 +37,37 @@ BEGIN_HADRONS_NAMESPACE
/****************************************************************************** /******************************************************************************
* Domain wall quark action * * Domain wall quark action *
******************************************************************************/ ******************************************************************************/
class ADWFPar: Serializable namespace MAction
{ {
public: class DWFPar: Serializable
GRID_SERIALIZABLE_CLASS_MEMBERS(ADWFPar, {
std::string, gauge, public:
unsigned int, Ls, GRID_SERIALIZABLE_CLASS_MEMBERS(DWFPar,
double , mass, std::string, gauge,
double , M5); unsigned int, Ls,
}; double , mass,
double , M5);
};
class DWF: public Module<DWFPar>
{
public:
// constructor
DWF(const std::string name);
// destructor
virtual ~DWF(void) = default;
// dependency relation
virtual std::vector<std::string> getInput(void);
virtual std::vector<std::string> getOutput(void);
// setup
virtual void setup(void);
// execution
virtual void execute(void);
};
}
class ADWF: public Module<ADWFPar> MODULE_REGISTER_NS(DWF, MAction);
{
public:
// constructor
ADWF(const std::string name);
// destructor
virtual ~ADWF(void) = default;
// dependency relation
virtual std::vector<std::string> getInput(void);
virtual std::vector<std::string> getOutput(void);
// setup
virtual void setup(void);
// execution
virtual void execute(void);
};
MODULE_REGISTER(ADWF);
END_HADRONS_NAMESPACE END_HADRONS_NAMESPACE
#endif // Hadrons_ADWF_hpp_ #endif // Hadrons_DWF_hpp_

View File

@ -1,7 +1,7 @@
/******************************************************************************* /*******************************************************************************
Grid physics library, www.github.com/paboyle/Grid Grid physics library, www.github.com/paboyle/Grid
Source file: programs/Hadrons/AWilson.cc Source file: programs/Hadrons/Wilson.cc
Copyright (C) 2016 Copyright (C) 2016
@ -25,28 +25,29 @@ See the full license in the file "LICENSE" in the top level distribution
directory. directory.
*******************************************************************************/ *******************************************************************************/
#include <Grid/Hadrons/Modules/AWilson.hpp> #include <Grid/Hadrons/Modules/MAction/Wilson.hpp>
using namespace Grid; using namespace Grid;
using namespace Hadrons; using namespace Hadrons;
using namespace MAction;
/****************************************************************************** /******************************************************************************
* AWilson implementation * * Wilson implementation *
******************************************************************************/ ******************************************************************************/
// constructor ///////////////////////////////////////////////////////////////// // constructor /////////////////////////////////////////////////////////////////
AWilson::AWilson(const std::string name) Wilson::Wilson(const std::string name)
: Module<AWilsonPar>(name) : Module<WilsonPar>(name)
{} {}
// dependencies/products /////////////////////////////////////////////////////// // dependencies/products ///////////////////////////////////////////////////////
std::vector<std::string> AWilson::getInput(void) std::vector<std::string> Wilson::getInput(void)
{ {
std::vector<std::string> in = {par().gauge}; std::vector<std::string> in = {par().gauge};
return in; return in;
} }
std::vector<std::string> AWilson::getOutput(void) std::vector<std::string> Wilson::getOutput(void)
{ {
std::vector<std::string> out = {getName()}; std::vector<std::string> out = {getName()};
@ -54,7 +55,7 @@ std::vector<std::string> AWilson::getOutput(void)
} }
// setup /////////////////////////////////////////////////////////////////////// // setup ///////////////////////////////////////////////////////////////////////
void AWilson::setup(void) void Wilson::setup(void)
{ {
unsigned int size; unsigned int size;
@ -63,7 +64,7 @@ void AWilson::setup(void)
} }
// execution /////////////////////////////////////////////////////////////////// // execution ///////////////////////////////////////////////////////////////////
void AWilson::execute() void Wilson::execute()
{ {
LOG(Message) << "Setting up Wilson fermion matrix with m= " << par().mass LOG(Message) << "Setting up Wilson fermion matrix with m= " << par().mass
<< " using gauge field '" << par().gauge << "'" << std::endl; << " using gauge field '" << par().gauge << "'" << std::endl;

View File

@ -1,7 +1,7 @@
/******************************************************************************* /*******************************************************************************
Grid physics library, www.github.com/paboyle/Grid Grid physics library, www.github.com/paboyle/Grid
Source file: programs/Hadrons/AWilson.hpp Source file: programs/Hadrons/Wilson.hpp
Copyright (C) 2016 Copyright (C) 2016
@ -25,8 +25,8 @@ See the full license in the file "LICENSE" in the top level distribution
directory. directory.
*******************************************************************************/ *******************************************************************************/
#ifndef Hadrons_AWilson_hpp_ #ifndef Hadrons_Wilson_hpp_
#define Hadrons_AWilson_hpp_ #define Hadrons_Wilson_hpp_
#include <Grid/Hadrons/Global.hpp> #include <Grid/Hadrons/Global.hpp>
#include <Grid/Hadrons/Module.hpp> #include <Grid/Hadrons/Module.hpp>
@ -37,32 +37,35 @@ BEGIN_HADRONS_NAMESPACE
/****************************************************************************** /******************************************************************************
* Wilson quark action * * Wilson quark action *
******************************************************************************/ ******************************************************************************/
class AWilsonPar: Serializable namespace MAction
{ {
public: class WilsonPar: Serializable
GRID_SERIALIZABLE_CLASS_MEMBERS(AWilsonPar, {
std::string, gauge, public:
double , mass); GRID_SERIALIZABLE_CLASS_MEMBERS(WilsonPar,
}; std::string, gauge,
double , mass);
};
class AWilson: public Module<AWilsonPar> class Wilson: public Module<WilsonPar>
{ {
public: public:
// constructor // constructor
AWilson(const std::string name); Wilson(const std::string name);
// destructor // destructor
virtual ~AWilson(void) = default; virtual ~Wilson(void) = default;
// dependencies/products // dependencies/products
virtual std::vector<std::string> getInput(void); virtual std::vector<std::string> getInput(void);
virtual std::vector<std::string> getOutput(void); virtual std::vector<std::string> getOutput(void);
// setup // setup
virtual void setup(void); virtual void setup(void);
// execution // execution
virtual void execute(void); virtual void execute(void);
}; };
}
MODULE_REGISTER(AWilson); MODULE_REGISTER_NS(Wilson, MAction);
END_HADRONS_NAMESPACE END_HADRONS_NAMESPACE
#endif // Hadrons_AWilson_hpp_ #endif // Hadrons_Wilson_hpp_

View File

@ -1,7 +1,7 @@
/******************************************************************************* /*******************************************************************************
Grid physics library, www.github.com/paboyle/Grid Grid physics library, www.github.com/paboyle/Grid
Source file: programs/Hadrons/CMeson.cc Source file: programs/Hadrons/Meson.cc
Copyright (C) 2015 Copyright (C) 2015
@ -25,29 +25,30 @@ See the full license in the file "LICENSE" in the top level distribution
directory. directory.
*******************************************************************************/ *******************************************************************************/
#include <Grid/Hadrons/Modules/CMeson.hpp> #include <Grid/Hadrons/Modules/MContraction/Meson.hpp>
using namespace Grid; using namespace Grid;
using namespace QCD; using namespace QCD;
using namespace Hadrons; using namespace Hadrons;
using namespace MContraction;
/****************************************************************************** /******************************************************************************
* CMeson implementation * * Meson implementation *
******************************************************************************/ ******************************************************************************/
// constructor ///////////////////////////////////////////////////////////////// // constructor /////////////////////////////////////////////////////////////////
CMeson::CMeson(const std::string name) Meson::Meson(const std::string name)
: Module<CMesonPar>(name) : Module<MesonPar>(name)
{} {}
// dependencies/products /////////////////////////////////////////////////////// // dependencies/products ///////////////////////////////////////////////////////
std::vector<std::string> CMeson::getInput(void) std::vector<std::string> Meson::getInput(void)
{ {
std::vector<std::string> input = {par().q1, par().q2}; std::vector<std::string> input = {par().q1, par().q2};
return input; return input;
} }
std::vector<std::string> CMeson::getOutput(void) std::vector<std::string> Meson::getOutput(void)
{ {
std::vector<std::string> output = {getName()}; std::vector<std::string> output = {getName()};
@ -55,7 +56,7 @@ std::vector<std::string> CMeson::getOutput(void)
} }
// execution /////////////////////////////////////////////////////////////////// // execution ///////////////////////////////////////////////////////////////////
void CMeson::execute(void) void Meson::execute(void)
{ {
LOG(Message) << "Computing meson contraction '" << getName() << "' using" LOG(Message) << "Computing meson contraction '" << getName() << "' using"
<< " quarks '" << par().q1 << "' and '" << par().q2 << "'" << " quarks '" << par().q1 << "' and '" << par().q2 << "'"

View File

@ -1,7 +1,7 @@
/******************************************************************************* /*******************************************************************************
Grid physics library, www.github.com/paboyle/Grid Grid physics library, www.github.com/paboyle/Grid
Source file: programs/Hadrons/CMeson.hpp Source file: programs/Hadrons/Meson.hpp
Copyright (C) 2015 Copyright (C) 2015
@ -25,8 +25,8 @@ See the full license in the file "LICENSE" in the top level distribution
directory. directory.
*******************************************************************************/ *******************************************************************************/
#ifndef Hadrons_CMeson_hpp_ #ifndef Hadrons_Meson_hpp_
#define Hadrons_CMeson_hpp_ #define Hadrons_Meson_hpp_
#include <Grid/Hadrons/Global.hpp> #include <Grid/Hadrons/Global.hpp>
#include <Grid/Hadrons/Module.hpp> #include <Grid/Hadrons/Module.hpp>
@ -35,40 +35,43 @@ directory.
BEGIN_HADRONS_NAMESPACE BEGIN_HADRONS_NAMESPACE
/****************************************************************************** /******************************************************************************
* CMeson * * Meson *
******************************************************************************/ ******************************************************************************/
class CMesonPar: Serializable namespace MContraction
{ {
public: class MesonPar: Serializable
GRID_SERIALIZABLE_CLASS_MEMBERS(CMesonPar,
std::string, q1,
std::string, q2,
std::string, output);
};
class CMeson: public Module<CMesonPar>
{
public:
class Result: Serializable
{ {
public: public:
GRID_SERIALIZABLE_CLASS_MEMBERS(Result, GRID_SERIALIZABLE_CLASS_MEMBERS(MesonPar,
std::vector<std::vector<std::vector<Complex>>>, corr); std::string, q1,
std::string, q2,
std::string, output);
}; };
public:
// constructor class Meson: public Module<MesonPar>
CMeson(const std::string name); {
// destructor public:
virtual ~CMeson(void) = default; class Result: Serializable
// dependencies/products {
virtual std::vector<std::string> getInput(void); public:
virtual std::vector<std::string> getOutput(void); GRID_SERIALIZABLE_CLASS_MEMBERS(Result,
// execution std::vector<std::vector<std::vector<Complex>>>, corr);
virtual void execute(void); };
}; public:
// constructor
Meson(const std::string name);
// destructor
virtual ~Meson(void) = default;
// dependencies/products
virtual std::vector<std::string> getInput(void);
virtual std::vector<std::string> getOutput(void);
// execution
virtual void execute(void);
};
}
MODULE_REGISTER(CMeson); MODULE_REGISTER_NS(Meson, MContraction);
END_HADRONS_NAMESPACE END_HADRONS_NAMESPACE
#endif // Hadrons_CMeson_hpp_ #endif // Hadrons_Meson_hpp_

View File

@ -1,7 +1,7 @@
/******************************************************************************* /*******************************************************************************
Grid physics library, www.github.com/paboyle/Grid Grid physics library, www.github.com/paboyle/Grid
Source file: programs/Hadrons/GLoad.cc Source file: programs/Hadrons/Load.cc
Copyright (C) 2016 Copyright (C) 2016
@ -25,28 +25,29 @@ See the full license in the file "LICENSE" in the top level distribution
directory. directory.
*******************************************************************************/ *******************************************************************************/
#include <Grid/Hadrons/Modules/GLoad.hpp> #include <Grid/Hadrons/Modules/MGauge/Load.hpp>
using namespace Grid; using namespace Grid;
using namespace Hadrons; using namespace Hadrons;
using namespace MGauge;
/****************************************************************************** /******************************************************************************
* GLoad implementation * * Load implementation *
******************************************************************************/ ******************************************************************************/
// constructor ///////////////////////////////////////////////////////////////// // constructor /////////////////////////////////////////////////////////////////
GLoad::GLoad(const std::string name) Load::Load(const std::string name)
: Module<GLoadPar>(name) : Module<LoadPar>(name)
{} {}
// dependencies/products /////////////////////////////////////////////////////// // dependencies/products ///////////////////////////////////////////////////////
std::vector<std::string> GLoad::getInput(void) std::vector<std::string> Load::getInput(void)
{ {
std::vector<std::string> in; std::vector<std::string> in;
return in; return in;
} }
std::vector<std::string> GLoad::getOutput(void) std::vector<std::string> Load::getOutput(void)
{ {
std::vector<std::string> out = {getName()}; std::vector<std::string> out = {getName()};
@ -54,13 +55,13 @@ std::vector<std::string> GLoad::getOutput(void)
} }
// setup /////////////////////////////////////////////////////////////////////// // setup ///////////////////////////////////////////////////////////////////////
void GLoad::setup(void) void Load::setup(void)
{ {
env().registerLattice<LatticeGaugeField>(getName()); env().registerLattice<LatticeGaugeField>(getName());
} }
// execution /////////////////////////////////////////////////////////////////// // execution ///////////////////////////////////////////////////////////////////
void GLoad::execute(void) void Load::execute(void)
{ {
NerscField header; NerscField header;
std::string fileName = par().file + "." std::string fileName = par().file + "."

View File

@ -1,7 +1,7 @@
/******************************************************************************* /*******************************************************************************
Grid physics library, www.github.com/paboyle/Grid Grid physics library, www.github.com/paboyle/Grid
Source file: programs/Hadrons/GLoad.hpp Source file: programs/Hadrons/Load.hpp
Copyright (C) 2016 Copyright (C) 2016
@ -25,8 +25,8 @@ See the full license in the file "LICENSE" in the top level distribution
directory. directory.
*******************************************************************************/ *******************************************************************************/
#ifndef Hadrons_GLoad_hpp_ #ifndef Hadrons_Load_hpp_
#define Hadrons_GLoad_hpp_ #define Hadrons_Load_hpp_
#include <Grid/Hadrons/Global.hpp> #include <Grid/Hadrons/Global.hpp>
#include <Grid/Hadrons/Module.hpp> #include <Grid/Hadrons/Module.hpp>
@ -37,31 +37,34 @@ BEGIN_HADRONS_NAMESPACE
/****************************************************************************** /******************************************************************************
* Load a NERSC configuration * * Load a NERSC configuration *
******************************************************************************/ ******************************************************************************/
class GLoadPar: Serializable namespace MGauge
{ {
public: class LoadPar: Serializable
GRID_SERIALIZABLE_CLASS_MEMBERS(GLoadPar, {
std::string, file); public:
}; GRID_SERIALIZABLE_CLASS_MEMBERS(LoadPar,
std::string, file);
};
class GLoad: public Module<GLoadPar> class Load: public Module<LoadPar>
{ {
public: public:
// constructor // constructor
GLoad(const std::string name); Load(const std::string name);
// destructor // destructor
virtual ~GLoad(void) = default; virtual ~Load(void) = default;
// dependency relation // dependency relation
virtual std::vector<std::string> getInput(void); virtual std::vector<std::string> getInput(void);
virtual std::vector<std::string> getOutput(void); virtual std::vector<std::string> getOutput(void);
// setup // setup
virtual void setup(void); virtual void setup(void);
// execution // execution
virtual void execute(void); virtual void execute(void);
}; };
}
MODULE_REGISTER(GLoad); MODULE_REGISTER_NS(Load, MGauge);
END_HADRONS_NAMESPACE END_HADRONS_NAMESPACE
#endif // Hadrons_GLoad_hpp_ #endif // Hadrons_Load_hpp_

View File

@ -1,7 +1,7 @@
/******************************************************************************* /*******************************************************************************
Grid physics library, www.github.com/paboyle/Grid Grid physics library, www.github.com/paboyle/Grid
Source file: programs/Hadrons/GRandom.cc Source file: programs/Hadrons/Random.cc
Copyright (C) 2016 Copyright (C) 2016
@ -25,26 +25,27 @@ See the full license in the file "LICENSE" in the top level distribution
directory. directory.
*******************************************************************************/ *******************************************************************************/
#include <Grid/Hadrons/Modules/GRandom.hpp> #include <Grid/Hadrons/Modules/MGauge/Random.hpp>
using namespace Grid; using namespace Grid;
using namespace Hadrons; using namespace Hadrons;
using namespace MGauge;
/****************************************************************************** /******************************************************************************
* GRandom implementation * * Random implementation *
******************************************************************************/ ******************************************************************************/
// constructor ///////////////////////////////////////////////////////////////// // constructor /////////////////////////////////////////////////////////////////
GRandom::GRandom(const std::string name) Random::Random(const std::string name)
: Module<NoPar>(name) : Module<NoPar>(name)
{} {}
// dependencies/products /////////////////////////////////////////////////////// // dependencies/products ///////////////////////////////////////////////////////
std::vector<std::string> GRandom::getInput(void) std::vector<std::string> Random::getInput(void)
{ {
return std::vector<std::string>(); return std::vector<std::string>();
} }
std::vector<std::string> GRandom::getOutput(void) std::vector<std::string> Random::getOutput(void)
{ {
std::vector<std::string> out = {getName()}; std::vector<std::string> out = {getName()};
@ -52,13 +53,13 @@ std::vector<std::string> GRandom::getOutput(void)
} }
// setup /////////////////////////////////////////////////////////////////////// // setup ///////////////////////////////////////////////////////////////////////
void GRandom::setup(void) void Random::setup(void)
{ {
env().registerLattice<LatticeGaugeField>(getName()); env().registerLattice<LatticeGaugeField>(getName());
} }
// execution /////////////////////////////////////////////////////////////////// // execution ///////////////////////////////////////////////////////////////////
void GRandom::execute(void) void Random::execute(void)
{ {
LOG(Message) << "Generating random gauge configuration" << std::endl; LOG(Message) << "Generating random gauge configuration" << std::endl;
LatticeGaugeField &U = *env().createLattice<LatticeGaugeField>(getName()); LatticeGaugeField &U = *env().createLattice<LatticeGaugeField>(getName());

View File

@ -1,7 +1,7 @@
/******************************************************************************* /*******************************************************************************
Grid physics library, www.github.com/paboyle/Grid Grid physics library, www.github.com/paboyle/Grid
Source file: programs/Hadrons/GRandom.hpp Source file: programs/Hadrons/Random.hpp
Copyright (C) 2016 Copyright (C) 2016
@ -25,8 +25,8 @@ See the full license in the file "LICENSE" in the top level distribution
directory. directory.
*******************************************************************************/ *******************************************************************************/
#ifndef Hadrons_GRandom_hpp_ #ifndef Hadrons_Random_hpp_
#define Hadrons_GRandom_hpp_ #define Hadrons_Random_hpp_
#include <Grid/Hadrons/Global.hpp> #include <Grid/Hadrons/Global.hpp>
#include <Grid/Hadrons/Module.hpp> #include <Grid/Hadrons/Module.hpp>
@ -37,24 +37,27 @@ BEGIN_HADRONS_NAMESPACE
/****************************************************************************** /******************************************************************************
* Random gauge * * Random gauge *
******************************************************************************/ ******************************************************************************/
class GRandom: public Module<NoPar> namespace MGauge
{ {
public: class Random: public Module<NoPar>
// constructor {
GRandom(const std::string name); public:
// destructor // constructor
virtual ~GRandom(void) = default; Random(const std::string name);
// dependency relation // destructor
virtual std::vector<std::string> getInput(void); virtual ~Random(void) = default;
virtual std::vector<std::string> getOutput(void); // dependency relation
// setup virtual std::vector<std::string> getInput(void);
virtual void setup(void); virtual std::vector<std::string> getOutput(void);
// execution // setup
virtual void execute(void); virtual void setup(void);
}; // execution
virtual void execute(void);
};
}
MODULE_REGISTER(GRandom); MODULE_REGISTER_NS(Random, MGauge);
END_HADRONS_NAMESPACE END_HADRONS_NAMESPACE
#endif // Hadrons_GRandom_hpp_ #endif // Hadrons_Random_hpp_

View File

@ -1,7 +1,7 @@
/******************************************************************************* /*******************************************************************************
Grid physics library, www.github.com/paboyle/Grid Grid physics library, www.github.com/paboyle/Grid
Source file: programs/Hadrons/GUnit.cc Source file: programs/Hadrons/Unit.cc
Copyright (C) 2016 Copyright (C) 2016
@ -25,26 +25,27 @@ See the full license in the file "LICENSE" in the top level distribution
directory. directory.
*******************************************************************************/ *******************************************************************************/
#include <Grid/Hadrons/Modules/GUnit.hpp> #include <Grid/Hadrons/Modules/MGauge/Unit.hpp>
using namespace Grid; using namespace Grid;
using namespace Hadrons; using namespace Hadrons;
using namespace MGauge;
/****************************************************************************** /******************************************************************************
* GUnit implementation * * Unit implementation *
******************************************************************************/ ******************************************************************************/
// constructor ///////////////////////////////////////////////////////////////// // constructor /////////////////////////////////////////////////////////////////
GUnit::GUnit(const std::string name) Unit::Unit(const std::string name)
: Module<NoPar>(name) : Module<NoPar>(name)
{} {}
// dependencies/products /////////////////////////////////////////////////////// // dependencies/products ///////////////////////////////////////////////////////
std::vector<std::string> GUnit::getInput(void) std::vector<std::string> Unit::getInput(void)
{ {
return std::vector<std::string>(); return std::vector<std::string>();
} }
std::vector<std::string> GUnit::getOutput(void) std::vector<std::string> Unit::getOutput(void)
{ {
std::vector<std::string> out = {getName()}; std::vector<std::string> out = {getName()};
@ -52,13 +53,13 @@ std::vector<std::string> GUnit::getOutput(void)
} }
// setup /////////////////////////////////////////////////////////////////////// // setup ///////////////////////////////////////////////////////////////////////
void GUnit::setup(void) void Unit::setup(void)
{ {
env().registerLattice<LatticeGaugeField>(getName()); env().registerLattice<LatticeGaugeField>(getName());
} }
// execution /////////////////////////////////////////////////////////////////// // execution ///////////////////////////////////////////////////////////////////
void GUnit::execute(void) void Unit::execute(void)
{ {
LOG(Message) << "Creating unit gauge configuration" << std::endl; LOG(Message) << "Creating unit gauge configuration" << std::endl;
LatticeGaugeField &U = *env().createLattice<LatticeGaugeField>(getName()); LatticeGaugeField &U = *env().createLattice<LatticeGaugeField>(getName());

View File

@ -1,7 +1,7 @@
/******************************************************************************* /*******************************************************************************
Grid physics library, www.github.com/paboyle/Grid Grid physics library, www.github.com/paboyle/Grid
Source file: programs/Hadrons/GUnit.hpp Source file: programs/Hadrons/Unit.hpp
Copyright (C) 2016 Copyright (C) 2016
@ -25,8 +25,8 @@ See the full license in the file "LICENSE" in the top level distribution
directory. directory.
*******************************************************************************/ *******************************************************************************/
#ifndef Hadrons_GUnit_hpp_ #ifndef Hadrons_Unit_hpp_
#define Hadrons_GUnit_hpp_ #define Hadrons_Unit_hpp_
#include <Grid/Hadrons/Global.hpp> #include <Grid/Hadrons/Global.hpp>
#include <Grid/Hadrons/Module.hpp> #include <Grid/Hadrons/Module.hpp>
@ -37,24 +37,27 @@ BEGIN_HADRONS_NAMESPACE
/****************************************************************************** /******************************************************************************
* Unit gauge * * Unit gauge *
******************************************************************************/ ******************************************************************************/
class GUnit: public Module<NoPar> namespace MGauge
{ {
public: class Unit: public Module<NoPar>
// constructor {
GUnit(const std::string name); public:
// destructor // constructor
virtual ~GUnit(void) = default; Unit(const std::string name);
// dependencies/products // destructor
virtual std::vector<std::string> getInput(void); virtual ~Unit(void) = default;
virtual std::vector<std::string> getOutput(void); // dependencies/products
// setup virtual std::vector<std::string> getInput(void);
virtual void setup(void); virtual std::vector<std::string> getOutput(void);
// execution // setup
virtual void execute(void); virtual void setup(void);
}; // execution
virtual void execute(void);
};
}
MODULE_REGISTER(GUnit); MODULE_REGISTER_NS(Unit, MGauge);
END_HADRONS_NAMESPACE END_HADRONS_NAMESPACE
#endif // Hadrons_GUnit_hpp_ #endif // Hadrons_Unit_hpp_

View File

@ -76,7 +76,7 @@ void MQuark::execute(void)
<< std::endl; << std::endl;
LatticePropagator &prop = *env().createLattice<LatticePropagator>(propName); LatticePropagator &prop = *env().createLattice<LatticePropagator>(propName);
LatticePropagator &fullSrc = *env().getObject<LatticePropagator>(par().source); LatticePropagator &fullSrc = *env().getObject<LatticePropagator>(par().source);
Solver &solver = *env().getObject<Solver>(par().solver); SolverFn &solver = *env().getObject<SolverFn>(par().solver);
if (Ls_ > 1) if (Ls_ > 1)
{ {
env().createLattice<LatticePropagator>(getName()); env().createLattice<LatticePropagator>(getName());

View File

@ -61,7 +61,7 @@ public:
virtual void execute(void); virtual void execute(void);
private: private:
unsigned int Ls_; unsigned int Ls_;
Solver *solver_{nullptr}; SolverFn *solver_{nullptr};
}; };
MODULE_REGISTER(MQuark); MODULE_REGISTER(MQuark);

View File

@ -1,7 +1,7 @@
/******************************************************************************* /*******************************************************************************
Grid physics library, www.github.com/paboyle/Grid Grid physics library, www.github.com/paboyle/Grid
Source file: programs/Hadrons/SolRBPrecCG.cc Source file: programs/Hadrons/RBPrecCG.cc
Copyright (C) 2016 Copyright (C) 2016
@ -25,29 +25,30 @@ See the full license in the file "LICENSE" in the top level distribution
directory. directory.
*******************************************************************************/ *******************************************************************************/
#include <Grid/Hadrons/Modules/SolRBPrecCG.hpp> #include <Grid/Hadrons/Modules/MSolver/RBPrecCG.hpp>
using namespace Grid; using namespace Grid;
using namespace QCD; using namespace QCD;
using namespace Hadrons; using namespace Hadrons;
using namespace MSolver;
/****************************************************************************** /******************************************************************************
* SolRBPrecCG implementation * * RBPrecCG implementation *
******************************************************************************/ ******************************************************************************/
// constructor ///////////////////////////////////////////////////////////////// // constructor /////////////////////////////////////////////////////////////////
SolRBPrecCG::SolRBPrecCG(const std::string name) RBPrecCG::RBPrecCG(const std::string name)
: Module(name) : Module(name)
{} {}
// dependencies/products /////////////////////////////////////////////////////// // dependencies/products ///////////////////////////////////////////////////////
std::vector<std::string> SolRBPrecCG::getInput(void) std::vector<std::string> RBPrecCG::getInput(void)
{ {
std::vector<std::string> in = {par().action}; std::vector<std::string> in = {par().action};
return in; return in;
} }
std::vector<std::string> SolRBPrecCG::getOutput(void) std::vector<std::string> RBPrecCG::getOutput(void)
{ {
std::vector<std::string> out = {getName()}; std::vector<std::string> out = {getName()};
@ -55,7 +56,7 @@ std::vector<std::string> SolRBPrecCG::getOutput(void)
} }
// setup /////////////////////////////////////////////////////////////////////// // setup ///////////////////////////////////////////////////////////////////////
void SolRBPrecCG::setup(void) void RBPrecCG::setup(void)
{ {
auto Ls = env().getObjectLs(par().action); auto Ls = env().getObjectLs(par().action);
@ -64,7 +65,7 @@ void SolRBPrecCG::setup(void)
} }
// execution /////////////////////////////////////////////////////////////////// // execution ///////////////////////////////////////////////////////////////////
void SolRBPrecCG::execute(void) void RBPrecCG::execute(void)
{ {
auto &mat = *(env().getObject<FMat>(par().action)); auto &mat = *(env().getObject<FMat>(par().action));
auto solver = [&mat, this](LatticeFermion &sol, auto solver = [&mat, this](LatticeFermion &sol,
@ -79,5 +80,5 @@ void SolRBPrecCG::execute(void)
LOG(Message) << "setting up Schur red-black preconditioned CG for" LOG(Message) << "setting up Schur red-black preconditioned CG for"
<< " action '" << par().action << "' with residual " << " action '" << par().action << "' with residual "
<< par().residual << std::endl; << par().residual << std::endl;
env().setObject(getName(), new Solver(solver)); env().setObject(getName(), new SolverFn(solver));
} }

View File

@ -1,7 +1,7 @@
/******************************************************************************* /*******************************************************************************
Grid physics library, www.github.com/paboyle/Grid Grid physics library, www.github.com/paboyle/Grid
Source file: programs/Hadrons/SolRBPrecCG.hpp Source file: programs/Hadrons/RBPrecCG.hpp
Copyright (C) 2016 Copyright (C) 2016
@ -25,8 +25,8 @@ See the full license in the file "LICENSE" in the top level distribution
directory. directory.
*******************************************************************************/ *******************************************************************************/
#ifndef Hadrons_SolRBPrecCG_hpp_ #ifndef Hadrons_RBPrecCG_hpp_
#define Hadrons_SolRBPrecCG_hpp_ #define Hadrons_RBPrecCG_hpp_
#include <Grid/Hadrons/Global.hpp> #include <Grid/Hadrons/Global.hpp>
#include <Grid/Hadrons/Module.hpp> #include <Grid/Hadrons/Module.hpp>
@ -37,32 +37,35 @@ BEGIN_HADRONS_NAMESPACE
/****************************************************************************** /******************************************************************************
* Schur red-black preconditioned CG * * Schur red-black preconditioned CG *
******************************************************************************/ ******************************************************************************/
class SolRBPrecCGPar: Serializable namespace MSolver
{ {
public: class RBPrecCGPar: Serializable
GRID_SERIALIZABLE_CLASS_MEMBERS(SolRBPrecCGPar, {
std::string, action, public:
double , residual); GRID_SERIALIZABLE_CLASS_MEMBERS(RBPrecCGPar,
}; std::string, action,
double , residual);
};
class RBPrecCG: public Module<RBPrecCGPar>
{
public:
// constructor
RBPrecCG(const std::string name);
// destructor
virtual ~RBPrecCG(void) = default;
// dependencies/products
virtual std::vector<std::string> getInput(void);
virtual std::vector<std::string> getOutput(void);
// setup
virtual void setup(void);
// execution
virtual void execute(void);
};
}
class SolRBPrecCG: public Module<SolRBPrecCGPar> MODULE_REGISTER_NS(RBPrecCG, MSolver);
{
public:
// constructor
SolRBPrecCG(const std::string name);
// destructor
virtual ~SolRBPrecCG(void) = default;
// dependencies/products
virtual std::vector<std::string> getInput(void);
virtual std::vector<std::string> getOutput(void);
// setup
virtual void setup(void);
// execution
virtual void execute(void);
};
MODULE_REGISTER(SolRBPrecCG);
END_HADRONS_NAMESPACE END_HADRONS_NAMESPACE
#endif // Hadrons_SolRBPrecCG_hpp_ #endif // Hadrons_RBPrecCG_hpp_

View File

@ -1,7 +1,7 @@
/******************************************************************************* /*******************************************************************************
Grid physics library, www.github.com/paboyle/Grid Grid physics library, www.github.com/paboyle/Grid
Source file: programs/Hadrons/SrcPoint.cc Source file: programs/Hadrons/Point.cc
Copyright (C) 2016 Copyright (C) 2016
@ -25,28 +25,29 @@ See the full license in the file "LICENSE" in the top level distribution
directory. directory.
*******************************************************************************/ *******************************************************************************/
#include <Grid/Hadrons/Modules/SrcPoint.hpp> #include <Grid/Hadrons/Modules/MSource/Point.hpp>
using namespace Grid; using namespace Grid;
using namespace Hadrons; using namespace Hadrons;
using namespace MSource;
/****************************************************************************** /******************************************************************************
* SrcPoint implementation * * Point implementation *
******************************************************************************/ ******************************************************************************/
// constructor ///////////////////////////////////////////////////////////////// // constructor /////////////////////////////////////////////////////////////////
SrcPoint::SrcPoint(const std::string name) Point::Point(const std::string name)
: Module<SrcPointPar>(name) : Module<PointPar>(name)
{} {}
// dependencies/products /////////////////////////////////////////////////////// // dependencies/products ///////////////////////////////////////////////////////
std::vector<std::string> SrcPoint::getInput(void) std::vector<std::string> Point::getInput(void)
{ {
std::vector<std::string> in; std::vector<std::string> in;
return in; return in;
} }
std::vector<std::string> SrcPoint::getOutput(void) std::vector<std::string> Point::getOutput(void)
{ {
std::vector<std::string> out = {getName()}; std::vector<std::string> out = {getName()};
@ -54,13 +55,13 @@ std::vector<std::string> SrcPoint::getOutput(void)
} }
// setup /////////////////////////////////////////////////////////////////////// // setup ///////////////////////////////////////////////////////////////////////
void SrcPoint::setup(void) void Point::setup(void)
{ {
env().registerLattice<PropagatorField>(getName()); env().registerLattice<PropagatorField>(getName());
} }
// execution /////////////////////////////////////////////////////////////////// // execution ///////////////////////////////////////////////////////////////////
void SrcPoint::execute(void) void Point::execute(void)
{ {
std::vector<int> position = strToVec<int>(par().position); std::vector<int> position = strToVec<int>(par().position);
SpinColourMatrix id; SpinColourMatrix id;

View File

@ -1,7 +1,7 @@
/******************************************************************************* /*******************************************************************************
Grid physics library, www.github.com/paboyle/Grid Grid physics library, www.github.com/paboyle/Grid
Source file: programs/Hadrons/SrcPoint.hpp Source file: programs/Hadrons/Point.hpp
Copyright (C) 2016 Copyright (C) 2016
@ -25,8 +25,8 @@ See the full license in the file "LICENSE" in the top level distribution
directory. directory.
*******************************************************************************/ *******************************************************************************/
#ifndef Hadrons_SrcPoint_hpp_ #ifndef Hadrons_Point_hpp_
#define Hadrons_SrcPoint_hpp_ #define Hadrons_Point_hpp_
#include <Grid/Hadrons/Global.hpp> #include <Grid/Hadrons/Global.hpp>
#include <Grid/Hadrons/Module.hpp> #include <Grid/Hadrons/Module.hpp>
@ -46,33 +46,36 @@ BEGIN_HADRONS_NAMESPACE
*/ */
/****************************************************************************** /******************************************************************************
* SrcPoint * * Point *
******************************************************************************/ ******************************************************************************/
class SrcPointPar: Serializable namespace MSource
{ {
public: class PointPar: Serializable
GRID_SERIALIZABLE_CLASS_MEMBERS(SrcPointPar, {
std::string, position); public:
}; GRID_SERIALIZABLE_CLASS_MEMBERS(PointPar,
std::string, position);
};
class Point: public Module<PointPar>
{
public:
// constructor
Point(const std::string name);
// destructor
virtual ~Point(void) = default;
// dependency relation
virtual std::vector<std::string> getInput(void);
virtual std::vector<std::string> getOutput(void);
// setup
virtual void setup(void);
// execution
virtual void execute(void);
};
}
class SrcPoint: public Module<SrcPointPar> MODULE_REGISTER_NS(Point, MSource);
{
public:
// constructor
SrcPoint(const std::string name);
// destructor
virtual ~SrcPoint(void) = default;
// dependency relation
virtual std::vector<std::string> getInput(void);
virtual std::vector<std::string> getOutput(void);
// setup
virtual void setup(void);
// execution
virtual void execute(void);
};
MODULE_REGISTER(SrcPoint);
END_HADRONS_NAMESPACE END_HADRONS_NAMESPACE
#endif // Hadrons_SrcPoint_hpp_ #endif // Hadrons_Point_hpp_

View File

@ -1,7 +1,7 @@
/******************************************************************************* /*******************************************************************************
Grid physics library, www.github.com/paboyle/Grid Grid physics library, www.github.com/paboyle/Grid
Source file: programs/Hadrons/SrcZ2.cc Source file: programs/Hadrons/Z2.cc
Copyright (C) 2016 Copyright (C) 2016
@ -25,28 +25,29 @@ See the full license in the file "LICENSE" in the top level distribution
directory. directory.
*******************************************************************************/ *******************************************************************************/
#include <Grid/Hadrons/Modules/SrcZ2.hpp> #include <Grid/Hadrons/Modules/MSource/Z2.hpp>
using namespace Grid; using namespace Grid;
using namespace Hadrons; using namespace Hadrons;
using namespace MSource;
/****************************************************************************** /******************************************************************************
* SrcZ2 implementation * * Z2 implementation *
******************************************************************************/ ******************************************************************************/
// constructor ///////////////////////////////////////////////////////////////// // constructor /////////////////////////////////////////////////////////////////
SrcZ2::SrcZ2(const std::string name) Z2::Z2(const std::string name)
: Module<SrcZ2Par>(name) : Module<Z2Par>(name)
{} {}
// dependencies/products /////////////////////////////////////////////////////// // dependencies/products ///////////////////////////////////////////////////////
std::vector<std::string> SrcZ2::getInput(void) std::vector<std::string> Z2::getInput(void)
{ {
std::vector<std::string> in; std::vector<std::string> in;
return in; return in;
} }
std::vector<std::string> SrcZ2::getOutput(void) std::vector<std::string> Z2::getOutput(void)
{ {
std::vector<std::string> out = {getName()}; std::vector<std::string> out = {getName()};
@ -54,13 +55,13 @@ std::vector<std::string> SrcZ2::getOutput(void)
} }
// setup /////////////////////////////////////////////////////////////////////// // setup ///////////////////////////////////////////////////////////////////////
void SrcZ2::setup(void) void Z2::setup(void)
{ {
env().registerLattice<PropagatorField>(getName()); env().registerLattice<PropagatorField>(getName());
} }
// execution /////////////////////////////////////////////////////////////////// // execution ///////////////////////////////////////////////////////////////////
void SrcZ2::execute(void) void Z2::execute(void)
{ {
Lattice<iScalar<vInteger>> t(env().getGrid()); Lattice<iScalar<vInteger>> t(env().getGrid());
LatticeComplex eta(env().getGrid()); LatticeComplex eta(env().getGrid());

View File

@ -1,7 +1,7 @@
/******************************************************************************* /*******************************************************************************
Grid physics library, www.github.com/paboyle/Grid Grid physics library, www.github.com/paboyle/Grid
Source file: programs/Hadrons/SrcZ2.hpp Source file: programs/Hadrons/Z2.hpp
Copyright (C) 2016 Copyright (C) 2016
@ -25,8 +25,8 @@ See the full license in the file "LICENSE" in the top level distribution
directory. directory.
*******************************************************************************/ *******************************************************************************/
#ifndef Hadrons_SrcZ2_hpp_ #ifndef Hadrons_Z2_hpp_
#define Hadrons_SrcZ2_hpp_ #define Hadrons_Z2_hpp_
#include <Grid/Hadrons/Global.hpp> #include <Grid/Hadrons/Global.hpp>
#include <Grid/Hadrons/Module.hpp> #include <Grid/Hadrons/Module.hpp>
@ -47,34 +47,37 @@ BEGIN_HADRONS_NAMESPACE
*/ */
/****************************************************************************** /******************************************************************************
* SrcZ2 * * Z2 *
******************************************************************************/ ******************************************************************************/
class SrcZ2Par: Serializable namespace MSource
{ {
public: class Z2Par: Serializable
GRID_SERIALIZABLE_CLASS_MEMBERS(SrcZ2Par, {
unsigned int, tA, public:
unsigned int, tB); GRID_SERIALIZABLE_CLASS_MEMBERS(Z2Par,
}; unsigned int, tA,
unsigned int, tB);
};
class SrcZ2: public Module<SrcZ2Par> class Z2: public Module<Z2Par>
{ {
public: public:
// constructor // constructor
SrcZ2(const std::string name); Z2(const std::string name);
// destructor // destructor
virtual ~SrcZ2(void) = default; virtual ~Z2(void) = default;
// dependency relation // dependency relation
virtual std::vector<std::string> getInput(void); virtual std::vector<std::string> getInput(void);
virtual std::vector<std::string> getOutput(void); virtual std::vector<std::string> getOutput(void);
// setup // setup
virtual void setup(void); virtual void setup(void);
// execution // execution
virtual void execute(void); virtual void execute(void);
}; };
}
MODULE_REGISTER(SrcZ2); MODULE_REGISTER_NS(Z2, MSource);
END_HADRONS_NAMESPACE END_HADRONS_NAMESPACE
#endif // Hadrons_SrcZ2_hpp_ #endif // Hadrons_Z2_hpp_

View File

@ -1,4 +1,4 @@
#include <Hadrons/___FILEBASENAME___.hpp> #include <Grid/Hadrons/Modules/___FILEBASENAME___.hpp>
using namespace Grid; using namespace Grid;
using namespace Hadrons; using namespace Hadrons;

View File

@ -1,9 +1,9 @@
#ifndef Hadrons____FILEBASENAME____hpp_ #ifndef Hadrons____FILEBASENAME____hpp_
#define Hadrons____FILEBASENAME____hpp_ #define Hadrons____FILEBASENAME____hpp_
#include <Hadrons/Global.hpp> #include <Grid/Hadrons/Global.hpp>
#include <Hadrons/Module.hpp> #include <Grid/Hadrons/Module.hpp>
#include <Hadrons/ModuleFactory.hpp> #include <Grid/Hadrons/ModuleFactory.hpp>
BEGIN_HADRONS_NAMESPACE BEGIN_HADRONS_NAMESPACE

View File

@ -0,0 +1,40 @@
#include <Grid/Hadrons/Modules/___NAMESPACE___/___FILEBASENAME___.hpp>
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<std::string> ___FILEBASENAME___::getInput(void)
{
std::vector<std::string> in;
return in;
}
std::vector<std::string> ___FILEBASENAME___::getOutput(void)
{
std::vector<std::string> out = {getName()};
return out;
}
// setup ///////////////////////////////////////////////////////////////////////
void ___FILEBASENAME___::setup(void)
{
}
// execution ///////////////////////////////////////////////////////////////////
void ___FILEBASENAME___::execute(void)
{
}

View File

@ -0,0 +1,43 @@
#ifndef Hadrons____FILEBASENAME____hpp_
#define Hadrons____FILEBASENAME____hpp_
#include <Grid/Hadrons/Global.hpp>
#include <Grid/Hadrons/Module.hpp>
#include <Grid/Hadrons/ModuleFactory.hpp>
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<std::string> getInput(void);
virtual std::vector<std::string> getOutput(void);
// setup
virtual void setup(void);
// execution
virtual void execute(void);
};
}
MODULE_REGISTER_NS(___FILEBASENAME___, ___NAMESPACE___);
END_HADRONS_NAMESPACE
#endif // Hadrons____FILEBASENAME____hpp_

View File

@ -1,15 +1,31 @@
#!/usr/bin/env bash #!/usr/bin/env bash
if (( $# != 1 )); then if (( $# != 1 && $# != 2)); then
echo "usage: `basename $0` <module name>" 1>&2 echo "usage: `basename $0` <module name> [<namespace>]" 1>&2
exit 1 exit 1
fi fi
NAME=$1 NAME=$1
NS=$2
if [ -e "Modules/${NAME}.cc" ] || [ -e "Modules/${NAME}.hpp" ]; then if (( $# == 1 )); then
echo "error: files Modules/${NAME}.* already exists" 1>&2 if [ -e "Modules/${NAME}.cc" ] || [ -e "Modules/${NAME}.hpp" ]; then
exit 1 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 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 ./make_module_list.sh

View File

@ -1,24 +1,24 @@
modules_cc =\ modules_cc =\
Modules/ADWF.cc \ Modules/MAction/DWF.cc \
Modules/AWilson.cc \ Modules/MAction/Wilson.cc \
Modules/CMeson.cc \ Modules/MContraction/Meson.cc \
Modules/GLoad.cc \ Modules/MGauge/Load.cc \
Modules/GRandom.cc \ Modules/MGauge/Random.cc \
Modules/GUnit.cc \ Modules/MGauge/Unit.cc \
Modules/MQuark.cc \ Modules/MQuark.cc \
Modules/SolRBPrecCG.cc \ Modules/MSolver/RBPrecCG.cc \
Modules/SrcPoint.cc \ Modules/MSource/Point.cc \
Modules/SrcZ2.cc Modules/MSource/Z2.cc
modules_hpp =\ modules_hpp =\
Modules/ADWF.hpp \ Modules/MAction/DWF.hpp \
Modules/AWilson.hpp \ Modules/MAction/Wilson.hpp \
Modules/CMeson.hpp \ Modules/MContraction/Meson.hpp \
Modules/GLoad.hpp \ Modules/MGauge/Load.hpp \
Modules/GRandom.hpp \ Modules/MGauge/Random.hpp \
Modules/GUnit.hpp \ Modules/MGauge/Unit.hpp \
Modules/MQuark.hpp \ Modules/MQuark.hpp \
Modules/SolRBPrecCG.hpp \ Modules/MSolver/RBPrecCG.hpp \
Modules/SrcPoint.hpp \ Modules/MSource/Point.hpp \
Modules/SrcZ2.hpp Modules/MSource/Z2.hpp

View File

@ -28,7 +28,6 @@
#include <Grid/Hadrons/Application.hpp> #include <Grid/Hadrons/Application.hpp>
using namespace Grid; using namespace Grid;
using namespace QCD;
using namespace Hadrons; using namespace Hadrons;
int main(int argc, char *argv[]) int main(int argc, char *argv[])
@ -56,30 +55,31 @@ int main(int argc, char *argv[])
globalPar.seed = "1 2 3 4"; globalPar.seed = "1 2 3 4";
application.setPar(globalPar); application.setPar(globalPar);
// gauge field // gauge field
application.createModule<GUnit>("gauge"); application.createModule<MGauge::Unit>("gauge");
// sources // sources
SrcZ2::Par z2Par; MSource::Z2::Par z2Par;
z2Par.tA = 0; z2Par.tA = 0;
z2Par.tB = 0; z2Par.tB = 0;
application.createModule<SrcZ2>("z2", z2Par); application.createModule<MSource::Z2>("z2", z2Par);
SrcPoint::Par ptPar; MSource::Point::Par ptPar;
ptPar.position = "0 0 0 0"; ptPar.position = "0 0 0 0";
application.createModule<SrcPoint>("pt", ptPar); application.createModule<MSource::Point>("pt", ptPar);
for (unsigned int i = 0; i < flavour.size(); ++i) for (unsigned int i = 0; i < flavour.size(); ++i)
{ {
// actions // actions
ADWF::Par actionPar; MAction::DWF::Par actionPar;
actionPar.gauge = "gauge"; actionPar.gauge = "gauge";
actionPar.Ls = 12; actionPar.Ls = 12;
actionPar.M5 = 1.8; actionPar.M5 = 1.8;
actionPar.mass = mass[i]; actionPar.mass = mass[i];
application.createModule<ADWF>("DWF_" + flavour[i], actionPar); application.createModule<MAction::DWF>("DWF_" + flavour[i], actionPar);
// solvers // solvers
SolRBPrecCG::Par solverPar; MSolver::RBPrecCG::Par solverPar;
solverPar.action = "DWF_" + flavour[i]; solverPar.action = "DWF_" + flavour[i];
solverPar.residual = 1.0e-8; solverPar.residual = 1.0e-8;
application.createModule<SolRBPrecCG>("CG_" + flavour[i], solverPar); application.createModule<MSolver::RBPrecCG>("CG_" + flavour[i],
solverPar);
// propagators // propagators
MQuark::Par quarkPar; 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 i = 0; i < flavour.size(); ++i)
for (unsigned int j = i + 1; j < flavour.size(); ++j) 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.output = "mesons/" + flavour[i] + flavour[j];
mesPar.q1 = "Q_" + flavour[i]; mesPar.q1 = "Q_" + flavour[i];
mesPar.q2 = "Q_" + flavour[j]; mesPar.q2 = "Q_" + flavour[j];
application.createModule<CMeson>("meson_" + flavour[i] + flavour[j], application.createModule<MContraction::Meson>("meson_"
mesPar); + flavour[i] + flavour[j],
mesPar);
} }
// execution // execution