diff --git a/extras/Hadrons/Modules/MSolver/RBPrecCG.hpp b/extras/Hadrons/Modules/MSolver/RBPrecCG.hpp index 4af81537..8d1b0fc6 100644 --- a/extras/Hadrons/Modules/MSolver/RBPrecCG.hpp +++ b/extras/Hadrons/Modules/MSolver/RBPrecCG.hpp @@ -55,13 +55,14 @@ template class TRBPrecCG: public Module { public: + FGS_TYPE_ALIASES(FImpl,); typedef FermionEigenPack EPack; typedef CoarseFermionEigenPack CoarseEPack; + typedef std::shared_ptr> GuesserPt; typedef DeflatedGuesser FineGuesser; typedef LocalCoherenceDeflatedGuesser< typename FImpl::FermionField, typename CoarseEPack::CoarseField> CoarseGuesser; - FGS_TYPE_ALIASES(FImpl,); public: // constructor TRBPrecCG(const std::string name); @@ -131,41 +132,39 @@ void TRBPrecCG::setup(void) << par().residual << ", maximum iteration " << par().maxIteration << std::endl; - auto Ls = env().getObjectLs(par().action); - auto &mat = envGet(FMat, par().action); + auto Ls = env().getObjectLs(par().action); + auto &mat = envGet(FMat, par().action); std::string guesserName = getName() + "_guesser"; + GuesserPt guesser{nullptr}; if (par().eigenPack.empty()) { - env().template createDerivedObject, ZeroGuesser> - (guesserName, Environment::Storage::object, Ls); + guesser.reset(new ZeroGuesser()); } else { try { auto &epack = envGetDerived(EPack, CoarseEPack, par().eigenPack); - - envCreateDerived(Guesser, CoarseGuesser, - guesserName, Ls, epack.evec, epack.evecCoarse, - epack.evalCoarse); + + guesser.reset(new CoarseGuesser(epack.evec, epack.evecCoarse, + epack.evalCoarse)); } catch (Exceptions::Definition &e) { auto &epack = envGet(EPack, par().eigenPack); - envCreateDerived(Guesser, FineGuesser, - guesserName, Ls, epack.evec, epack.eval); + guesser.reset(new FineGuesser(epack.evec, epack.eval)); } } - auto &guesser = envGet(Guesser, guesserName); - auto solver = [&mat, &guesser, this](FermionField &sol, const FermionField &source) + auto solver = [&mat, guesser, this](FermionField &sol, + const FermionField &source) { ConjugateGradient cg(par().residual, par().maxIteration); HADRONS_DEFAULT_SCHUR_SOLVE schurSolver(cg); - schurSolver(mat, source, sol, guesser); + schurSolver(mat, source, sol, *guesser); }; envCreate(SolverFn, getName(), Ls, solver); }