From 746ddc2ae871e70cd50940c2cca03a17a9b7ec1a Mon Sep 17 00:00:00 2001 From: David Grote Date: Thu, 16 Dec 2021 10:12:57 -0800 Subject: Wrap shared object in a class to control its loading (#2637) * Wrap shared object in a class to control its loading * Fix libwarpx attribute references * Updated callbacks.py for updated libwarpx * Removed the wx module plus other clean up * Further revision of how to use the pywarpx module. Now, _libwarpx should not be imported by external scripts except in special circumstances. * Updated documentation * Clean up end of line whitespace * Added more wrapping routines plus some clean up * Fixed use of pywarpx in two examples * Fix for getistep * Fixed for the EB Python interface * Silence a warning for our wrapper Co-authored-by: Axel Huebl --- Python/pywarpx/WarpX.py | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) (limited to 'Python/pywarpx/WarpX.py') diff --git a/Python/pywarpx/WarpX.py b/Python/pywarpx/WarpX.py index 7b1a07e24..232550764 100644 --- a/Python/pywarpx/WarpX.py +++ b/Python/pywarpx/WarpX.py @@ -20,6 +20,8 @@ from .Collisions import collisions, collisions_list from .PSATD import psatd from .Diagnostics import diagnostics +from . import _libwarpx + class WarpX(Bucket): """ @@ -74,25 +76,20 @@ class WarpX(Bucket): return argv def init(self, mpi_comm=None): - from . import wx argv = ['warpx'] + self.create_argv_list() - wx.initialize(argv, mpi_comm=mpi_comm) + _libwarpx.initialize(argv, mpi_comm=mpi_comm) def evolve(self, nsteps=-1): - from . import wx - wx.evolve(nsteps) + _libwarpx.evolve(nsteps) def finalize(self, finalize_mpi=1): - from . import wx - wx.finalize(finalize_mpi) + _libwarpx.finalize(finalize_mpi) def getProbLo(self, direction): - from . import wx - return wx.libwarpx.warpx_getProbLo(direction) + return _libwarpx.libwarpx.libwarpx_so.warpx_getProbLo(direction) def getProbHi(self, direction): - from . import wx - return wx.libwarpx.warpx_getProbHi(direction) + return _libwarpx.libwarpx.libwarpx_so.warpx_getProbHi(direction) def write_inputs(self, filename='inputs', **kw): argv = self.create_argv_list() -- cgit v1.2.3