diff --git a/Solver/linearSystemPETSc.h b/Solver/linearSystemPETSc.h index c2ed187e375b31076470efdfdcc1e1d76f55b51a..5de035d36433e8c126810b65b0a73089fda83a95 100644 --- a/Solver/linearSystemPETSc.h +++ b/Solver/linearSystemPETSc.h @@ -41,12 +41,17 @@ #include "fullMatrix.h" #include <vector> #if defined(HAVE_PETSC) +#ifndef SWIG #include "petsc.h" -#include <petscksp.h> +#else +typedef struct _p_Mat* Mat; +typedef struct _p_Vec* Vec; +typedef struct _p_KSP* KSP; +#endif + template <class scalar> class linearSystemPETSc : public linearSystem<scalar> { protected: - MPI_Comm _comm; int _blockSize; // for block Matrix bool _isAllocated, _kspAllocated, _entriesPreAllocated, _matrixModified; Mat _a; @@ -55,8 +60,10 @@ class linearSystemPETSc : public linearSystem<scalar> { int _localRowStart, _localRowEnd, _localSize, _globalSize; sparsityPattern _sparsity; void _kspCreate(); + #ifndef SWIG + MPI_Comm _comm; + #endif public: - linearSystemPETSc(MPI_Comm com = PETSC_COMM_WORLD); virtual ~linearSystemPETSc(); void insertInSparsityPattern (int i, int j); virtual bool isAllocated() const { return _isAllocated; } @@ -79,7 +86,11 @@ class linearSystemPETSc : public linearSystem<scalar> { std::vector<scalar> getData(); std::vector<int> getRowPointers(); std::vector<int> getColumnsIndices(); + #ifndef SWIG + linearSystemPETSc(MPI_Comm com); MPI_Comm& getComm() {return _comm;} + #endif + linearSystemPETSc(); }; class linearSystemPETScBlockDouble : public linearSystem<fullMatrix<double> > { diff --git a/Solver/linearSystemPETSc.hpp b/Solver/linearSystemPETSc.hpp index ac1d2f06f7769587562d1741a9a3552a5865d6cb..7922ec42bc003d701b05b50a9a762e6f7220bee1 100644 --- a/Solver/linearSystemPETSc.hpp +++ b/Solver/linearSystemPETSc.hpp @@ -43,6 +43,16 @@ linearSystemPETSc<scalar>::linearSystemPETSc(MPI_Comm com) _matrixModified=true; } +template <class scalar> +linearSystemPETSc<scalar>::linearSystemPETSc() +{ + _comm = PETSC_COMM_WORLD; + _isAllocated = false; + _blockSize = 0; + _kspAllocated = false; + _matrixModified=true; +} + template <class scalar> linearSystemPETSc<scalar>::~linearSystemPETSc() {