From 90ca0852c798243e3217e2395cf4acaa7c2fc145 Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Mon, 5 Jun 2017 15:48:23 -0400 Subject: [PATCH] use "body" list via Fix::extract() to correctly identify atoms in bodies --- src/modify.cpp | 36 +++++++++++++++++++++++++++--------- src/modify.h | 2 +- 2 files changed, 28 insertions(+), 10 deletions(-) diff --git a/src/modify.cpp b/src/modify.cpp index 4422ee6890..b390b7f89a 100644 --- a/src/modify.cpp +++ b/src/modify.cpp @@ -1006,13 +1006,20 @@ int Modify::check_rigid_group_overlap(int groupbit) { const int * const mask = atom->mask; const int nlocal = atom->nlocal; + int dim; int n = 0; for (int ifix = 0; ifix < nfix; ifix++) { if (strncmp("rigid",fix[ifix]->style,5) == 0) { const int bothbits = groupbit | fix[ifix]->groupbit; - for (int i=0; i < nlocal; ++i) - if (mask[i] & bothbits) {++n; break;} + const int * const body = (const int *)fix[ifix]->extract("body",dim); + 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; } } @@ -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 - currently existing rigid fixes. return 1 in this case otherwise 0 + check if the atoms in the group indicated by groupbit _and_ region + 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 double * const * const x = atom->x; const int nlocal = atom->nlocal; + int dim; int n = 0; reg->prematch(); for (int ifix = 0; ifix < nfix; ifix++) { 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) - 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; break; } @@ -1066,16 +1079,21 @@ int Modify::check_rigid_list_overlap(int *select) { const int * const mask = atom->mask; const int nlocal = atom->nlocal; + int dim; int n = 0; for (int ifix = 0; ifix < nfix; ifix++) { if (strncmp("rigid",fix[ifix]->style,5) == 0) { const int groupbit = fix[ifix]->groupbit; - for (int i=0; i < nlocal; ++i) - if ((mask[i] & groupbit) && select[i]) { + const int * const body = (const int *)fix[ifix]->extract("body",dim); + if ((body == NULL) || (dim != 1)) break; + + for (int i=0; i < nlocal; ++i) { + if ((mask[i] & groupbit) && (body[i] >= 0) && select[i]) { ++n; break; } + } if (n > 0) break; } } diff --git a/src/modify.h b/src/modify.h index 2ad244f8fb..d825d5c4ef 100644 --- a/src/modify.h +++ b/src/modify.h @@ -99,7 +99,7 @@ class Modify : protected Pointers { int find_fix_by_style(const char *); int check_package(const char *); 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 *); void add_compute(int, char **, int trysuffix=1);