2017-06-08 02:10:48 +01:00
|
|
|
#ifndef Hadrons_MFermion_GaugeProp_hpp_
|
|
|
|
#define Hadrons_MFermion_GaugeProp_hpp_
|
2015-12-23 14:21:35 +00:00
|
|
|
|
2016-12-05 07:47:29 +00:00
|
|
|
#include <Grid/Hadrons/Global.hpp>
|
|
|
|
#include <Grid/Hadrons/Module.hpp>
|
|
|
|
#include <Grid/Hadrons/ModuleFactory.hpp>
|
|
|
|
|
|
|
|
BEGIN_HADRONS_NAMESPACE
|
|
|
|
|
|
|
|
/******************************************************************************
|
2017-06-08 02:10:48 +01:00
|
|
|
* GaugeProp *
|
2016-12-05 07:47:29 +00:00
|
|
|
******************************************************************************/
|
2017-06-08 02:10:48 +01:00
|
|
|
BEGIN_MODULE_NAMESPACE(MFermion)
|
|
|
|
|
|
|
|
class GaugePropPar: Serializable
|
2016-12-05 07:47:29 +00:00
|
|
|
{
|
|
|
|
public:
|
2017-06-08 02:10:48 +01:00
|
|
|
GRID_SERIALIZABLE_CLASS_MEMBERS(GaugePropPar,
|
2016-12-05 07:47:29 +00:00
|
|
|
std::string, source,
|
|
|
|
std::string, solver);
|
|
|
|
};
|
|
|
|
|
|
|
|
template <typename FImpl>
|
2017-06-08 02:10:48 +01:00
|
|
|
class TGaugeProp: public Module<GaugePropPar>
|
2016-12-05 07:47:29 +00:00
|
|
|
{
|
|
|
|
public:
|
2017-06-06 17:45:30 +01:00
|
|
|
FGS_TYPE_ALIASES(FImpl,);
|
2016-12-05 07:47:29 +00:00
|
|
|
public:
|
|
|
|
// constructor
|
2017-06-08 02:10:48 +01:00
|
|
|
TGaugeProp(const std::string name);
|
2016-12-05 07:47:29 +00:00
|
|
|
// destructor
|
2017-06-08 02:10:48 +01:00
|
|
|
virtual ~TGaugeProp(void) = default;
|
|
|
|
// dependency relation
|
2016-12-05 07:47:29 +00:00
|
|
|
virtual std::vector<std::string> getInput(void);
|
|
|
|
virtual std::vector<std::string> getOutput(void);
|
|
|
|
// setup
|
|
|
|
virtual void setup(void);
|
|
|
|
// execution
|
|
|
|
virtual void execute(void);
|
|
|
|
private:
|
|
|
|
unsigned int Ls_;
|
|
|
|
SolverFn *solver_{nullptr};
|
|
|
|
};
|
2015-12-23 14:21:35 +00:00
|
|
|
|
2017-06-08 02:10:48 +01:00
|
|
|
MODULE_REGISTER_NS(GaugeProp, TGaugeProp<FIMPL>, MFermion);
|
2016-12-14 17:59:45 +00:00
|
|
|
|
2015-12-23 14:21:35 +00:00
|
|
|
/******************************************************************************
|
2017-06-08 02:10:48 +01:00
|
|
|
* TGaugeProp implementation *
|
2015-12-23 14:21:35 +00:00
|
|
|
******************************************************************************/
|
|
|
|
// constructor /////////////////////////////////////////////////////////////////
|
2016-12-05 07:47:29 +00:00
|
|
|
template <typename FImpl>
|
2017-06-08 02:10:48 +01:00
|
|
|
TGaugeProp<FImpl>::TGaugeProp(const std::string name)
|
|
|
|
: Module<GaugePropPar>(name)
|
2015-12-23 14:21:35 +00:00
|
|
|
{}
|
|
|
|
|
2016-05-04 00:30:29 +01:00
|
|
|
// dependencies/products ///////////////////////////////////////////////////////
|
2016-12-05 07:47:29 +00:00
|
|
|
template <typename FImpl>
|
2017-06-08 02:10:48 +01:00
|
|
|
std::vector<std::string> TGaugeProp<FImpl>::getInput(void)
|
2015-12-23 14:21:35 +00:00
|
|
|
{
|
2016-05-12 11:59:28 +01:00
|
|
|
std::vector<std::string> in = {par().source, par().solver};
|
2016-04-30 08:17:04 +01:00
|
|
|
|
|
|
|
return in;
|
2015-12-23 14:21:35 +00:00
|
|
|
}
|
|
|
|
|
2016-12-05 07:47:29 +00:00
|
|
|
template <typename FImpl>
|
2017-06-08 02:10:48 +01:00
|
|
|
std::vector<std::string> TGaugeProp<FImpl>::getOutput(void)
|
2015-12-23 14:21:35 +00:00
|
|
|
{
|
2015-12-23 14:30:33 +00:00
|
|
|
std::vector<std::string> out = {getName(), getName() + "_5d"};
|
2015-12-23 14:21:35 +00:00
|
|
|
|
|
|
|
return out;
|
|
|
|
}
|
|
|
|
|
2016-04-30 08:17:04 +01:00
|
|
|
// setup ///////////////////////////////////////////////////////////////////////
|
2016-12-05 07:47:29 +00:00
|
|
|
template <typename FImpl>
|
2017-06-08 02:10:48 +01:00
|
|
|
void TGaugeProp<FImpl>::setup(void)
|
2016-04-30 08:17:04 +01:00
|
|
|
{
|
2016-06-06 17:45:37 +01:00
|
|
|
Ls_ = env().getObjectLs(par().solver);
|
2016-12-05 07:47:29 +00:00
|
|
|
env().template registerLattice<PropagatorField>(getName());
|
2016-04-30 08:17:04 +01:00
|
|
|
if (Ls_ > 1)
|
2016-01-14 04:23:51 +00:00
|
|
|
{
|
2016-12-05 07:47:29 +00:00
|
|
|
env().template registerLattice<PropagatorField>(getName() + "_5d", Ls_);
|
2016-01-14 04:23:51 +00:00
|
|
|
}
|
2015-12-23 14:21:35 +00:00
|
|
|
}
|
|
|
|
|
2016-05-04 00:30:29 +01:00
|
|
|
// execution ///////////////////////////////////////////////////////////////////
|
2016-12-05 07:47:29 +00:00
|
|
|
template <typename FImpl>
|
2017-06-08 02:10:48 +01:00
|
|
|
void TGaugeProp<FImpl>::execute(void)
|
2015-12-23 14:21:35 +00:00
|
|
|
{
|
2016-05-04 20:17:27 +01:00
|
|
|
LOG(Message) << "Computing quark propagator '" << getName() << "'"
|
2017-06-08 02:10:48 +01:00
|
|
|
<< std::endl;
|
2016-12-05 07:47:29 +00:00
|
|
|
|
|
|
|
FermionField source(env().getGrid(Ls_)), sol(env().getGrid(Ls_)),
|
2017-06-08 02:10:48 +01:00
|
|
|
tmp(env().getGrid());
|
2016-12-05 07:47:29 +00:00
|
|
|
std::string propName = (Ls_ == 1) ? getName() : (getName() + "_5d");
|
|
|
|
PropagatorField &prop = *env().template createLattice<PropagatorField>(propName);
|
|
|
|
PropagatorField &fullSrc = *env().template getObject<PropagatorField>(par().source);
|
|
|
|
SolverFn &solver = *env().template getObject<SolverFn>(par().solver);
|
2016-05-12 18:34:42 +01:00
|
|
|
if (Ls_ > 1)
|
|
|
|
{
|
2016-12-05 07:47:29 +00:00
|
|
|
env().template createLattice<PropagatorField>(getName());
|
2016-05-12 18:34:42 +01:00
|
|
|
}
|
2016-12-05 07:47:29 +00:00
|
|
|
|
2016-05-12 11:59:28 +01:00
|
|
|
LOG(Message) << "Inverting using solver '" << par().solver
|
2017-06-08 02:10:48 +01:00
|
|
|
<< "' on source '" << par().source << "'" << std::endl;
|
2016-05-12 11:59:28 +01:00
|
|
|
for (unsigned int s = 0; s < Ns; ++s)
|
|
|
|
for (unsigned int c = 0; c < Nc; ++c)
|
2016-04-30 08:17:04 +01:00
|
|
|
{
|
2016-06-06 17:45:37 +01:00
|
|
|
LOG(Message) << "Inversion for spin= " << s << ", color= " << c
|
2017-06-08 02:10:48 +01:00
|
|
|
<< std::endl;
|
2016-05-12 11:59:28 +01:00
|
|
|
// source conversion for 4D sources
|
|
|
|
if (!env().isObject5d(par().source))
|
2016-04-30 08:17:04 +01:00
|
|
|
{
|
2016-05-12 11:59:28 +01:00
|
|
|
if (Ls_ == 1)
|
|
|
|
{
|
|
|
|
PropToFerm(source, fullSrc, s, c);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2016-05-12 18:34:42 +01:00
|
|
|
source = zero;
|
2016-05-12 11:59:28 +01:00
|
|
|
PropToFerm(tmp, fullSrc, s, c);
|
2016-05-12 18:34:42 +01:00
|
|
|
InsertSlice(tmp, source, 0, 0);
|
|
|
|
InsertSlice(tmp, source, Ls_-1, 0);
|
2016-05-12 12:49:49 +01:00
|
|
|
axpby_ssp_pplus(source, 0., source, 1., source, 0, 0);
|
|
|
|
axpby_ssp_pminus(source, 0., source, 1., source, Ls_-1, Ls_-1);
|
2016-05-12 11:59:28 +01:00
|
|
|
}
|
2016-04-30 08:17:04 +01:00
|
|
|
}
|
2016-05-12 11:59:28 +01:00
|
|
|
// source conversion for 5D sources
|
2016-04-30 08:17:04 +01:00
|
|
|
else
|
|
|
|
{
|
2016-05-12 11:59:28 +01:00
|
|
|
if (Ls_ != env().getObjectLs(par().source))
|
|
|
|
{
|
|
|
|
HADRON_ERROR("Ls mismatch between quark action and source");
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
PropToFerm(source, fullSrc, s, c);
|
|
|
|
}
|
2016-04-30 08:17:04 +01:00
|
|
|
}
|
|
|
|
sol = zero;
|
2016-06-06 17:45:37 +01:00
|
|
|
solver(sol, source);
|
2016-05-07 21:19:38 +01:00
|
|
|
FermToProp(prop, sol, s, c);
|
2016-05-12 18:34:42 +01:00
|
|
|
// create 4D propagators from 5D one if necessary
|
|
|
|
if (Ls_ > 1)
|
|
|
|
{
|
2016-12-05 07:47:29 +00:00
|
|
|
PropagatorField &p4d =
|
2017-06-08 02:10:48 +01:00
|
|
|
*env().template getObject<PropagatorField>(getName());
|
2016-05-12 18:34:42 +01:00
|
|
|
|
|
|
|
axpby_ssp_pminus(sol, 0., sol, 1., sol, 0, 0);
|
2017-02-14 14:07:17 +00:00
|
|
|
axpby_ssp_pplus(sol, 1., sol, 1., sol, 0, Ls_-1);
|
2016-05-12 18:34:42 +01:00
|
|
|
ExtractSlice(tmp, sol, 0, 0);
|
|
|
|
FermToProp(p4d, tmp, s, c);
|
|
|
|
}
|
2016-04-30 08:17:04 +01:00
|
|
|
}
|
2015-12-23 14:21:35 +00:00
|
|
|
}
|
2016-12-05 07:47:29 +00:00
|
|
|
|
2017-06-08 02:10:48 +01:00
|
|
|
END_MODULE_NAMESPACE
|
|
|
|
|
2016-12-05 07:47:29 +00:00
|
|
|
END_HADRONS_NAMESPACE
|
|
|
|
|
2017-06-08 02:10:48 +01:00
|
|
|
#endif // Hadrons_MFermion_GaugeProp_hpp_
|