aboutsummaryrefslogtreecommitdiff
path: root/Python/pywarpx/_libwarpx.py
diff options
context:
space:
mode:
authorGravatar David Grote <grote1@llnl.gov> 2020-03-23 13:45:33 -0700
committerGravatar GitHub <noreply@github.com> 2020-03-23 13:45:33 -0700
commit984c6f89ead2f761b6f948d19dc8724052a48a6d (patch)
tree702c7cdb89fc9c3f9dd8dac47a334d80c21da316 /Python/pywarpx/_libwarpx.py
parent24aef3703b91c74c9cf049ee863415bb3ce4fbe1 (diff)
downloadWarpX-984c6f89ead2f761b6f948d19dc8724052a48a6d.tar.gz
WarpX-984c6f89ead2f761b6f948d19dc8724052a48a6d.tar.zst
WarpX-984c6f89ead2f761b6f948d19dc8724052a48a6d.zip
Updated Python interface for Python_Langmuir_rz_multimode test (#810)
* Added nodal and cell size data to the Python interface and updates the Python_Langmuir_rz_multimode regression test * Cleanup of PICMI_inputs_langmuir_rz_multimode_analyze.py
Diffstat (limited to 'Python/pywarpx/_libwarpx.py')
-rwxr-xr-xPython/pywarpx/_libwarpx.py114
1 files changed, 114 insertions, 0 deletions
diff --git a/Python/pywarpx/_libwarpx.py b/Python/pywarpx/_libwarpx.py
index 2550cb92a..d7e3e8ba2 100755
--- a/Python/pywarpx/_libwarpx.py
+++ b/Python/pywarpx/_libwarpx.py
@@ -166,6 +166,17 @@ libwarpx.warpx_getChargeDensityCPLoVects.restype = _LP_c_int
libwarpx.warpx_getChargeDensityFP.restype = _LP_LP_c_real
libwarpx.warpx_getChargeDensityFPLoVects.restype = _LP_c_int
+libwarpx.warpx_getEx_nodal_flag.restype = _LP_c_int
+libwarpx.warpx_getEy_nodal_flag.restype = _LP_c_int
+libwarpx.warpx_getEz_nodal_flag.restype = _LP_c_int
+libwarpx.warpx_getBx_nodal_flag.restype = _LP_c_int
+libwarpx.warpx_getBy_nodal_flag.restype = _LP_c_int
+libwarpx.warpx_getBz_nodal_flag.restype = _LP_c_int
+libwarpx.warpx_getJx_nodal_flag.restype = _LP_c_int
+libwarpx.warpx_getJy_nodal_flag.restype = _LP_c_int
+libwarpx.warpx_getJz_nodal_flag.restype = _LP_c_int
+libwarpx.warpx_getRho_nodal_flag.restype = _LP_c_int
+
#libwarpx.warpx_getPMLSigma.restype = _LP_c_real
#libwarpx.warpx_getPMLSigmaStar.restype = _LP_c_real
#libwarpx.warpx_ComputePMLFactors.argtypes = (ctypes.c_int, c_real)
@@ -183,6 +194,7 @@ libwarpx.warpx_addNParticles.argtypes = (ctypes.c_int, ctypes.c_int,
libwarpx.warpx_getProbLo.restype = c_real
libwarpx.warpx_getProbHi.restype = c_real
+libwarpx.warpx_getCellSize.restype = c_real
libwarpx.warpx_getistep.restype = ctypes.c_int
libwarpx.warpx_gett_new.restype = c_real
libwarpx.warpx_getdt.restype = c_real
@@ -199,6 +211,9 @@ libwarpx.warpx_FillBoundaryB.argtypes = []
libwarpx.warpx_UpdateAuxilaryData.argtypes = []
libwarpx.warpx_SyncCurrent.argtypes = []
libwarpx.warpx_PushParticlesandDepose.argtypes = [c_real]
+libwarpx.warpx_getProbLo.argtypes = [ctypes.c_int]
+libwarpx.warpx_getProbHi.argtypes = [ctypes.c_int]
+libwarpx.warpx_getCellSize.argtypes = [ctypes.c_int, ctypes.c_int]
libwarpx.warpx_getistep.argtypes = [ctypes.c_int]
libwarpx.warpx_setistep.argtypes = [ctypes.c_int, ctypes.c_int]
libwarpx.warpx_gett_new.argtypes = [ctypes.c_int]
@@ -267,6 +282,22 @@ def evolve(num_steps=-1):
libwarpx.warpx_evolve(num_steps);
+def getProbLo(direction):
+ assert 0 <= direction < dim, 'Inappropriate direction specified'
+ return libwarpx.warpx_getProbLo(direction)
+
+
+def getProbHi(direction):
+ assert 0 <= direction < dim, 'Inappropriate direction specified'
+ return libwarpx.warpx_getProbHi(direction)
+
+
+def getCellSize(direction, level=0):
+ assert 0 <= direction < 3, 'Inappropriate direction specified'
+ assert 0 <= level and level <= libwarpx.warpx_finestLevel(), 'Inappropriate level specified'
+ return libwarpx.warpx_getCellSize(direction, level)
+
+
#def get_sigma(direction):
# '''
#
@@ -1539,6 +1570,8 @@ def get_mesh_current_density_fp_lovects_pml(level, direction, include_ghosts=Tru
return _get_mesh_array_lovects(level, direction, include_ghosts, libwarpx.warpx_getCurrentDensityFPLoVects_PML)
except ValueError:
raise Exception('PML not initialized')
+
+
def get_mesh_charge_density_cp_lovects(level, include_ghosts=True):
'''
@@ -1579,3 +1612,84 @@ def get_mesh_charge_density_fp_lovects(level, include_ghosts=True):
'''
return _get_mesh_array_lovects(level, None, include_ghosts, libwarpx.warpx_getChargeDensityFPLoVects)
+
+def _get_nodal_flag(getdatafunc):
+ data = getdatafunc()
+ nodal_flag_ref = np.ctypeslib.as_array(data, (dim,))
+
+ # --- Make a copy of the data to avoid memory problems
+ nodal_flag = nodal_flag_ref.copy()
+
+ del nodal_flag_ref
+ _libc.free(data)
+ return nodal_flag
+
+
+def get_Ex_nodal_flag():
+ '''
+ This returns a 1d array of the nodal flags for Ex along each direction. A 1 means node centered, and 0 cell centered.
+ '''
+ return _get_nodal_flag(libwarpx.warpx_getEx_nodal_flag)
+
+
+def get_Ey_nodal_flag():
+ '''
+ This returns a 1d array of the nodal flags for Ey along each direction. A 1 means node centered, and 0 cell centered.
+ '''
+ return _get_nodal_flag(libwarpx.warpx_getEy_nodal_flag)
+
+
+def get_Ez_nodal_flag():
+ '''
+ This returns a 1d array of the nodal flags for Ez along each direction. A 1 means node centered, and 0 cell centered.
+ '''
+ return _get_nodal_flag(libwarpx.warpx_getEz_nodal_flag)
+
+
+def get_Bx_nodal_flag():
+ '''
+ This returns a 1d array of the nodal flags for Bx along each direction. A 1 means node centered, and 0 cell centered.
+ '''
+ return _get_nodal_flag(libwarpx.warpx_getBx_nodal_flag)
+
+
+def get_By_nodal_flag():
+ '''
+ This returns a 1d array of the nodal flags for By along each direction. A 1 means node centered, and 0 cell centered.
+ '''
+ return _get_nodal_flag(libwarpx.warpx_getBy_nodal_flag)
+
+
+def get_Bz_nodal_flag():
+ '''
+ This returns a 1d array of the nodal flags for Bz along each direction. A 1 means node centered, and 0 cell centered.
+ '''
+ return _get_nodal_flag(libwarpx.warpx_getBz_nodal_flag)
+
+
+def get_Jx_nodal_flag():
+ '''
+ This returns a 1d array of the nodal flags for Jx along each direction. A 1 means node centered, and 0 cell centered.
+ '''
+ return _get_nodal_flag(libwarpx.warpx_getJx_nodal_flag)
+
+
+def get_Jy_nodal_flag():
+ '''
+ This returns a 1d array of the nodal flags for Jy along each direction. A 1 means node centered, and 0 cell centered.
+ '''
+ return _get_nodal_flag(libwarpx.warpx_getJy_nodal_flag)
+
+
+def get_Jz_nodal_flag():
+ '''
+ This returns a 1d array of the nodal flags for Jz along each direction. A 1 means node centered, and 0 cell centered.
+ '''
+ return _get_nodal_flag(libwarpx.warpx_getJz_nodal_flag)
+
+
+def get_Rho_nodal_flag():
+ '''
+ This returns a 1d array of the nodal flags for Rho along each direction. A 1 means node centered, and 0 cell centered.
+ '''
+ return _get_nodal_flag(libwarpx.warpx_getRho_nodal_flag)