2018-05-31 17:18:58 +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>
|
2018-06-28 16:14:49 +01:00
|
|
|
#include <Grid/Hadrons/Solver.hpp>
|
2018-05-31 17:18:58 +01:00
|
|
|
#include <Grid/Hadrons/EigenPack.hpp>
|
|
|
|
#include <Grid/Hadrons/AllToAllVectors.hpp>
|
|
|
|
|
|
|
|
BEGIN_HADRONS_NAMESPACE
|
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
* A2AVectors *
|
|
|
|
******************************************************************************/
|
|
|
|
BEGIN_MODULE_NAMESPACE(MSolver)
|
|
|
|
|
|
|
|
class A2AVectorsPar: Serializable
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
GRID_SERIALIZABLE_CLASS_MEMBERS(A2AVectorsPar,
|
2018-06-20 10:59:07 +01:00
|
|
|
bool, return_5d,
|
2018-05-31 17:18:58 +01:00
|
|
|
int, Nl,
|
|
|
|
int, N,
|
|
|
|
std::vector<std::string>, sources,
|
|
|
|
std::string, action,
|
2018-06-28 16:14:49 +01:00
|
|
|
std::string, eigenPack,
|
2018-05-31 17:18:58 +01:00
|
|
|
std::string, solver);
|
|
|
|
};
|
|
|
|
|
|
|
|
template <typename FImpl, int nBasis>
|
|
|
|
class TA2AVectors : public Module<A2AVectorsPar>
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
FERM_TYPE_ALIASES(FImpl,);
|
|
|
|
SOLVER_TYPE_ALIASES(FImpl,);
|
|
|
|
|
|
|
|
typedef FermionEigenPack<FImpl> EPack;
|
|
|
|
typedef CoarseFermionEigenPack<FImpl, nBasis> CoarseEPack;
|
|
|
|
|
2018-06-28 16:14:49 +01:00
|
|
|
typedef A2AModesSchurDiagTwo<typename FImpl::FermionField, FMat, Solver> A2ABase;
|
2018-05-31 17:18:58 +01:00
|
|
|
|
|
|
|
public:
|
|
|
|
// constructor
|
|
|
|
TA2AVectors(const std::string name);
|
|
|
|
// destructor
|
|
|
|
virtual ~TA2AVectors(void) {};
|
|
|
|
// dependency relation
|
|
|
|
virtual std::vector<std::string> getInput(void);
|
2018-06-28 16:14:49 +01:00
|
|
|
virtual std::vector<std::string> getReference(void);
|
2018-05-31 17:18:58 +01:00
|
|
|
virtual std::vector<std::string> getOutput(void);
|
|
|
|
// setup
|
|
|
|
virtual void setup(void);
|
|
|
|
// execution
|
|
|
|
virtual void execute(void);
|
|
|
|
|
|
|
|
private:
|
|
|
|
unsigned int Ls_;
|
2018-06-28 16:14:49 +01:00
|
|
|
std::string className_;
|
2018-05-31 17:18:58 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
MODULE_REGISTER_TMP(A2AVectors, ARG(TA2AVectors<FIMPL, HADRONS_DEFAULT_LANCZOS_NBASIS>), MSolver);
|
|
|
|
MODULE_REGISTER_TMP(ZA2AVectors, ARG(TA2AVectors<ZFIMPL, HADRONS_DEFAULT_LANCZOS_NBASIS>), MSolver);
|
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
* TA2AVectors implementation *
|
|
|
|
******************************************************************************/
|
|
|
|
// constructor /////////////////////////////////////////////////////////////////
|
|
|
|
template <typename FImpl, int nBasis>
|
|
|
|
TA2AVectors<FImpl, nBasis>::TA2AVectors(const std::string name)
|
|
|
|
: Module<A2AVectorsPar>(name)
|
2018-06-28 16:14:49 +01:00
|
|
|
, className_ (name + "_class")
|
2018-05-31 17:18:58 +01:00
|
|
|
{}
|
|
|
|
|
|
|
|
// dependencies/products ///////////////////////////////////////////////////////
|
|
|
|
template <typename FImpl, int nBasis>
|
|
|
|
std::vector<std::string> TA2AVectors<FImpl, nBasis>::getInput(void)
|
|
|
|
{
|
2018-06-28 16:14:49 +01:00
|
|
|
int Nl = par().Nl;
|
|
|
|
std::string sub_string = "";
|
|
|
|
if (Nl > 0) sub_string = "_subtract";
|
|
|
|
std::vector<std::string> in = {par().solver + sub_string};
|
2018-05-31 17:18:58 +01:00
|
|
|
|
|
|
|
int n = par().sources.size();
|
|
|
|
|
|
|
|
for (unsigned int t = 0; t < n; t += 1)
|
|
|
|
{
|
|
|
|
in.push_back(par().sources[t]);
|
|
|
|
}
|
|
|
|
|
|
|
|
return in;
|
|
|
|
}
|
|
|
|
|
2018-06-28 16:14:49 +01:00
|
|
|
template <typename FImpl, int nBasis>
|
|
|
|
std::vector<std::string> TA2AVectors<FImpl, nBasis>::getReference(void)
|
|
|
|
{
|
|
|
|
std::vector<std::string> ref = {par().action};
|
|
|
|
|
|
|
|
if (!par().eigenPack.empty())
|
|
|
|
{
|
|
|
|
ref.push_back(par().eigenPack);
|
|
|
|
}
|
|
|
|
|
|
|
|
return ref;
|
|
|
|
}
|
|
|
|
|
2018-05-31 17:18:58 +01:00
|
|
|
template <typename FImpl, int nBasis>
|
|
|
|
std::vector<std::string> TA2AVectors<FImpl, nBasis>::getOutput(void)
|
|
|
|
{
|
2018-07-22 14:40:31 +01:00
|
|
|
std::vector<std::string> out = {getName(), className_,
|
|
|
|
getName() + "_w_high_5d", getName() + "_v_high_5d",
|
|
|
|
getName() + "_w_high_4d", getName() + "_v_high_4d"};
|
2018-05-31 17:18:58 +01:00
|
|
|
|
|
|
|
return out;
|
|
|
|
}
|
|
|
|
|
|
|
|
// setup ///////////////////////////////////////////////////////////////////////
|
|
|
|
template <typename FImpl, int nBasis>
|
|
|
|
void TA2AVectors<FImpl, nBasis>::setup(void)
|
|
|
|
{
|
|
|
|
int N = par().N;
|
|
|
|
int Nl = par().Nl;
|
|
|
|
int Nh = N - Nl;
|
2018-06-20 10:59:07 +01:00
|
|
|
bool return_5d = par().return_5d;
|
2018-07-22 14:40:31 +01:00
|
|
|
int Ls;
|
2018-05-31 17:18:58 +01:00
|
|
|
|
2018-06-21 16:36:59 +01:00
|
|
|
std::string sub_string = "";
|
|
|
|
if (Nl > 0) sub_string = "_subtract";
|
2018-06-28 16:14:49 +01:00
|
|
|
auto &solver = envGet(Solver, par().solver + sub_string);
|
2018-07-22 14:40:31 +01:00
|
|
|
Ls = env().getObjectLs(par().solver + sub_string);
|
2018-06-20 10:59:07 +01:00
|
|
|
|
|
|
|
auto &action = envGet(FMat, par().action);
|
2018-05-31 17:18:58 +01:00
|
|
|
|
2018-07-22 14:40:31 +01:00
|
|
|
envTmpLat(FermionField, "ferm_src", Ls);
|
|
|
|
envTmpLat(FermionField, "unphys_ferm", Ls);
|
2018-05-31 17:18:58 +01:00
|
|
|
envTmpLat(FermionField, "tmp");
|
2018-06-21 16:36:59 +01:00
|
|
|
envTmpLat(FermionField, "tmp2");
|
2018-05-31 17:18:58 +01:00
|
|
|
|
2018-06-20 10:59:07 +01:00
|
|
|
std::vector<FermionField> *evec;
|
|
|
|
const std::vector<RealD> *eval;
|
|
|
|
|
2018-05-31 17:18:58 +01:00
|
|
|
if (Nl > 0)
|
|
|
|
{
|
|
|
|
// Low modes
|
2018-06-28 16:14:49 +01:00
|
|
|
auto &epack = envGet(EPack, par().eigenPack);
|
2018-05-31 17:18:58 +01:00
|
|
|
|
2018-06-20 10:59:07 +01:00
|
|
|
LOG(Message) << "Creating a2a vectors " << getName() <<
|
2018-06-28 16:14:49 +01:00
|
|
|
" using eigenpack '" << par().eigenPack << "' ("
|
2018-06-20 10:59:07 +01:00
|
|
|
<< epack.evec.size() << " modes)" <<
|
|
|
|
" and " << Nh << " high modes." << std::endl;
|
|
|
|
evec = &epack.evec;
|
|
|
|
eval = &epack.eval;
|
2018-05-31 17:18:58 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2018-06-20 10:59:07 +01:00
|
|
|
LOG(Message) << "Creating a2a vectors " << getName() <<
|
|
|
|
" using " << Nh << " high modes only." << std::endl;
|
2018-05-31 17:18:58 +01:00
|
|
|
}
|
2018-07-22 14:40:31 +01:00
|
|
|
|
|
|
|
int size_5d = 1;
|
|
|
|
if (return_5d) size_5d = Nh;
|
|
|
|
envCreate(std::vector<FermionField>, getName() + "_w_high_5d", Ls, size_5d, FermionField(env().getGrid(Ls)));
|
|
|
|
envCreate(std::vector<FermionField>, getName() + "_v_high_5d", Ls, size_5d, FermionField(env().getGrid(Ls)));
|
|
|
|
envCreate(std::vector<FermionField>, getName() + "_w_high_4d", 1, Nh, FermionField(env().getGrid(1)));
|
|
|
|
envCreate(std::vector<FermionField>, getName() + "_v_high_4d", 1, Nh, FermionField(env().getGrid(1)));
|
|
|
|
|
|
|
|
auto &w_high_5d = envGet(std::vector<FermionField>, getName() + "_w_high_5d");
|
|
|
|
auto &v_high_5d = envGet(std::vector<FermionField>, getName() + "_v_high_5d");
|
|
|
|
auto &w_high_4d = envGet(std::vector<FermionField>, getName() + "_w_high_4d");
|
|
|
|
auto &v_high_4d = envGet(std::vector<FermionField>, getName() + "_v_high_4d");
|
|
|
|
|
|
|
|
envCreate(A2ABase, className_, Ls,
|
2018-06-20 10:59:07 +01:00
|
|
|
evec, eval,
|
|
|
|
action,
|
|
|
|
solver,
|
2018-07-22 14:40:31 +01:00
|
|
|
w_high_5d, v_high_5d,
|
|
|
|
w_high_4d, v_high_4d,
|
2018-06-20 10:59:07 +01:00
|
|
|
Nl, Nh,
|
|
|
|
return_5d);
|
2018-05-31 17:18:58 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
// execution ///////////////////////////////////////////////////////////////////
|
|
|
|
template <typename FImpl, int nBasis>
|
|
|
|
void TA2AVectors<FImpl, nBasis>::execute(void)
|
|
|
|
{
|
|
|
|
auto &action = envGet(FMat, par().action);
|
|
|
|
|
|
|
|
int Nt = env().getDim(Tp);
|
|
|
|
int Nc = FImpl::Dimension;
|
2018-06-20 10:59:07 +01:00
|
|
|
int Ls_;
|
|
|
|
int Nl = par().Nl;
|
|
|
|
|
2018-06-21 16:36:59 +01:00
|
|
|
std::string sub_string = "";
|
|
|
|
if (Nl > 0) sub_string = "_subtract";
|
|
|
|
Ls_ = env().getObjectLs(par().solver + sub_string);
|
|
|
|
|
2018-06-28 16:14:49 +01:00
|
|
|
auto &a2areturn = envGet(A2ABase, className_);
|
2018-05-31 17:18:58 +01:00
|
|
|
|
|
|
|
// High modes
|
|
|
|
auto sources = par().sources;
|
2018-06-20 10:59:07 +01:00
|
|
|
int Nsrc = par().sources.size();
|
2018-05-31 17:18:58 +01:00
|
|
|
|
|
|
|
envGetTmp(FermionField, ferm_src);
|
2018-07-21 00:08:11 +01:00
|
|
|
envGetTmp(FermionField, unphys_ferm);
|
2018-05-31 17:18:58 +01:00
|
|
|
envGetTmp(FermionField, tmp);
|
2018-06-21 16:36:59 +01:00
|
|
|
envGetTmp(FermionField, tmp2);
|
2018-06-20 10:59:07 +01:00
|
|
|
|
2018-05-31 17:18:58 +01:00
|
|
|
int N_count = 0;
|
|
|
|
for (unsigned int s = 0; s < Ns; ++s)
|
|
|
|
for (unsigned int c = 0; c < Nc; ++c)
|
2018-06-20 10:59:07 +01:00
|
|
|
for (unsigned int T = 0; T < Nsrc; T++)
|
2018-05-31 17:18:58 +01:00
|
|
|
{
|
2018-06-20 10:59:07 +01:00
|
|
|
auto &prop_src = envGet(PropagatorField, sources[T]);
|
|
|
|
LOG(Message) << "A2A src for s = " << s << " , c = " << c << ", T = " << T << std::endl;
|
2018-05-31 17:18:58 +01:00
|
|
|
// source conversion for 4D sources
|
|
|
|
if (!env().isObject5d(sources[T]))
|
|
|
|
{
|
|
|
|
if (Ls_ == 1)
|
|
|
|
{
|
2018-06-20 10:59:07 +01:00
|
|
|
PropToFerm<FImpl>(ferm_src, prop_src, s, c);
|
2018-06-28 16:14:49 +01:00
|
|
|
tmp = ferm_src;
|
2018-05-31 17:18:58 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2018-06-28 16:14:49 +01:00
|
|
|
PropToFerm<FImpl>(tmp, prop_src, s, c);
|
2018-05-31 17:18:58 +01:00
|
|
|
action.ImportPhysicalFermionSource(tmp, ferm_src);
|
2018-07-21 00:08:11 +01:00
|
|
|
action.ImportUnphysicalFermion(tmp, unphys_ferm);
|
2018-05-31 17:18:58 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
// source conversion for 5D sources
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (Ls_ != env().getObjectLs(sources[T]))
|
|
|
|
{
|
|
|
|
HADRONS_ERROR(Size, "Ls mismatch between quark action and source");
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2018-06-20 10:59:07 +01:00
|
|
|
PropToFerm<FImpl>(ferm_src, prop_src, s, c);
|
2018-06-28 16:14:49 +01:00
|
|
|
action.ExportPhysicalFermionSolution(ferm_src, tmp);
|
2018-07-21 00:08:11 +01:00
|
|
|
unphys_ferm = ferm_src;
|
2018-05-31 17:18:58 +01:00
|
|
|
}
|
|
|
|
}
|
2018-06-20 10:59:07 +01:00
|
|
|
LOG(Message) << "a2areturn.high_modes Ncount = " << N_count << std::endl;
|
2018-07-21 00:08:11 +01:00
|
|
|
a2areturn.high_modes(ferm_src, unphys_ferm, tmp, N_count);
|
2018-05-31 17:18:58 +01:00
|
|
|
N_count++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
END_MODULE_NAMESPACE
|
|
|
|
|
|
|
|
END_HADRONS_NAMESPACE
|
|
|
|
|
|
|
|
#endif // Hadrons_MSolver_A2AVectors_hpp_
|