Currently, the python interface crashes if you ask for the value of a field at a point outside of the domain. As you don't always know the domain a priori, or you want to look at things on a rectangular grid that the domain boundary may run through, I would suggest that zero gets returned instead of null. @nferraro If you could give me the ability to write to this repository (at least new branches if not master), I can push the suggested changes for your review. Alternatively, I've included the suggested changes below that worked for me.
diff --git a/fusion_io/python_interface.cpp b/fusion_io/python_interface.cpp
index 338170e..e3e4c41 100644
--- a/fusion_io/python_interface.cpp
+++ b/fusion_io/python_interface.cpp
@@ -148,6 +148,8 @@ PyObject* fio_eval_scalar_field_py(PyObject* self, PyObject *args)
double v;
int ierr = fio_eval_field(ifield, x, &v);
+ if(ierr == FIO_OUT_OF_BOUNDS)
+ return Py_BuildValue("d", 0.);
if(ierr != FIO_SUCCESS)
return NULL;
@@ -180,6 +182,8 @@ PyObject* fio_eval_vector_field_py(PyObject* self, PyObject *args)
double v[3];
int ierr = fio_eval_field(ifield, x, v);
+ if(ierr == FIO_OUT_OF_BOUNDS)
+ return Py_BuildValue("(ddd)", 0., 0., 0.);
if(ierr != FIO_SUCCESS)
return NULL;
Currently, the python interface crashes if you ask for the value of a field at a point outside of the domain. As you don't always know the domain a priori, or you want to look at things on a rectangular grid that the domain boundary may run through, I would suggest that zero gets returned instead of null. @nferraro If you could give me the ability to write to this repository (at least new branches if not master), I can push the suggested changes for your review. Alternatively, I've included the suggested changes below that worked for me.