aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xExec/Langmuir/python/Langmuir.py12
-rw-r--r--Source/WarpXWrappers.cpp6
-rw-r--r--Source/WarpXWrappers.h2
3 files changed, 15 insertions, 5 deletions
diff --git a/Exec/Langmuir/python/Langmuir.py b/Exec/Langmuir/python/Langmuir.py
index 6ae631e1c..b288d24a8 100755
--- a/Exec/Langmuir/python/Langmuir.py
+++ b/Exec/Langmuir/python/Langmuir.py
@@ -10,9 +10,11 @@ import matplotlib.pyplot as plt
libwarpx = ctypes.CDLL("libwarpx.so")
libc = ctypes.CDLL(find_library('c'))
+dim = libwarpx.warpx_SpaceDim()
+
# our particle data type
-p_dtype = np.dtype([('x', 'f8'), ('y', 'f8'), ('z', 'f8'),
- ('id', 'i4'), ('cpu', 'i4')])
+p_struct = [(d, 'f8') for d in 'xyz'[:dim]] + [('id', 'i4'), ('cpu', 'i4')]
+p_dtype = np.dtype(p_struct)
# some useful typenames
LP_c_int = ctypes.POINTER(ctypes.c_int)
@@ -416,7 +418,7 @@ def get_mesh_electric_field(level, direction, include_ghosts=True):
ng = ngrow.value
grid_data = []
for i in range(size.value):
- shape=(shapes[3*i+0], shapes[3*i+1], shapes[3*i+2])
+ shape=(shapes[dim*i+0], shapes[dim*i+1], shapes[dim*i+2])
arr = np.ctypeslib.as_array(data[i], shape)
arr.setflags(write=1)
if include_ghosts:
@@ -463,7 +465,7 @@ def get_mesh_magnetic_field(level, direction, include_ghosts=True):
ng = ngrow.value
grid_data = []
for i in range(size.value):
- shape=(shapes[3*i+0], shapes[3*i+1], shapes[3*i+2])
+ shape=(shapes[dim*i+0], shapes[dim*i+1], shapes[dim*i+2])
arr = np.ctypeslib.as_array(data[i], shape)
arr.setflags(write=1)
if include_ghosts:
@@ -510,7 +512,7 @@ def get_mesh_current_density(level, direction, include_ghosts=True):
ng = ngrow.value
grid_data = []
for i in range(size.value):
- shape=(shapes[3*i+0], shapes[3*i+1], shapes[3*i+2])
+ shape=(shapes[dim*i+0], shapes[dim*i+1], shapes[dim*i+2])
arr = np.ctypeslib.as_array(data[i], shape)
arr.setflags(write=1)
if include_ghosts:
diff --git a/Source/WarpXWrappers.cpp b/Source/WarpXWrappers.cpp
index 1d0698ffc..233eacfc4 100644
--- a/Source/WarpXWrappers.cpp
+++ b/Source/WarpXWrappers.cpp
@@ -27,6 +27,12 @@ namespace
extern "C"
{
+
+ int warpx_SpaceDim()
+ {
+ return BL_SPACEDIM;
+ }
+
void amrex_init (int argc, char* argv[])
{
amrex::Initialize(argc,argv);
diff --git a/Source/WarpXWrappers.h b/Source/WarpXWrappers.h
index 28ee28a0c..e8ffc998e 100644
--- a/Source/WarpXWrappers.h
+++ b/Source/WarpXWrappers.h
@@ -9,6 +9,8 @@
extern "C" {
#endif
+ int warpx_SpaceDim();
+
void amrex_init (int argc, char* argv[]);
#ifdef BL_USE_MPI