aboutsummaryrefslogtreecommitdiff
path: root/Python/pywarpx/_libwarpx.py
diff options
context:
space:
mode:
authorGravatar David Grote <grote1@llnl.gov> 2021-10-25 16:05:41 -0700
committerGravatar GitHub <noreply@github.com> 2021-10-25 16:05:41 -0700
commit0032c91a358369bfa5b2ace82118d91acd60cdd5 (patch)
tree5420f52ef4f018ee6795e47df05b0474e765706b /Python/pywarpx/_libwarpx.py
parent105e127b95db5707d17cadc77fe68f1d68453d06 (diff)
downloadWarpX-0032c91a358369bfa5b2ace82118d91acd60cdd5.tar.gz
WarpX-0032c91a358369bfa5b2ace82118d91acd60cdd5.tar.zst
WarpX-0032c91a358369bfa5b2ace82118d91acd60cdd5.zip
Raise an exception if an MultiFab was not intialized (#2476)
Diffstat (limited to 'Python/pywarpx/_libwarpx.py')
-rwxr-xr-xPython/pywarpx/_libwarpx.py9
1 files changed, 9 insertions, 0 deletions
diff --git a/Python/pywarpx/_libwarpx.py b/Python/pywarpx/_libwarpx.py
index 804110fd6..e1f7d8fc4 100755
--- a/Python/pywarpx/_libwarpx.py
+++ b/Python/pywarpx/_libwarpx.py
@@ -922,6 +922,9 @@ def _get_mesh_field_list(warpx_func, level, direction, include_ghosts):
data = warpx_func(level, direction,
ctypes.byref(size), ctypes.byref(ncomps),
ctypes.byref(ngrowvect), ctypes.byref(shapes))
+ if not data:
+ raise Exception('object was not initialized')
+
ngvect = [ngrowvect[i] for i in range(dim)]
grid_data = []
shapesize = dim
@@ -1561,6 +1564,9 @@ def _get_mesh_array_lovects(level, direction, include_ghosts=True, getlovectsfun
else:
data = getlovectsfunc(level, direction, ctypes.byref(size), ctypes.byref(ngrowvect))
+ if not data:
+ raise Exception('object was not initialized')
+
lovects_ref = np.ctypeslib.as_array(data, (size.value, dim))
# --- Make a copy of the data to avoid memory problems
@@ -2080,6 +2086,9 @@ def get_mesh_G_fp_lovects(level, include_ghosts=True):
def _get_nodal_flag(getdatafunc):
data = getdatafunc()
+ if not data:
+ raise Exception('object was not initialized')
+
nodal_flag_ref = np.ctypeslib.as_array(data, (dim,))
# --- Make a copy of the data to avoid memory problems