aboutsummaryrefslogtreecommitdiff
path: root/Python/pywarpx/_libwarpx.py
diff options
context:
space:
mode:
authorGravatar Dave Grote <grote1@llnl.gov> 2019-06-14 16:26:47 -0700
committerGravatar Dave Grote <grote1@llnl.gov> 2019-06-14 16:26:47 -0700
commitee5dbceb99e5498250be3ef5db919518bd6783f3 (patch)
tree37995ee440a6b514bc63d27d3f96d3dde178093b /Python/pywarpx/_libwarpx.py
parent771a6966692d27af1d8f002afb7e12b4fc9c94fe (diff)
downloadWarpX-ee5dbceb99e5498250be3ef5db919518bd6783f3.tar.gz
WarpX-ee5dbceb99e5498250be3ef5db919518bd6783f3.tar.zst
WarpX-ee5dbceb99e5498250be3ef5db919518bd6783f3.zip
Updated Python interface, adding WarpInterface
Diffstat (limited to 'Python/pywarpx/_libwarpx.py')
-rwxr-xr-xPython/pywarpx/_libwarpx.py11
1 files changed, 10 insertions, 1 deletions
diff --git a/Python/pywarpx/_libwarpx.py b/Python/pywarpx/_libwarpx.py
index 5b7e14dbb..2a37dbd5e 100755
--- a/Python/pywarpx/_libwarpx.py
+++ b/Python/pywarpx/_libwarpx.py
@@ -1,6 +1,7 @@
# --- This defines the wrapper functions that directly call the underlying compiled routines
import os
import sys
+import atexit
import ctypes
from ctypes.util import find_library as _find_library
import numpy as np
@@ -8,6 +9,13 @@ from numpy.ctypeslib import ndpointer as _ndpointer
from .Geometry import geometry
+try:
+ # --- If mpi4py is going to be used, this needs to be imported
+ # --- before libwarpx is loaded (though don't know why)
+ from mpi4py import MPI
+except ImportError:
+ pass
+
# --- Is there a better way of handling constants?
clight = 2.99792458e+8 # m/s
@@ -184,6 +192,7 @@ def initialize(argv=None):
libwarpx.warpx_init()
+@atexit.register
def finalize(finalize_mpi=1):
'''
@@ -618,7 +627,7 @@ def _get_mesh_field_list(warpx_func, level, direction, include_ghosts):
if include_ghosts:
grid_data.append(arr)
else:
- grid_data.append(arr[[slice(ng, -ng) for _ in range(dim)]])
+ grid_data.append(arr[tuple([slice(ng, -ng) for _ in range(dim)])])
_libc.free(shapes)
_libc.free(data)