From a210867025e19c1bd9243a863fdc3e66e62bc3c5 Mon Sep 17 00:00:00 2001 From: Richard Berger Date: Wed, 15 Mar 2017 22:13:06 -0400 Subject: [PATCH] Fixes lammps_create_atoms library function and its Python interface variant The interface of that function has changed and includes two additional parameters, which haven't been added to the Python interface either. This showed up by trying to run the simple.py example. --- python/lammps.py | 14 +++++++++++--- src/library.cpp | 8 +++----- 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/python/lammps.py b/python/lammps.py index 80d1a87159..0581b475a4 100644 --- a/python/lammps.py +++ b/python/lammps.py @@ -362,14 +362,22 @@ class lammps(object): # e.g. for Python list or NumPy, etc # ditto for gather_atoms() above - def create_atoms(self,n,id,type,x,v): + def create_atoms(self,n,id,type,x,v,image=None,shrinkexceed=False): if id: id_lmp = (c_int * n)() id_lmp[:] = id - else: id_lmp = id + else: + id_lmp = id + + if image: + image_lmp = (c_int * n)() + image_lmp[:] = image + else: + image_lmp = image + type_lmp = (c_int * n)() type_lmp[:] = type - self.lib.lammps_create_atoms(self.lmp,n,id_lmp,type_lmp,x,v) + self.lib.lammps_create_atoms(self.lmp,n,id_lmp,type_lmp,x,v,image_lmp,shrinkexceed) # document this? diff --git a/src/library.cpp b/src/library.cpp index 5980b135eb..da491f7152 100644 --- a/src/library.cpp +++ b/src/library.cpp @@ -971,11 +971,9 @@ void lammps_create_atoms(void *ptr, int n, tagint *id, int *type, xdata[0] = x[3*i]; xdata[1] = x[3*i+1]; xdata[2] = x[3*i+2]; - if (image) { - if (!domain->ownatom(id[i],xdata,&image[i],shrinkexceed)) continue; - } else { - if (!domain->ownatom(id[i],xdata,NULL,shrinkexceed)) continue; - } + imageint * img = image ? &image[i] : NULL; + tagint tag = id ? id[i] : -1; + if (!domain->ownatom(tag, xdata, img, shrinkexceed)) continue; atom->avec->create_atom(type[i],xdata); if (id) atom->tag[nlocal] = id[i];