add 3 APIs to Modify for checking if atoms overlap with any rigid fixes

This commit is contained in:
Axel Kohlmeyer
2017-06-05 12:41:37 -04:00
parent 286d4f2743
commit 95d6f05a76
2 changed files with 95 additions and 0 deletions

View File

@ -23,6 +23,7 @@
#include "group.h"
#include "update.h"
#include "domain.h"
#include "region.h"
#include "input.h"
#include "variable.h"
#include "memory.h"
@ -995,6 +996,97 @@ int Modify::check_package(const char *package_fix_name)
return 1;
}
/* ----------------------------------------------------------------------
check if the group indicated by groupbit overlaps with any
currently existing rigid fixes. return 1 in this case otherwise 0
------------------------------------------------------------------------- */
int Modify::check_rigid_group_overlap(int groupbit)
{
const int * const mask = atom->mask;
const int nlocal = atom->nlocal;
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;}
if (n > 0) break;
}
}
int n_all = 0;
MPI_Allreduce(&n,&n_all,1,MPI_INT,MPI_SUM,world);
if (n_all > 0) return 1;
return 0;
}
/* ----------------------------------------------------------------------
check if the atoms in the 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)
{
const int * const mask = atom->mask;
const double * const * const x = atom->x;
const int nlocal = atom->nlocal;
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;
for (int i=0; i < nlocal; ++i)
if ((mask[i] & groupbit) && reg->match(x[i][0],x[i][1],x[i][2])) {
++n;
break;
}
if (n > 0) break;
}
}
int n_all = 0;
MPI_Allreduce(&n,&n_all,1,MPI_INT,MPI_SUM,world);
if (n_all > 0) return 1;
return 0;
}
/* ----------------------------------------------------------------------
check if the atoms in the selection list (length atom->nlocal,
content: 1 if atom is contained, 0 if not) overlap with currently
existing rigid fixes. return 1 in this case otherwise 0
------------------------------------------------------------------------- */
int Modify::check_rigid_list_overlap(int *select)
{
const int * const mask = atom->mask;
const int nlocal = atom->nlocal;
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]) {
++n;
break;
}
if (n > 0) break;
}
}
int n_all = 0;
MPI_Allreduce(&n,&n_all,1,MPI_INT,MPI_SUM,world);
if (n_all > 0) return 1;
return 0;
}
/* ----------------------------------------------------------------------
add a new compute
------------------------------------------------------------------------- */