From 3a0853600cb82afb5e444f4ee7435f6a4479356a Mon Sep 17 00:00:00 2001 From: Jonathan Lambrechts <jonathan.lambrechts@uclouvain.be> Date: Thu, 4 Jul 2013 08:54:41 +0000 Subject: [PATCH] PETSc : remove function imcompatible with recent PETSc and add the destructor of the block solver --- Solver/linearSystemPETSc.cpp | 12 ++++++++++++ Solver/linearSystemPETSc.h | 3 ++- Solver/linearSystemPETSc.hpp | 12 ++++++------ 3 files changed, 20 insertions(+), 7 deletions(-) diff --git a/Solver/linearSystemPETSc.cpp b/Solver/linearSystemPETSc.cpp index 0d241d368d..b458d8b2ba 100644 --- a/Solver/linearSystemPETSc.cpp +++ b/Solver/linearSystemPETSc.cpp @@ -27,6 +27,18 @@ void linearSystemPETScBlockDouble::_kspCreate() _kspAllocated = true; } +linearSystemPETScBlockDouble::~linearSystemPETScBlockDouble() +{ + if (_isAllocated) { + MatDestroy(&_a); + VecDestroy(&_b); + VecDestroy(&_x); + } + if (_kspAllocated) { + KSPDestroy(&_ksp); + } +} + void linearSystemPETScBlockDouble::addToMatrix(int row, int col, const fullMatrix<double> &val) { diff --git a/Solver/linearSystemPETSc.h b/Solver/linearSystemPETSc.h index b82aa17d17..3d28023c44 100644 --- a/Solver/linearSystemPETSc.h +++ b/Solver/linearSystemPETSc.h @@ -84,7 +84,7 @@ class linearSystemPETSc : public linearSystem<scalar> { virtual void zeroSolution(); virtual int systemSolve(); Mat &getMatrix(){ return _a; } - std::vector<scalar> getData(); + //std::vector<scalar> getData(); std::vector<int> getRowPointers(); std::vector<int> getColumnsIndices(); #ifndef SWIG @@ -122,6 +122,7 @@ class linearSystemPETScBlockDouble : public linearSystem<fullMatrix<double> > { double normInfRightHandSide() const; void insertInSparsityPattern (int i, int j); linearSystemPETScBlockDouble(bool sequential = false); + ~linearSystemPETScBlockDouble(); }; #else diff --git a/Solver/linearSystemPETSc.hpp b/Solver/linearSystemPETSc.hpp index 7922ec42bc..ecafc8af35 100644 --- a/Solver/linearSystemPETSc.hpp +++ b/Solver/linearSystemPETSc.hpp @@ -349,7 +349,7 @@ int linearSystemPETSc<scalar>::systemSolve() return 1; } -template <class scalar> +/*template <class scalar> std::vector<scalar> linearSystemPETSc<scalar>::getData() { _try(MatAssemblyBegin(_a, MAT_FINAL_ASSEMBLY)); @@ -369,15 +369,15 @@ std::vector<scalar> linearSystemPETSc<scalar>::getData() #endif _try(MatRestoreArray(_a,&v)); return data; -} +}*/ template <class scalar> std::vector<int> linearSystemPETSc<scalar>::getRowPointers() { _try(MatAssemblyBegin(_a, MAT_FINAL_ASSEMBLY)); _try(MatAssemblyEnd(_a, MAT_FINAL_ASSEMBLY)); - PetscInt *rows; - PetscInt *columns; + const PetscInt *rows; + const PetscInt *columns; PetscInt n; PetscTruth done; _try(MatGetRowIJ(_a,0,PETSC_FALSE,PETSC_FALSE,&n,&rows,&columns,&done)); //case done == PETSC_FALSE should be handled @@ -393,8 +393,8 @@ std::vector<int> linearSystemPETSc<scalar>::getColumnsIndices() { _try(MatAssemblyBegin(_a, MAT_FINAL_ASSEMBLY)); _try(MatAssemblyEnd(_a, MAT_FINAL_ASSEMBLY)); - PetscInt *rows; - PetscInt *columns; + const PetscInt *rows; + const PetscInt *columns; PetscInt n; PetscTruth done; _try(MatGetRowIJ(_a,0,PETSC_FALSE,PETSC_FALSE,&n,&rows,&columns,&done)); //case done == PETSC_FALSE should be handled -- GitLab