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

Now action factory support different Fields (templated)

This commit is contained in:
Guido Cossu 2017-01-30 14:22:41 +00:00
parent f05d0565aa
commit 16be6d378c
3 changed files with 29 additions and 31 deletions

View File

@ -269,10 +269,7 @@ private:
// here gauge
Read.push("Action");
do{
// I need to modify the Factory generator depending on the Implementation
// Solution: pass the field as a template parameter
//auto &ActionFactory = HMC_ScalarActionModuleFactory<gauge_string, ReaderClass>::getInstance();
auto &ActionFactory = HMC_LGTActionModuleFactory<gauge_string, ReaderClass>::getInstance();
auto &ActionFactory = HMC_ActionModuleFactory<gauge_string, typename ImplementationPolicy::Field, ReaderClass>::getInstance();
std::string action_type;
Read.readDefault("name", action_type);
std::cout << ActionFactory.getBuilderList() << std::endl; // temporary

View File

@ -486,31 +486,31 @@ class OneFlavourRatioEOFModule:
// Registar must be changed because I do not want to use the ModuleFactory
// explicit ref to LatticeGaugeField must be changed or put in the factory
typedef ActionModuleBase< QCD::Action< QCD::LatticeGaugeField >, QCD::GridModule > HMC_LGTActionModBase;
typedef ActionModuleBase< QCD::Action< QCD::LatticeReal >, QCD::GridModule > HMC_ScalarActionModBase;
//typedef ActionModuleBase< QCD::Action< QCD::LatticeGaugeField >, QCD::GridModule > HMC_LGTActionModBase;
//typedef ActionModuleBase< QCD::Action< QCD::LatticeReal >, QCD::GridModule > HMC_ScalarActionModBase;
template <char const *str, class ReaderClass >
class HMC_LGTActionModuleFactory
: public Factory < HMC_LGTActionModBase , Reader<ReaderClass> > {
template <char const *str, class Field, class ReaderClass >
class HMC_ActionModuleFactory
: public Factory < ActionModuleBase< QCD::Action< Field >, QCD::GridModule > , Reader<ReaderClass> > {
public:
typedef Reader<ReaderClass> TheReader;
// use SINGLETON FUNCTOR MACRO HERE
HMC_LGTActionModuleFactory(const HMC_LGTActionModuleFactory& e) = delete;
void operator=(const HMC_LGTActionModuleFactory& e) = delete;
static HMC_LGTActionModuleFactory& getInstance(void) {
static HMC_LGTActionModuleFactory e;
HMC_ActionModuleFactory(const HMC_ActionModuleFactory& e) = delete;
void operator=(const HMC_ActionModuleFactory& e) = delete;
static HMC_ActionModuleFactory& getInstance(void) {
static HMC_ActionModuleFactory e;
return e;
}
private:
HMC_LGTActionModuleFactory(void) = default;
HMC_ActionModuleFactory(void) = default;
std::string obj_type() const {
return std::string(str);
}
};
/*
template <char const *str, class ReaderClass >
class HMC_ScalarActionModuleFactory
: public Factory < HMC_ScalarActionModBase , Reader<ReaderClass> > {
@ -530,8 +530,7 @@ class HMC_ScalarActionModuleFactory
return std::string(str);
}
};
*/
extern char gauge_string[];
} // Grid

View File

@ -30,6 +30,8 @@ directory
#ifndef MODULES_REGISTRATION_H
#define MODULES_REGISTRATION_H
// simplify with macros
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Actions
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@ -40,31 +42,31 @@ typedef QCD::DBW2GModule<ImplementationPolicy> DBW2GMod;
typedef QCD::RBCGModule<ImplementationPolicy> RBCGMod;
typedef QCD::PlaqPlusRectangleGModule<ImplementationPolicy> PlaqPlusRectangleGMod;
static Registrar<QCD::WilsonGMod, HMC_LGTActionModuleFactory<gauge_string, Serialiser> > __WGmodXMLInit("Wilson");
static Registrar<QCD::SymanzikGMod, HMC_LGTActionModuleFactory<gauge_string, Serialiser> > __SymGmodXMLInit("Symanzik");
static Registrar<QCD::IwasakiGMod, HMC_LGTActionModuleFactory<gauge_string, Serialiser> > __IwGmodXMLInit("Iwasaki");
static Registrar<QCD::DBW2GMod, HMC_LGTActionModuleFactory<gauge_string, Serialiser> > __DBW2GmodXMLInit("DBW2");
static Registrar<QCD::RBCGMod, HMC_LGTActionModuleFactory<gauge_string, Serialiser> > __RBCGmodXMLInit("RBC");
static Registrar<QCD::PlaqPlusRectangleGMod, HMC_LGTActionModuleFactory<gauge_string, Serialiser> > __PPRectGmodXMLInit("PlaqPlusRect");
static Registrar<QCD::WilsonGMod, HMC_ActionModuleFactory<gauge_string, typename ImplementationPolicy::Field, Serialiser> > __WGmodXMLInit("Wilson");
static Registrar<QCD::SymanzikGMod, HMC_ActionModuleFactory<gauge_string, typename ImplementationPolicy::Field, Serialiser> > __SymGmodXMLInit("Symanzik");
static Registrar<QCD::IwasakiGMod, HMC_ActionModuleFactory<gauge_string, typename ImplementationPolicy::Field, Serialiser> > __IwGmodXMLInit("Iwasaki");
static Registrar<QCD::DBW2GMod, HMC_ActionModuleFactory<gauge_string, typename ImplementationPolicy::Field, Serialiser> > __DBW2GmodXMLInit("DBW2");
static Registrar<QCD::RBCGMod, HMC_ActionModuleFactory<gauge_string, typename ImplementationPolicy::Field, Serialiser> > __RBCGmodXMLInit("RBC");
static Registrar<QCD::PlaqPlusRectangleGMod, HMC_ActionModuleFactory<gauge_string, typename ImplementationPolicy::Field, Serialiser> > __PPRectGmodXMLInit("PlaqPlusRect");
// FIXME more general implementation
static Registrar<QCD::TwoFlavourFModule<FermionImplementationPolicy> ,
HMC_LGTActionModuleFactory<gauge_string, Serialiser> > __TwoFlavourFmodXMLInit("TwoFlavours");
HMC_ActionModuleFactory<gauge_string, typename ImplementationPolicy::Field, Serialiser> > __TwoFlavourFmodXMLInit("TwoFlavours");
static Registrar<QCD::TwoFlavourRatioFModule<FermionImplementationPolicy> ,
HMC_LGTActionModuleFactory<gauge_string, Serialiser> > __TwoFlavourRatioFmodXMLInit("TwoFlavoursRatio");
HMC_ActionModuleFactory<gauge_string, typename ImplementationPolicy::Field, Serialiser> > __TwoFlavourRatioFmodXMLInit("TwoFlavoursRatio");
static Registrar<QCD::TwoFlavourEOFModule<FermionImplementationPolicy> ,
HMC_LGTActionModuleFactory<gauge_string, Serialiser> > __TwoFlavourEOFmodXMLInit("TwoFlavoursEvenOdd");
HMC_ActionModuleFactory<gauge_string, typename ImplementationPolicy::Field, Serialiser> > __TwoFlavourEOFmodXMLInit("TwoFlavoursEvenOdd");
static Registrar<QCD::TwoFlavourRatioEOFModule<FermionImplementationPolicy>,
HMC_LGTActionModuleFactory<gauge_string, Serialiser> > __TwoFlavourRatioEOFmodXMLInit("TwoFlavoursEvenOddRatio");
HMC_ActionModuleFactory<gauge_string, typename ImplementationPolicy::Field, Serialiser> > __TwoFlavourRatioEOFmodXMLInit("TwoFlavoursEvenOddRatio");
static Registrar<QCD::OneFlavourFModule<FermionImplementationPolicy> ,
HMC_LGTActionModuleFactory<gauge_string, Serialiser> > __OneFlavourFmodXMLInit("OneFlavour");
HMC_ActionModuleFactory<gauge_string, typename ImplementationPolicy::Field, Serialiser> > __OneFlavourFmodXMLInit("OneFlavour");
static Registrar<QCD::OneFlavourEOFModule<FermionImplementationPolicy> ,
HMC_LGTActionModuleFactory<gauge_string, Serialiser> > __OneFlavourEOFmodXMLInit("OneFlavourEvenOdd");
HMC_ActionModuleFactory<gauge_string, typename ImplementationPolicy::Field, Serialiser> > __OneFlavourEOFmodXMLInit("OneFlavourEvenOdd");
static Registrar<QCD::OneFlavourRatioFModule<FermionImplementationPolicy> ,
HMC_LGTActionModuleFactory<gauge_string, Serialiser> > __OneFlavourRatioFmodXMLInit("OneFlavourRatio");
HMC_ActionModuleFactory<gauge_string, typename ImplementationPolicy::Field, Serialiser> > __OneFlavourRatioFmodXMLInit("OneFlavourRatio");
static Registrar<QCD::OneFlavourRatioEOFModule<FermionImplementationPolicy>,
HMC_LGTActionModuleFactory<gauge_string, Serialiser> > __OneFlavourRatioEOFmodXMLInit("OneFlavourEvenOddRatio");
HMC_ActionModuleFactory<gauge_string, typename ImplementationPolicy::Field, Serialiser> > __OneFlavourRatioEOFmodXMLInit("OneFlavourEvenOddRatio");