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

python : split in four libraries : libGmsh.so, libDG.so gmshpy and dgpy

parent 49e5f7b8
Branches
Tags
No related merge requests found
...@@ -1125,9 +1125,8 @@ if(ENABLE_SWIG_EXPERIMENTAL) ...@@ -1125,9 +1125,8 @@ if(ENABLE_SWIG_EXPERIMENTAL)
FIND_PACKAGE(SWIG REQUIRED) FIND_PACKAGE(SWIG REQUIRED)
INCLUDE(${SWIG_USE_FILE}) INCLUDE(${SWIG_USE_FILE})
FIND_PACKAGE(PythonLibs) FIND_PACKAGE(PythonLibs)
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR};${PYTHON_INCLUDE_DIR};../Common;${CMAKE_CURRENT_BINARY_DIR}/../Common) INCLUDE_DIRECTORIES(${PYTHON_INCLUDE_DIR})
SET_SOURCE_FILES_PROPERTIES(Geo/GModel.i PROPERTIES CPLUSPLUS ON) SET_SOURCE_FILES_PROPERTIES(Common/gmshpy.i PROPERTIES CPLUSPLUS ON)
#SET_SOURCE_FILES_PROPERTIES(Geo/GModel.i SWIG_FLAGS "-includeall -importall") SWIG_ADD_MODULE(gmshpy python Common/gmshpy.i)
SWIG_ADD_MODULE(gmshPython python Geo/GModel.i ${GMSH_SRC}) SWIG_LINK_LIBRARIES(gmshpy ${PYTHON_LIBRARIES} ${EXTERNAL_LIBRARIES} ${LINK_LIBRARIES} shared)
SWIG_LINK_LIBRARIES(gmshPython ${PYTHON_LIBRARIES} ${EXTERNAL_LIBRARIES} ${LINK_LIBRARIES})
endif(ENABLE_SWIG_EXPERIMENTAL) endif(ENABLE_SWIG_EXPERIMENTAL)
%feature("autodoc", "1");
%module gmshpy
%include std_string.i
%include std_vector.i
%{
#include "GModel.h"
#include "fullMatrix.h"
#include "function.h"
#include "dofManager.h"
#include "linearSystem.h"
#include "linearSystemPETSc.h"
#include "linearSystemPETSc.cpp" // needed for the specialization
#include "GEntity.h"
#include "GVertex.h"
#include "GEdge.h"
#include "GFace.h"
#include "GRegion.h"
#include "GPoint.h"
#include "MElement.h"
#include "MVertex.h"
#include "MTriangle.h"
#include "MPrism.h"
#include "MQuadrangle.h"
#include "MLine.h"
#include "GmshMessage.h"
#include "polynomialBasis.h"
#include "Gauss.h"
#include "meshPartitionOptions.h"
#include "linearSystemCSR.h"
#include "elasticitySolver.h"
#include "PView.h"
#include "PViewData.h"
#include "PViewFactory.h"
#include "DivideAndConquer.h"
#include "Gmsh.h"
#include "functionPython.h"
%}
namespace std {
%template(IntVector) vector<int>;
%template(DoubleVector) vector<double, std::allocator<double> >;
%template(VectorFunctionConst) vector<const function*, std::allocator<const function*> >;
}
%include "fullMatrix.h"
%include "dofManager.h"
%include "GModel.h"
%include "function.h"
%include "linearSystem.h"
%include "linearSystemPETSc.h"
%include "GEntity.h"
%include "GVertex.h"
%include "GEdge.h"
%include "GFace.h"
%include "GRegion.h"
%include "GPoint.h"
%include "MElement.h"
%include "MVertex.h"
%include "MTriangle.h"
%include "MPrism.h"
%include "MQuadrangle.h"
%include "MLine.h"
%include "GmshMessage.h"
%include "polynomialBasis.h"
%include "Gauss.h"
%include "meshPartitionOptions.h"
%include "linearSystemCSR.h"
%include "elasticitySolver.h"
%include "PView.h"
%include "PViewData.h"
%include "PViewFactory.h"
%include "DivideAndConquer.h"
%include "Gmsh.h"
%template(dofManagerDouble) dofManager<double>;
%template(linearSystemDouble) linearSystem<double>;
%template(linearSystemFullMatrixDouble) linearSystem<fullMatrix<double> >;
%template(linearSystemPETScDouble) linearSystemPETSc<double>;
%template(fullMatrixDouble) fullMatrix<double>;
%template(linearSystemPETScBlockDouble) linearSystemPETSc<fullMatrix<double> >;
%include "functionPython.h"
#ifndef _FUNCTION_PYTHON_H_
#define _FUNCTION_PYTHON_H_
#include "Python.h"
class functionPython : public function {
PyObject *_pycallback, *_pyargs;
PyObject *_swigR, *_swigCacheMap;
std::vector<PyObject*> _swigA;
std::string _luaFunctionName;
std::vector<fullMatrix<double> > args;
fullMatrix<double> R;
public:
void call (dataCacheMap *m, fullMatrix<double> &res)
{
R.setAsProxy(res);
PyEval_CallObject(_pycallback, _pyargs);
}
functionPython (int nbCol, PyObject *callback, std::vector<const function*> dependencies)
: function(nbCol), _pycallback(callback)
{
args.resize(dependencies.size());
_swigA.resize(args.size());
_swigR = SWIG_NewPointerObj((void*)&R,SWIGTYPE_p_fullMatrixT_double_t, 0);
for (int i = 0; i < dependencies.size(); i++) {
setArgument(args[i], dependencies[i]);
_swigA[i] = SWIG_NewPointerObj((void*)&args[i],SWIGTYPE_p_fullMatrixT_double_t, 0);
}
switch(args.size()) {
case 0 : _pyargs = Py_BuildValue("(O)", _swigR); break;
case 1 : _pyargs = Py_BuildValue("(OO)", _swigR, _swigA[0], _swigA[1], _swigA[2], _swigA[3], _swigA[4], _swigA[5], _swigA[6]); break;
case 2 : _pyargs = Py_BuildValue("(OOO)", _swigR, _swigA[0], _swigA[1], _swigA[2], _swigA[3], _swigA[4], _swigA[5], _swigA[6]); break;
case 3 : _pyargs = Py_BuildValue("(OOOO)", _swigR, _swigA[0], _swigA[1], _swigA[2], _swigA[3], _swigA[4], _swigA[5], _swigA[6]); break;
case 4 : _pyargs = Py_BuildValue("(OOOOO)", _swigR, _swigA[0], _swigA[1], _swigA[2], _swigA[3], _swigA[4], _swigA[5], _swigA[6]); break;
case 5 : _pyargs = Py_BuildValue("(OOOOOO)", _swigR, _swigA[0], _swigA[1], _swigA[2], _swigA[3], _swigA[4], _swigA[5], _swigA[6]); break;
case 6 : _pyargs = Py_BuildValue("(OOOOOOO)", _swigR, _swigA[0], _swigA[1], _swigA[2], _swigA[3], _swigA[4], _swigA[5], _swigA[6]); break;
case 7 : _pyargs = Py_BuildValue("(OOOOOOOO)", _swigR, _swigA[0], _swigA[1], _swigA[2], _swigA[3], _swigA[4], _swigA[5], _swigA[6]); break;
default:Msg::Error("python function not implemented for more than 7 arguments");
}
}
};
#endif
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment