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.
This commit is contained in:
Richard Berger 2017-03-15 22:13:06 -04:00
parent 0262a54ecf
commit a210867025
2 changed files with 14 additions and 8 deletions

View File

@ -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?

View File

@ -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];