mirror of
				https://github.com/paboyle/Grid.git
				synced 2025-10-31 20:14:32 +00:00 
			
		
		
		
	Hadrons: CG guesser fix
This commit is contained in:
		| @@ -55,13 +55,14 @@ template <typename FImpl, int nBasis> | |||||||
| class TRBPrecCG: public Module<RBPrecCGPar> | class TRBPrecCG: public Module<RBPrecCGPar> | ||||||
| { | { | ||||||
| public: | public: | ||||||
|  |     FGS_TYPE_ALIASES(FImpl,); | ||||||
|     typedef FermionEigenPack<FImpl>                       EPack; |     typedef FermionEigenPack<FImpl>                       EPack; | ||||||
|     typedef CoarseFermionEigenPack<FImpl, nBasis>         CoarseEPack; |     typedef CoarseFermionEigenPack<FImpl, nBasis>         CoarseEPack; | ||||||
|  |     typedef std::shared_ptr<Guesser<FermionField>>        GuesserPt; | ||||||
|     typedef DeflatedGuesser<typename FImpl::FermionField> FineGuesser; |     typedef DeflatedGuesser<typename FImpl::FermionField> FineGuesser; | ||||||
|     typedef LocalCoherenceDeflatedGuesser< |     typedef LocalCoherenceDeflatedGuesser< | ||||||
|         typename FImpl::FermionField, |         typename FImpl::FermionField, | ||||||
|         typename CoarseEPack::CoarseField> CoarseGuesser; |         typename CoarseEPack::CoarseField> CoarseGuesser; | ||||||
|     FGS_TYPE_ALIASES(FImpl,); |  | ||||||
| public: | public: | ||||||
|     // constructor |     // constructor | ||||||
|     TRBPrecCG(const std::string name); |     TRBPrecCG(const std::string name); | ||||||
| @@ -131,41 +132,39 @@ void TRBPrecCG<FImpl, nBasis>::setup(void) | |||||||
|                  << par().residual << ", maximum iteration "  |                  << par().residual << ", maximum iteration "  | ||||||
|                  << par().maxIteration << std::endl; |                  << par().maxIteration << std::endl; | ||||||
|  |  | ||||||
|     auto Ls                 = env().getObjectLs(par().action); |     auto        Ls          = env().getObjectLs(par().action); | ||||||
|     auto &mat               = envGet(FMat, par().action); |     auto        &mat        = envGet(FMat, par().action); | ||||||
|     std::string guesserName = getName() + "_guesser"; |     std::string guesserName = getName() + "_guesser"; | ||||||
|  |     GuesserPt   guesser{nullptr}; | ||||||
|  |  | ||||||
|     if (par().eigenPack.empty()) |     if (par().eigenPack.empty()) | ||||||
|     { |     { | ||||||
|         env().template createDerivedObject<Guesser<FermionField>, ZeroGuesser<FermionField>> |         guesser.reset(new ZeroGuesser<FermionField>()); | ||||||
|             (guesserName, Environment::Storage::object, Ls); |  | ||||||
|     } |     } | ||||||
|     else |     else | ||||||
|     { |     { | ||||||
|         try |         try | ||||||
|         { |         { | ||||||
|             auto &epack = envGetDerived(EPack, CoarseEPack, par().eigenPack); |             auto &epack = envGetDerived(EPack, CoarseEPack, par().eigenPack); | ||||||
|  |              | ||||||
|             envCreateDerived(Guesser<FermionField>, CoarseGuesser, |             guesser.reset(new CoarseGuesser(epack.evec, epack.evecCoarse, | ||||||
|                              guesserName, Ls, epack.evec, epack.evecCoarse, |                                             epack.evalCoarse)); | ||||||
|                              epack.evalCoarse); |  | ||||||
|         } |         } | ||||||
|         catch (Exceptions::Definition &e) |         catch (Exceptions::Definition &e) | ||||||
|         { |         { | ||||||
|             auto &epack = envGet(EPack, par().eigenPack); |             auto &epack = envGet(EPack, par().eigenPack); | ||||||
|  |  | ||||||
|             envCreateDerived(Guesser<FermionField>, FineGuesser, |             guesser.reset(new FineGuesser(epack.evec, epack.eval)); | ||||||
|                              guesserName, Ls, epack.evec, epack.eval); |  | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
|     auto &guesser = envGet(Guesser<FermionField>, guesserName); |     auto solver = [&mat, guesser, this](FermionField &sol,  | ||||||
|     auto solver = [&mat, &guesser, this](FermionField &sol, const FermionField &source) |                                         const FermionField &source) | ||||||
|     { |     { | ||||||
|         ConjugateGradient<FermionField>           cg(par().residual,  |         ConjugateGradient<FermionField>           cg(par().residual,  | ||||||
|                                                      par().maxIteration); |                                                      par().maxIteration); | ||||||
|         HADRONS_DEFAULT_SCHUR_SOLVE<FermionField> schurSolver(cg); |         HADRONS_DEFAULT_SCHUR_SOLVE<FermionField> schurSolver(cg); | ||||||
|          |          | ||||||
|         schurSolver(mat, source, sol, guesser); |         schurSolver(mat, source, sol, *guesser); | ||||||
|     }; |     }; | ||||||
|     envCreate(SolverFn, getName(), Ls, solver); |     envCreate(SolverFn, getName(), Ls, solver); | ||||||
| } | } | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user