2018-07-30 18:40:50 +01:00
|
|
|
#ifndef Hadrons_MSolver_A2AVectors_hpp_
|
|
|
|
#define Hadrons_MSolver_A2AVectors_hpp_
|
|
|
|
|
|
|
|
#include <Grid/Hadrons/Global.hpp>
|
|
|
|
#include <Grid/Hadrons/Module.hpp>
|
|
|
|
#include <Grid/Hadrons/ModuleFactory.hpp>
|
|
|
|
#include <Grid/Hadrons/Solver.hpp>
|
|
|
|
#include <Grid/Hadrons/EigenPack.hpp>
|
|
|
|
#include <Grid/Hadrons/AllToAllVectors.hpp>
|
2018-08-06 12:11:52 +01:00
|
|
|
#include <Grid/Hadrons/DilutedNoise.hpp>
|
2018-07-30 18:40:50 +01:00
|
|
|
|
|
|
|
BEGIN_HADRONS_NAMESPACE
|
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
* A2AVectors *
|
|
|
|
******************************************************************************/
|
|
|
|
BEGIN_MODULE_NAMESPACE(MSolver)
|
|
|
|
|
|
|
|
class A2AVectorsPar: Serializable
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
GRID_SERIALIZABLE_CLASS_MEMBERS(A2AVectorsPar,
|
|
|
|
bool, return_5d,
|
|
|
|
int, Nl,
|
2018-08-06 12:11:52 +01:00
|
|
|
std::string, noise,
|
2018-07-30 18:40:50 +01:00
|
|
|
std::string, action,
|
|
|
|
std::string, eigenPack,
|
|
|
|
std::string, solver);
|
|
|
|
};
|
|
|
|
|
2018-08-06 12:11:52 +01:00
|
|
|
template <typename FImpl, typename Pack>
|
2018-07-30 18:40:50 +01:00
|
|
|
class TA2AVectors : public Module<A2AVectorsPar>
|
|
|
|
{
|
2018-08-06 12:11:52 +01:00
|
|
|
public:
|
2018-07-30 18:40:50 +01:00
|
|
|
FERM_TYPE_ALIASES(FImpl,);
|
|
|
|
SOLVER_TYPE_ALIASES(FImpl,);
|
2018-08-06 12:11:52 +01:00
|
|
|
typedef A2AModesSchurDiagTwo<FermionField, FMat, Solver> A2ABase;
|
|
|
|
public:
|
2018-07-30 18:40:50 +01:00
|
|
|
// constructor
|
|
|
|
TA2AVectors(const std::string name);
|
|
|
|
// destructor
|
|
|
|
virtual ~TA2AVectors(void) {};
|
|
|
|
// dependency relation
|
|
|
|
virtual std::vector<std::string> getInput(void);
|
|
|
|
virtual std::vector<std::string> getReference(void);
|
|
|
|
virtual std::vector<std::string> getOutput(void);
|
|
|
|
// setup
|
|
|
|
virtual void setup(void);
|
|
|
|
// execution
|
|
|
|
virtual void execute(void);
|
|
|
|
};
|
|
|
|
|
2018-08-06 12:11:52 +01:00
|
|
|
MODULE_REGISTER_TMP(A2AVectors,
|
|
|
|
ARG(TA2AVectors<FIMPL, FermionEigenPack<FIMPL>>), MSolver);
|
|
|
|
MODULE_REGISTER_TMP(ZA2AVectors,
|
|
|
|
ARG(TA2AVectors<ZFIMPL, FermionEigenPack<ZFIMPL>>), MSolver);
|
2018-07-30 18:40:50 +01:00
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
* TA2AVectors implementation *
|
|
|
|
******************************************************************************/
|
|
|
|
// constructor /////////////////////////////////////////////////////////////////
|
2018-08-06 12:11:52 +01:00
|
|
|
template <typename FImpl, typename Pack>
|
|
|
|
TA2AVectors<FImpl, Pack>::TA2AVectors(const std::string name)
|
2018-07-30 18:40:50 +01:00
|
|
|
: Module<A2AVectorsPar>(name)
|
|
|
|
{}
|
|
|
|
|
|
|
|
// dependencies/products ///////////////////////////////////////////////////////
|
2018-08-06 12:11:52 +01:00
|
|
|
template <typename FImpl, typename Pack>
|
|
|
|
std::vector<std::string> TA2AVectors<FImpl, Pack>::getInput(void)
|
2018-07-30 18:40:50 +01:00
|
|
|
{
|
|
|
|
int Nl = par().Nl;
|
|
|
|
std::string sub_string = "";
|
|
|
|
if (Nl > 0) sub_string = "_subtract";
|
|
|
|
|
2018-08-06 12:11:52 +01:00
|
|
|
std::vector<std::string> in = {par().solver + sub_string, par().noise};
|
2018-07-30 18:40:50 +01:00
|
|
|
|
|
|
|
return in;
|
|
|
|
}
|
|
|
|
|
2018-08-06 12:11:52 +01:00
|
|
|
template <typename FImpl, typename Pack>
|
|
|
|
std::vector<std::string> TA2AVectors<FImpl, Pack>::getReference(void)
|
2018-07-30 18:40:50 +01:00
|
|
|
{
|
|
|
|
std::vector<std::string> ref = {par().action};
|
|
|
|
|
|
|
|
if (!par().eigenPack.empty())
|
|
|
|
{
|
|
|
|
ref.push_back(par().eigenPack);
|
|
|
|
}
|
|
|
|
|
|
|
|
return ref;
|
|
|
|
}
|
|
|
|
|
2018-08-06 12:11:52 +01:00
|
|
|
template <typename FImpl, typename Pack>
|
|
|
|
std::vector<std::string> TA2AVectors<FImpl, Pack>::getOutput(void)
|
2018-07-30 18:40:50 +01:00
|
|
|
{
|
2018-08-06 12:11:52 +01:00
|
|
|
std::vector<std::string> out = {getName()};
|
2018-07-30 18:40:50 +01:00
|
|
|
|
|
|
|
return out;
|
|
|
|
}
|
|
|
|
|
|
|
|
// setup ///////////////////////////////////////////////////////////////////////
|
2018-08-06 12:11:52 +01:00
|
|
|
template <typename FImpl, typename Pack>
|
|
|
|
void TA2AVectors<FImpl, Pack>::setup(void)
|
2018-07-30 18:40:50 +01:00
|
|
|
{
|
|
|
|
int Nl = par().Nl;
|
2018-08-06 12:11:52 +01:00
|
|
|
bool return_5d = par().return_5d;
|
|
|
|
auto &noise = envGet(DilutedNoise<FImpl>, par().noise);
|
2018-07-30 18:40:50 +01:00
|
|
|
int Ls;
|
|
|
|
|
|
|
|
std::string sub_string = "";
|
|
|
|
if (Nl > 0) sub_string = "_subtract";
|
|
|
|
auto &solver = envGet(Solver, par().solver + sub_string);
|
|
|
|
Ls = env().getObjectLs(par().solver + sub_string);
|
|
|
|
|
|
|
|
auto &action = envGet(FMat, par().action);
|
|
|
|
|
|
|
|
envTmpLat(FermionField, "ferm_src", Ls);
|
|
|
|
envTmpLat(FermionField, "unphys_ferm", Ls);
|
|
|
|
envTmpLat(FermionField, "tmp");
|
|
|
|
|
|
|
|
std::vector<FermionField> *evec;
|
|
|
|
const std::vector<RealD> *eval;
|
|
|
|
|
|
|
|
if (Nl > 0)
|
|
|
|
{
|
|
|
|
// Low modes
|
2018-08-06 12:11:52 +01:00
|
|
|
auto &epack = envGet(Pack, par().eigenPack);
|
2018-07-30 18:40:50 +01:00
|
|
|
|
|
|
|
LOG(Message) << "Creating a2a vectors " << getName() <<
|
|
|
|
" using eigenpack '" << par().eigenPack << "' ("
|
|
|
|
<< epack.evec.size() << " modes)" <<
|
2018-08-06 12:11:52 +01:00
|
|
|
" and " << noise.size() << " high modes." << std::endl;
|
2018-07-30 18:40:50 +01:00
|
|
|
evec = &epack.evec;
|
|
|
|
eval = &epack.eval;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
LOG(Message) << "Creating a2a vectors " << getName() <<
|
2018-08-06 12:11:52 +01:00
|
|
|
" using " << noise.size() << " high modes only." << std::endl;
|
2018-07-30 18:40:50 +01:00
|
|
|
}
|
|
|
|
|
2018-08-06 12:11:52 +01:00
|
|
|
envCreate(A2ABase, getName(), Ls, evec, eval, action, solver, Nl, noise.size(),
|
|
|
|
return_5d);
|
2018-07-30 18:40:50 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
// execution ///////////////////////////////////////////////////////////////////
|
2018-08-06 12:11:52 +01:00
|
|
|
template <typename FImpl, typename Pack>
|
|
|
|
void TA2AVectors<FImpl, Pack>::execute(void)
|
2018-07-30 18:40:50 +01:00
|
|
|
{
|
|
|
|
auto &action = envGet(FMat, par().action);
|
2018-08-06 12:11:52 +01:00
|
|
|
auto &noise = envGet(DilutedNoise<FImpl>, par().noise);
|
2018-07-30 18:40:50 +01:00
|
|
|
|
2018-08-06 12:11:52 +01:00
|
|
|
int Ls;
|
2018-07-30 18:40:50 +01:00
|
|
|
int Nl = par().Nl;
|
|
|
|
|
|
|
|
std::string sub_string = "";
|
|
|
|
if (Nl > 0) sub_string = "_subtract";
|
2018-08-06 12:11:52 +01:00
|
|
|
Ls = env().getObjectLs(par().solver + sub_string);
|
2018-07-30 18:40:50 +01:00
|
|
|
|
2018-08-06 12:11:52 +01:00
|
|
|
auto &a2areturn = envGet(A2ABase, getName());
|
2018-07-30 18:40:50 +01:00
|
|
|
|
|
|
|
// High modes
|
|
|
|
envGetTmp(FermionField, ferm_src);
|
|
|
|
envGetTmp(FermionField, unphys_ferm);
|
|
|
|
envGetTmp(FermionField, tmp);
|
2018-08-06 12:11:52 +01:00
|
|
|
for (unsigned int i = 0; i < noise.size(); i++)
|
|
|
|
{
|
|
|
|
LOG(Message) << "A2A src for noise vector " << i << std::endl;
|
|
|
|
// source conversion for 4D sources
|
|
|
|
if (!env().isObject5d(par().noise))
|
2018-07-30 18:40:50 +01:00
|
|
|
{
|
2018-08-06 12:11:52 +01:00
|
|
|
if (Ls == 1)
|
2018-07-30 18:40:50 +01:00
|
|
|
{
|
2018-08-06 12:11:52 +01:00
|
|
|
ferm_src = noise[i];
|
|
|
|
tmp = ferm_src;
|
2018-07-30 18:40:50 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2018-08-06 12:11:52 +01:00
|
|
|
tmp = noise[i];
|
|
|
|
action.ImportPhysicalFermionSource(noise[i], ferm_src);
|
|
|
|
action.ImportUnphysicalFermion(noise[i], unphys_ferm);
|
2018-07-30 18:40:50 +01:00
|
|
|
}
|
|
|
|
}
|
2018-08-06 12:11:52 +01:00
|
|
|
// source conversion for 5D sources
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (Ls != env().getObjectLs(par().noise))
|
|
|
|
{
|
|
|
|
HADRONS_ERROR(Size, "Ls mismatch between quark action and source");
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
ferm_src = noise[i];
|
|
|
|
action.ExportPhysicalFermionSolution(ferm_src, tmp);
|
|
|
|
unphys_ferm = ferm_src;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
LOG(Message) << "solveHighMode i = " << i << std::endl;
|
|
|
|
a2areturn.high_modes(ferm_src, unphys_ferm, tmp, i);
|
|
|
|
}
|
2018-07-30 18:40:50 +01:00
|
|
|
}
|
|
|
|
END_MODULE_NAMESPACE
|
|
|
|
|
|
|
|
END_HADRONS_NAMESPACE
|
|
|
|
|
|
|
|
#endif // Hadrons_MSolver_A2AVectors_hpp_
|