diff --git a/MathLib/LinAlg/Solvers/CG.h b/MathLib/LinAlg/Solvers/CG.h index 60961d003b5adead7b4bbdd6f2e303cee365ad5c..9996a872cbe9df765c3f1455abd54e279809fc94 100644 --- a/MathLib/LinAlg/Solvers/CG.h +++ b/MathLib/LinAlg/Solvers/CG.h @@ -18,7 +18,7 @@ unsigned CG(CRSMatrix<double,unsigned> const * mat, double const * const b, #ifdef _OPENMP unsigned CGParallel(CRSMatrix<double,unsigned> const * mat, double const * const b, - double* const x, double& eps, unsigned& nsteps, unsigned num_threads = 1); + double* const x, double& eps, unsigned& nsteps); #endif } // end namespace MathLib diff --git a/MathLib/LinAlg/Solvers/CGParallel.cpp b/MathLib/LinAlg/Solvers/CGParallel.cpp index e5fc627ec8395a7b862666f38d447da506fa01d1..f14824dc4af645b89fc64fcbd65a788fbce605bc 100644 --- a/MathLib/LinAlg/Solvers/CGParallel.cpp +++ b/MathLib/LinAlg/Solvers/CGParallel.cpp @@ -33,9 +33,9 @@ namespace MathLib { #ifdef _OPENMP unsigned CGParallel(CRSMatrix<double,unsigned> const * mat, double const * const b, - double* const x, double& eps, unsigned& nsteps, unsigned num_threads) + double* const x, double& eps, unsigned& nsteps) { - unsigned N = mat->getNRows(); + const unsigned N(mat->getNRows()); double * __restrict__ p(new double[N]); double * __restrict__ q(new double[N]); double * __restrict__ r(new double[N]); @@ -63,6 +63,9 @@ unsigned CGParallel(CRSMatrix<double,unsigned> const * mat, double const * const eps = resid / nrmb; nsteps = 0; delete[] p; + delete[] q; + delete[] r; + delete[] rhat; return 0; } @@ -128,6 +131,9 @@ unsigned CGParallel(CRSMatrix<double,unsigned> const * mat, double const * const eps = resid / nrmb; nsteps = l; delete[] p; + delete[] q; + delete[] r; + delete[] rhat; return 0; } @@ -135,6 +141,9 @@ unsigned CGParallel(CRSMatrix<double,unsigned> const * mat, double const * const } eps = resid / nrmb; delete[] p; + delete[] q; + delete[] r; + delete[] rhat; return 1; } #endif diff --git a/SimpleTests/SolverTests/ConjugateGradientDiagonalPreconditioned.cpp b/SimpleTests/SolverTests/ConjugateGradientDiagonalPreconditioned.cpp index 30700aa9524c204d1043504c44ab8ca85d99ce1c..bfb4333f4593059e946c3c5b4b827feec25b865d 100644 --- a/SimpleTests/SolverTests/ConjugateGradientDiagonalPreconditioned.cpp +++ b/SimpleTests/SolverTests/ConjugateGradientDiagonalPreconditioned.cpp @@ -68,7 +68,7 @@ int main(int argc, char *argv[]) MathLib::CG(mat, b, x, eps, steps); } else { #ifdef _OPENMP - MathLib::CGParallel(mat, b, x, eps, steps, num_omp_threads); + MathLib::CGParallel(mat, b, x, eps, steps); #else std::cout << "OpenMP is not switched on" << std::endl; #endif