mirror of
https://github.com/paboyle/Grid.git
synced 2025-04-10 14:10:46 +01:00
Hadrons: Fermion actions and gauge fields are modules now
This commit is contained in:
parent
6e83b6a203
commit
02ec23cdad
@ -26,10 +26,8 @@ directory.
|
||||
*******************************************************************************/
|
||||
|
||||
#include <Hadrons/AWilson.hpp>
|
||||
#include <Hadrons/Environment.hpp>
|
||||
|
||||
using namespace Grid;
|
||||
using namespace QCD;
|
||||
using namespace Hadrons;
|
||||
|
||||
/******************************************************************************
|
||||
@ -37,7 +35,7 @@ using namespace Hadrons;
|
||||
******************************************************************************/
|
||||
// constructor /////////////////////////////////////////////////////////////////
|
||||
AWilson::AWilson(const std::string name)
|
||||
: FermionAction(name)
|
||||
: Module(name)
|
||||
{}
|
||||
|
||||
// parse parameters ////////////////////////////////////////////////////////////
|
||||
@ -46,12 +44,28 @@ void AWilson::parseParameters(XmlReader &reader, const std::string name)
|
||||
read(reader, name, par_);
|
||||
}
|
||||
|
||||
// create operator /////////////////////////////////////////////////////////////
|
||||
void AWilson::create(Environment &env)
|
||||
// dependencies/products ///////////////////////////////////////////////////////
|
||||
std::vector<std::string> AWilson::getInput(void)
|
||||
{
|
||||
auto &U = *env.getGauge();
|
||||
std::vector<std::string> in = {par_.gauge};
|
||||
|
||||
return in;
|
||||
}
|
||||
|
||||
std::vector<std::string> AWilson::getOutput(void)
|
||||
{
|
||||
std::vector<std::string> out = {getName()};
|
||||
|
||||
return out;
|
||||
}
|
||||
|
||||
// execution ///////////////////////////////////////////////////////////////////
|
||||
void AWilson::execute(Environment &env)
|
||||
{
|
||||
auto &U = *env.getGauge(par_.gauge);
|
||||
auto &grid = *env.getGrid();
|
||||
auto &gridRb = *env.getRbGrid();
|
||||
|
||||
setFMat(new WilsonFermionR(U, grid, gridRb, par_.mass));
|
||||
env.addFermionMatrix(getName(),
|
||||
new WilsonFermionR(U, grid, gridRb, par_.mass));
|
||||
}
|
||||
|
@ -29,21 +29,22 @@ directory.
|
||||
#define Hadrons_AWilson_hpp_
|
||||
|
||||
#include <Hadrons/Global.hpp>
|
||||
#include <Hadrons/FermionAction.hpp>
|
||||
#include <Hadrons/FermionActionFactory.hpp>
|
||||
#include <Hadrons/Module.hpp>
|
||||
#include <Hadrons/ModuleFactory.hpp>
|
||||
|
||||
BEGIN_HADRONS_NAMESPACE
|
||||
|
||||
/******************************************************************************
|
||||
* Wilson fermions *
|
||||
* Wilson quark action *
|
||||
******************************************************************************/
|
||||
class AWilson: public FermionAction
|
||||
class AWilson: public Module
|
||||
{
|
||||
public:
|
||||
class Par: Serializable
|
||||
{
|
||||
public:
|
||||
GRID_SERIALIZABLE_CLASS_MEMBERS(Par, double, mass);
|
||||
GRID_SERIALIZABLE_CLASS_MEMBERS(Par, std::string, gauge,
|
||||
double , mass);
|
||||
};
|
||||
public:
|
||||
// constructor
|
||||
@ -52,13 +53,16 @@ public:
|
||||
virtual ~AWilson(void) = default;
|
||||
// parse parameters
|
||||
virtual void parseParameters(XmlReader &reader, const std::string name);
|
||||
// create operator
|
||||
virtual void create(Environment &env);
|
||||
// dependencies/products
|
||||
virtual std::vector<std::string> getInput(void);
|
||||
virtual std::vector<std::string> getOutput(void);
|
||||
// execution
|
||||
virtual void execute(Environment &env);
|
||||
private:
|
||||
Par par_;
|
||||
};
|
||||
|
||||
ACTION_REGISTER(AWilson);
|
||||
MODULE_REGISTER(AWilson);
|
||||
|
||||
END_HADRONS_NAMESPACE
|
||||
|
||||
|
@ -39,17 +39,10 @@ using namespace Hadrons;
|
||||
Application::Application(const std::string parameterFileName)
|
||||
: parameterFileName_(parameterFileName)
|
||||
, env_(Environment::getInstance())
|
||||
, actionFactory_(FermionActionFactory::getInstance())
|
||||
, modFactory_(ModuleFactory::getInstance())
|
||||
{
|
||||
LOG(Message) << "Fermion actions available:" << std::endl;
|
||||
auto list = actionFactory_.getBuilderList();
|
||||
for (auto &m: list)
|
||||
{
|
||||
LOG(Message) << " " << m << std::endl;
|
||||
}
|
||||
LOG(Message) << "Modules available:" << std::endl;
|
||||
list = modFactory_.getBuilderList();
|
||||
auto list = modFactory_.getBuilderList();
|
||||
for (auto &m: list)
|
||||
{
|
||||
LOG(Message) << " " << m << std::endl;
|
||||
@ -84,18 +77,6 @@ void Application::parseParameterFile(void)
|
||||
|
||||
LOG(Message) << "Reading '" << parameterFileName_ << "'..." << std::endl;
|
||||
read(reader, "parameters", par_);
|
||||
push(reader, "actions");
|
||||
push(reader, "action");
|
||||
do
|
||||
{
|
||||
read(reader, "id", id);
|
||||
env_.addFermionAction(actionFactory_.create(id.type, id.name));
|
||||
auto &action = *env_.getFermionAction(id.name);
|
||||
action.parseParameters(reader, "options");
|
||||
action.create(env_);
|
||||
} while (reader.nextElement("action"));
|
||||
pop(reader);
|
||||
pop(reader);
|
||||
push(reader, "modules");
|
||||
push(reader, "module");
|
||||
do
|
||||
@ -190,7 +171,6 @@ void Application::configLoop(void)
|
||||
{
|
||||
LOG(Message) << "Starting measurement for trajectory " << t
|
||||
<< std::endl;
|
||||
env_.loadUnitGauge();
|
||||
execute(program_);
|
||||
env_.freeAll();
|
||||
}
|
||||
@ -219,8 +199,8 @@ unsigned int Application::execute(const std::vector<std::string> &program)
|
||||
}
|
||||
for (unsigned int i = 0; i < program.size(); ++i)
|
||||
{
|
||||
LOG(Message) << "Measurement step (" << i+1 << "/" << program.size()
|
||||
<< ")" << std::endl;
|
||||
LOG(Message) << "Measurement step " << i+1 << "/" << program.size()
|
||||
<< " (module '" << program[i] << "')" << std::endl;
|
||||
(*module_[program[i]])(env_);
|
||||
LOG(Message) << "allocated propagators: " << env_.nProp() << std::endl;
|
||||
if (env_.nProp() > memPeak)
|
||||
|
@ -29,7 +29,6 @@ directory.
|
||||
#define Hadrons_Application_hpp_
|
||||
|
||||
#include <Hadrons/Global.hpp>
|
||||
#include <Hadrons/FermionActionFactory.hpp>
|
||||
#include <Hadrons/Environment.hpp>
|
||||
#include <Hadrons/ModuleFactory.hpp>
|
||||
|
||||
@ -90,7 +89,6 @@ private:
|
||||
std::string parameterFileName_;
|
||||
GlobalPar par_;
|
||||
Environment &env_;
|
||||
FermionActionFactory &actionFactory_;
|
||||
ModuleFactory &modFactory_;
|
||||
std::map<std::string, std::unique_ptr<Module>> module_;
|
||||
std::map<std::string, std::string> associatedModule_;
|
||||
|
@ -45,7 +45,7 @@ void CMeson::parseParameters(XmlReader &reader, const std::string name)
|
||||
read(reader, name, par_);
|
||||
}
|
||||
|
||||
// dependency relation /////////////////////////////////////////////////////////
|
||||
// dependencies/products ///////////////////////////////////////////////////////
|
||||
std::vector<std::string> CMeson::getInput(void)
|
||||
{
|
||||
std::vector<std::string> input = {par_.q1, par_.q2};
|
||||
|
@ -61,7 +61,7 @@ public:
|
||||
virtual ~CMeson(void) = default;
|
||||
// parse parameters
|
||||
virtual void parseParameters(XmlReader &reader, const std::string name);
|
||||
// dependency relation
|
||||
// dependencies/products
|
||||
virtual std::vector<std::string> getInput(void);
|
||||
virtual std::vector<std::string> getOutput(void);
|
||||
// execution
|
||||
|
@ -42,8 +42,6 @@ Environment::Environment(void)
|
||||
GridDefaultMpi()));
|
||||
gridRb4d_.reset(SpaceTimeGrid::makeFourDimRedBlackGrid(grid4d_.get()));
|
||||
rng4d_.reset(new GridParallelRNG(grid4d_.get()));
|
||||
gauge_.reset(new LatticeGaugeField(grid4d_.get()));
|
||||
loadUnitGauge();
|
||||
}
|
||||
|
||||
// dry run /////////////////////////////////////////////////////////////////////
|
||||
@ -97,22 +95,22 @@ GridRedBlackCartesian * Environment::getRbGrid(const unsigned int Ls) const
|
||||
}
|
||||
|
||||
// fermion actions /////////////////////////////////////////////////////////////
|
||||
void Environment::addFermionAction(FActionPt action)
|
||||
void Environment::addFermionMatrix(const std::string name, FMat *fMat)
|
||||
{
|
||||
fAction_[action->getName()] = std::move(action);
|
||||
fMat_[name].reset(fMat);
|
||||
}
|
||||
|
||||
FermionAction * Environment::getFermionAction(const std::string name) const
|
||||
Environment::FMat * Environment::getFermionMatrix(const std::string name) const
|
||||
{
|
||||
try
|
||||
{
|
||||
return fAction_.at(name).get();
|
||||
return fMat_.at(name).get();
|
||||
}
|
||||
catch(std::out_of_range &)
|
||||
{
|
||||
try
|
||||
{
|
||||
return fAction_.at(solverAction_.at(name)).get();
|
||||
return fMat_.at(solverAction_.at(name)).get();
|
||||
}
|
||||
catch (std::out_of_range &)
|
||||
{
|
||||
@ -143,9 +141,9 @@ void Environment::callSolver(const std::string name, LatticeFermion &sol,
|
||||
}
|
||||
|
||||
// quark propagators ///////////////////////////////////////////////////////////
|
||||
void Environment::addProp(const std::string name, const unsigned int Ls)
|
||||
void Environment::createProp(const std::string name, const unsigned int Ls)
|
||||
{
|
||||
GridCartesian *p4 = grid4d_.get();
|
||||
GridCartesian *g4 = getGrid();
|
||||
|
||||
if (propExists(name))
|
||||
{
|
||||
@ -153,21 +151,21 @@ void Environment::addProp(const std::string name, const unsigned int Ls)
|
||||
}
|
||||
if (Ls > 1)
|
||||
{
|
||||
GridCartesian *p;
|
||||
GridCartesian *g;
|
||||
|
||||
try
|
||||
{
|
||||
p = grid5d_.at(Ls).get();
|
||||
g = grid5d_.at(Ls).get();
|
||||
}
|
||||
catch(std::out_of_range &)
|
||||
{
|
||||
grid5d_[Ls].reset(SpaceTimeGrid::makeFiveDimGrid(Ls, p4));
|
||||
gridRb5d_[Ls].reset(SpaceTimeGrid::makeFiveDimRedBlackGrid(Ls, p4));
|
||||
p = grid5d_[Ls].get();
|
||||
grid5d_[Ls].reset(SpaceTimeGrid::makeFiveDimGrid(Ls, g4));
|
||||
gridRb5d_[Ls].reset(SpaceTimeGrid::makeFiveDimRedBlackGrid(Ls, g4));
|
||||
g = grid5d_[Ls].get();
|
||||
}
|
||||
if (!isDryRun())
|
||||
{
|
||||
prop_[name].reset(new LatticePropagator(p));
|
||||
prop_[name].reset(new LatticePropagator(g));
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -179,7 +177,7 @@ void Environment::addProp(const std::string name, const unsigned int Ls)
|
||||
{
|
||||
if (!isDryRun())
|
||||
{
|
||||
prop_[name].reset(new LatticePropagator(p4));
|
||||
prop_[name].reset(new LatticePropagator(g4));
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -269,19 +267,44 @@ unsigned int Environment::nProp(void) const
|
||||
}
|
||||
|
||||
// gauge configuration /////////////////////////////////////////////////////////
|
||||
LatticeGaugeField * Environment::getGauge(void) const
|
||||
void Environment::createGauge(const std::string name)
|
||||
{
|
||||
return gauge_.get();
|
||||
if (gaugeExists(name))
|
||||
{
|
||||
HADRON_ERROR("gauge field '" + name + "' already exists");
|
||||
}
|
||||
gauge_[name].reset(new LatticeGaugeField(getGrid()));
|
||||
}
|
||||
|
||||
void Environment::loadUnitGauge(void)
|
||||
void Environment::freeGauge(const std::string name)
|
||||
{
|
||||
SU3::ColdConfiguration(*rng4d_, *gauge_);
|
||||
if (gaugeExists(name))
|
||||
{
|
||||
gauge_.erase(name);
|
||||
}
|
||||
else
|
||||
{
|
||||
HADRON_ERROR("trying to free unknown gauge field '" + name + "'");
|
||||
}
|
||||
}
|
||||
|
||||
void Environment::loadRandomGauge(void)
|
||||
LatticeGaugeField * Environment::getGauge(const std::string name) const
|
||||
{
|
||||
SU3::HotConfiguration(*rng4d_, *gauge_);
|
||||
if (gaugeExists(name))
|
||||
{
|
||||
return gauge_.at(name).get();
|
||||
}
|
||||
else
|
||||
{
|
||||
HADRON_ERROR("gauge field '" + name + "' unknown");
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
bool Environment::gaugeExists(const std::string name) const
|
||||
{
|
||||
return (gauge_.find(name) != gauge_.end());
|
||||
}
|
||||
|
||||
// random number generator /////////////////////////////////////////////////////
|
||||
@ -300,13 +323,19 @@ void Environment::free(const std::string name)
|
||||
{
|
||||
if (propExists(name))
|
||||
{
|
||||
LOG(Message) << "freeing '" << name << "'" << std::endl;
|
||||
LOG(Message) << "freeing propagator '" << name << "'" << std::endl;
|
||||
freeProp(name);
|
||||
}
|
||||
else if (gaugeExists(name))
|
||||
{
|
||||
LOG(Message) << "freeing gauge field '" << name << "'" << std::endl;
|
||||
freeGauge(name);
|
||||
}
|
||||
}
|
||||
|
||||
void Environment::freeAll(void)
|
||||
{
|
||||
prop_.clear();
|
||||
propSize_.clear();
|
||||
gauge_.clear();
|
||||
}
|
||||
|
@ -29,7 +29,6 @@ directory.
|
||||
#define Hadrons_Environment_hpp_
|
||||
|
||||
#include <Hadrons/Global.hpp>
|
||||
#include <Hadrons/FermionAction.hpp>
|
||||
|
||||
BEGIN_HADRONS_NAMESPACE
|
||||
|
||||
@ -40,12 +39,13 @@ class Environment
|
||||
{
|
||||
SINGLETON(Environment);
|
||||
public:
|
||||
typedef FermionOperator<WilsonImplR> FMat;
|
||||
typedef std::function<void(LatticeFermion &,
|
||||
const LatticeFermion &)> Solver;
|
||||
typedef std::unique_ptr<GridCartesian> GridPt;
|
||||
typedef std::unique_ptr<GridRedBlackCartesian> GridRbPt;
|
||||
typedef std::unique_ptr<GridParallelRNG> RngPt;
|
||||
typedef std::unique_ptr<FermionAction> FActionPt;
|
||||
typedef std::unique_ptr<FMat> FMatPt;
|
||||
typedef std::unique_ptr<LatticePropagator> PropPt;
|
||||
typedef std::unique_ptr<LatticeGaugeField> GaugePt;
|
||||
public:
|
||||
@ -56,8 +56,8 @@ public:
|
||||
GridCartesian * getGrid(const unsigned int Ls = 1) const;
|
||||
GridRedBlackCartesian * getRbGrid(const unsigned int Ls = 1) const;
|
||||
// fermion actions
|
||||
void addFermionAction(FActionPt action);
|
||||
FermionAction * getFermionAction(const std::string name) const;
|
||||
void addFermionMatrix(const std::string name, FMat *mat);
|
||||
FMat * getFermionMatrix(const std::string name) const;
|
||||
// solvers
|
||||
void addSolver(const std::string name, Solver s,
|
||||
const std::string actionName);
|
||||
@ -65,7 +65,7 @@ public:
|
||||
LatticeFermion &sol,
|
||||
const LatticeFermion &src) const;
|
||||
// quark propagators
|
||||
void addProp(const std::string name,
|
||||
void createProp(const std::string name,
|
||||
const unsigned int Ls = 1);
|
||||
void freeProp(const std::string name);
|
||||
bool isProp5d(const std::string name) const;
|
||||
@ -73,10 +73,11 @@ public:
|
||||
LatticePropagator * getProp(const std::string name) const;
|
||||
bool propExists(const std::string name) const;
|
||||
unsigned int nProp(void) const;
|
||||
// gauge configuration
|
||||
LatticeGaugeField * getGauge(void) const;
|
||||
void loadUnitGauge(void);
|
||||
void loadRandomGauge(void);
|
||||
// gauge configurations
|
||||
void createGauge(const std::string name);
|
||||
void freeGauge(const std::string name);
|
||||
LatticeGaugeField * getGauge(const std::string name) const;
|
||||
bool gaugeExists(const std::string name) const;
|
||||
// random number generator
|
||||
void setSeed(const std::vector<int> &seed);
|
||||
GridParallelRNG * get4dRng(void) const;
|
||||
@ -90,13 +91,12 @@ private:
|
||||
GridRbPt gridRb4d_;
|
||||
std::map<unsigned int, GridRbPt> gridRb5d_;
|
||||
RngPt rng4d_;
|
||||
std::map<std::string, FActionPt> fAction_;
|
||||
std::map<std::string, FMatPt> fMat_;
|
||||
std::map<std::string, Solver> solver_;
|
||||
std::map<std::string, std::string> solverAction_;
|
||||
std::map<std::string, PropPt> prop_;
|
||||
std::map<std::string, unsigned int> propSize_;
|
||||
GaugePt gauge_;
|
||||
|
||||
std::map<std::string, GaugePt> gauge_;
|
||||
};
|
||||
|
||||
END_HADRONS_NAMESPACE
|
||||
|
@ -1,83 +0,0 @@
|
||||
/*******************************************************************************
|
||||
Grid physics library, www.github.com/paboyle/Grid
|
||||
|
||||
Source file: programs/Hadrons/FermionAction.hpp
|
||||
|
||||
Copyright (C) 2016
|
||||
|
||||
Author: Antonin Portelli <antonin.portelli@me.com>
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License along
|
||||
with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
|
||||
See the full license in the file "LICENSE" in the top level distribution
|
||||
directory.
|
||||
*******************************************************************************/
|
||||
|
||||
#ifndef Hadrons_FermionAction_hpp_
|
||||
#define Hadrons_FermionAction_hpp_
|
||||
|
||||
#include <Hadrons/Global.hpp>
|
||||
|
||||
BEGIN_HADRONS_NAMESPACE
|
||||
|
||||
// action registration macro
|
||||
#define ACTION_REGISTER(action)\
|
||||
class action##ActionRegistrar\
|
||||
{\
|
||||
public:\
|
||||
action##ActionRegistrar(void)\
|
||||
{\
|
||||
FermionActionFactory &actionFac = FermionActionFactory::getInstance();\
|
||||
actionFac.registerBuilder(#action, [&](const std::string name)\
|
||||
{\
|
||||
return std::unique_ptr<action>(\
|
||||
new action(name));\
|
||||
});\
|
||||
}\
|
||||
};\
|
||||
static action##ActionRegistrar action##ActionRegistrarInstance;
|
||||
|
||||
/******************************************************************************
|
||||
* FermionAction *
|
||||
******************************************************************************/
|
||||
class Environment;
|
||||
|
||||
class FermionAction
|
||||
{
|
||||
public:
|
||||
typedef FermionOperator<WilsonImplR> FMat;
|
||||
typedef std::unique_ptr<FMat> FMatPt;
|
||||
public:
|
||||
// constructor
|
||||
FermionAction(const std::string name);
|
||||
// destructor
|
||||
virtual ~FermionAction(void) = default;
|
||||
// access
|
||||
std::string getName(void) const;
|
||||
virtual unsigned int getLs(void) const;
|
||||
void setFMat(FMat *fMat);
|
||||
FMat * getFMat(void);
|
||||
// parse parameters
|
||||
virtual void parseParameters(XmlReader &reader, const std::string name) = 0;
|
||||
// create operator
|
||||
virtual void create(Environment &env) = 0;
|
||||
private:
|
||||
std::string name_;
|
||||
FMatPt fMat_;
|
||||
};
|
||||
|
||||
END_HADRONS_NAMESPACE
|
||||
|
||||
#endif // Hadrons_FermionAction_hpp_
|
@ -1,7 +1,7 @@
|
||||
/*******************************************************************************
|
||||
Grid physics library, www.github.com/paboyle/Grid
|
||||
|
||||
Source file: programs/Hadrons/FermionAction.cc
|
||||
Source file: programs/Hadrons/GUnit.cc
|
||||
|
||||
Copyright (C) 2016
|
||||
|
||||
@ -25,37 +25,41 @@ See the full license in the file "LICENSE" in the top level distribution
|
||||
directory.
|
||||
*******************************************************************************/
|
||||
|
||||
#include <Hadrons/FermionAction.hpp>
|
||||
#include <Hadrons/GUnit.hpp>
|
||||
|
||||
using namespace Grid;
|
||||
using namespace QCD;
|
||||
using namespace Hadrons;
|
||||
|
||||
/******************************************************************************
|
||||
* FermionAction implementation *
|
||||
* GUnit implementation *
|
||||
******************************************************************************/
|
||||
// constructor /////////////////////////////////////////////////////////////////
|
||||
FermionAction::FermionAction(const std::string name)
|
||||
: name_(name)
|
||||
GUnit::GUnit(const std::string name)
|
||||
: Module(name)
|
||||
{}
|
||||
|
||||
// access //////////////////////////////////////////////////////////////////////
|
||||
std::string FermionAction::getName(void) const
|
||||
// dependencies/products ///////////////////////////////////////////////////////
|
||||
std::vector<std::string> GUnit::getInput(void)
|
||||
{
|
||||
return name_;
|
||||
return std::vector<std::string>();
|
||||
}
|
||||
|
||||
unsigned int FermionAction::getLs(void) const
|
||||
std::vector<std::string> GUnit::getOutput(void)
|
||||
{
|
||||
return 1;
|
||||
std::vector<std::string> out = {getName()};
|
||||
|
||||
return out;
|
||||
}
|
||||
|
||||
void FermionAction::setFMat(FMat *fMat)
|
||||
// allocation //////////////////////////////////////////////////////////////////
|
||||
void GUnit::allocate(Environment &env)
|
||||
{
|
||||
fMat_.reset(fMat);
|
||||
env.createGauge(getName());
|
||||
gauge_ = env.getGauge(getName());
|
||||
}
|
||||
|
||||
FermionAction::FMat * FermionAction::getFMat(void)
|
||||
// execution ///////////////////////////////////////////////////////////////////
|
||||
void GUnit::execute(Environment &env)
|
||||
{
|
||||
return fMat_.get();
|
||||
SU3::ColdConfiguration(*env.get4dRng(), *gauge_);
|
||||
}
|
@ -1,7 +1,7 @@
|
||||
/*******************************************************************************
|
||||
Grid physics library, www.github.com/paboyle/Grid
|
||||
|
||||
Source file: programs/Hadrons/FermionActionFactory.hpp
|
||||
Source file: programs/Hadrons/GUnit.hpp
|
||||
|
||||
Copyright (C) 2016
|
||||
|
||||
@ -25,23 +25,38 @@ See the full license in the file "LICENSE" in the top level distribution
|
||||
directory.
|
||||
*******************************************************************************/
|
||||
|
||||
#ifndef Hadrons_FermionActionFactory_hpp_
|
||||
#define Hadrons_FermionActionFactory_hpp_
|
||||
#ifndef Hadrons_GUnit_hpp_
|
||||
#define Hadrons_GUnit_hpp_
|
||||
|
||||
#include <Hadrons/Global.hpp>
|
||||
#include <Hadrons/Factory.hpp>
|
||||
#include <Hadrons/FermionAction.hpp>
|
||||
#include <Hadrons/Module.hpp>
|
||||
#include <Hadrons/ModuleFactory.hpp>
|
||||
|
||||
BEGIN_HADRONS_NAMESPACE
|
||||
|
||||
/******************************************************************************
|
||||
* FermionActionFactory *
|
||||
* Unit gauge *
|
||||
******************************************************************************/
|
||||
class FermionActionFactory: public Factory<FermionAction>
|
||||
class GUnit: public Module
|
||||
{
|
||||
SINGLETON_DEFCTOR(FermionActionFactory)
|
||||
public:
|
||||
// constructor
|
||||
GUnit(const std::string name);
|
||||
// destructor
|
||||
virtual ~GUnit(void) = default;
|
||||
// dependencies/products
|
||||
virtual std::vector<std::string> getInput(void);
|
||||
virtual std::vector<std::string> getOutput(void);
|
||||
// allocation
|
||||
virtual void allocate(Environment &env);
|
||||
// execution
|
||||
virtual void execute(Environment &env);
|
||||
private:
|
||||
LatticeGaugeField *gauge_ = nullptr;
|
||||
};
|
||||
|
||||
MODULE_REGISTER(GUnit);
|
||||
|
||||
END_HADRONS_NAMESPACE
|
||||
|
||||
#endif // Hadrons_FermionActionFactory_hpp_
|
||||
#endif // Hadrons_GUnit_hpp_
|
@ -39,13 +39,13 @@ MQuark::MQuark(const std::string name)
|
||||
: Module(name)
|
||||
{}
|
||||
|
||||
// parse parameters
|
||||
// parse parameters ////////////////////////////////////////////////////////////
|
||||
void MQuark::parseParameters(XmlReader &reader, const std::string name)
|
||||
{
|
||||
read(reader, name, par_);
|
||||
}
|
||||
|
||||
// dependency relation
|
||||
// dependencies/products ///////////////////////////////////////////////////////
|
||||
std::vector<std::string> MQuark::getInput(void)
|
||||
{
|
||||
std::vector<std::string> in = {par_.source, par_.solver};
|
||||
@ -63,22 +63,31 @@ std::vector<std::string> MQuark::getOutput(void)
|
||||
// setup ///////////////////////////////////////////////////////////////////////
|
||||
void MQuark::setup(Environment &env)
|
||||
{
|
||||
Ls_ = env.getFermionAction(par_.solver)->getLs();
|
||||
auto dim = env.getFermionMatrix(par_.solver)->Grid()->GlobalDimensions();
|
||||
|
||||
if (dim.size() == Nd)
|
||||
{
|
||||
Ls_ = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
Ls_ = dim[0];
|
||||
}
|
||||
}
|
||||
|
||||
// allocation //////////////////////////////////////////////////////////////////
|
||||
void MQuark::allocate(Environment &env)
|
||||
{
|
||||
env.addProp(getName());
|
||||
env.createProp(getName());
|
||||
quark_ = env.getProp(getName());
|
||||
if (Ls_ > 1)
|
||||
{
|
||||
env.addProp(getName() + "_5d", Ls_);
|
||||
env.createProp(getName() + "_5d", Ls_);
|
||||
quark5d_ = env.getProp(getName() + "_5d");
|
||||
}
|
||||
}
|
||||
|
||||
// execution
|
||||
// execution ///////////////////////////////////////////////////////////////////
|
||||
void MQuark::execute(Environment &env)
|
||||
{
|
||||
LatticePropagator *fullSource;
|
||||
|
@ -53,7 +53,7 @@ public:
|
||||
virtual ~MQuark(void) = default;
|
||||
// parse parameters
|
||||
virtual void parseParameters(XmlReader &reader, const std::string name);
|
||||
// dependency relation
|
||||
// dependencies/products
|
||||
virtual std::vector<std::string> getInput(void);
|
||||
virtual std::vector<std::string> getOutput(void);
|
||||
// setup
|
||||
|
@ -41,13 +41,13 @@ MSource::MSource(const std::string name)
|
||||
: Module(name)
|
||||
{}
|
||||
|
||||
// parse parameters
|
||||
// parse parameters ////////////////////////////////////////////////////////////
|
||||
void MSource::parseParameters(XmlReader &reader, const std::string name)
|
||||
{
|
||||
read(reader, name, par_);
|
||||
}
|
||||
|
||||
// dependency relation
|
||||
// dependencies/products ///////////////////////////////////////////////////////
|
||||
std::vector<std::string> MSource::getInput(void)
|
||||
{
|
||||
return std::vector<std::string>();
|
||||
@ -68,7 +68,7 @@ void MSource::allocate(Environment &env)
|
||||
// 4D sources
|
||||
case Grid::SourceType::point:
|
||||
case Grid::SourceType::z2Band:
|
||||
env.addProp(getName());
|
||||
env.createProp(getName());
|
||||
src_ = env.getProp(getName());
|
||||
break;
|
||||
// error
|
||||
|
@ -84,7 +84,7 @@ public:
|
||||
virtual ~MSource(void) = default;
|
||||
// parse parameters
|
||||
virtual void parseParameters(XmlReader &reader, const std::string name);
|
||||
// dependency relation
|
||||
// dependencies/products
|
||||
virtual std::vector<std::string> getInput(void);
|
||||
virtual std::vector<std::string> getOutput(void);
|
||||
// allocation
|
||||
|
@ -3,30 +3,33 @@ AM_LDFLAGS = -L$(top_builddir)/lib
|
||||
|
||||
bin_PROGRAMS = Hadrons
|
||||
|
||||
## general sources
|
||||
# general sources
|
||||
Hadrons_SOURCES = \
|
||||
Application.cc \
|
||||
Environment.cc \
|
||||
FermionAction.cc\
|
||||
Global.cc \
|
||||
Hadrons.cc \
|
||||
Module.cc
|
||||
|
||||
## fermion actions
|
||||
Hadrons_SOURCES += \
|
||||
AWilson.cc
|
||||
|
||||
## general modules
|
||||
# general modules
|
||||
Hadrons_SOURCES += \
|
||||
MQuark.cc \
|
||||
MSource.cc
|
||||
|
||||
## solver modules
|
||||
# fermion actions
|
||||
Hadrons_SOURCES += \
|
||||
SRBPrecCG.cc
|
||||
AWilson.cc
|
||||
|
||||
## contraction modules
|
||||
# contraction modules
|
||||
Hadrons_SOURCES += \
|
||||
CMeson.cc
|
||||
|
||||
# gauge modules
|
||||
Hadrons_SOURCES += \
|
||||
GUnit.cc
|
||||
|
||||
# solver modules
|
||||
Hadrons_SOURCES += \
|
||||
SRBPrecCG.cc
|
||||
|
||||
Hadrons_LDADD = -lGrid
|
||||
|
@ -62,8 +62,8 @@ public:
|
||||
// access
|
||||
std::string getName(void) const;
|
||||
// parse parameters
|
||||
virtual void parseParameters(XmlReader &reader, const std::string name) = 0;
|
||||
// dependency relation
|
||||
virtual void parseParameters(XmlReader &reader, const std::string name) {};
|
||||
// dependencies/products
|
||||
virtual std::vector<std::string> getInput(void) = 0;
|
||||
virtual std::vector<std::string> getOutput(void) = 0;
|
||||
// setup
|
||||
|
@ -39,16 +39,18 @@ SRBPrecCG::SRBPrecCG(const std::string name)
|
||||
: Module(name)
|
||||
{}
|
||||
|
||||
// parse parameters
|
||||
// parse parameters ////////////////////////////////////////////////////////////
|
||||
void SRBPrecCG::parseParameters(XmlReader &reader, const std::string name)
|
||||
{
|
||||
read(reader, name, par_);
|
||||
}
|
||||
|
||||
// dependency relation
|
||||
// dependencies/products ///////////////////////////////////////////////////////
|
||||
std::vector<std::string> SRBPrecCG::getInput(void)
|
||||
{
|
||||
return std::vector<std::string>();
|
||||
std::vector<std::string> in = {par_.action};
|
||||
|
||||
return in;
|
||||
}
|
||||
|
||||
std::vector<std::string> SRBPrecCG::getOutput(void)
|
||||
@ -61,7 +63,7 @@ std::vector<std::string> SRBPrecCG::getOutput(void)
|
||||
// execution ///////////////////////////////////////////////////////////////////
|
||||
void SRBPrecCG::execute(Environment &env)
|
||||
{
|
||||
auto &mat = *(env.getFermionAction(par_.action)->getFMat());
|
||||
auto &mat = *(env.getFermionMatrix(par_.action));
|
||||
auto solver = [&mat, this](LatticeFermion &sol,
|
||||
const LatticeFermion &source)
|
||||
{
|
||||
|
@ -35,7 +35,7 @@ directory.
|
||||
BEGIN_HADRONS_NAMESPACE
|
||||
|
||||
/******************************************************************************
|
||||
* SRBPrecCG *
|
||||
* Schur red-black preconditioned CG *
|
||||
******************************************************************************/
|
||||
class SRBPrecCG: public Module
|
||||
{
|
||||
@ -53,7 +53,7 @@ public:
|
||||
virtual ~SRBPrecCG(void) = default;
|
||||
// parse parameters
|
||||
virtual void parseParameters(XmlReader &reader, const std::string name);
|
||||
// dependency relation
|
||||
// dependencies/products
|
||||
virtual std::vector<std::string> getInput(void);
|
||||
virtual std::vector<std::string> getOutput(void);
|
||||
// execution
|
||||
|
Loading…
x
Reference in New Issue
Block a user