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

linearSystemPETSc.h remove #include "petsc.h" when building python

bindings (a better solution would be welcome)
parent 23ae4fe3
No related branches found
No related tags found
No related merge requests found
...@@ -41,12 +41,17 @@ ...@@ -41,12 +41,17 @@
#include "fullMatrix.h" #include "fullMatrix.h"
#include <vector> #include <vector>
#if defined(HAVE_PETSC) #if defined(HAVE_PETSC)
#ifndef SWIG
#include "petsc.h" #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> template <class scalar>
class linearSystemPETSc : public linearSystem<scalar> { class linearSystemPETSc : public linearSystem<scalar> {
protected: protected:
MPI_Comm _comm;
int _blockSize; // for block Matrix int _blockSize; // for block Matrix
bool _isAllocated, _kspAllocated, _entriesPreAllocated, _matrixModified; bool _isAllocated, _kspAllocated, _entriesPreAllocated, _matrixModified;
Mat _a; Mat _a;
...@@ -55,8 +60,10 @@ class linearSystemPETSc : public linearSystem<scalar> { ...@@ -55,8 +60,10 @@ class linearSystemPETSc : public linearSystem<scalar> {
int _localRowStart, _localRowEnd, _localSize, _globalSize; int _localRowStart, _localRowEnd, _localSize, _globalSize;
sparsityPattern _sparsity; sparsityPattern _sparsity;
void _kspCreate(); void _kspCreate();
#ifndef SWIG
MPI_Comm _comm;
#endif
public: public:
linearSystemPETSc(MPI_Comm com = PETSC_COMM_WORLD);
virtual ~linearSystemPETSc(); virtual ~linearSystemPETSc();
void insertInSparsityPattern (int i, int j); void insertInSparsityPattern (int i, int j);
virtual bool isAllocated() const { return _isAllocated; } virtual bool isAllocated() const { return _isAllocated; }
...@@ -79,7 +86,11 @@ class linearSystemPETSc : public linearSystem<scalar> { ...@@ -79,7 +86,11 @@ class linearSystemPETSc : public linearSystem<scalar> {
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
linearSystemPETSc(MPI_Comm com);
MPI_Comm& getComm() {return _comm;} MPI_Comm& getComm() {return _comm;}
#endif
linearSystemPETSc();
}; };
class linearSystemPETScBlockDouble : public linearSystem<fullMatrix<double> > { class linearSystemPETScBlockDouble : public linearSystem<fullMatrix<double> > {
......
...@@ -43,6 +43,16 @@ linearSystemPETSc<scalar>::linearSystemPETSc(MPI_Comm com) ...@@ -43,6 +43,16 @@ linearSystemPETSc<scalar>::linearSystemPETSc(MPI_Comm com)
_matrixModified=true; _matrixModified=true;
} }
template <class scalar>
linearSystemPETSc<scalar>::linearSystemPETSc()
{
_comm = PETSC_COMM_WORLD;
_isAllocated = false;
_blockSize = 0;
_kspAllocated = false;
_matrixModified=true;
}
template <class scalar> template <class scalar>
linearSystemPETSc<scalar>::~linearSystemPETSc() linearSystemPETSc<scalar>::~linearSystemPETSc()
{ {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment