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

python : add petsc4py optional dependency to allow direct access to

petsc matrices
parent e5185a00
No related branches found
No related tags found
No related merge requests found
...@@ -63,6 +63,7 @@ opt(MUMPS "Enable MUMPS sparse direct linear solver" OFF) ...@@ -63,6 +63,7 @@ opt(MUMPS "Enable MUMPS sparse direct linear solver" OFF)
opt(NATIVE_FILE_CHOOSER "Enable native file chooser in GUI" ${DEFAULT}) opt(NATIVE_FILE_CHOOSER "Enable native file chooser in GUI" ${DEFAULT})
opt(NETGEN "Enable Netgen 3D frontal mesh generator" ${DEFAULT}) opt(NETGEN "Enable Netgen 3D frontal mesh generator" ${DEFAULT})
opt(NUMPY "Enable conversion between fullMatrix and numpy array (requires SWIG)" OFF) opt(NUMPY "Enable conversion between fullMatrix and numpy array (requires SWIG)" OFF)
opt(PETSC4PY "Enable petsc4py wrappers for petsc matrices" ON)
opt(OCC "Enable Open CASCADE geometrical models" ${DEFAULT}) opt(OCC "Enable Open CASCADE geometrical models" ${DEFAULT})
opt(ONELAB "Enable ONELAB solver interface" ${DEFAULT}) opt(ONELAB "Enable ONELAB solver interface" ${DEFAULT})
opt(ONELAB2 "Enable experimental ONELAB-Cloud solver interface" OFF) opt(ONELAB2 "Enable experimental ONELAB-Cloud solver interface" OFF)
...@@ -1120,6 +1121,18 @@ if(HAVE_PYTHON) ...@@ -1120,6 +1121,18 @@ if(HAVE_PYTHON)
set_config_option(HAVE_NUMPY "Numpy") set_config_option(HAVE_NUMPY "Numpy")
endif(NUMPY_INC) endif(NUMPY_INC)
endif(ENABLE_NUMPY) endif(ENABLE_NUMPY)
if(HAVE_PETSC)
if(ENABLE_PETSC4PY)
EXEC_PROGRAM (${PYTHON_EXECUTABLE}
ARGS "-c \"import petsc4py; print(petsc4py.get_include())\""
OUTPUT_VARIABLE PETSC4PY_INC
RETURN_VALUE PETSC4PY_NOT_FOUND)
if(PETSC4PY_INC)
list(APPEND EXTERNAL_INCLUDES ${PETSC4PY_INC})
set_config_option(HAVE_PETSC4PY "PETSc4py")
endif(PETSC4PY_INC)
endif(ENABLE_PETSC4PY)
endif(HAVE_PETSC)
endif(HAVE_PYTHON) endif(HAVE_PYTHON)
check_function_exists(vsnprintf HAVE_VSNPRINTF) check_function_exists(vsnprintf HAVE_VSNPRINTF)
......
...@@ -54,6 +54,7 @@ ...@@ -54,6 +54,7 @@
#cmakedefine HAVE_OSMESA #cmakedefine HAVE_OSMESA
#cmakedefine HAVE_PARSER #cmakedefine HAVE_PARSER
#cmakedefine HAVE_PETSC #cmakedefine HAVE_PETSC
#cmakedefine HAVE_PETSC4PY
#cmakedefine HAVE_PLUGINS #cmakedefine HAVE_PLUGINS
#cmakedefine HAVE_POST #cmakedefine HAVE_POST
#cmakedefine HAVE_POPPLER #cmakedefine HAVE_POPPLER
......
...@@ -114,7 +114,7 @@ class linearSystemPETSc : public linearSystem<scalar> { ...@@ -114,7 +114,7 @@ class linearSystemPETSc : public linearSystem<scalar> {
void zeroSolution(); void zeroSolution();
void printMatlab(const char *filename) const; void printMatlab(const char *filename) const;
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();
......
...@@ -36,6 +36,9 @@ ...@@ -36,6 +36,9 @@
%include "linearSystemFull.h" %include "linearSystemFull.h"
%template(linearSystemFullDouble) linearSystemFull<double> ; %template(linearSystemFullDouble) linearSystemFull<double> ;
#if defined(HAVE_PETSC) #if defined(HAVE_PETSC)
#if defined(HAVE_PETSC4PY)
%include petsc4py/petsc4py.i
#endif
%include "linearSystemPETSc.h" %include "linearSystemPETSc.h"
%template(linearSystemPETScDouble) linearSystemPETSc<double>; %template(linearSystemPETScDouble) linearSystemPETSc<double>;
%template(linearSystemPETScBlockDouble) linearSystemPETSc<fullMatrix<double> >; %template(linearSystemPETScBlockDouble) linearSystemPETSc<fullMatrix<double> >;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment