Skip to content
Snippets Groups Projects
Commit 3a085360 authored by Jonathan Lambrechts's avatar Jonathan Lambrechts
Browse files

PETSc : remove function imcompatible with recent PETSc and add the

destructor of the block solver
parent 33179040
No related branches found
No related tags found
No related merge requests found
...@@ -27,6 +27,18 @@ void linearSystemPETScBlockDouble::_kspCreate() ...@@ -27,6 +27,18 @@ void linearSystemPETScBlockDouble::_kspCreate()
_kspAllocated = true; _kspAllocated = true;
} }
linearSystemPETScBlockDouble::~linearSystemPETScBlockDouble()
{
if (_isAllocated) {
MatDestroy(&_a);
VecDestroy(&_b);
VecDestroy(&_x);
}
if (_kspAllocated) {
KSPDestroy(&_ksp);
}
}
void linearSystemPETScBlockDouble::addToMatrix(int row, int col, void linearSystemPETScBlockDouble::addToMatrix(int row, int col,
const fullMatrix<double> &val) const fullMatrix<double> &val)
{ {
......
...@@ -84,7 +84,7 @@ class linearSystemPETSc : public linearSystem<scalar> { ...@@ -84,7 +84,7 @@ class linearSystemPETSc : public linearSystem<scalar> {
virtual void zeroSolution(); virtual void zeroSolution();
virtual int systemSolve(); virtual int systemSolve();
Mat &getMatrix(){ return _a; } Mat &getMatrix(){ return _a; }
std::vector<scalar> getData(); //std::vector<scalar> getData();
std::vector<int> getRowPointers(); std::vector<int> getRowPointers();
std::vector<int> getColumnsIndices(); std::vector<int> getColumnsIndices();
#ifndef SWIG #ifndef SWIG
...@@ -122,6 +122,7 @@ class linearSystemPETScBlockDouble : public linearSystem<fullMatrix<double> > { ...@@ -122,6 +122,7 @@ class linearSystemPETScBlockDouble : public linearSystem<fullMatrix<double> > {
double normInfRightHandSide() const; double normInfRightHandSide() const;
void insertInSparsityPattern (int i, int j); void insertInSparsityPattern (int i, int j);
linearSystemPETScBlockDouble(bool sequential = false); linearSystemPETScBlockDouble(bool sequential = false);
~linearSystemPETScBlockDouble();
}; };
#else #else
......
...@@ -349,7 +349,7 @@ int linearSystemPETSc<scalar>::systemSolve() ...@@ -349,7 +349,7 @@ int linearSystemPETSc<scalar>::systemSolve()
return 1; return 1;
} }
template <class scalar> /*template <class scalar>
std::vector<scalar> linearSystemPETSc<scalar>::getData() std::vector<scalar> linearSystemPETSc<scalar>::getData()
{ {
_try(MatAssemblyBegin(_a, MAT_FINAL_ASSEMBLY)); _try(MatAssemblyBegin(_a, MAT_FINAL_ASSEMBLY));
...@@ -369,15 +369,15 @@ std::vector<scalar> linearSystemPETSc<scalar>::getData() ...@@ -369,15 +369,15 @@ std::vector<scalar> linearSystemPETSc<scalar>::getData()
#endif #endif
_try(MatRestoreArray(_a,&v)); _try(MatRestoreArray(_a,&v));
return data; return data;
} }*/
template <class scalar> template <class scalar>
std::vector<int> linearSystemPETSc<scalar>::getRowPointers() std::vector<int> linearSystemPETSc<scalar>::getRowPointers()
{ {
_try(MatAssemblyBegin(_a, MAT_FINAL_ASSEMBLY)); _try(MatAssemblyBegin(_a, MAT_FINAL_ASSEMBLY));
_try(MatAssemblyEnd(_a, MAT_FINAL_ASSEMBLY)); _try(MatAssemblyEnd(_a, MAT_FINAL_ASSEMBLY));
PetscInt *rows; const PetscInt *rows;
PetscInt *columns; const PetscInt *columns;
PetscInt n; PetscInt n;
PetscTruth done; PetscTruth done;
_try(MatGetRowIJ(_a,0,PETSC_FALSE,PETSC_FALSE,&n,&rows,&columns,&done)); //case done == PETSC_FALSE should be handled _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() ...@@ -393,8 +393,8 @@ std::vector<int> linearSystemPETSc<scalar>::getColumnsIndices()
{ {
_try(MatAssemblyBegin(_a, MAT_FINAL_ASSEMBLY)); _try(MatAssemblyBegin(_a, MAT_FINAL_ASSEMBLY));
_try(MatAssemblyEnd(_a, MAT_FINAL_ASSEMBLY)); _try(MatAssemblyEnd(_a, MAT_FINAL_ASSEMBLY));
PetscInt *rows; const PetscInt *rows;
PetscInt *columns; const PetscInt *columns;
PetscInt n; PetscInt n;
PetscTruth done; PetscTruth done;
_try(MatGetRowIJ(_a,0,PETSC_FALSE,PETSC_FALSE,&n,&rows,&columns,&done)); //case done == PETSC_FALSE should be handled _try(MatGetRowIJ(_a,0,PETSC_FALSE,PETSC_FALSE,&n,&rows,&columns,&done)); //case done == PETSC_FALSE should be handled
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment