@ -133,14 +133,11 @@ class lammps(object):
|
|||||||
# self.lmp = self.lib.lammps_open_no_mpi(0,None)
|
# self.lmp = self.lib.lammps_open_no_mpi(0,None)
|
||||||
|
|
||||||
else:
|
else:
|
||||||
if isinstance(ptr,lammps):
|
self.opened = 0
|
||||||
# magic to convert ptr to ctypes ptr
|
# magic to convert ptr to ctypes ptr
|
||||||
pythonapi.PyCObject_AsVoidPtr.restype = c_void_p
|
pythonapi.PyCObject_AsVoidPtr.restype = c_void_p
|
||||||
pythonapi.PyCObject_AsVoidPtr.argtypes = [py_object]
|
pythonapi.PyCObject_AsVoidPtr.argtypes = [py_object]
|
||||||
self.lmp = c_void_p(pythonapi.PyCObject_AsVoidPtr(ptr))
|
self.lmp = c_void_p(pythonapi.PyCObject_AsVoidPtr(ptr))
|
||||||
else:
|
|
||||||
self.lmp = None
|
|
||||||
raise TypeError('Unsupported type passed as "ptr"')
|
|
||||||
|
|
||||||
def __del__(self):
|
def __del__(self):
|
||||||
if self.lmp and self.opened: self.lib.lammps_close(self.lmp)
|
if self.lmp and self.opened: self.lib.lammps_close(self.lmp)
|
||||||
|
|||||||
Reference in New Issue
Block a user