use "body" list via Fix::extract() to correctly identify atoms in bodies

This commit is contained in:
Axel Kohlmeyer
2017-06-05 15:48:23 -04:00
parent 968de8548c
commit 90ca0852c7
2 changed files with 28 additions and 10 deletions

View File

@ -1006,13 +1006,20 @@ int Modify::check_rigid_group_overlap(int groupbit)
{ {
const int * const mask = atom->mask; const int * const mask = atom->mask;
const int nlocal = atom->nlocal; const int nlocal = atom->nlocal;
int dim;
int n = 0; int n = 0;
for (int ifix = 0; ifix < nfix; ifix++) { for (int ifix = 0; ifix < nfix; ifix++) {
if (strncmp("rigid",fix[ifix]->style,5) == 0) { if (strncmp("rigid",fix[ifix]->style,5) == 0) {
const int bothbits = groupbit | fix[ifix]->groupbit; const int bothbits = groupbit | fix[ifix]->groupbit;
for (int i=0; i < nlocal; ++i) const int * const body = (const int *)fix[ifix]->extract("body",dim);
if (mask[i] & bothbits) {++n; break;} if ((body == NULL) || (dim != 1)) break;
for (int i=0; i < nlocal; ++i) {
if (((mask[i] & bothbits) == bothbits) && (body[i] >= 0)) {
++n; break;
}
}
if (n > 0) break; if (n > 0) break;
} }
} }
@ -1025,23 +1032,29 @@ int Modify::check_rigid_group_overlap(int groupbit)
} }
/* ---------------------------------------------------------------------- /* ----------------------------------------------------------------------
check if the atoms in the region indicated by regionid overlap with any check if the atoms in the group indicated by groupbit _and_ region
currently existing rigid fixes. return 1 in this case otherwise 0 indicated by regionid overlap with any currently existing rigid fixes.
return 1 in this case, otherwise 0
------------------------------------------------------------------------- */ ------------------------------------------------------------------------- */
int Modify::check_rigid_region_overlap(Region *reg) int Modify::check_rigid_region_overlap(int groupbit, Region *reg)
{ {
const int * const mask = atom->mask; const int * const mask = atom->mask;
const double * const * const x = atom->x; const double * const * const x = atom->x;
const int nlocal = atom->nlocal; const int nlocal = atom->nlocal;
int dim;
int n = 0; int n = 0;
reg->prematch(); reg->prematch();
for (int ifix = 0; ifix < nfix; ifix++) { for (int ifix = 0; ifix < nfix; ifix++) {
if (strncmp("rigid",fix[ifix]->style,5) == 0) { if (strncmp("rigid",fix[ifix]->style,5) == 0) {
const int groupbit = fix[ifix]->groupbit; const int bothbits = groupbit | fix[ifix]->groupbit;
const int * const body = (const int *)fix[ifix]->extract("body",dim);
if ((body == NULL) || (dim != 1)) break;
for (int i=0; i < nlocal; ++i) for (int i=0; i < nlocal; ++i)
if ((mask[i] & groupbit) && reg->match(x[i][0],x[i][1],x[i][2])) { if (((mask[i] & bothbits) == bothbits) && (body[i] >= 0)
&& reg->match(x[i][0],x[i][1],x[i][2])) {
++n; ++n;
break; break;
} }
@ -1066,16 +1079,21 @@ int Modify::check_rigid_list_overlap(int *select)
{ {
const int * const mask = atom->mask; const int * const mask = atom->mask;
const int nlocal = atom->nlocal; const int nlocal = atom->nlocal;
int dim;
int n = 0; int n = 0;
for (int ifix = 0; ifix < nfix; ifix++) { for (int ifix = 0; ifix < nfix; ifix++) {
if (strncmp("rigid",fix[ifix]->style,5) == 0) { if (strncmp("rigid",fix[ifix]->style,5) == 0) {
const int groupbit = fix[ifix]->groupbit; const int groupbit = fix[ifix]->groupbit;
for (int i=0; i < nlocal; ++i) const int * const body = (const int *)fix[ifix]->extract("body",dim);
if ((mask[i] & groupbit) && select[i]) { if ((body == NULL) || (dim != 1)) break;
for (int i=0; i < nlocal; ++i) {
if ((mask[i] & groupbit) && (body[i] >= 0) && select[i]) {
++n; ++n;
break; break;
} }
}
if (n > 0) break; if (n > 0) break;
} }
} }

View File

@ -99,7 +99,7 @@ class Modify : protected Pointers {
int find_fix_by_style(const char *); int find_fix_by_style(const char *);
int check_package(const char *); int check_package(const char *);
int check_rigid_group_overlap(int); int check_rigid_group_overlap(int);
int check_rigid_region_overlap(class Region *); int check_rigid_region_overlap(int, class Region *);
int check_rigid_list_overlap(int *); int check_rigid_list_overlap(int *);
void add_compute(int, char **, int trysuffix=1); void add_compute(int, char **, int trysuffix=1);