add 3 APIs to Modify for checking if atoms overlap with any rigid fixes
This commit is contained in:
@ -23,6 +23,7 @@
|
|||||||
#include "group.h"
|
#include "group.h"
|
||||||
#include "update.h"
|
#include "update.h"
|
||||||
#include "domain.h"
|
#include "domain.h"
|
||||||
|
#include "region.h"
|
||||||
#include "input.h"
|
#include "input.h"
|
||||||
#include "variable.h"
|
#include "variable.h"
|
||||||
#include "memory.h"
|
#include "memory.h"
|
||||||
@ -995,6 +996,97 @@ int Modify::check_package(const char *package_fix_name)
|
|||||||
return 1;
|
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
|
add a new compute
|
||||||
------------------------------------------------------------------------- */
|
------------------------------------------------------------------------- */
|
||||||
|
|||||||
@ -98,6 +98,9 @@ class Modify : protected Pointers {
|
|||||||
int find_fix(const char *);
|
int find_fix(const char *);
|
||||||
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_region_overlap(class Region *);
|
||||||
|
int check_rigid_list_overlap(int *);
|
||||||
|
|
||||||
void add_compute(int, char **, int trysuffix=1);
|
void add_compute(int, char **, int trysuffix=1);
|
||||||
void modify_compute(int, char **);
|
void modify_compute(int, char **);
|
||||||
|
|||||||
Reference in New Issue
Block a user