1
0
mirror of https://github.com/paboyle/Grid.git synced 2025-06-15 06:17:05 +01:00

Hadrons: new solver exposing fermion matrix and generic source/solve import/export

This commit is contained in:
2018-06-22 12:14:37 +02:00
parent 8db0ef9736
commit 91405de3f7
11 changed files with 92 additions and 20 deletions

View File

@ -56,7 +56,7 @@ template <typename FImpl>
class TDWF: public Module<DWFPar>
{
public:
FGS_TYPE_ALIASES(FImpl,);
FG_TYPE_ALIASES(FImpl,);
public:
// constructor
TDWF(const std::string name);

View File

@ -54,7 +54,7 @@ template <typename FImpl>
class TWilson: public Module<WilsonPar>
{
public:
FGS_TYPE_ALIASES(FImpl,);
FG_TYPE_ALIASES(FImpl,);
public:
// constructor
TWilson(const std::string name);

View File

@ -59,7 +59,7 @@ template <typename FImpl>
class TWilsonClover: public Module<WilsonCloverPar>
{
public:
FGS_TYPE_ALIASES(FImpl,);
FG_TYPE_ALIASES(FImpl,);
public:
// constructor
TWilsonClover(const std::string name);

View File

@ -57,7 +57,7 @@ template <typename FImpl>
class TZMobiusDWF: public Module<ZMobiusDWFPar>
{
public:
FGS_TYPE_ALIASES(FImpl,);
FG_TYPE_ALIASES(FImpl,);
public:
// constructor
TZMobiusDWF(const std::string name);

View File

@ -57,7 +57,7 @@ template <typename FImpl>
class TFreeProp: public Module<FreePropPar>
{
public:
FGS_TYPE_ALIASES(FImpl,);
FG_TYPE_ALIASES(FImpl,);
public:
// constructor
TFreeProp(const std::string name);

View File

@ -35,6 +35,7 @@ See the full license in the file "LICENSE" in the top level distribution directo
#include <Grid/Hadrons/Global.hpp>
#include <Grid/Hadrons/Module.hpp>
#include <Grid/Hadrons/ModuleFactory.hpp>
#include <Grid/Hadrons/Solver.hpp>
BEGIN_HADRONS_NAMESPACE
@ -76,7 +77,8 @@ template <typename FImpl>
class TGaugeProp: public Module<GaugePropPar>
{
public:
FGS_TYPE_ALIASES(FImpl,);
FG_TYPE_ALIASES(FImpl,);
SOLVER_TYPE_ALIASES(FImpl,);
public:
// constructor
TGaugeProp(const std::string name);
@ -92,7 +94,7 @@ protected:
virtual void execute(void);
private:
unsigned int Ls_;
SolverFn *solver_{nullptr};
Solver *solver_{nullptr};
};
MODULE_REGISTER_TMP(GaugeProp, TGaugeProp<FIMPL>, MFermion);
@ -147,7 +149,8 @@ void TGaugeProp<FImpl>::execute(void)
std::string propName = (Ls_ == 1) ? getName() : (getName() + "_5d");
auto &prop = envGet(PropagatorField, propName);
auto &fullSrc = envGet(PropagatorField, par().source);
auto &solver = envGet(SolverFn, par().solver);
auto &solver = envGet(Solver, par().solver);
auto &mat = solver.getFMat();
envGetTmp(FermionField, source);
envGetTmp(FermionField, sol);
@ -155,11 +158,12 @@ void TGaugeProp<FImpl>::execute(void)
LOG(Message) << "Inverting using solver '" << par().solver
<< "' on source '" << par().source << "'" << std::endl;
for (unsigned int s = 0; s < Ns; ++s)
for (unsigned int c = 0; c < FImpl::Dimension; ++c)
for (unsigned int c = 0; c < FImpl::Dimension; ++c)
{
LOG(Message) << "Inversion for spin= " << s << ", color= " << c
<< std::endl;
// source conversion for 4D sources
LOG(Message) << "Import source" << std::endl;
if (!env().isObject5d(par().source))
{
if (Ls_ == 1)
@ -169,7 +173,7 @@ void TGaugeProp<FImpl>::execute(void)
else
{
PropToFerm<FImpl>(tmp, fullSrc, s, c);
make_5D(tmp, source, Ls_);
mat.ImportPhysicalFermionSource(tmp, source);
}
}
// source conversion for 5D sources
@ -184,14 +188,19 @@ void TGaugeProp<FImpl>::execute(void)
PropToFerm<FImpl>(source, fullSrc, s, c);
}
}
LOG(Message) << "Prepare source" << std::endl;
sol = source;
mat.Dminus(sol, source);
sol = zero;
LOG(Message) << "Solve" << std::endl;
solver(sol, source);
LOG(Message) << "Export solution" << std::endl;
FermToProp<FImpl>(prop, sol, s, c);
// create 4D propagators from 5D one if necessary
if (Ls_ > 1)
{
PropagatorField &p4d = envGet(PropagatorField, getName());
make_4D(sol, tmp, Ls_);
mat.ExportPhysicalFermionSolution(sol, tmp);
FermToProp<FImpl>(p4d, tmp, s, c);
}
}

View File

@ -32,6 +32,7 @@ See the full license in the file "LICENSE" in the top level distribution directo
#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>
BEGIN_HADRONS_NAMESPACE
@ -55,7 +56,8 @@ template <typename FImpl, int nBasis>
class TRBPrecCG: public Module<RBPrecCGPar>
{
public:
FGS_TYPE_ALIASES(FImpl,);
FG_TYPE_ALIASES(FImpl,);
SOLVER_TYPE_ALIASES(FImpl,);
typedef FermionEigenPack<FImpl> EPack;
typedef CoarseFermionEigenPack<FImpl, nBasis> CoarseEPack;
typedef std::shared_ptr<Guesser<FermionField>> GuesserPt;
@ -175,7 +177,7 @@ void TRBPrecCG<FImpl, nBasis>::setup(void)
schurSolver(mat, source, sol, *guesser);
};
envCreate(SolverFn, getName(), Ls, solver);
envCreate(Solver, getName(), Ls, solver, mat);
}

View File

@ -71,7 +71,7 @@ template <typename FImpl>
class TSeqGamma: public Module<SeqGammaPar>
{
public:
FGS_TYPE_ALIASES(FImpl,);
FG_TYPE_ALIASES(FImpl,);
public:
// constructor
TSeqGamma(const std::string name);