From 458e0b71ba8ca9b2ec238cb2b70f45ec485ee4b6 Mon Sep 17 00:00:00 2001 From: wolf Date: Fri, 9 Apr 1999 14:44:26 +0000 Subject: [PATCH] Make PCG solver a bit faster by not initializing memory that will be overwritten soon anyway. git-svn-id: https://svn.dealii.org/trunk@1114 0785d39b-7218-0410-832d-ea1e28bc413d --- deal.II/lac/include/lac/solver_cg.h | 21 ++++++++++++++++----- deal.II/lac/include/lac/solver_gmres.h | 6 ++++-- 2 files changed, 20 insertions(+), 7 deletions(-) diff --git a/deal.II/lac/include/lac/solver_cg.h b/deal.II/lac/include/lac/solver_cg.h index e7e8cf6b60..5cd18d9641 100644 --- a/deal.II/lac/include/lac/solver_cg.h +++ b/deal.II/lac/include/lac/solver_cg.h @@ -83,11 +83,22 @@ SolverPCG::solve (const Matrix &A, SolverControl::State conv=SolverControl::iterate; // Memory allocation - Vr = memory.alloc(); Vector& g = *Vr; g.reinit(x); - Vp = memory.alloc(); Vector& h = *Vp; h.reinit(x); - Vz = memory.alloc(); Vector& d = *Vz; d.reinit(x); - VAp = memory.alloc(); Vector& Ad = *VAp; Ad.reinit(x); - + Vr = memory.alloc(); + Vp = memory.alloc(); + Vz = memory.alloc(); + VAp = memory.alloc(); + // define some aliases for simpler access + Vector& g = *Vr; + Vector& h = *Vp; + Vector& d = *Vz; + Vector& Ad = *VAp; + // resize the vectors, but do not set + // the values since they'd be overwritten + // soon anyway. + g.reinit(x.size(), true); + h.reinit(x.size(), true); + d.reinit(x.size(), true); + Ad.reinit(x.size(), true); // Implementation taken from the DEAL // library int it=0; diff --git a/deal.II/lac/include/lac/solver_gmres.h b/deal.II/lac/include/lac/solver_gmres.h index 1f2536164c..c5a7ad833d 100644 --- a/deal.II/lac/include/lac/solver_gmres.h +++ b/deal.II/lac/include/lac/solver_gmres.h @@ -146,12 +146,14 @@ SolverGMRES::solve (const Matrix& A, // allocate an array of n_tmp_vectors // temporary vectors from the VectorMemory - // object + // object; resize them but do not set their + // values since they will be overwritten soon + // anyway. vector tmp_vectors (n_tmp_vectors, 0); for (unsigned int tmp=0; tmpreinit (x.size()); + tmp_vectors[tmp]->reinit (x.size(), true); }; // number of the present iteration; this -- 2.39.5