Remove magic numbers and additional data types in extract_global

This commit is contained in:
Richard Berger
2019-08-22 10:45:24 -06:00
parent 5d7ce839a1
commit 3353bffb72

View File

@ -32,6 +32,11 @@ import select
import re
import sys
LAMMPS_INT = 0
LAMMPS_DOUBLE = 1
LAMMPS_BIGINT = 2
LAMMPS_TAGINT = 3
def get_ctypes_int(size):
if size == 4:
return c_int32
@ -283,10 +288,14 @@ class lammps(object):
def extract_global(self,name,type):
if name: name = name.encode()
if type == 0:
if type == LAMMPS_INT:
self.lib.lammps_extract_global.restype = POINTER(c_int)
elif type == 1:
elif type == LAMMPS_DOUBLE:
self.lib.lammps_extract_global.restype = POINTER(c_double)
elif type == LAMMPS_BIGINT:
self.lib.lammps_extract_global.restype = POINTER(self.c_bigint)
elif type == LAMMPS_TAGINT:
self.lib.lammps_extract_global.restype = POINTER(self.c_tagint)
else: return None
ptr = self.lib.lammps_extract_global(self.lmp,name)
return ptr[0]