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

This commit is contained in:
sjplimp
2013-02-01 16:52:14 +00:00
parent 9b7bd3e892
commit 69a209f09d
5 changed files with 72 additions and 12 deletions

View File

@ -219,8 +219,9 @@ void AtomVecBody::copy(int i, int j, int delflag)
} }
// if atom I has bonus data, reset I's bonus.ilocal to loc J // if atom I has bonus data, reset I's bonus.ilocal to loc J
// do NOT do this if self-copy (I=J) since I's bonus data is already deleted
if (body[i] >= 0) bonus[body[i]].ilocal = j; if (body[i] >= 0 && i != j) bonus[body[i]].ilocal = j;
body[j] = body[i]; body[j] = body[i];
if (atom->nextra_grow) if (atom->nextra_grow)
@ -230,13 +231,13 @@ void AtomVecBody::copy(int i, int j, int delflag)
/* ---------------------------------------------------------------------- /* ----------------------------------------------------------------------
copy bonus data from I to J, effectively deleting the J entry copy bonus data from I to J, effectively deleting the J entry
insure index pointers between per-atom and bonus data are updated also reset body that points to I to now point to J
------------------------------------------------------------------------- */ ------------------------------------------------------------------------- */
void AtomVecBody::copy_bonus(int i, int j) void AtomVecBody::copy_bonus(int i, int j)
{ {
body[bonus[i].ilocal] = j;
memcpy(&bonus[j],&bonus[i],sizeof(Bonus)); memcpy(&bonus[j],&bonus[i],sizeof(Bonus));
body[bonus[j].ilocal] = j;
} }
/* ---------------------------------------------------------------------- /* ----------------------------------------------------------------------
@ -1407,3 +1408,52 @@ bigint AtomVecBody::memory_usage()
return bytes; return bytes;
} }
/* ----------------------------------------------------------------------
debug method for sanity checking of own/bonus data pointers
------------------------------------------------------------------------- */
/*
void AtomVecBody::check(int flag)
{
for (int i = 0; i < atom->nlocal; i++) {
if (atom->body[i] >= 0 && atom->body[i] >= nlocal_bonus) {
printf("Proc %d, step %ld, flag %d\n",comm->me,update->ntimestep,flag);
error->one(FLERR,"BAD AAA");
}
}
for (int i = atom->nlocal; i < atom->nlocal+atom->nghost; i++) {
if (atom->body[i] >= 0 &&
(atom->body[i] < nlocal_bonus ||
atom->body[i] >= nlocal_bonus+nghost_bonus)) {
printf("Proc %d, step %ld, flag %d\n",comm->me,update->ntimestep,flag);
error->one(FLERR,"BAD BBB");
}
}
for (int i = 0; i < nlocal_bonus; i++) {
if (bonus[i].ilocal < 0 || bonus[i].ilocal >= atom->nlocal) {
printf("Proc %d, step %ld, flag %d\n",comm->me,update->ntimestep,flag);
error->one(FLERR,"BAD CCC");
}
}
for (int i = 0; i < nlocal_bonus; i++) {
if (atom->body[bonus[i].ilocal] != i) {
printf("Proc %d, step %ld, flag %d\n",comm->me,update->ntimestep,flag);
error->one(FLERR,"BAD DDD");
}
}
for (int i = nlocal_bonus; i < nlocal_bonus+nghost_bonus; i++) {
if (bonus[i].ilocal < atom->nlocal ||
bonus[i].ilocal >= atom->nlocal+atom->nghost) {
printf("Proc %d, step %ld, flag %d\n",comm->me,update->ntimestep,flag);
error->one(FLERR,"BAD EEE");
}
}
for (int i = nlocal_bonus; i < nlocal_bonus+nghost_bonus; i++) {
if (atom->body[bonus[i].ilocal] != i) {
printf("Proc %d, step %ld, flag %d\n",comm->me,update->ntimestep,flag);
error->one(FLERR,"BAD FFF");
}
}
}
*/

View File

@ -25,6 +25,12 @@ AtomStyle(body,AtomVecBody)
namespace LAMMPS_NS { namespace LAMMPS_NS {
class AtomVecBody : public AtomVec { class AtomVecBody : public AtomVec {
friend class Comm;
public: public:
class Body *bptr; class Body *bptr;
@ -96,6 +102,7 @@ class AtomVecBody : public AtomVec {
void grow_bonus(); void grow_bonus();
void copy_bonus(int, int); void copy_bonus(int, int);
//void check(int);
}; };
} }

View File

@ -153,8 +153,9 @@ void AtomVecEllipsoid::copy(int i, int j, int delflag)
} }
// if atom I has bonus data, reset I's bonus.ilocal to loc J // if atom I has bonus data, reset I's bonus.ilocal to loc J
// do NOT do this if self-copy (I=J) since I's bonus data is already deleted
if (ellipsoid[i] >= 0) bonus[ellipsoid[i]].ilocal = j; if (ellipsoid[i] >= 0 && i != j) bonus[ellipsoid[i]].ilocal = j;
ellipsoid[j] = ellipsoid[i]; ellipsoid[j] = ellipsoid[i];
if (atom->nextra_grow) if (atom->nextra_grow)
@ -164,13 +165,13 @@ void AtomVecEllipsoid::copy(int i, int j, int delflag)
/* ---------------------------------------------------------------------- /* ----------------------------------------------------------------------
copy bonus data from I to J, effectively deleting the J entry copy bonus data from I to J, effectively deleting the J entry
insure index pointers between per-atom and bonus data are updated also reset ellipsoid that points to I to now point to J
------------------------------------------------------------------------- */ ------------------------------------------------------------------------- */
void AtomVecEllipsoid::copy_bonus(int i, int j) void AtomVecEllipsoid::copy_bonus(int i, int j)
{ {
ellipsoid[bonus[i].ilocal] = j;
memcpy(&bonus[j],&bonus[i],sizeof(Bonus)); memcpy(&bonus[j],&bonus[i],sizeof(Bonus));
ellipsoid[bonus[j].ilocal] = j;
} }
/* ---------------------------------------------------------------------- /* ----------------------------------------------------------------------

View File

@ -163,8 +163,9 @@ void AtomVecLine::copy(int i, int j, int delflag)
} }
// if atom I has bonus data, reset I's bonus.ilocal to loc J // if atom I has bonus data, reset I's bonus.ilocal to loc J
// do NOT do this if self-copy (I=J) since I's bonus data is already deleted
if (line[i] >= 0) bonus[line[i]].ilocal = j; if (line[i] >= 0 && i != j) bonus[line[i]].ilocal = j;
line[j] = line[i]; line[j] = line[i];
if (atom->nextra_grow) if (atom->nextra_grow)
@ -174,13 +175,13 @@ void AtomVecLine::copy(int i, int j, int delflag)
/* ---------------------------------------------------------------------- /* ----------------------------------------------------------------------
copy bonus data from I to J, effectively deleting the J entry copy bonus data from I to J, effectively deleting the J entry
insure index pointers between per-atom and bonus data are updated also reset ine that points to I to now point to J
------------------------------------------------------------------------- */ ------------------------------------------------------------------------- */
void AtomVecLine::copy_bonus(int i, int j) void AtomVecLine::copy_bonus(int i, int j)
{ {
line[bonus[i].ilocal] = j;
memcpy(&bonus[j],&bonus[i],sizeof(Bonus)); memcpy(&bonus[j],&bonus[i],sizeof(Bonus));
line[bonus[j].ilocal] = j;
} }
/* ---------------------------------------------------------------------- /* ----------------------------------------------------------------------

View File

@ -165,8 +165,9 @@ void AtomVecTri::copy(int i, int j, int delflag)
} }
// if atom I has bonus data, reset I's bonus.ilocal to loc J // if atom I has bonus data, reset I's bonus.ilocal to loc J
// do NOT do this if self-copy (I=J) since I's bonus data is already deleted
if (tri[i] >= 0) bonus[tri[i]].ilocal = j; if (tri[i] >= 0 && i != j) bonus[tri[i]].ilocal = j;
tri[j] = tri[i]; tri[j] = tri[i];
if (atom->nextra_grow) if (atom->nextra_grow)
@ -176,13 +177,13 @@ void AtomVecTri::copy(int i, int j, int delflag)
/* ---------------------------------------------------------------------- /* ----------------------------------------------------------------------
copy bonus data from I to J, effectively deleting the J entry copy bonus data from I to J, effectively deleting the J entry
insure index pointers between per-atom and bonus data are updated also reset tri that points to I to now point to J
------------------------------------------------------------------------- */ ------------------------------------------------------------------------- */
void AtomVecTri::copy_bonus(int i, int j) void AtomVecTri::copy_bonus(int i, int j)
{ {
tri[bonus[i].ilocal] = j;
memcpy(&bonus[j],&bonus[i],sizeof(Bonus)); memcpy(&bonus[j],&bonus[i],sizeof(Bonus));
tri[bonus[j].ilocal] = j;
} }
/* ---------------------------------------------------------------------- /* ----------------------------------------------------------------------