git-svn-id: svn://svn.icms.temple.edu/lammps-ro/trunk@14419 f3b2605a-c512-4ea7-a41b-209d697bcdaa

This commit is contained in:
sjplimp
2016-01-11 22:00:09 +00:00
parent f5946c73f7
commit d3f534f5cc
2 changed files with 67 additions and 9 deletions

View File

@ -26,6 +26,10 @@
#include "memory.h"
#include "error.h"
// debug
#include "update.h"
using namespace LAMMPS_NS;
/* ---------------------------------------------------------------------- */
@ -48,6 +52,7 @@ AtomVecBody::AtomVecBody(LAMMPS *lmp) : AtomVec(lmp)
atom->body_flag = 1;
atom->rmass_flag = 1;
atom->angmom_flag = atom->torque_flag = 1;
atom->radius_flag = 1;
nlocal_bonus = nghost_bonus = nmax_bonus = 0;
bonus = NULL;
@ -103,7 +108,7 @@ void AtomVecBody::process_args(int narg, char **arg)
// bptr values = max number of additional ivalues/dvalues from Body class
size_forward = 7 + bptr->size_forward;
size_border = 16 + bptr->size_border;
size_border = 18 + bptr->size_border;
}
/* ----------------------------------------------------------------------
@ -128,6 +133,7 @@ void AtomVecBody::grow(int n)
v = memory->grow(atom->v,nmax,3,"atom:v");
f = memory->grow(atom->f,nmax*comm->nthreads,3,"atom:f");
radius = memory->grow(atom->radius,nmax,"atom:radius");
rmass = memory->grow(atom->rmass,nmax,"atom:rmass");
angmom = memory->grow(atom->angmom,nmax,3,"atom:angmom");
torque = memory->grow(atom->torque,nmax*comm->nthreads,3,"atom:torque");
@ -147,7 +153,8 @@ void AtomVecBody::grow_reset()
tag = atom->tag; type = atom->type;
mask = atom->mask; image = atom->image;
x = atom->x; v = atom->v; f = atom->f;
rmass = atom->rmass; angmom = atom->angmom; torque = atom->torque;
radius = atom->radius; rmass = atom->rmass;
angmom = atom->angmom; torque = atom->torque;
body = atom->body;
}
@ -183,6 +190,7 @@ void AtomVecBody::copy(int i, int j, int delflag)
v[j][1] = v[i][1];
v[j][2] = v[i][2];
radius[j] = radius[i];
rmass[j] = rmass[i];
angmom[j][0] = angmom[i][0];
angmom[j][1] = angmom[i][1];
@ -571,6 +579,8 @@ int AtomVecBody::pack_border(int n, int *list, double *buf,
buf[m++] = ubuf(tag[j]).d;
buf[m++] = ubuf(type[j]).d;
buf[m++] = ubuf(mask[j]).d;
buf[m++] = radius[j];
buf[m++] = rmass[j];
if (body[j] < 0) buf[m++] = ubuf(0).d;
else {
buf[m++] = ubuf(1).d;
@ -606,6 +616,8 @@ int AtomVecBody::pack_border(int n, int *list, double *buf,
buf[m++] = ubuf(tag[j]).d;
buf[m++] = ubuf(type[j]).d;
buf[m++] = ubuf(mask[j]).d;
buf[m++] = radius[j];
buf[m++] = rmass[j];
if (body[j] < 0) buf[m++] = ubuf(0).d;
else {
buf[m++] = ubuf(1).d;
@ -651,6 +663,8 @@ int AtomVecBody::pack_border_vel(int n, int *list, double *buf,
buf[m++] = ubuf(tag[j]).d;
buf[m++] = ubuf(type[j]).d;
buf[m++] = ubuf(mask[j]).d;
buf[m++] = radius[j];
buf[m++] = rmass[j];
if (body[j] < 0) buf[m++] = ubuf(0).d;
else {
buf[m++] = ubuf(1).d;
@ -693,6 +707,8 @@ int AtomVecBody::pack_border_vel(int n, int *list, double *buf,
buf[m++] = ubuf(tag[j]).d;
buf[m++] = ubuf(type[j]).d;
buf[m++] = ubuf(mask[j]).d;
buf[m++] = radius[j];
buf[m++] = rmass[j];
if (body[j] < 0) buf[m++] = ubuf(0).d;
else {
buf[m++] = ubuf(1).d;
@ -777,6 +793,8 @@ int AtomVecBody::pack_border_hybrid(int n, int *list, double *buf)
m = 0;
for (i = 0; i < n; i++) {
j = list[i];
buf[m++] = radius[j];
buf[m++] = rmass[j];
if (body[j] < 0) buf[m++] = ubuf(0).d;
else {
buf[m++] = ubuf(1).d;
@ -814,6 +832,8 @@ void AtomVecBody::unpack_border(int n, int first, double *buf)
tag[i] = (tagint) ubuf(buf[m++]).i;
type[i] = (int) ubuf(buf[m++]).i;
mask[i] = (int) ubuf(buf[m++]).i;
radius[i] = buf[m++];
rmass[i] = buf[m++];
body[i] = (int) ubuf(buf[m++]).i;
if (body[i] == 0) body[i] = -1;
else {
@ -862,6 +882,8 @@ void AtomVecBody::unpack_border_vel(int n, int first, double *buf)
tag[i] = (tagint) ubuf(buf[m++]).i;
type[i] = (int) ubuf(buf[m++]).i;
mask[i] = (int) ubuf(buf[m++]).i;
radius[i] = buf[m++];
rmass[i] = buf[m++];
body[i] = (int) ubuf(buf[m++]).i;
if (body[i] == 0) body[i] = -1;
else {
@ -909,6 +931,8 @@ int AtomVecBody::unpack_border_hybrid(int n, int first, double *buf)
m = 0;
last = first + n;
for (i = first; i < last; i++) {
radius[i] = buf[m++];
rmass[i] = buf[m++];
body[i] = (int) ubuf(buf[m++]).i;
if (body[i] == 0) body[i] = -1;
else {
@ -954,7 +978,7 @@ int AtomVecBody::pack_exchange(int i, double *buf)
buf[m++] = ubuf(type[i]).d;
buf[m++] = ubuf(mask[i]).d;
buf[m++] = ubuf(image[i]).d;
buf[m++] = radius[i];
buf[m++] = rmass[i];
buf[m++] = angmom[i][0];
buf[m++] = angmom[i][1];
@ -1008,7 +1032,7 @@ int AtomVecBody::unpack_exchange(double *buf)
type[nlocal] = (int) ubuf(buf[m++]).i;
mask[nlocal] = (int) ubuf(buf[m++]).i;
image[nlocal] = (imageint) ubuf(buf[m++]).i;
radius[nlocal] = buf[m++];
rmass[nlocal] = buf[m++];
angmom[nlocal][0] = buf[m++];
angmom[nlocal][1] = buf[m++];
@ -1067,11 +1091,11 @@ int AtomVecBody::size_restart()
int nlocal = atom->nlocal;
for (i = 0; i < nlocal; i++)
if (body[i] >= 0) {
n += 25;
n += 26;
if (intdoubleratio == 1) n += bonus[body[i]].ninteger;
else n += (bonus[body[i]].ninteger+1)/2;
n += bonus[body[i]].ndouble;
} else n += 16;
} else n += 17;
if (atom->nextra_restart)
for (int iextra = 0; iextra < atom->nextra_restart; iextra++)
@ -1101,6 +1125,7 @@ int AtomVecBody::pack_restart(int i, double *buf)
buf[m++] = v[i][1];
buf[m++] = v[i][2];
buf[m++] = radius[i];
buf[m++] = rmass[i];
buf[m++] = angmom[i][0];
buf[m++] = angmom[i][1];
@ -1161,6 +1186,7 @@ int AtomVecBody::unpack_restart(double *buf)
v[nlocal][1] = buf[m++];
v[nlocal][2] = buf[m++];
radius[nlocal] = buf[m++];
rmass[nlocal] = buf[m++];
angmom[nlocal][0] = buf[m++];
angmom[nlocal][1] = buf[m++];
@ -1228,6 +1254,7 @@ void AtomVecBody::create_atom(int itype, double *coord)
v[nlocal][1] = 0.0;
v[nlocal][2] = 0.0;
radius[nlocal] = 0.5;
rmass[nlocal] = 1.0;
angmom[nlocal][0] = 0.0;
angmom[nlocal][1] = 0.0;
@ -1274,6 +1301,7 @@ void AtomVecBody::data_atom(double *coord, imageint imagetmp, char **values)
angmom[nlocal][0] = 0.0;
angmom[nlocal][1] = 0.0;
angmom[nlocal][2] = 0.0;
radius[nlocal] = 0.5;
atom->nlocal++;
}
@ -1302,12 +1330,12 @@ int AtomVecBody::data_atom_hybrid(int nlocal, char **values)
------------------------------------------------------------------------- */
void AtomVecBody::data_body(int m, int ninteger, int ndouble,
char **ivalues, char **dvalues)
int *ivalues, double *dvalues)
{
if (body[m]) error->one(FLERR,"Assigning body parameters to non-body atom");
if (nlocal_bonus == nmax_bonus) grow_bonus();
bptr->data_body(nlocal_bonus,ninteger,ndouble,ivalues,dvalues);
bonus[nlocal_bonus].ilocal = m;
bptr->data_body(nlocal_bonus,ninteger,ndouble,ivalues,dvalues);
body[m] = nlocal_bonus++;
}
@ -1448,6 +1476,29 @@ int AtomVecBody::write_vel_hybrid(FILE *fp, double *buf)
return 3;
}
/* ----------------------------------------------------------------------
body computes its size based on ivalues/dvalues and returns it
------------------------------------------------------------------------- */
double AtomVecBody::radius_body(int ninteger, int ndouble,
int *ivalues, double *dvalues)
{
return bptr->radius_body(ninteger,ndouble,ivalues,dvalues);
}
/* ----------------------------------------------------------------------
reset quat orientation for atom M to quat_external
called by Atom:add_molecule_atom()
------------------------------------------------------------------------- */
void AtomVecBody::set_quat(int m, double *quat_external)
{
if (body[m] < 0) error->one(FLERR,"Assigning quat to non-body atom");
double *quat = bonus[body[m]].quat;
quat[0] = quat_external[0]; quat[1] = quat_external[1];
quat[2] = quat_external[2]; quat[3] = quat_external[3];
}
/* ----------------------------------------------------------------------
return # of bytes of allocated memory
------------------------------------------------------------------------- */
@ -1464,6 +1515,7 @@ bigint AtomVecBody::memory_usage()
if (atom->memcheck("v")) bytes += memory->usage(v,nmax,3);
if (atom->memcheck("f")) bytes += memory->usage(f,nmax*comm->nthreads,3);
if (atom->memcheck("radius")) bytes += memory->usage(radius,nmax);
if (atom->memcheck("rmass")) bytes += memory->usage(rmass,nmax);
if (atom->memcheck("angmom")) bytes += memory->usage(angmom,nmax,3);
if (atom->memcheck("torque")) bytes +=

View File

@ -85,13 +85,19 @@ class AtomVecBody : public AtomVec {
// manipulate Bonus data structure for extra atom info
void clear_bonus();
void data_body(int, int, int, char **, char **);
void data_body(int, int, int, int *, double *);
// methods used by other classes to query/set body info
double radius_body(int, int, int *, double *);
void set_quat(int, double *);
private:
tagint *tag;
int *type,*mask;
imageint *image;
double **x,**v,**f;
double *radius;
double *rmass;
double **angmom,**torque;
int *body;