Skip to content

Commit

Permalink
Merge pull request #249 from mfem/fix_mfem_real_t
Browse files Browse the repository at this point in the history
Fix some wrapper code not handling mfem::real_t correctly
  • Loading branch information
sshiraiwa authored Aug 9, 2024
2 parents 95a58de + 70e00e5 commit 0054c54
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 13 deletions.
2 changes: 1 addition & 1 deletion mfem/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,5 @@ def debug_print(message):

print(message)

__version__ = '4.7.0'
__version__ = '4.7.0.1'

12 changes: 6 additions & 6 deletions mfem/_par/hypre.i
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ bool is_HYPRE_USING_CUDA(){
HYPRE_Int *col);
*/
%typemap(in) (double *data_, HYPRE_BigInt *col)(PyArrayObject * tmp_arr1_ = NULL, PyArrayObject * tmp_arr2_ = NULL){
%typemap(in) (mfem::real_t *data_, HYPRE_BigInt *col)(PyArrayObject * tmp_arr1_ = NULL, PyArrayObject * tmp_arr2_ = NULL){
//HypreParVec constructer requires outside object alive
// We keep reference to such outside numpy array in ProxyClass
tmp_arr1_ = (PyArrayObject *)PyList_GetItem($input,0);
Expand All @@ -75,9 +75,9 @@ bool is_HYPRE_USING_CUDA(){
$1 = (double *) PyArray_DATA(tmp_arr1_);
$2 = (HYPRE_BigInt *) PyArray_DATA(tmp_arr2_);
}
%typemap(freearg) (double *data_, HYPRE_BigInt *col){
%typemap(freearg) (mfem::real_t *data_, HYPRE_BigInt *col){
}
%typemap(typecheck )(double *data_, HYPRE_BigInt *col){
%typemap(typecheck )(mfem::real_t *data_, HYPRE_BigInt *col){
/* check if list of 2 numpy array or not */
if (!PyList_Check($input)) $1 = 0;
else {
Expand All @@ -103,7 +103,7 @@ bool is_HYPRE_USING_CUDA(){

%typemap(in) (int *I,
HYPRE_BigInt *J,
double *data,
mfem::real_t *data,
HYPRE_BigInt *rows,
HYPRE_BigInt *cols)
(PyArrayObject *tmp_arr1_ = NULL,
Expand Down Expand Up @@ -131,7 +131,7 @@ bool is_HYPRE_USING_CUDA(){
}
}
%typemap(freearg) (int *I, HYPRE_BigInt *J,
double *data, HYPRE_BigInt *rows, HYPRE_BigInt *cols){
mfem::real_t *data, HYPRE_BigInt *rows, HYPRE_BigInt *cols){
Py_XDECREF(tmp_arr1_$argnum);
Py_XDECREF(tmp_arr2_$argnum);
Py_XDECREF(tmp_arr3_$argnum);
Expand All @@ -142,7 +142,7 @@ bool is_HYPRE_USING_CUDA(){
}

%typemap(typecheck ) (int *I, HYPRE_BigInt *J,
double *data, HYPRE_BigInt *rows,
mfem::real_t *data, HYPRE_BigInt *rows,
HYPRE_BigInt *cols){
/* check if list of 5 numpy array or not */
if (!PyList_Check($input)) $1 = 0;
Expand Down
8 changes: 5 additions & 3 deletions mfem/_par/sparsemat.i
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ using namespace mfem;
import_array();
%}

%import "../common/mfem_config.i"

%include "exception.i"
%import "array.i"
%import "mem_manager.i"
Expand Down Expand Up @@ -100,7 +102,7 @@ if len(args) == 1 and isinstance(args[0], csr_matrix):
SparseMatrix(int *i, int *j, double *data, int m, int n);
allows to use numpy array to call this
*/
%typemap(in) (int *i, int *j, double *data, int m, int n)
%typemap(in) (int *i, int *j, mfem::real_t *data, int m, int n)
(PyArrayObject *tmp_arr1_ = NULL,
PyArrayObject *tmp_arr2_ = NULL,
PyArrayObject *tmp_arr3_ = NULL,
Expand All @@ -121,13 +123,13 @@ if len(args) == 1 and isinstance(args[0], csr_matrix):
//
PyArray_CLEARFLAGS(tmp_arr3_, NPY_ARRAY_OWNDATA);
}
%typemap(freearg) (int *i, int *j, double *data, int m, int n){
%typemap(freearg) (int *i, int *j, mfem::real_t *data, int m, int n){
//Py_XDECREF(tmp_arr1_$argnum); Dont do this.. We set OwnsGraph and OwnsData to Fase in Python
//Py_XDECREF(tmp_arr2_$argnum);
//Py_XDECREF(tmp_arr3_$argnum);
}

%typemap(typecheck ) (int *i, int *j, double *data, int m, int n){
%typemap(typecheck ) (int *i, int *j, mfem::real_t *data, int m, int n){
/* check if list of 5 numpy array or not */
if (!PyList_Check($input)) $1 = 0;
else {
Expand Down
6 changes: 3 additions & 3 deletions mfem/_ser/sparsemat.i
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ if len(args) == 1 and isinstance(args[0], csr_matrix):
SparseMatrix(int *i, int *j, double *data, int m, int n);
allows to use numpy array to call this
*/
%typemap(in) (int *i, int *j, double *data, int m, int n)
%typemap(in) (int *i, int *j, mfem::real_t *data, int m, int n)
(PyArrayObject *tmp_arr1_ = NULL,
PyArrayObject *tmp_arr2_ = NULL,
PyArrayObject *tmp_arr3_ = NULL,
Expand All @@ -120,13 +120,13 @@ if len(args) == 1 and isinstance(args[0], csr_matrix):
//
PyArray_CLEARFLAGS(tmp_arr3_, NPY_ARRAY_OWNDATA);
}
%typemap(freearg) (int *i, int *j, double *data, int m, int n){
%typemap(freearg) (int *i, int *j, mfem::real_t *data, int m, int n){
//Py_XDECREF(tmp_arr1_$argnum); Dont do this.. We set OwnsGraph and OwnsData to Fase in Python
//Py_XDECREF(tmp_arr2_$argnum);
//Py_XDECREF(tmp_arr3_$argnum);
}

%typemap(typecheck ) (int *i, int *j, double *data, int m, int n){
%typemap(typecheck ) (int *i, int *j, mfem::real_t *data, int m, int n){
/* check if list of 5 numpy array or not */
if (!PyList_Check($input)) $1 = 0;
else {
Expand Down

0 comments on commit 0054c54

Please sign in to comment.