From 7c86d2085b93c185680a05f2bd4b9bd474b3b55f Mon Sep 17 00:00:00 2001 From: Daniel Richtmann Date: Thu, 1 Feb 2018 12:24:16 +0100 Subject: [PATCH] WilsonMG: Some minor cleanup --- tests/solver/Test_wilson_mg.cc | 66 ++++++++++++++++------------------ 1 file changed, 31 insertions(+), 35 deletions(-) diff --git a/tests/solver/Test_wilson_mg.cc b/tests/solver/Test_wilson_mg.cc index 71fe5837..49026395 100644 --- a/tests/solver/Test_wilson_mg.cc +++ b/tests/solver/Test_wilson_mg.cc @@ -836,18 +836,20 @@ int main(int argc, char **argv) { coarseResult = zero; std::cout << GridLogMessage << "**************************************************" << std::endl; - std::cout << GridLogMessage << "Solving posdef-MR on coarse space " << std::endl; + std::cout << GridLogMessage << "Testing some coarse space solvers" << std::endl; std::cout << GridLogMessage << "**************************************************" << std::endl; MdagMLinearOperator CoarsePosDefHermOp(Dc); - MinimalResidual CoarseMR(5.0e-2, 100, false); - ConjugateGradient CoarseCG(5.0e-2, 100, false); - CoarseMR(CoarsePosDefHermOp, coarseSource, coarseResult); + std::vector>> coarseSolvers; + coarseSolvers.emplace_back(new GeneralisedMinimalResidual(5.0e-2, 100, 8, false)); + coarseSolvers.emplace_back(new MinimalResidual(5.0e-2, 100, false)); + coarseSolvers.emplace_back(new ConjugateGradient(5.0e-2, 100, false)); - gaussian(coarseGrids.PRNGs[0], coarseSource); - coarseResult = zero; - CoarseCG(CoarsePosDefHermOp, coarseSource, coarseResult); + for(auto const &solver : coarseSolvers) { + coarseResult = zero; + (*solver)(CoarsePosDefHermOp, coarseSource, coarseResult); + } std::cout << GridLogMessage << "**************************************************" << std::endl; std::cout << GridLogMessage << "Testing the operators" << std::endl; @@ -917,12 +919,16 @@ int main(int argc, char **argv) { coarseCoarseResult = zero; MdagMLinearOperator CoarseCoarsePosDefHermOp(Dcc); - MinimalResidual CoarseCoarseMR(5.0e-2, 100, false); - ConjugateGradient CoarseCoarseCG(5.0e-2, 100, false); - CoarseCoarseMR(CoarseCoarsePosDefHermOp, coarseCoarseSource, coarseCoarseResult); - gaussian(coarseGrids.PRNGs[1], coarseCoarseSource); - coarseCoarseResult = zero; - CoarseCoarseCG(CoarseCoarsePosDefHermOp, coarseCoarseSource, coarseCoarseResult); + + std::vector>> coarseCoarseSolvers; + coarseSolvers.emplace_back(new GeneralisedMinimalResidual(5.0e-2, 100, 8, false)); + coarseSolvers.emplace_back(new MinimalResidual(5.0e-2, 100, false)); + coarseSolvers.emplace_back(new ConjugateGradient(5.0e-2, 100, false)); + + for(auto const &solver : coarseCoarseSolvers) { + coarseCoarseResult = zero; + (*solver)(CoarseCoarsePosDefHermOp, coarseCoarseSource, coarseCoarseResult); + } CoarseMGPreconditioner CoarseMGPrecon(CoarseAggregates, Dcc, CoarsePosDefHermOp, Dc, CoarsePosDefHermOp, Dc); @@ -933,34 +939,24 @@ int main(int argc, char **argv) { } std::cout << GridLogMessage << "**************************************************" << std::endl; - std::cout << GridLogMessage << "Building two level VPGCR and FGMRES solvers" << std::endl; + std::cout << GridLogMessage << "Building VPGCR and FGMRES solvers w/ & w/o MG Preconditioner" << std::endl; std::cout << GridLogMessage << "**************************************************" << std::endl; - PrecGeneralisedConjugateResidual VPGCRMG(1.0e-12, 100, FineMGPrecon, 8, 8); - FlexibleGeneralisedMinimalResidual FGMRESMG(1.0e-12, 100, FineMGPrecon, 8); + std::vector>> solvers; + solvers.emplace_back(new PrecGeneralisedConjugateResidual(1.0e-12, 100, FineMGPrecon, 8, 8)); + solvers.emplace_back(new FlexibleGeneralisedMinimalResidual(1.0e-12, 100, FineMGPrecon, 8)); + solvers.emplace_back(new PrecGeneralisedConjugateResidual(1.0e-12, 4000000, FineSimplePrecon, 8, 8)); + solvers.emplace_back(new FlexibleGeneralisedMinimalResidual(1.0e-12, 4000000, FineSimplePrecon, 8)); + + std::cout << GridLogMessage << "**************************************************" << std::endl; + std::cout << GridLogMessage << "Testing the solvers" << std::endl; + std::cout << GridLogMessage << "**************************************************" << std::endl; std::cout << GridLogMessage << "checking norm src " << norm2(src) << std::endl; - std::cout << GridLogMessage << "**************************************************" << std::endl; - std::cout << GridLogMessage << "Building unpreconditioned VPGCR and FGMRES solvers" << std::endl; - std::cout << GridLogMessage << "**************************************************" << std::endl; - - PrecGeneralisedConjugateResidual VPGCRT(1.0e-12, 4000000, FineSimplePrecon, 8, 8); - FlexibleGeneralisedMinimalResidual FGMREST(1.0e-12, 4000000, FineSimplePrecon, 8); - - std::cout << GridLogMessage << "**************************************************" << std::endl; - std::cout << GridLogMessage << "Testing the four solvers" << std::endl; - std::cout << GridLogMessage << "**************************************************" << std::endl; - - std::vector *> solvers; - solvers.push_back(&VPGCRMG); - solvers.push_back(&FGMRESMG); - solvers.push_back(&VPGCRT); - solvers.push_back(&FGMREST); - - for(auto elem : solvers) { + for(auto const &solver : solvers) { result = zero; - (*elem)(FineHermIndefOp, src, result); + (*solver)(FineHermIndefOp, src, result); } Grid_finalize();